OSDN Git Service

test-hwc2: fix build errors on other branches
authorMarissa Wall <marissaw@google.com>
Tue, 14 Mar 2017 19:30:35 +0000 (12:30 -0700)
committerMarissa Wall <marissaw@google.com>
Tue, 14 Mar 2017 20:10:09 +0000 (13:10 -0700)
Currently, test-hwc2 does not build on other branches due to
differences in GraphicBufferAlloc. Switch to directly allocating
graphic buffers.

Test: run the test-hwc2 tests

Change-Id: I63a058a9b0bf48d1e3236f5e124ecaa1dfb4593a

services/surfaceflinger/tests/hwc2/Hwc2TestBuffer.cpp
services/surfaceflinger/tests/hwc2/Hwc2TestBuffer.h

index a59f388..5f90c7a 100644 (file)
@@ -21,7 +21,6 @@
 
 #include <gui/Surface.h>
 #include <gui/BufferItemConsumer.h>
-#include <gui/GraphicBufferAlloc.h>
 
 #include <ui/GraphicBuffer.h>
 #include <ui/vec4.h>
@@ -395,15 +394,17 @@ int Hwc2TestBuffer::get(buffer_handle_t* outHandle, int32_t* outFence)
  * devices */
 int Hwc2TestBuffer::generateBuffer()
 {
-    int ret;
-
     /* Create new graphic buffer with correct dimensions */
-    mGraphicBuffer = mGraphicBufferAlloc.createGraphicBuffer(
-            mBufferArea.width, mBufferArea.height, mFormat,
-            GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_HW_RENDER,
-            "hwc2_test_buffer", &ret);
-    if (ret)
+    mGraphicBuffer = new GraphicBuffer(mBufferArea.width, mBufferArea.height,
+            mFormat, GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_HW_RENDER,
+            "hwc2_test_buffer");
+    int ret = mGraphicBuffer->initCheck();
+    if (ret) {
         return ret;
+    }
+    if (!mGraphicBuffer->handle) {
+        return -EINVAL;
+    }
 
     /* Locks the buffer for writing */
     uint8_t* img;
@@ -466,15 +467,17 @@ int Hwc2TestClientTargetBuffer::get(buffer_handle_t* outHandle,
         const std::set<hwc2_layer_t>* clientLayers,
         const std::set<hwc2_layer_t>* clearLayers)
 {
-    int err;
-
-    /* Create new graphic buffer with updated size */
-    mGraphicBuffer = mGraphicBufferAlloc.createGraphicBuffer(bufferArea.width,
-            bufferArea.height, mFormat,
-            GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_HW_RENDER,
-            "hwc2_test_buffer", &err);
-    if (err)
-        return err;
+    /* Create new graphic buffer with correct dimensions */
+    mGraphicBuffer = new GraphicBuffer(bufferArea.width, bufferArea.height,
+            mFormat, GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_HW_RENDER,
+            "hwc2_test_buffer");
+    int ret = mGraphicBuffer->initCheck();
+    if (ret) {
+        return ret;
+    }
+    if (!mGraphicBuffer->handle) {
+        return -EINVAL;
+    }
 
     uint8_t* img;
     mGraphicBuffer->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void**)(&img));
index ca60940..b2b3a66 100644 (file)
@@ -22,7 +22,6 @@
 
 #include <hardware/hwcomposer2.h>
 
-#include <gui/GraphicBufferAlloc.h>
 #include <ui/GraphicBuffer.h>
 
 #include "Hwc2TestProperties.h"
@@ -42,7 +41,6 @@ public:
 protected:
     int generateBuffer();
 
-    android::GraphicBufferAlloc mGraphicBufferAlloc;
     android::sp<android::GraphicBuffer> mGraphicBuffer;
 
     std::unique_ptr<Hwc2TestFenceGenerator> mFenceGenerator;
@@ -66,7 +64,6 @@ public:
             const std::set<hwc2_layer_t>* clearLayers);
 
 protected:
-    android::GraphicBufferAlloc mGraphicBufferAlloc;
     android::sp<android::GraphicBuffer> mGraphicBuffer;
 
     std::unique_ptr<Hwc2TestFenceGenerator> mFenceGenerator;