Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f18cfb0a authored by Marissa Wall's avatar Marissa Wall
Browse files

test-hwc2: add client target support

Test: Add "#define HAVE_NO_SURFACE_FLINGER" to
      frameworks/native/libs/gui/BufferQueueCore.cpp.
      Recompile and flash.
      Run "mm" in frameworks/native/services/surfaceflinger/tests/hwc2.
      Push test-hwc2 to device.
      Run "adb root && adb shell stop".
      Run test case. Ex: "./test-hwc2"

Change-Id: I94c86795b2e334df0570c6c5a3cbbcb5a8ca2826
parent 706178db
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ LOCAL_SRC_FILES := \
    Hwc2TestProperties.cpp \
    Hwc2TestLayer.cpp \
    Hwc2TestLayers.cpp \
    Hwc2TestBuffer.cpp
    Hwc2TestBuffer.cpp \
    Hwc2TestClientTarget.cpp

include $(BUILD_NATIVE_TEST)
+261 −12
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@

#include "Hwc2TestLayer.h"
#include "Hwc2TestLayers.h"
#include "Hwc2TestClientTarget.h"

void hwc2TestHotplugCallback(hwc2_callback_data_t callbackData,
        hwc2_display_t display, int32_t connected);
@@ -772,6 +773,53 @@ public:
        }
    }

    void getClientTargetSupport(hwc2_display_t display, int32_t width,
            int32_t height, android_pixel_format_t format,
            android_dataspace_t dataspace, hwc2_error_t* outErr = nullptr)
    {
        auto pfn = reinterpret_cast<HWC2_PFN_GET_CLIENT_TARGET_SUPPORT>(
                getFunction(HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT));
        ASSERT_TRUE(pfn) << "failed to get function";

        auto err = static_cast<hwc2_error_t>(pfn(mHwc2Device, display, width,
                height, format, dataspace));
        if (outErr) {
            *outErr = err;
        } else {
            ASSERT_EQ(err, HWC2_ERROR_NONE) << "failed to get client target"
                    " support";
        }
    }

    void setClientTarget(hwc2_display_t display, buffer_handle_t handle,
            int32_t acquireFence, android_dataspace_t dataspace,
            hwc_region_t damage, hwc2_error_t* outErr = nullptr)
    {
        auto pfn = reinterpret_cast<HWC2_PFN_SET_CLIENT_TARGET>(
                getFunction(HWC2_FUNCTION_SET_CLIENT_TARGET));
        ASSERT_TRUE(pfn) << "failed to get function";

        auto err = static_cast<hwc2_error_t>(pfn(mHwc2Device, display, handle,
                acquireFence, dataspace, damage));
        if (outErr) {
            *outErr = err;
        } else {
            ASSERT_EQ(err, HWC2_ERROR_NONE) << "failed to set client target";
        }
    }

    void getBadDisplay(hwc2_display_t* outDisplay)
    {
        for (hwc2_display_t display = 0; display < UINT64_MAX; display++) {
            if (mDisplays.count(display) == 0) {
                *outDisplay = display;
                return;
            }
        }
        ASSERT_TRUE(false) << "Unable to find bad display. UINT64_MAX displays"
                " are registered. This should never happen.";
    }

protected:
    hwc2_function_pointer_t getFunction(hwc2_function_descriptor_t descriptor)
    {
@@ -820,18 +868,6 @@ protected:
        mHotplugStatus = Hwc2TestHotplugStatus::Done;
    }

    void getBadDisplay(hwc2_display_t* outDisplay)
    {
        for (hwc2_display_t display = 0; display < UINT64_MAX; display++) {
            if (mDisplays.count(display) == 0) {
                *outDisplay = display;
                return;
            }
        }
        ASSERT_TRUE(false) << "Unable to find bad display. UINT64_MAX displays"
                " are registered. This should never happen.";
    }

    /* NOTE: will create min(newlayerCnt, max supported layers) layers */
    void createLayers(hwc2_display_t display,
            std::vector<hwc2_layer_t>* outLayers, size_t newLayerCnt)
@@ -943,12 +979,21 @@ protected:
    using TestDisplayNonValidatedLayersFunction = void (*)(Hwc2Test* test,
            hwc2_display_t display, std::vector<hwc2_layer_t>* layers);

    /* Tests client target support on a particular display and config */
    using TestClientTargetSupportFunction = void (*)(Hwc2Test* test,
            hwc2_display_t display,
            const Hwc2TestClientTargetSupport& testClientTargetSupport);

    /* Advances a property of Hwc2TestLayer */
    using AdvanceProperty = bool (*)(Hwc2TestLayer* testLayer);

    /* Advances properties of Hwc2TestLayers */
    using AdvanceProperties = bool (*)(Hwc2TestLayers* testLayer);

    /* Advances properties of Hwc2TestClientTargetSupport */
    using AdvanceClientTargetSupport = bool (*)(
            Hwc2TestClientTargetSupport* testClientTargetSupport);

    /* For each active display it cycles through each display config and tests
     * each property value. It creates a layer, sets the property and then
     * destroys the layer */
@@ -1206,6 +1251,34 @@ protected:
        }
    }

    /* Test client target support on each config on each active display */
    void setClientTargetSupport(Hwc2TestCoverage coverage,
            TestClientTargetSupportFunction function,
            AdvanceClientTargetSupport advance)
    {
        for (auto display : mDisplays) {
            std::vector<hwc2_config_t> configs;

            ASSERT_NO_FATAL_FAILURE(getDisplayConfigs(display, &configs));

            for (auto config : configs) {
                Area displayArea;

                ASSERT_NO_FATAL_FAILURE(setActiveConfig(display, config));
                ASSERT_NO_FATAL_FAILURE(getActiveDisplayArea(display,
                        &displayArea));
                Hwc2TestClientTargetSupport testClientTargetSupport(coverage,
                        displayArea);

                do {
                    EXPECT_NO_FATAL_FAILURE(function(this, display,
                            testClientTargetSupport));

                } while (advance(&testClientTargetSupport));
            }
        }
    }

    void getActiveConfigAttribute(hwc2_display_t display,
            hwc2_attribute_t attribute, int32_t* outValue)
    {
@@ -1539,6 +1612,11 @@ bool advanceVisibleRegions(Hwc2TestLayers* testLayers)
    return testLayers->advanceVisibleRegions();
}

bool advanceClientTargetSupport(
        Hwc2TestClientTargetSupport* testClientTargetSupport)
{
    return testClientTargetSupport->advance();
}

static const std::array<hwc2_function_descriptor_t, 42> requiredFunctions = {{
    HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES,
@@ -3014,3 +3092,174 @@ TEST_F(Hwc2Test, ACCEPT_DISPLAY_CHANGES_not_validated)
            }
    ));
}

/* TESTCASE: Tests that the HWC2 supports client target with required values */
TEST_F(Hwc2Test, GET_CLIENT_TARGET_SUPPORT)
{
    ASSERT_NO_FATAL_FAILURE(setClientTargetSupport(Hwc2TestCoverage::Default,
            [] (Hwc2Test* test, hwc2_display_t display,
                    const Hwc2TestClientTargetSupport& testClientTargetSupport) {

                const Area bufferArea = testClientTargetSupport.getBufferArea();
                const android_pixel_format_t format = HAL_PIXEL_FORMAT_RGBA_8888;

                ASSERT_NO_FATAL_FAILURE(test->getClientTargetSupport(display,
                        bufferArea.width, bufferArea.height, format,
                        testClientTargetSupport.getDataspace()));
            },

            advanceClientTargetSupport));
}

/* TESTCASE: Tests that the HWC2 cannot get client target support for a bad
 * display. */
TEST_F(Hwc2Test, GET_CLIENT_TARGET_SUPPORT_bad_display)
{
    ASSERT_NO_FATAL_FAILURE(setClientTargetSupport(Hwc2TestCoverage::Default,
            [] (Hwc2Test* test, hwc2_display_t /*display*/,
                    const Hwc2TestClientTargetSupport& testClientTargetSupport) {

                const Area bufferArea = testClientTargetSupport.getBufferArea();
                const android_pixel_format_t format = HAL_PIXEL_FORMAT_RGBA_8888;
                hwc2_display_t badDisplay;
                hwc2_error_t err = HWC2_ERROR_NONE;

                ASSERT_NO_FATAL_FAILURE(test->getBadDisplay(&badDisplay));

                ASSERT_NO_FATAL_FAILURE(test->getClientTargetSupport(badDisplay,
                        bufferArea.width, bufferArea.height, format,
                        testClientTargetSupport.getDataspace(), &err));
                EXPECT_EQ(err, HWC2_ERROR_BAD_DISPLAY) << "returned wrong error code";
            },

            advanceClientTargetSupport));
}

/* TESTCASE: Tests that the HWC2 either supports or returns error unsupported
 * for a variety of client target values. */
TEST_F(Hwc2Test, GET_CLIENT_TARGET_SUPPORT_unsupported)
{
    ASSERT_NO_FATAL_FAILURE(setClientTargetSupport(Hwc2TestCoverage::Complete,
            [] (Hwc2Test* test, hwc2_display_t display,
                    const Hwc2TestClientTargetSupport& testClientTargetSupport) {

                const Area bufferArea = testClientTargetSupport.getBufferArea();
                const android_pixel_format_t format = HAL_PIXEL_FORMAT_RGBA_8888;
                hwc2_error_t err = HWC2_ERROR_NONE;

                ASSERT_NO_FATAL_FAILURE(test->getClientTargetSupport(display,
                        bufferArea.width, bufferArea.height, format,
                        testClientTargetSupport.getDataspace(), &err));
                EXPECT_TRUE(err == HWC2_ERROR_NONE
                        || err == HWC2_ERROR_UNSUPPORTED)
                        << "returned wrong error code";
            },

            advanceClientTargetSupport));
}

/* TESTCASE: Tests that the HWC2 can set a client target buffer for a basic
 * layer. */
TEST_F(Hwc2Test, SET_CLIENT_TARGET_basic)
{
    const android_dataspace_t dataspace = HAL_DATASPACE_UNKNOWN;
    const hwc_region_t damage = { };
    const size_t layerCnt = 1;

    for (auto display : mDisplays) {
        std::vector<hwc2_config_t> configs;

        ASSERT_NO_FATAL_FAILURE(setPowerMode(display, HWC2_POWER_MODE_ON));

        ASSERT_NO_FATAL_FAILURE(getDisplayConfigs(display, &configs));

        for (auto config : configs) {
            Area displayArea;
            std::vector<hwc2_layer_t> layers;

            ASSERT_NO_FATAL_FAILURE(setActiveConfig(display, config));
            ASSERT_NO_FATAL_FAILURE(getActiveDisplayArea(display, &displayArea));

            ASSERT_NO_FATAL_FAILURE(createLayers(display, &layers, layerCnt));
            Hwc2TestLayers testLayers(layers, Hwc2TestCoverage::Basic,
                    displayArea);

            if (!testLayers.optimizeLayouts())
                continue;

            Hwc2TestClientTarget testClientTarget;

            do {
                std::set<hwc2_layer_t> clientLayers;
                std::set<hwc2_layer_t> clearLayers;
                uint32_t numTypes, numRequests;
                bool hasChanges, skip;
                bool flipClientTarget;
                buffer_handle_t handle;
                int32_t acquireFence;

                ASSERT_NO_FATAL_FAILURE(setLayerProperties(display, layers,
                        &testLayers, &skip));
                if (skip)
                    continue;

                ASSERT_NO_FATAL_FAILURE(validateDisplay(display, &numTypes,
                        &numRequests, &hasChanges));
                if (hasChanges)
                    EXPECT_LE(numTypes, layers.size())
                            << "wrong number of requests";

                ASSERT_NO_FATAL_FAILURE(handleCompositionChanges(display,
                        testLayers, layers, numTypes, &clientLayers));
                ASSERT_NO_FATAL_FAILURE(handleRequests(display, layers,
                        numRequests, &clearLayers, &flipClientTarget));
                ASSERT_EQ(testClientTarget.getBuffer(testLayers, clientLayers,
                        clearLayers, flipClientTarget, displayArea, &handle,
                        &acquireFence), 0);
                EXPECT_NO_FATAL_FAILURE(setClientTarget(display, handle,
                        acquireFence, dataspace, damage));

                if (acquireFence >= 0)
                    close(acquireFence);

            } while (testLayers.advance());

            ASSERT_NO_FATAL_FAILURE(destroyLayers(display, std::move(layers)));
        }

        ASSERT_NO_FATAL_FAILURE(setPowerMode(display, HWC2_POWER_MODE_OFF));
    }
}

/* TESTCASE: Tests that the HWC2 cannot set a client target for a bad display. */
TEST_F(Hwc2Test, SET_CLIENT_TARGET_bad_display)
{
    hwc2_display_t display;
    std::vector<hwc2_layer_t> layers;
    const Area displayArea = {0, 0};
    Hwc2TestLayers testLayers(layers, Hwc2TestCoverage::Default, displayArea);
    std::set<hwc2_layer_t> clientLayers;
    std::set<hwc2_layer_t> flipClientTargetLayers;
    bool flipClientTarget = true;
    const android_dataspace_t dataspace = HAL_DATASPACE_UNKNOWN;
    const hwc_region_t damage = { };
    buffer_handle_t handle;
    int32_t acquireFence;
    hwc2_error_t err = HWC2_ERROR_NONE;

    ASSERT_NO_FATAL_FAILURE(getBadDisplay(&display));

    Hwc2TestClientTarget testClientTarget;

    ASSERT_EQ(testClientTarget.getBuffer(testLayers, clientLayers,
            flipClientTargetLayers, flipClientTarget, displayArea, &handle,
            &acquireFence), 0);

    EXPECT_NO_FATAL_FAILURE(setClientTarget(display, handle, acquireFence,
            dataspace, damage, &err));

    if (acquireFence >= 0)
        close(acquireFence);

    EXPECT_EQ(err, HWC2_ERROR_BAD_DISPLAY) << "returned wrong error code";
}
+255 −15
Original line number Diff line number Diff line
@@ -330,6 +330,24 @@ static void setFence(int32_t fence, void* fenceGenerator)
}


/* Sets the pixel of a buffer given the location, format, stride and color.
 * Currently only supports RGBA_8888 */
static void setColor(int32_t x, int32_t y,
        android_pixel_format_t format, uint32_t stride, uint8_t* img, uint8_t r,
        uint8_t g, uint8_t b, uint8_t a)
{
       switch (format) {
       case HAL_PIXEL_FORMAT_RGBA_8888:
           img[(y * stride + x) * 4 + 0] = r;
           img[(y * stride + x) * 4 + 1] = g;
           img[(y * stride + x) * 4 + 2] = b;
           img[(y * stride + x) * 4 + 3] = a;
           break;
       default:
           break;
       }
}

Hwc2TestBuffer::Hwc2TestBuffer()
    : mFenceGenerator(new Hwc2TestFenceGenerator()) { }

@@ -433,20 +451,242 @@ int Hwc2TestBuffer::generateBuffer()
    return 0;
}

/* Sets the pixel of a buffer given the location, format, stride and color.
 * Currently only supports RGBA_8888 */
void Hwc2TestBuffer::setColor(int32_t x, int32_t y,
        android_pixel_format_t format, uint32_t stride, uint8_t* img, uint8_t r,
        uint8_t g, uint8_t b, uint8_t a)

Hwc2TestClientTargetBuffer::Hwc2TestClientTargetBuffer()
    : mFenceGenerator(new Hwc2TestFenceGenerator()) { }

Hwc2TestClientTargetBuffer::~Hwc2TestClientTargetBuffer() { }

/* Generates a client target buffer using the layers assigned for client
 * composition. Takes into account the individual layer properties such as
 * transform, blend mode, source crop, etc. */
int Hwc2TestClientTargetBuffer::get(buffer_handle_t* outHandle,
        int32_t* outFence, const Area& bufferArea,
        const Hwc2TestLayers* testLayers,
        const std::set<hwc2_layer_t>* clientLayers,
        const std::set<hwc2_layer_t>* clearLayers)
{
       switch (format) {
       case HAL_PIXEL_FORMAT_RGBA_8888:
           img[(y * stride + x) * 4 + 0] = r;
           img[(y * stride + x) * 4 + 1] = g;
           img[(y * stride + x) * 4 + 2] = b;
           img[(y * stride + x) * 4 + 3] = a;
           break;
       default:
           break;
    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;

    uint8_t* img;
    mGraphicBuffer->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void**)(&img));

    uint32_t stride = mGraphicBuffer->getStride();

    float bWDiv3 = bufferArea.width / 3;
    float bW2Div3 = bufferArea.width * 2 / 3;
    float bHDiv3 = bufferArea.height / 3;
    float bH2Div3 = bufferArea.height * 2 / 3;

    /* Cycle through every pixel in the buffer and determine what color it
     * should be. */
    for (int32_t y = 0; y < bufferArea.height; y++) {
        for (int32_t x = 0; x < bufferArea.width; x++) {

            uint8_t r = 0, g = 0, b = 0;
            float a = 0.0f;

            /* Cycle through each client layer from back to front and
             * update the pixel color. */
            for (auto layer = clientLayers->rbegin();
                    layer != clientLayers->rend(); ++layer) {

                const hwc_rect_t df = testLayers->getDisplayFrame(*layer);

                float dfL = df.left;
                float dfT = df.top;
                float dfR = df.right;
                float dfB = df.bottom;

                /* If the pixel location falls outside of the layer display
                 * frame, skip the layer. */
                if (x < dfL || x >= dfR || y < dfT || y >= dfB)
                    continue;

                /* If the device has requested the layer be clear, clear
                 * the pixel and continue. */
                if (clearLayers->count(*layer) != 0) {
                    r = 0;
                    g = 0;
                    b = 0;
                    a = 0.0f;
                    continue;
                }

                float planeAlpha = testLayers->getPlaneAlpha(*layer);

                /* If the layer is a solid color, fill the color and
                 * continue. */
                if (testLayers->getComposition(*layer)
                        == HWC2_COMPOSITION_SOLID_COLOR) {
                    const auto color = testLayers->getColor(*layer);
                    r = color.r;
                    g = color.g;
                    b = color.b;
                    a = color.a * planeAlpha;
                    continue;
                }

                float xPos = x;
                float yPos = y;

                hwc_transform_t transform = testLayers->getTransform(*layer);

                float dfW = dfR - dfL;
                float dfH = dfB - dfT;

                /* If a layer has a transform, find which location on the
                 * layer will end up in the current pixel location. We
                 * can calculate the color of the current pixel using that
                 * location. */
                if (transform > 0) {
                    /* Change origin to be the center of the layer. */
                    xPos = xPos - dfL - dfW / 2.0;
                    yPos = yPos - dfT - dfH / 2.0;

                    /* Flip Horizontal by reflecting across the y axis. */
                    if (transform & HWC_TRANSFORM_FLIP_H)
                        xPos = -xPos;

                    /* Flip vertical by reflecting across the x axis. */
                    if (transform & HWC_TRANSFORM_FLIP_V)
                        yPos = -yPos;

                    /* Rotate 90 by using a basic linear algebra rotation
                     * and scaling the result so the display frame remains
                     * the same. For example, a buffer of size 100x50 should
                     * rotate 90 degress but remain the same dimension
                     * (100x50) at the end of the transformation. */
                    if (transform & HWC_TRANSFORM_ROT_90) {
                        float tmp = xPos;
                        xPos = -yPos * dfW / dfH;
                        yPos = tmp * dfH / dfW;
                    }

                    /* Change origin back to the top left corner of the
                     * layer. */
                    xPos = xPos + dfL + dfW / 2.0;
                    yPos = yPos + dfT + dfH / 2.0;
                }

                hwc_frect_t sc = testLayers->getSourceCrop(*layer);
                float scL = sc.left, scT = sc.top;

                float dfWDivScW = dfW / (sc.right - scL);
                float dfHDivScH = dfH / (sc.bottom - scT);

                float max = 255, min = 0;

                /* Choose the pixel color. Similar to generateBuffer,
                 * each layer will be divided into 3x3 colors. Because
                 * both the source crop and display frame must be taken into
                 * account, the formulas are more complicated.
                 *
                 * If the source crop and display frame were not taken into
                 * account, we would simply divide the buffer into three
                 * sections by height. Each section would get one color.
                 * For example the formula for the first section would be:
                 *
                 * if (yPos < bufferArea.height / 3)
                 *        //Select first section color
                 *
                 * However the pixel color is chosen based on the source
                 * crop and displayed based on the display frame.
                 *
                 * If the display frame top was 0 and the source crop height
                 * and display frame height were the same. The only factor
                 * would be the source crop top. To calculate the new
                 * section boundary, the section boundary would be moved up
                 * by the height of the source crop top. The formula would
                 * be:
                 * if (yPos < (bufferArea.height / 3 - sourceCrop.top)
                 *        //Select first section color
                 *
                 * If the display frame top could also vary but source crop
                 * and display frame heights were the same, the formula
                 * would be:
                 * if (yPos < (bufferArea.height / 3 - sourceCrop.top
                 *              + displayFrameTop)
                 *        //Select first section color
                 *
                 * If the heights were not the same, the conversion between
                 * the source crop and display frame dimensions must be
                 * taken into account. The formula would be:
                 * if (yPos < ((bufferArea.height / 3) - sourceCrop.top)
                 *              * displayFrameHeight / sourceCropHeight
                 *              + displayFrameTop)
                 *        //Select first section color
                 */
                if (yPos < ((bHDiv3) - scT) * dfHDivScH + dfT) {
                    min = 255 / 2;
                } else if (yPos >= ((bH2Div3) - scT) * dfHDivScH + dfT) {
                    max = 255 / 2;
                }

                uint8_t rCur = min, gCur = min, bCur = min;
                float aCur = 1.0f;

                /* This further divides the color sections from 3 to 3x3.
                 * The math behind it follows the same logic as the previous
                 * comment */
                if (xPos < ((bWDiv3) - scL) * (dfWDivScW) + dfL) {
                    rCur = max;
                } else if (xPos < ((bW2Div3) - scL) * (dfWDivScW) + dfL) {
                    gCur = max;
                } else {
                    bCur = max;
                }


                /* Blend the pixel color with the previous layers' pixel
                 * colors using the plane alpha and blend mode. The final
                 * pixel color is chosen using the plane alpha and blend
                 * mode formulas found in hwcomposer2.h */
                hwc2_blend_mode_t blendMode = testLayers->getBlendMode(*layer);

                if (blendMode == HWC2_BLEND_MODE_PREMULTIPLIED) {
                    rCur *= planeAlpha;
                    gCur *= planeAlpha;
                    bCur *= planeAlpha;
                }

                aCur *= planeAlpha;

                if (blendMode == HWC2_BLEND_MODE_PREMULTIPLIED) {
                    r = rCur + r * (1.0 - aCur);
                    g = gCur + g * (1.0 - aCur);
                    b = bCur + b * (1.0 - aCur);
                    a = aCur + a * (1.0 - aCur);
                } else if (blendMode == HWC2_BLEND_MODE_COVERAGE) {
                    r = rCur * aCur + r * (1.0 - aCur);
                    g = gCur * aCur + g * (1.0 - aCur);
                    b = bCur * aCur + b * (1.0 - aCur);
                    a = aCur * aCur + a * (1.0 - aCur);
                } else {
                    r = rCur;
                    g = gCur;
                    b = bCur;
                    a = aCur;
                }
            }

            /* Set the pixel color */
            setColor(x, y, mFormat, stride, img, r, g, b, a * 255);
        }
    }

    mGraphicBuffer->unlock();

    *outFence = mFenceGenerator->get();
    *outHandle = mGraphicBuffer->handle;

    return 0;
}
+23 −4
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@
#define _HWC2_TEST_BUFFER_H

#include <android-base/unique_fd.h>
#include <set>

#include <hardware/hwcomposer2.h>

#include <gui/GraphicBufferAlloc.h>
@@ -26,6 +28,7 @@
#include "Hwc2TestProperties.h"

class Hwc2TestFenceGenerator;
class Hwc2TestLayers;

class Hwc2TestBuffer {
public:
@@ -39,10 +42,6 @@ public:
protected:
    int generateBuffer();

    void setColor(int32_t x, int32_t y, android_pixel_format_t format,
            uint32_t stride, uint8_t* img, uint8_t r, uint8_t g, uint8_t b,
            uint8_t a);

    android::GraphicBufferAlloc mGraphicBufferAlloc;
    android::sp<android::GraphicBuffer> mGraphicBuffer;

@@ -55,4 +54,24 @@ protected:
    buffer_handle_t mHandle = nullptr;
};


class Hwc2TestClientTargetBuffer {
public:
    Hwc2TestClientTargetBuffer();
    ~Hwc2TestClientTargetBuffer();

    int  get(buffer_handle_t* outHandle, int32_t* outFence,
            const Area& bufferArea, const Hwc2TestLayers* testLayers,
            const std::set<hwc2_layer_t>* clientLayers,
            const std::set<hwc2_layer_t>* clearLayers);

protected:
    android::GraphicBufferAlloc mGraphicBufferAlloc;
    android::sp<android::GraphicBuffer> mGraphicBuffer;

    std::unique_ptr<Hwc2TestFenceGenerator> mFenceGenerator;

    const android_pixel_format_t mFormat = HAL_PIXEL_FORMAT_RGBA_8888;
};

#endif /* ifndef _HWC2_TEST_BUFFER_H */
+102 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading