mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-01-27 18:59:11 +00:00
Adding Dataspace BT2020_SRGB and ColorMode BT2020_SRGB
BT2020_SRGB is BT2020 with SRGB transfer function. Adding to types V1.2 and upgrading methods that utilize Dataspace and ColorMode Bug: 115335239 Test: ./libsurfaceflinger_unittest --gtest_filter=GetBestColorMode.* Change-Id: Ic807183ae2bd0212cd8c5d7a24c93db0a1bc28fb
This commit is contained in:
@@ -12,8 +12,8 @@ hidl_interface {
|
||||
interfaces: [
|
||||
"android.hardware.configstore@1.1",
|
||||
"android.hardware.configstore@1.0",
|
||||
"android.hardware.graphics.common@1.1",
|
||||
"android.hardware.graphics.common@1.2",
|
||||
"android.hidl.base@1.0",
|
||||
],
|
||||
gen_java: true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package android.hardware.configstore@1.2;
|
||||
|
||||
import android.hardware.graphics.common@1.1::Dataspace;
|
||||
import android.hardware.graphics.common@1.1::PixelFormat;
|
||||
import android.hardware.graphics.common@1.2::Dataspace;
|
||||
import @1.1::ISurfaceFlingerConfigs;
|
||||
import @1.0::OptionalBool;
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace configstore {
|
||||
namespace V1_2 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::graphics::common::V1_1::Dataspace;
|
||||
using ::android::hardware::graphics::common::V1_1::PixelFormat;
|
||||
using ::android::hardware::graphics::common::V1_2::Dataspace;
|
||||
|
||||
// ::android::hardware::configstore::V1_0::ISurfaceFlingerConfigs implementation.
|
||||
Return<void> SurfaceFlingerConfigs::vsyncEventPhaseOffsetNs(vsyncEventPhaseOffsetNs_cb _hidl_cb) {
|
||||
|
||||
23
graphics/common/1.2/Android.bp
Normal file
23
graphics/common/1.2/Android.bp
Normal file
@@ -0,0 +1,23 @@
|
||||
// This file is autogenerated by hidl-gen -Landroidbp.
|
||||
|
||||
hidl_interface {
|
||||
name: "android.hardware.graphics.common@1.2",
|
||||
root: "android.hardware",
|
||||
vndk: {
|
||||
enabled: true,
|
||||
support_system_process: true,
|
||||
},
|
||||
srcs: [
|
||||
"types.hal",
|
||||
],
|
||||
interfaces: [
|
||||
"android.hardware.graphics.common@1.0",
|
||||
"android.hardware.graphics.common@1.1",
|
||||
],
|
||||
types: [
|
||||
"Dataspace",
|
||||
],
|
||||
gen_java: true,
|
||||
gen_java_constants: true,
|
||||
}
|
||||
|
||||
53
graphics/common/1.2/types.hal
Normal file
53
graphics/common/1.2/types.hal
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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 android.hardware.graphics.common@1.2;
|
||||
|
||||
import @1.1::BufferUsage;
|
||||
import @1.1::ColorMode;
|
||||
import @1.1::Dataspace;
|
||||
import @1.1::PixelFormat;
|
||||
|
||||
@export(name="android_dataspace_v1_2_t", value_prefix="HAL_DATASPACE_",
|
||||
export_parent="false")
|
||||
enum Dataspace : @1.1::Dataspace {
|
||||
/**
|
||||
* ITU-R Recommendation 2020 (BT.2020)
|
||||
*
|
||||
* Ultra High-definition television
|
||||
*
|
||||
* Use full range, sRGB transfer and BT2020 standard
|
||||
*/
|
||||
DISPLAY_BT2020 = STANDARD_BT2020 | TRANSFER_SRGB | RANGE_FULL,
|
||||
};
|
||||
|
||||
enum ColorMode : @1.1::ColorMode {
|
||||
/**
|
||||
* DISPLAY_BT2020 corresponds with display settings that implement the ITU-R
|
||||
* Recommendation BT.2020 / Rec. 2020 for UHDTV, but specifies an SRGB
|
||||
* transfer function.
|
||||
*
|
||||
* Primaries:
|
||||
* x y
|
||||
* green 0.170 0.797
|
||||
* blue 0.131 0.046
|
||||
* red 0.708 0.292
|
||||
* white (D65) 0.3127 0.3290
|
||||
*
|
||||
* Transfer Function is sRGB
|
||||
*/
|
||||
DISPLAY_BT2020 = 13,
|
||||
};
|
||||
@@ -13,6 +13,7 @@ hidl_interface {
|
||||
interfaces: [
|
||||
"android.hardware.graphics.common@1.0",
|
||||
"android.hardware.graphics.common@1.1",
|
||||
"android.hardware.graphics.common@1.2",
|
||||
"android.hardware.graphics.composer@2.1",
|
||||
"android.hardware.graphics.composer@2.2",
|
||||
"android.hidl.base@1.0",
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
|
||||
package android.hardware.graphics.composer@2.3;
|
||||
|
||||
import android.hardware.graphics.common@1.1::RenderIntent;
|
||||
import android.hardware.graphics.common@1.1::PixelFormat;
|
||||
import android.hardware.graphics.common@1.2::ColorMode;
|
||||
import android.hardware.graphics.common@1.2::Dataspace;
|
||||
import android.hardware.graphics.composer@2.1::IComposerClient.Command;
|
||||
import @2.2::IComposerClient;
|
||||
import @2.1::Display;
|
||||
@@ -87,6 +91,75 @@ interface IComposerClient extends @2.2::IComposerClient {
|
||||
generates (Error error,
|
||||
uint8_t port,
|
||||
vec<uint8_t> data);
|
||||
/**
|
||||
* getReadbackBufferAttributes_2_3
|
||||
* Returns the format which should be used when allocating a buffer for use by
|
||||
* device readback as well as the dataspace in which its contents must be
|
||||
* interpreted.
|
||||
*
|
||||
* The width and height of this buffer must be those of the currently-active
|
||||
* display configuration, and the usage flags must consist of the following:
|
||||
* BufferUsage::CPU_READ | BufferUsage::GPU_TEXTURE |
|
||||
* BufferUsage::COMPOSER_OUTPUT
|
||||
*
|
||||
* The format and dataspace provided must be sufficient such that if a
|
||||
* correctly-configured buffer is passed into setReadbackBuffer, filled by
|
||||
* the device, and then displayed by the client as a full-screen buffer, the
|
||||
* output of the display remains the same (subject to the note about protected
|
||||
* content in the description of setReadbackBuffer).
|
||||
*
|
||||
* If the active configuration or color mode of this display has changed
|
||||
* since a previous call to this function, it must be called again prior to
|
||||
* setting a readback buffer such that the returned format and dataspace will
|
||||
* be updated accordingly.
|
||||
*
|
||||
* Parameters:
|
||||
* @param display - the display on which to create the layer.
|
||||
*
|
||||
* @return format - the format the client should use when allocating a device
|
||||
* readback buffer
|
||||
* @return dataspace - the dataspace to use when interpreting the
|
||||
* contents of a device readback buffer
|
||||
* @return error is NONE upon success. Otherwise,
|
||||
* BAD_DISPLAY when an invalid display handle was passed in.
|
||||
* UNSUPPORTED if not supported on underlying HAL
|
||||
*
|
||||
* See also:
|
||||
* setReadbackBuffer
|
||||
* getReadbackBufferFence
|
||||
*/
|
||||
getReadbackBufferAttributes_2_3(Display display)
|
||||
generates (Error error,
|
||||
PixelFormat format,
|
||||
Dataspace dataspace);
|
||||
|
||||
/**
|
||||
* getClientTargetSupport_2_3
|
||||
* Returns whether a client target with the given properties can be
|
||||
* handled by the device.
|
||||
*
|
||||
* This function must return true for a client target with width and
|
||||
* height equal to the active display configuration dimensions,
|
||||
* PixelFormat::RGBA_8888, and Dataspace::UNKNOWN. It is not required to
|
||||
* return true for any other configuration.
|
||||
*
|
||||
* @param display is the display to query.
|
||||
* @param width is the client target width in pixels.
|
||||
* @param height is the client target height in pixels.
|
||||
* @param format is the client target format.
|
||||
* @param dataspace is the client target dataspace, as described in
|
||||
* setLayerDataspace.
|
||||
* @return error is NONE upon success. Otherwise,
|
||||
* BAD_DISPLAY when an invalid display handle was passed in.
|
||||
* UNSUPPORTED when the given configuration is not supported.
|
||||
*/
|
||||
@callflow(next="*")
|
||||
getClientTargetSupport_2_3(Display display,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
PixelFormat format,
|
||||
Dataspace dataspace)
|
||||
generates (Error error);
|
||||
|
||||
/**
|
||||
* Executes commands from the input command message queue. Return values
|
||||
@@ -113,4 +186,58 @@ interface IComposerClient extends @2.2::IComposerClient {
|
||||
bool outQueueChanged,
|
||||
uint32_t outLength,
|
||||
vec<handle> outHandles);
|
||||
|
||||
/**
|
||||
* Returns the render intents supported by the specified display and color
|
||||
* mode.
|
||||
*
|
||||
* For SDR color modes, RenderIntent::COLORIMETRIC must be supported. For
|
||||
* HDR color modes, RenderIntent::TONE_MAP_COLORIMETRIC must be supported.
|
||||
*
|
||||
* @param display is the display to query.
|
||||
* @param mode is the color mode to query.
|
||||
* @return error is NONE upon success. Otherwise,
|
||||
* BAD_DISPLAY when an invalid display handle was passed in.
|
||||
* BAD_PARAMETER when an invalid color mode was passed in.
|
||||
* @return intents is an array of render intents.
|
||||
*/
|
||||
getRenderIntents_2_3(Display display, ColorMode mode)
|
||||
generates (Error error,
|
||||
vec<RenderIntent> intents);
|
||||
|
||||
/**
|
||||
* Returns the color modes supported on this display.
|
||||
*
|
||||
* All devices must support at least ColorMode::NATIVE.
|
||||
*
|
||||
* @param display is the display to query.
|
||||
* @return error is NONE upon success. Otherwise,
|
||||
* BAD_DISPLAY when an invalid display handle was passed in.
|
||||
* @return modes is an array of color modes.
|
||||
*/
|
||||
getColorModes_2_3(Display display)
|
||||
generates (Error error,
|
||||
vec<ColorMode> modes);
|
||||
|
||||
/**
|
||||
* Sets the color mode and render intent of the given display.
|
||||
*
|
||||
* The color mode and render intent change must take effect on next
|
||||
* presentDisplay.
|
||||
*
|
||||
* All devices must support at least ColorMode::NATIVE and
|
||||
* RenderIntent::COLORIMETRIC, and displays are assumed to be in this mode
|
||||
* upon hotplug.
|
||||
*
|
||||
* @param display is the display to which the color mode is set.
|
||||
* @param mode is the color mode to set to.
|
||||
* @param intent is the render intent to set to.
|
||||
* @return error is NONE upon success. Otherwise,
|
||||
* BAD_DISPLAY when an invalid display handle was passed in.
|
||||
* BAD_PARAMETER when mode or intent is invalid
|
||||
* UNSUPPORTED when mode or intent is not supported on this
|
||||
* display.
|
||||
*/
|
||||
setColorMode_2_3(Display display, ColorMode mode, RenderIntent intent)
|
||||
generates (Error error);
|
||||
};
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace composer {
|
||||
namespace V2_3 {
|
||||
|
||||
using android::hardware::MessageQueue;
|
||||
using android::hardware::graphics::common::V1_2::Dataspace;
|
||||
using android::hardware::graphics::composer::V2_1::Error;
|
||||
using android::hardware::graphics::composer::V2_1::IComposerCallback;
|
||||
using android::hardware::graphics::composer::V2_1::Layer;
|
||||
@@ -43,6 +44,16 @@ using android::hardware::graphics::composer::V2_3::IComposerClient;
|
||||
// units of uint32_t's.
|
||||
class CommandWriterBase : public V2_2::CommandWriterBase {
|
||||
public:
|
||||
void setLayerDataspace(Dataspace dataspace) {
|
||||
setLayerDataspaceInternal(static_cast<int32_t>(dataspace));
|
||||
}
|
||||
|
||||
void setClientTarget(uint32_t slot, const native_handle_t* target, int acquireFence,
|
||||
Dataspace dataspace, const std::vector<IComposerClient::Rect>& damage) {
|
||||
setClientTargetInternal(slot, target, acquireFence, static_cast<int32_t>(dataspace),
|
||||
damage);
|
||||
}
|
||||
|
||||
CommandWriterBase(uint32_t initialMaxSize) : V2_2::CommandWriterBase(initialMaxSize) {}
|
||||
|
||||
static constexpr uint16_t kSetLayerColorTransformLength = 16;
|
||||
|
||||
@@ -38,6 +38,52 @@ namespace detail {
|
||||
template <typename Interface, typename Hal>
|
||||
class ComposerClientImpl : public V2_2::hal::detail::ComposerClientImpl<Interface, Hal> {
|
||||
public:
|
||||
Return<Error> setColorMode_2_3(Display display, ColorMode mode, RenderIntent intent) override {
|
||||
#ifndef USES_DISPLAY_RENDER_INTENTS
|
||||
if (intent != RenderIntent::COLORIMETRIC) {
|
||||
return Error::BAD_PARAMETER;
|
||||
}
|
||||
#endif
|
||||
return mHal->setColorMode_2_3(display, mode, intent);
|
||||
}
|
||||
|
||||
Return<void> getRenderIntents_2_3(Display display, ColorMode mode,
|
||||
IComposerClient::getRenderIntents_2_3_cb hidl_cb) override {
|
||||
#ifdef USES_DISPLAY_RENDER_INTENTS
|
||||
std::vector<RenderIntent> intents;
|
||||
Error err = mHal->getRenderIntents_2_3(display, mode, &intents);
|
||||
hidl_cb(err, intents);
|
||||
#else
|
||||
(void)display;
|
||||
(void)mode;
|
||||
hidl_cb(Error::NONE, hidl_vec<RenderIntent>({RenderIntent::COLORIMETRIC}));
|
||||
#endif
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> getColorModes_2_3(Display display,
|
||||
IComposerClient::getColorModes_2_3_cb hidl_cb) override {
|
||||
hidl_vec<ColorMode> modes;
|
||||
Error err = mHal->getColorModes_2_3(display, &modes);
|
||||
hidl_cb(err, modes);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> getReadbackBufferAttributes_2_3(
|
||||
Display display, IComposerClient::getReadbackBufferAttributes_2_3_cb hidl_cb) override {
|
||||
PixelFormat format = PixelFormat::RGB_888;
|
||||
Dataspace dataspace = Dataspace::UNKNOWN;
|
||||
Error error = mHal->getReadbackBufferAttributes_2_3(display, &format, &dataspace);
|
||||
hidl_cb(error, format, dataspace);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<Error> getClientTargetSupport_2_3(Display display, uint32_t width, uint32_t height,
|
||||
PixelFormat format, Dataspace dataspace) override {
|
||||
Error err = mHal->getClientTargetSupport_2_3(display, width, height, format, dataspace);
|
||||
return err;
|
||||
}
|
||||
|
||||
static std::unique_ptr<ComposerClientImpl> create(Hal* hal) {
|
||||
auto client = std::make_unique<ComposerClientImpl>(hal);
|
||||
return client->init() ? std::move(client) : nullptr;
|
||||
|
||||
@@ -25,12 +25,50 @@ namespace composer {
|
||||
namespace V2_3 {
|
||||
namespace hal {
|
||||
|
||||
using common::V1_1::PixelFormat;
|
||||
using common::V1_1::RenderIntent;
|
||||
using common::V1_2::ColorMode;
|
||||
using common::V1_2::Dataspace;
|
||||
using V2_1::Display;
|
||||
using V2_1::Error;
|
||||
using V2_1::Layer;
|
||||
|
||||
class ComposerHal : public V2_2::hal::ComposerHal {
|
||||
public:
|
||||
Error setColorMode_2_2(Display display, common::V1_1::ColorMode mode,
|
||||
RenderIntent intent) override {
|
||||
return setColorMode_2_3(display, static_cast<ColorMode>(mode), intent);
|
||||
}
|
||||
|
||||
Error getColorModes_2_2(Display display, hidl_vec<common::V1_1::ColorMode>* outModes) override {
|
||||
return getColorModes_2_3(display, reinterpret_cast<hidl_vec<ColorMode>*>(outModes));
|
||||
}
|
||||
|
||||
Error getClientTargetSupport_2_2(Display display, uint32_t width, uint32_t height,
|
||||
common::V1_1::PixelFormat format,
|
||||
common::V1_1::Dataspace dataspace) override {
|
||||
return getClientTargetSupport_2_3(display, width, height, static_cast<PixelFormat>(format),
|
||||
static_cast<Dataspace>(dataspace));
|
||||
}
|
||||
|
||||
Error getReadbackBufferAttributes(Display display, common::V1_1::PixelFormat* outFormat,
|
||||
common::V1_1::Dataspace* outDataspace) override {
|
||||
return getReadbackBufferAttributes_2_3(display, reinterpret_cast<PixelFormat*>(outFormat),
|
||||
reinterpret_cast<Dataspace*>(outDataspace));
|
||||
}
|
||||
|
||||
virtual Error setColorMode_2_3(Display display, ColorMode mode, RenderIntent intent) = 0;
|
||||
|
||||
virtual Error getRenderIntents_2_3(Display display, ColorMode mode,
|
||||
std::vector<RenderIntent>* outIntents) = 0;
|
||||
|
||||
virtual Error getColorModes_2_3(Display display, hidl_vec<ColorMode>* outModes) = 0;
|
||||
|
||||
virtual Error getClientTargetSupport_2_3(Display display, uint32_t width, uint32_t height,
|
||||
PixelFormat format, Dataspace dataspace) = 0;
|
||||
virtual Error getReadbackBufferAttributes_2_3(Display display, PixelFormat* outFormat,
|
||||
Dataspace* outDataspace) = 0;
|
||||
|
||||
virtual Error getDisplayIdentificationData(Display display, uint8_t* outPort,
|
||||
std::vector<uint8_t>* outData) = 0;
|
||||
virtual Error setLayerColorTransform(Display display, Layer layer, const float* matrix) = 0;
|
||||
|
||||
@@ -34,6 +34,10 @@ namespace passthrough {
|
||||
|
||||
namespace detail {
|
||||
|
||||
using common::V1_1::PixelFormat;
|
||||
using common::V1_1::RenderIntent;
|
||||
using common::V1_2::ColorMode;
|
||||
using common::V1_2::Dataspace;
|
||||
using V2_1::Display;
|
||||
using V2_1::Error;
|
||||
|
||||
@@ -41,6 +45,32 @@ using V2_1::Error;
|
||||
template <typename Hal>
|
||||
class HwcHalImpl : public V2_2::passthrough::detail::HwcHalImpl<Hal> {
|
||||
public:
|
||||
Error setColorMode_2_3(Display display, ColorMode mode, RenderIntent intent) override {
|
||||
return setColorMode_2_2(display, static_cast<common::V1_1::ColorMode>(mode), intent);
|
||||
}
|
||||
|
||||
Error getRenderIntents_2_3(Display display, ColorMode mode,
|
||||
std::vector<RenderIntent>* outIntents) override {
|
||||
return getRenderIntents(display, static_cast<common::V1_1::ColorMode>(mode), outIntents);
|
||||
}
|
||||
|
||||
Error getColorModes_2_3(Display display, hidl_vec<ColorMode>* outModes) override {
|
||||
return getColorModes_2_2(display,
|
||||
reinterpret_cast<hidl_vec<common::V1_1::ColorMode>*>(outModes));
|
||||
}
|
||||
|
||||
Error getClientTargetSupport_2_3(Display display, uint32_t width, uint32_t height,
|
||||
PixelFormat format, Dataspace dataspace) override {
|
||||
return getClientTargetSupport_2_2(display, width, height, format,
|
||||
static_cast<common::V1_1::Dataspace>(dataspace));
|
||||
}
|
||||
|
||||
Error getReadbackBufferAttributes_2_3(Display display, PixelFormat* outFormat,
|
||||
Dataspace* outDataspace) override {
|
||||
return getReadbackBufferAttributes(
|
||||
display, outFormat, reinterpret_cast<common::V1_1::Dataspace*>(outDataspace));
|
||||
}
|
||||
|
||||
Error getDisplayIdentificationData(Display display, uint8_t* outPort,
|
||||
std::vector<uint8_t>* outData) override {
|
||||
if (!mDispatch.getDisplayIdentificationData) {
|
||||
@@ -96,6 +126,11 @@ class HwcHalImpl : public V2_2::passthrough::detail::HwcHalImpl<Hal> {
|
||||
using BaseType2_2 = V2_2::passthrough::detail::HwcHalImpl<Hal>;
|
||||
using BaseType2_1 = V2_1::passthrough::detail::HwcHalImpl<Hal>;
|
||||
using BaseType2_1::mDevice;
|
||||
using BaseType2_2::getClientTargetSupport_2_2;
|
||||
using BaseType2_2::getColorModes_2_2;
|
||||
using BaseType2_2::getReadbackBufferAttributes;
|
||||
using BaseType2_2::getRenderIntents;
|
||||
using BaseType2_2::setColorMode_2_2;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -45,6 +45,10 @@ std::unique_ptr<ComposerClient> Composer::createClient() {
|
||||
return client;
|
||||
}
|
||||
|
||||
sp<IComposerClient> ComposerClient::getRaw() const {
|
||||
return mClient;
|
||||
}
|
||||
|
||||
bool ComposerClient::getDisplayIdentificationData(Display display, uint8_t* outPort,
|
||||
std::vector<uint8_t>* outData) {
|
||||
bool supported = true;
|
||||
@@ -64,6 +68,46 @@ bool ComposerClient::getDisplayIdentificationData(Display display, uint8_t* outP
|
||||
return supported;
|
||||
}
|
||||
|
||||
std::vector<ColorMode> ComposerClient::getColorModes_2_3(Display display) {
|
||||
std::vector<ColorMode> modes;
|
||||
mClient->getColorModes_2_3(display, [&](const auto& tmpError, const auto& tmpModes) {
|
||||
ASSERT_EQ(Error::NONE, tmpError) << "failed to get color modes";
|
||||
modes = tmpModes;
|
||||
});
|
||||
return modes;
|
||||
}
|
||||
|
||||
void ComposerClient::setColorMode_2_3(Display display, ColorMode mode, RenderIntent intent) {
|
||||
Error error = mClient->setColorMode_2_3(display, mode, intent);
|
||||
ASSERT_TRUE(error == Error::NONE || error == Error::UNSUPPORTED) << "failed to set color mode";
|
||||
}
|
||||
|
||||
std::vector<RenderIntent> ComposerClient::getRenderIntents_2_3(Display display, ColorMode mode) {
|
||||
std::vector<RenderIntent> intents;
|
||||
mClient->getRenderIntents_2_3(display, mode, [&](const auto& tmpError, const auto& tmpIntents) {
|
||||
ASSERT_EQ(Error::NONE, tmpError) << "failed to get render intents";
|
||||
intents = tmpIntents;
|
||||
});
|
||||
return intents;
|
||||
}
|
||||
|
||||
void ComposerClient::getReadbackBufferAttributes_2_3(Display display, PixelFormat* outPixelFormat,
|
||||
Dataspace* outDataspace) {
|
||||
mClient->getReadbackBufferAttributes_2_3(
|
||||
display,
|
||||
[&](const auto& tmpError, const auto& tmpOutPixelFormat, const auto& tmpOutDataspace) {
|
||||
ASSERT_EQ(Error::NONE, tmpError) << "failed to get readback buffer attributes";
|
||||
*outPixelFormat = tmpOutPixelFormat;
|
||||
*outDataspace = tmpOutDataspace;
|
||||
});
|
||||
}
|
||||
|
||||
bool ComposerClient::getClientTargetSupport_2_3(Display display, uint32_t width, uint32_t height,
|
||||
PixelFormat format, Dataspace dataspace) {
|
||||
Error error = mClient->getClientTargetSupport_2_3(display, width, height, format, dataspace);
|
||||
return error == Error::NONE;
|
||||
}
|
||||
|
||||
} // namespace vts
|
||||
} // namespace V2_3
|
||||
} // namespace composer
|
||||
|
||||
@@ -32,6 +32,10 @@ namespace composer {
|
||||
namespace V2_3 {
|
||||
namespace vts {
|
||||
|
||||
using common::V1_1::PixelFormat;
|
||||
using common::V1_1::RenderIntent;
|
||||
using common::V1_2::ColorMode;
|
||||
using common::V1_2::Dataspace;
|
||||
using V2_1::Display;
|
||||
using V2_3::IComposer;
|
||||
using V2_3::IComposerClient;
|
||||
@@ -59,9 +63,23 @@ class ComposerClient : public V2_2::vts::ComposerClient {
|
||||
explicit ComposerClient(const sp<IComposerClient>& client)
|
||||
: V2_2::vts::ComposerClient(client), mClient(client) {}
|
||||
|
||||
sp<IComposerClient> getRaw() const;
|
||||
|
||||
bool getDisplayIdentificationData(Display display, uint8_t* outPort,
|
||||
std::vector<uint8_t>* outData);
|
||||
|
||||
std::vector<ColorMode> getColorModes_2_3(Display display);
|
||||
|
||||
void setColorMode_2_3(Display display, ColorMode mode, RenderIntent intent);
|
||||
|
||||
std::vector<RenderIntent> getRenderIntents_2_3(Display display, ColorMode mode);
|
||||
|
||||
void getReadbackBufferAttributes_2_3(Display display, PixelFormat* outPixelFormat,
|
||||
Dataspace* outDataspace);
|
||||
|
||||
bool getClientTargetSupport_2_3(Display display, uint32_t width, uint32_t height,
|
||||
PixelFormat format, Dataspace dataspace);
|
||||
|
||||
private:
|
||||
const sp<IComposerClient> mClient;
|
||||
};
|
||||
|
||||
@@ -33,6 +33,11 @@ namespace V2_3 {
|
||||
namespace vts {
|
||||
namespace {
|
||||
|
||||
using common::V1_1::PixelFormat;
|
||||
using common::V1_1::RenderIntent;
|
||||
using common::V1_2::ColorMode;
|
||||
using common::V1_2::Dataspace;
|
||||
|
||||
// Test environment for graphics.composer
|
||||
class GraphicsComposerHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
|
||||
public:
|
||||
@@ -64,6 +69,8 @@ class GraphicsComposerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
// assume the first display is primary and is never removed
|
||||
mPrimaryDisplay = waitForFirstDisplay();
|
||||
|
||||
mInvalidDisplayId = GetInvalidDisplayId();
|
||||
|
||||
// explicitly disable vsync
|
||||
mComposerClient->setVsyncEnabled(mPrimaryDisplay, false);
|
||||
mComposerCallback->setVsyncAllowed(false);
|
||||
@@ -80,6 +87,22 @@ class GraphicsComposerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
}
|
||||
}
|
||||
|
||||
// returns an invalid display id (one that has not been registered to a
|
||||
// display. Currently assuming that a device will never have close to
|
||||
// std::numeric_limit<uint64_t>::max() displays registered while running tests
|
||||
Display GetInvalidDisplayId() {
|
||||
std::vector<Display> validDisplays = mComposerCallback->getDisplays();
|
||||
uint64_t id = std::numeric_limits<uint64_t>::max();
|
||||
while (id > 0) {
|
||||
if (std::find(validDisplays.begin(), validDisplays.end(), id) == validDisplays.end()) {
|
||||
return id;
|
||||
}
|
||||
id--;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void execute() { mComposerClient->execute(mReader.get(), mWriter.get()); }
|
||||
|
||||
// use the slot count usually set by SF
|
||||
@@ -90,6 +113,7 @@ class GraphicsComposerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
sp<V2_1::vts::GraphicsComposerCallback> mComposerCallback;
|
||||
// the first display and is assumed never to be removed
|
||||
Display mPrimaryDisplay;
|
||||
Display mInvalidDisplayId;
|
||||
std::unique_ptr<CommandWriterBase> mWriter;
|
||||
std::unique_ptr<V2_1::vts::TestCommandReader> mReader;
|
||||
|
||||
@@ -127,6 +151,185 @@ TEST_F(GraphicsComposerHidlTest, GetDisplayIdentificationData) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TestIComposerClient::getReadbackBufferAttributes_2_3
|
||||
*/
|
||||
TEST_F(GraphicsComposerHidlTest, GetReadbackBufferAttributes_2_3) {
|
||||
Dataspace dataspace;
|
||||
PixelFormat pixelFormat;
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(mComposerClient->getReadbackBufferAttributes_2_3(
|
||||
mPrimaryDisplay, &pixelFormat, &dataspace));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test IComposerClient::getClientTargetSupport_2_3
|
||||
*/
|
||||
TEST_F(GraphicsComposerHidlTest, GetClientTargetSupport_2_3) {
|
||||
std::vector<V2_1::Config> configs = mComposerClient->getDisplayConfigs(mPrimaryDisplay);
|
||||
for (auto config : configs) {
|
||||
int32_t width = mComposerClient->getDisplayAttribute(mPrimaryDisplay, config,
|
||||
IComposerClient::Attribute::WIDTH);
|
||||
int32_t height = mComposerClient->getDisplayAttribute(mPrimaryDisplay, config,
|
||||
IComposerClient::Attribute::HEIGHT);
|
||||
ASSERT_LT(0, width);
|
||||
ASSERT_LT(0, height);
|
||||
|
||||
mComposerClient->setActiveConfig(mPrimaryDisplay, config);
|
||||
|
||||
ASSERT_TRUE(mComposerClient->getClientTargetSupport_2_3(
|
||||
mPrimaryDisplay, width, height, PixelFormat::RGBA_8888, Dataspace::UNKNOWN));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Test IComposerClient::getClientTargetSupport_2_3
|
||||
*
|
||||
* Test that IComposerClient::getClientTargetSupport_2_3 returns
|
||||
* Error::BAD_DISPLAY when passed in an invalid display handle
|
||||
*/
|
||||
|
||||
TEST_F(GraphicsComposerHidlTest, GetClientTargetSupport_2_3BadDisplay) {
|
||||
std::vector<V2_1::Config> configs = mComposerClient->getDisplayConfigs(mPrimaryDisplay);
|
||||
for (auto config : configs) {
|
||||
int32_t width = mComposerClient->getDisplayAttribute(mPrimaryDisplay, config,
|
||||
IComposerClient::Attribute::WIDTH);
|
||||
int32_t height = mComposerClient->getDisplayAttribute(mPrimaryDisplay, config,
|
||||
IComposerClient::Attribute::HEIGHT);
|
||||
ASSERT_LT(0, width);
|
||||
ASSERT_LT(0, height);
|
||||
|
||||
mComposerClient->setActiveConfig(mPrimaryDisplay, config);
|
||||
|
||||
Error error = mComposerClient->getRaw()->getClientTargetSupport_2_3(
|
||||
mInvalidDisplayId, width, height, PixelFormat::RGBA_8888, Dataspace::UNKNOWN);
|
||||
|
||||
EXPECT_EQ(Error::BAD_DISPLAY, error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test IComposerClient::getRenderIntents_2_3
|
||||
*/
|
||||
TEST_F(GraphicsComposerHidlTest, GetRenderIntents_2_3) {
|
||||
std::vector<ColorMode> modes = mComposerClient->getColorModes_2_3(mPrimaryDisplay);
|
||||
for (auto mode : modes) {
|
||||
std::vector<RenderIntent> intents =
|
||||
mComposerClient->getRenderIntents_2_3(mPrimaryDisplay, mode);
|
||||
|
||||
bool isHdr;
|
||||
switch (mode) {
|
||||
case ColorMode::BT2100_PQ:
|
||||
case ColorMode::BT2100_HLG:
|
||||
isHdr = true;
|
||||
break;
|
||||
default:
|
||||
isHdr = false;
|
||||
break;
|
||||
}
|
||||
RenderIntent requiredIntent =
|
||||
isHdr ? RenderIntent::TONE_MAP_COLORIMETRIC : RenderIntent::COLORIMETRIC;
|
||||
|
||||
auto iter = std::find(intents.cbegin(), intents.cend(), requiredIntent);
|
||||
EXPECT_NE(intents.cend(), iter);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Test IComposerClient::getRenderIntents_2_3
|
||||
*
|
||||
* Test that IComposerClient::getRenderIntents_2_3 returns Error::BAD_DISPLAY when
|
||||
* passed an invalid display handle
|
||||
*/
|
||||
TEST_F(GraphicsComposerHidlTest, GetRenderIntents_2_3BadDisplay) {
|
||||
std::vector<ColorMode> modes = mComposerClient->getColorModes_2_3(mPrimaryDisplay);
|
||||
for (auto mode : modes) {
|
||||
mComposerClient->getRaw()->getRenderIntents_2_3(
|
||||
mInvalidDisplayId, mode,
|
||||
[&](const auto& tmpError, const auto&) { EXPECT_EQ(Error::BAD_DISPLAY, tmpError); });
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Test IComposerClient::getRenderIntents_2_3
|
||||
*
|
||||
* Test that IComposerClient::getRenderIntents_2_3 returns Error::BAD_PARAMETER when
|
||||
* pased either an invalid Color mode or an invalid Render Intent
|
||||
*/
|
||||
TEST_F(GraphicsComposerHidlTest, GetRenderIntents_2_3BadParameter) {
|
||||
mComposerClient->getRaw()->getRenderIntents_2_3(
|
||||
mPrimaryDisplay, static_cast<ColorMode>(-1),
|
||||
[&](const auto& tmpError, const auto&) { EXPECT_EQ(Error::BAD_PARAMETER, tmpError); });
|
||||
}
|
||||
|
||||
/**
|
||||
* IComposerClient::getColorModes_2_3
|
||||
*/
|
||||
TEST_F(GraphicsComposerHidlTest, GetColorModes_2_3) {
|
||||
std::vector<ColorMode> colorModes = mComposerClient->getColorModes_2_3(mPrimaryDisplay);
|
||||
|
||||
auto native = std::find(colorModes.cbegin(), colorModes.cend(), ColorMode::NATIVE);
|
||||
ASSERT_NE(colorModes.cend(), native);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test IComposerClient::getColorModes_2_3
|
||||
*
|
||||
* Test that IComposerClient::getColorModes_2_3 returns Error::BAD_DISPLAY when
|
||||
* passed an invalid display handle
|
||||
*/
|
||||
TEST_F(GraphicsComposerHidlTest, GetColorMode_2_3BadDisplay) {
|
||||
mComposerClient->getRaw()->getColorModes_2_3(
|
||||
mInvalidDisplayId,
|
||||
[&](const auto& tmpError, const auto&) { ASSERT_EQ(Error::BAD_DISPLAY, tmpError); });
|
||||
}
|
||||
|
||||
/**
|
||||
* IComposerClient::setColorMode_2_3
|
||||
*/
|
||||
TEST_F(GraphicsComposerHidlTest, SetColorMode_2_3) {
|
||||
std::vector<ColorMode> colorModes = mComposerClient->getColorModes_2_3(mPrimaryDisplay);
|
||||
for (auto mode : colorModes) {
|
||||
std::vector<RenderIntent> intents =
|
||||
mComposerClient->getRenderIntents_2_3(mPrimaryDisplay, mode);
|
||||
for (auto intent : intents) {
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
mComposerClient->setColorMode_2_3(mPrimaryDisplay, mode, intent));
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(mComposerClient->setColorMode_2_3(mPrimaryDisplay, ColorMode::NATIVE,
|
||||
RenderIntent::COLORIMETRIC));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test IComposerClient::setColorMode_2_3
|
||||
*
|
||||
* Test that IComposerClient::setColorMode_2_3 returns an Error::BAD_DISPLAY
|
||||
* when passed an invalid display handle
|
||||
*/
|
||||
TEST_F(GraphicsComposerHidlTest, SetColorMode_2_3BadDisplay) {
|
||||
Error error = mComposerClient->getRaw()->setColorMode_2_3(mInvalidDisplayId, ColorMode::NATIVE,
|
||||
RenderIntent::COLORIMETRIC);
|
||||
|
||||
ASSERT_EQ(Error::BAD_DISPLAY, error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test IComposerClient::setColorMode_2_3
|
||||
*
|
||||
* Test that IComposerClient::setColorMode_2_3 returns Error::BAD_PARAMETER when
|
||||
* passed an invalid Color mode or an invalid render intent
|
||||
*/
|
||||
TEST_F(GraphicsComposerHidlTest, SetColorMode_2_3BadParameter) {
|
||||
Error colorModeError = mComposerClient->getRaw()->setColorMode_2_3(
|
||||
mPrimaryDisplay, static_cast<ColorMode>(-1), RenderIntent::COLORIMETRIC);
|
||||
EXPECT_EQ(Error::BAD_PARAMETER, colorModeError);
|
||||
|
||||
Error renderIntentError = mComposerClient->getRaw()->setColorMode_2_3(
|
||||
mPrimaryDisplay, ColorMode::NATIVE, static_cast<RenderIntent>(-1));
|
||||
EXPECT_EQ(Error::BAD_PARAMETER, renderIntentError);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test IComposerClient::Command::SET_LAYER_COLOR_TRANSFORM.
|
||||
* TODO Add color to the layer, use matrix to keep only red component,
|
||||
|
||||
@@ -36,6 +36,9 @@ hidl-gen $options \
|
||||
hidl-gen $options \
|
||||
-o $ANDROID_BUILD_TOP/system/core/include/system/graphics-base-v1.1.h \
|
||||
android.hardware.graphics.common@1.1
|
||||
hidl-gen $options \
|
||||
-o $ANDROID_BUILD_TOP/system/core/include/system/graphics-base-v1.2.h \
|
||||
android.hardware.graphics.common@1.2
|
||||
|
||||
# system/media
|
||||
hidl-gen $options \
|
||||
|
||||
Reference in New Issue
Block a user