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

Commit dcecfd46 authored by ramindani's avatar ramindani
Browse files

Use Wrapper in the readback tests.

BUG: 199413815

Test: atest VtsHalGraphicsComposer3_TargetTest
Change-Id: I3a7e81f8c04971b178ae703a3eb83de50ae0810f
parent 431aad4a
Loading
Loading
Loading
Loading
+448 −408

File changed.

Preview size limit exceeded, changes collapsed.

+11 −20
Original line number Diff line number Diff line
@@ -14,19 +14,12 @@
 * limitations under the License.
 */

// TODO(b/129481165): remove the #pragma below and fix conversion issues
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wconversion"

#include "include/ReadbackVts.h"
#include <aidl/android/hardware/graphics/common/BufferUsage.h>
#include "include/RenderEngineVts.h"
#include "renderengine/ExternalTexture.h"
#include "renderengine/impl/ExternalTexture.h"

// TODO(b/129481165): remove the #pragma below and fix conversion issues
#pragma clang diagnostic pop  // ignored "-Wconversion

namespace aidl::android::hardware::graphics::composer3::vts {

const std::vector<ColorMode> ReadbackHelper::colorModes = {ColorMode::SRGB, ColorMode::DISPLAY_P3};
@@ -195,13 +188,12 @@ void ReadbackHelper::compareColorBuffers(const std::vector<Color>& expectedColor
    }
}

ReadbackBuffer::ReadbackBuffer(int64_t display, const std::shared_ptr<IComposerClient>& client,
ReadbackBuffer::ReadbackBuffer(int64_t display, const std::shared_ptr<VtsComposerClient>& client,
                               int32_t width, int32_t height, common::PixelFormat pixelFormat,
                               common::Dataspace dataspace) {
                               common::Dataspace dataspace)
    : mComposerClient(client) {
    mDisplay = display;

    mComposerClient = client;

    mPixelFormat = pixelFormat;
    mDataspace = dataspace;

@@ -227,23 +219,22 @@ void ReadbackBuffer::setReadbackBuffer() {
    mGraphicBuffer = allocate();
    ASSERT_NE(nullptr, mGraphicBuffer);
    ASSERT_EQ(::android::OK, mGraphicBuffer->initCheck());
    aidl::android::hardware::common::NativeHandle bufferHandle =
            ::android::dupToAidl(mGraphicBuffer->handle);
    const auto& bufferHandle = mGraphicBuffer->handle;
    ::ndk::ScopedFileDescriptor fence = ::ndk::ScopedFileDescriptor(-1);
    EXPECT_TRUE(mComposerClient->setReadbackBuffer(mDisplay, bufferHandle, fence).isOk());
}

void ReadbackBuffer::checkReadbackBuffer(std::vector<Color> expectedColors) {
void ReadbackBuffer::checkReadbackBuffer(const std::vector<Color>& expectedColors) {
    ASSERT_NE(nullptr, mGraphicBuffer);
    // lock buffer for reading
    ndk::ScopedFileDescriptor fenceHandle;
    EXPECT_TRUE(mComposerClient->getReadbackBufferFence(mDisplay, &fenceHandle).isOk());
    const auto& [fenceStatus, bufferFence] = mComposerClient->getReadbackBufferFence(mDisplay);
    EXPECT_TRUE(fenceStatus.isOk());

    int bytesPerPixel = -1;
    int bytesPerStride = -1;
    void* bufData = nullptr;

    auto status = mGraphicBuffer->lockAsync(mUsage, mAccessRegion, &bufData, dup(fenceHandle.get()),
    auto status = mGraphicBuffer->lockAsync(mUsage, mAccessRegion, &bufData, dup(bufferFence.get()),
                                            &bytesPerPixel, &bytesPerStride);
    EXPECT_EQ(::android::OK, status);
    ASSERT_TRUE(mPixelFormat == PixelFormat::RGB_888 || mPixelFormat == PixelFormat::RGBA_8888);
@@ -270,7 +261,7 @@ LayerSettings TestColorLayer::toRenderEngineLayerSettings() {
    return layerSettings;
}

TestBufferLayer::TestBufferLayer(const std::shared_ptr<IComposerClient>& client,
TestBufferLayer::TestBufferLayer(const std::shared_ptr<VtsComposerClient>& client,
                                 const ::android::sp<::android::GraphicBuffer>& graphicBuffer,
                                 TestRenderEngine& renderEngine, int64_t display, uint32_t width,
                                 uint32_t height, common::PixelFormat format,
@@ -318,8 +309,8 @@ LayerSettings TestBufferLayer::toRenderEngineLayerSettings() {
    const float translateY = mSourceCrop.top / (static_cast<float>(mHeight));

    layerSettings.source.buffer.textureTransform =
            ::android::mat4::translate(::android::vec4(translateX, translateY, 0, 1.0)) *
            ::android::mat4::scale(::android::vec4(scaleX, scaleY, 1.0, 1.0));
            ::android::mat4::translate(::android::vec4(translateX, translateY, 0.0f, 1.0f)) *
            ::android::mat4::scale(::android::vec4(scaleX, scaleY, 1.0f, 1.0f));

    return layerSettings;
}
+10 −18
Original line number Diff line number Diff line
@@ -16,10 +16,6 @@

#pragma once

// TODO(b/129481165): remove the #pragma below and fix conversion issues
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wconversion"

#include <aidl/android/hardware/graphics/composer3/IComposerClient.h>
#include <android-base/unique_fd.h>
#include <android/hardware/graphics/composer3/ComposerClientReader.h>
@@ -31,9 +27,6 @@
#include "GraphicsComposerCallback.h"
#include "VtsComposerClient.h"

// TODO(b/129481165): remove the #pragma below and fix conversion issues
#pragma clang diagnostic pop  // ignored "-Wconversion

namespace aidl::android::hardware::graphics::composer3::vts {

using ::android::renderengine::LayerSettings;
@@ -56,9 +49,11 @@ class TestRenderEngine;

class TestLayer {
  public:
    TestLayer(const std::shared_ptr<IComposerClient>& client, int64_t display)
        : mDisplay(display), mComposerClient(client) {
        client->createLayer(display, kBufferSlotCount, &mLayer);
    TestLayer(const std::shared_ptr<VtsComposerClient>& client, int64_t display)
        : mDisplay(display) {
        const auto& [status, layer] = client->createLayer(display, kBufferSlotCount);
        EXPECT_TRUE(status.isOk());
        mLayer = layer;
    }

    // ComposerClient will take care of destroying layers, no need to explicitly
@@ -103,14 +98,11 @@ class TestLayer {
    float mAlpha = 1.0;
    BlendMode mBlendMode = BlendMode::NONE;
    uint32_t mZOrder = 0;

  private:
    std::shared_ptr<IComposerClient> const mComposerClient;
};

class TestColorLayer : public TestLayer {
  public:
    TestColorLayer(const std::shared_ptr<IComposerClient>& client, int64_t display)
    TestColorLayer(const std::shared_ptr<VtsComposerClient>& client, int64_t display)
        : TestLayer{client, display} {}

    void write(ComposerClientWriter& writer) override;
@@ -125,7 +117,7 @@ class TestColorLayer : public TestLayer {

class TestBufferLayer : public TestLayer {
  public:
    TestBufferLayer(const std::shared_ptr<IComposerClient>& client,
    TestBufferLayer(const std::shared_ptr<VtsComposerClient>& client,
                    const ::android::sp<::android::GraphicBuffer>& graphicBuffer,
                    TestRenderEngine& renderEngine, int64_t display, uint32_t width,
                    uint32_t height, common::PixelFormat format,
@@ -195,12 +187,12 @@ class ReadbackHelper {

class ReadbackBuffer {
  public:
    ReadbackBuffer(int64_t display, const std::shared_ptr<IComposerClient>& client, int32_t width,
    ReadbackBuffer(int64_t display, const std::shared_ptr<VtsComposerClient>& client, int32_t width,
                   int32_t height, common::PixelFormat pixelFormat, common::Dataspace dataspace);

    void setReadbackBuffer();

    void checkReadbackBuffer(std::vector<Color> expectedColors);
    void checkReadbackBuffer(const std::vector<Color>& expectedColors);

    ::android::sp<::android::GraphicBuffer> allocate();

@@ -213,7 +205,7 @@ class ReadbackBuffer {
    Dataspace mDataspace;
    int64_t mDisplay;
    ::android::sp<::android::GraphicBuffer> mGraphicBuffer;
    std::shared_ptr<IComposerClient> mComposerClient;
    std::shared_ptr<VtsComposerClient> mComposerClient;
    ::android::Rect mAccessRegion;
    native_handle_t mBufferHandle;
};
+0 −7
Original line number Diff line number Diff line
@@ -15,10 +15,6 @@
 */
#pragma once

// TODO(b/129481165): remove the #pragma below and fix conversion issues
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wconversion"

#include <mapper-vts/2.1/MapperVts.h>
#include <math/half.h>
#include <math/vec3.h>
@@ -31,9 +27,6 @@
#include <ui/Region.h>
#include "ReadbackVts.h"

// TODO(b/129481165): remove the #pragma below and fix conversion issues
#pragma clang diagnostic pop  // ignored "-Wconversion

namespace aidl::android::hardware::graphics::composer3::vts {

using ::android::hardware::graphics::mapper::V2_1::IMapper;