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

Commit 97c3ab25 authored by Ram Indani's avatar Ram Indani Committed by Android (Google) Code Review
Browse files

Merge changes from topic "vts-composerclient-wrapper"

* changes:
  Remove test `GetDisplayAttributeConfigsInAGroupDifferOnlyByVsyncPeriod`
  Use Wrapper in the readback tests.
  Use VtsComposerClient in Base test
  IComposerClient wrapper for VTS tests
parents 9512fcb9 8bb4ce13
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -35,6 +35,9 @@ cc_test {
        "VtsHalGraphicsComposer3_TargetTest.cpp",
        "VtsHalGraphicsComposer3_ReadbackTest.cpp",
        "composer-vts/GraphicsComposerCallback.cpp",
        "composer-vts/ReadbackVts.cpp",
        "composer-vts/RenderEngineVts.cpp",
        "composer-vts/VtsComposerClient.cpp",
    ],

    shared_libs: [
@@ -72,15 +75,19 @@ cc_test {
        "android.hardware.graphics.allocator@2.0",
        "android.hardware.graphics.allocator@3.0",
        "android.hardware.graphics.allocator@4.0",
        "android.hardware.graphics.composer@3-vts",
        "android.hardware.graphics.mapper@2.0-vts",
        "android.hardware.graphics.mapper@2.1-vts",
        "android.hardware.graphics.mapper@3.0-vts",
        "android.hardware.graphics.mapper@4.0-vts",
        "libaidlcommonsupport",
        "libarect",
        "libbase",
        "libfmq",
        "libgtest",
        "libmath",
        "librenderengine",
        "libshaders",
        "libsync",
        "libtonemap",
    ],
    cflags: [
+448 −408

File changed.

Preview size limit exceeded, changes collapsed.

+797 −1044

File changed.

Preview size limit exceeded, changes collapsed.

+0 −78
Original line number Diff line number Diff line
/**
 * Copyright (c) 2021, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "hardware_interfaces_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["hardware_interfaces_license"],
}

cc_library_static {
    name: "android.hardware.graphics.composer@3-vts",
    defaults: ["hidl_defaults"],
    srcs: [
        "GraphicsComposerCallback.cpp",
        "ReadbackVts.cpp",
        "RenderEngineVts.cpp",
    ],
    header_libs: [
        "android.hardware.graphics.composer3-command-buffer",
    ],
    static_libs: [
        "android.hardware.graphics.composer3-V1-ndk",
        "android.hardware.graphics.common-V3-ndk",
        "android.hardware.common-V2-ndk",
        "android.hardware.common.fmq-V1-ndk",
        "libarect",
        "libgtest",
        "libbase",
        "libfmq",
        "libsync",
        "libmath",
        "libaidlcommonsupport",
        "libnativewindow",
        "librenderengine",
        "libshaders",
        "libtonemap",
        "android.hardware.graphics.mapper@2.0-vts",
        "android.hardware.graphics.mapper@2.1-vts",
        "android.hardware.graphics.mapper@3.0-vts",
        "android.hardware.graphics.mapper@4.0-vts",
    ],
    shared_libs: [
        "libbinder_ndk",
        "libhidlbase",
        "libui",
        "android.hardware.graphics.composer3-V1-ndk",
    ],
    export_static_lib_headers: [
        "android.hardware.graphics.mapper@2.1-vts",
        "librenderengine",
    ],
    cflags: [
        "-O0",
        "-g",
        "-DLOG_TAG=\"ComposerVts\"",
        "-Wconversion",
    ],
    export_header_lib_headers: [
        "android.hardware.graphics.composer3-command-buffer",
    ],
    export_include_dirs: ["include"],
}
+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;
}
Loading