OSDN Git Service

Fix tests
authorJohn Reck <jreck@google.com>
Tue, 26 Jan 2016 18:50:10 +0000 (10:50 -0800)
committerJohn Reck <jreck@google.com>
Tue, 26 Jan 2016 18:50:10 +0000 (10:50 -0800)
Disable FrameBuilder.clippedMerging as it relies on
merged bitmap ops which was disabled in b/26793764

Fix Buffer to correctly initialize mRefs count

Change-Id: I87d2fcc690a2ae14eaf751f650f522be5b622edf

libs/hwui/BufferPool.h
libs/hwui/tests/unit/BufferPoolTests.cpp
libs/hwui/tests/unit/FrameBuilderTests.cpp

index 9bda233..005b399 100644 (file)
@@ -16,8 +16,9 @@
 
 #pragma once
 
-#include <utils/RefBase.h>
-#include <utils/Log.h>
+#include "utils/RefBase.h"
+#include "utils/Log.h"
+#include "utils/Macros.h"
 
 #include <atomic>
 #include <stdint.h>
@@ -37,6 +38,7 @@ namespace uirenderer {
 class BufferPool : public VirtualLightRefBase {
 public:
     class Buffer {
+        PREVENT_COPY_AND_ASSIGN(Buffer);
     public:
         int64_t* getBuffer() { return mBuffer.get(); }
         size_t getSize() { return mSize; }
@@ -57,14 +59,17 @@ public:
             return refs - 1;
         }
 
+        bool isUniqueRef() {
+            return mRefs.load() == 1;
+        }
+
     private:
         friend class BufferPool;
 
-        Buffer(BufferPool* pool, size_t size) {
+        Buffer(BufferPool* pool, size_t size) : mRefs(1) {
             mSize = size;
             mBuffer.reset(new int64_t[size]);
             mPool = pool;
-            mRefs++;
         }
 
         void setPool(BufferPool* pool) {
index 09bd302..44e6d3a 100644 (file)
@@ -36,6 +36,7 @@ TEST(BufferPool, acquireThenRelease) {
             ASSERT_EQ(bufferCount - i, pool->getAvailableBufferCount());
             acquiredBuffers[i] = pool->acquire();
             ASSERT_NE(nullptr, acquiredBuffers[i]);
+            ASSERT_TRUE(acquiredBuffers[i]->isUniqueRef());
         }
 
         for (size_t i = 0; i < bufferCount; i++) {
index b51bd2f..cdbab2e 100644 (file)
@@ -215,7 +215,8 @@ TEST(FrameBuilder, simpleBatching) {
             << "Expect number of ops = 2 * loop count";
 }
 
-TEST(FrameBuilder, clippedMerging) {
+// TODO: Disabled due to b/26793764
+TEST(FrameBuilder, DISABLED_clippedMerging) {
     class ClippedMergingTestRenderer : public TestRendererBase {
     public:
         void onMergedBitmapOps(const MergedBakedOpList& opList) override {