Merge changes from topic "hwc_float_color"
* changes:
composer: Color.aidl should use floats
composer: remove FloatColor
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Color.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Color.aidl
index 7733deb..8222909 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Color.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Color.aidl
@@ -34,8 +34,8 @@
package android.hardware.graphics.composer3;
@VintfStability
parcelable Color {
- byte r;
- byte g;
- byte b;
- byte a;
+ float r;
+ float g;
+ float b;
+ float a;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/FloatColor.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/FloatColor.aidl
deleted file mode 100644
index faadf57..0000000
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/FloatColor.aidl
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * 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.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.hardware.graphics.composer3;
-@VintfStability
-parcelable FloatColor {
- float r;
- float g;
- float b;
- float a;
-}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerCommand.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerCommand.aidl
index 2da1db2..c1c0117 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerCommand.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerCommand.aidl
@@ -40,7 +40,6 @@
@nullable android.hardware.graphics.common.Rect[] damage;
@nullable android.hardware.graphics.composer3.ParcelableBlendMode blendMode;
@nullable android.hardware.graphics.composer3.Color color;
- @nullable android.hardware.graphics.composer3.FloatColor floatColor;
@nullable android.hardware.graphics.composer3.ParcelableComposition composition;
@nullable android.hardware.graphics.composer3.ParcelableDataspace dataspace;
@nullable android.hardware.graphics.common.Rect displayFrame;
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/Color.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/Color.aidl
index 979f677..151a854 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/Color.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/Color.aidl
@@ -16,10 +16,13 @@
package android.hardware.graphics.composer3;
+/**
+ * Color representation as a floating point number in the range [0.0 - 1.0]
+ */
@VintfStability
parcelable Color {
- byte r;
- byte g;
- byte b;
- byte a;
+ float r;
+ float g;
+ float b;
+ float a;
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/FloatColor.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/FloatColor.aidl
deleted file mode 100644
index a0a1d4b..0000000
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/FloatColor.aidl
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * 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 android.hardware.graphics.composer3;
-
-/**
- * Color representation as a floating point number in the range [0.0 - 1.0]
- */
-
-@VintfStability
-parcelable FloatColor {
- float r;
- float g;
- float b;
- float a;
-}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/Hidl2AidlAsserts.cpp b/graphics/composer/aidl/android/hardware/graphics/composer3/Hidl2AidlAsserts.cpp
index d34b405..d2cabff 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/Hidl2AidlAsserts.cpp
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/Hidl2AidlAsserts.cpp
@@ -25,7 +25,6 @@
#include "aidl/android/hardware/graphics/composer3/DisplayAttribute.h"
#include "aidl/android/hardware/graphics/composer3/DisplayCapability.h"
#include "aidl/android/hardware/graphics/composer3/DisplayConnectionType.h"
-#include "aidl/android/hardware/graphics/composer3/FloatColor.h"
#include "aidl/android/hardware/graphics/composer3/FormatColorComponent.h"
#include "aidl/android/hardware/graphics/composer3/IComposer.h"
#include "aidl/android/hardware/graphics/composer3/PerFrameMetadata.h"
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerCommand.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/LayerCommand.aidl
index efc7fce..0a2711b 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerCommand.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/LayerCommand.aidl
@@ -22,7 +22,6 @@
import android.hardware.graphics.common.Rect;
import android.hardware.graphics.composer3.Buffer;
import android.hardware.graphics.composer3.Color;
-import android.hardware.graphics.composer3.FloatColor;
import android.hardware.graphics.composer3.Luminance;
import android.hardware.graphics.composer3.ParcelableBlendMode;
import android.hardware.graphics.composer3.ParcelableComposition;
@@ -114,13 +113,6 @@
@nullable Color color;
/**
- * Sets the color of the given layer. If the composition type of the layer
- * is not Composition.SOLID_COLOR, this call must succeed and have no
- * other effect.
- */
- @nullable FloatColor floatColor;
-
- /**
* Sets the desired composition type of the given layer. During
* validateDisplay, the device may request changes to the composition
* types of any of the layers as described in the definition of
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_ReadbackTest.cpp b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_ReadbackTest.cpp
index 0ece1d5..e519221 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_ReadbackTest.cpp
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_ReadbackTest.cpp
@@ -922,35 +922,30 @@
auto layer = mLayers[1];
BlendMode blendMode = layer->getBlendMode();
- float alpha = mTopLayerColor.a / 255.0f * layer->getAlpha();
+ float alpha = mTopLayerColor.a * layer->getAlpha();
if (blendMode == BlendMode::NONE) {
for (auto& expectedColor : expectedColors) {
- expectedColor.r = mTopLayerColor.r * static_cast<int8_t>(layer->getAlpha());
- expectedColor.g = mTopLayerColor.g * static_cast<int8_t>(layer->getAlpha());
- expectedColor.b = mTopLayerColor.b * static_cast<int8_t>(layer->getAlpha());
- expectedColor.a = static_cast<int8_t>(alpha * 255.0);
+ expectedColor.r = mTopLayerColor.r * layer->getAlpha();
+ expectedColor.g = mTopLayerColor.g * layer->getAlpha();
+ expectedColor.b = mTopLayerColor.b * layer->getAlpha();
+ expectedColor.a = alpha;
}
} else if (blendMode == BlendMode::PREMULTIPLIED) {
for (auto& expectedColor : expectedColors) {
- expectedColor.r = static_cast<int8_t>(
- mTopLayerColor.r * static_cast<int8_t>(layer->getAlpha()) +
- mBackgroundColor.r * (1.0 - alpha));
- expectedColor.g = static_cast<int8_t>(mTopLayerColor.g * layer->getAlpha() +
- mBackgroundColor.g * (1.0 - alpha));
- expectedColor.b = static_cast<int8_t>(mTopLayerColor.b * layer->getAlpha() +
- mBackgroundColor.b * (1.0 - alpha));
- expectedColor.a = static_cast<int8_t>(alpha + mBackgroundColor.a * (1.0 - alpha));
+ expectedColor.r =
+ mTopLayerColor.r * layer->getAlpha() + mBackgroundColor.r * (1.0f - alpha);
+ expectedColor.g =
+ mTopLayerColor.g * layer->getAlpha() + mBackgroundColor.g * (1.0f - alpha);
+ expectedColor.b =
+ mTopLayerColor.b * layer->getAlpha() + mBackgroundColor.b * (1.0f - alpha);
+ expectedColor.a = alpha + mBackgroundColor.a * (1.0f - alpha);
}
} else if (blendMode == BlendMode::COVERAGE) {
for (auto& expectedColor : expectedColors) {
- expectedColor.r = static_cast<int8_t>(mTopLayerColor.r * alpha +
- mBackgroundColor.r * (1.0 - alpha));
- expectedColor.g = static_cast<int8_t>(mTopLayerColor.g * alpha +
- mBackgroundColor.g * (1.0 - alpha));
- expectedColor.b = static_cast<int8_t>(mTopLayerColor.b * alpha +
- mBackgroundColor.b * (1.0 - alpha));
- expectedColor.a = static_cast<int8_t>(mTopLayerColor.a * alpha +
- mBackgroundColor.a * (1.0 - alpha));
+ expectedColor.r = mTopLayerColor.r * alpha + mBackgroundColor.r * (1.0f - alpha);
+ expectedColor.g = mTopLayerColor.g * alpha + mBackgroundColor.g * (1.0f - alpha);
+ expectedColor.b = mTopLayerColor.b * alpha + mBackgroundColor.b * (1.0f - alpha);
+ expectedColor.a = mTopLayerColor.a * alpha + mBackgroundColor.a * (1.0f - alpha);
}
}
}
@@ -1083,7 +1078,7 @@
GraphicsCompositionTest::SetUp();
auto backgroundLayer = std::make_shared<TestColorLayer>(mComposerClient, mPrimaryDisplay);
- backgroundLayer->setColor({0, 0, 0, 0});
+ backgroundLayer->setColor({0.0f, 0.0f, 0.0f, 0.0f});
backgroundLayer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
backgroundLayer->setZOrder(0);
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_TargetTest.cpp b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_TargetTest.cpp
index a591aaa..c61693e 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_TargetTest.cpp
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_TargetTest.cpp
@@ -1720,13 +1720,11 @@
int64_t layer;
EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk());
- mWriter.setLayerColor(mPrimaryDisplay, layer,
- Color{static_cast<int8_t>(0xff), static_cast<int8_t>(0xff),
- static_cast<int8_t>(0xff), static_cast<int8_t>(0xff)});
+ mWriter.setLayerColor(mPrimaryDisplay, layer, Color{1.0f, 1.0f, 1.0f, 1.0f});
execute();
ASSERT_TRUE(mReader.takeErrors().empty());
- mWriter.setLayerColor(mPrimaryDisplay, layer, Color{0, 0, 0, 0});
+ mWriter.setLayerColor(mPrimaryDisplay, layer, Color{0.0f, 0.0f, 0.0f, 0.0f});
execute();
ASSERT_TRUE(mReader.takeErrors().empty());
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/ReadbackVts.cpp b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/ReadbackVts.cpp
index 5eb912b..deb5ac3 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/ReadbackVts.cpp
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/ReadbackVts.cpp
@@ -131,12 +131,12 @@
int offset = (row * static_cast<int32_t>(stride) + col) * bytesPerPixel;
uint8_t* pixelColor = (uint8_t*)bufferData + offset;
- pixelColor[0] = static_cast<uint8_t>(srcColor.r);
- pixelColor[1] = static_cast<uint8_t>(srcColor.g);
- pixelColor[2] = static_cast<uint8_t>(srcColor.b);
+ pixelColor[0] = static_cast<uint8_t>(std::round(255.0f * srcColor.r));
+ pixelColor[1] = static_cast<uint8_t>(std::round(255.0f * srcColor.g));
+ pixelColor[2] = static_cast<uint8_t>(std::round(255.0f * srcColor.b));
if (bytesPerPixel == 4) {
- pixelColor[3] = static_cast<uint8_t>(srcColor.a);
+ pixelColor[3] = static_cast<uint8_t>(std::round(255.0f * srcColor.a));
}
}
}
@@ -184,13 +184,11 @@
auto pixel = row * static_cast<int32_t>(width) + col;
int offset = (row * stride + col) * bytesPerPixel;
uint8_t* pixelColor = (uint8_t*)bufferData + offset;
+ const Color expectedColor = expectedColors[static_cast<size_t>(pixel)];
- ASSERT_EQ(static_cast<int8_t>(expectedColors[static_cast<size_t>(pixel)].r),
- pixelColor[0]);
- ASSERT_EQ(static_cast<int8_t>(expectedColors[static_cast<size_t>(pixel)].g),
- pixelColor[1]);
- ASSERT_EQ(static_cast<int8_t>(expectedColors[static_cast<size_t>(pixel)].b),
- pixelColor[2]);
+ ASSERT_EQ(std::round(255.0f * expectedColor.r), pixelColor[0]);
+ ASSERT_EQ(std::round(255.0f * expectedColor.g), pixelColor[1]);
+ ASSERT_EQ(std::round(255.0f * expectedColor.b), pixelColor[2]);
}
}
}
@@ -262,12 +260,8 @@
LayerSettings TestColorLayer::toRenderEngineLayerSettings() {
LayerSettings layerSettings = TestLayer::toRenderEngineLayerSettings();
- layerSettings.source.solidColor =
- ::android::half3(static_cast<::android::half>(mColor.r) / 255.0,
- static_cast<::android::half>(mColor.g) / 255.0,
- static_cast<::android::half>(mColor.b) / 255.0);
- layerSettings.alpha =
- mAlpha * static_cast<float>((static_cast<::android::half>(mColor.a) / 255.0));
+ layerSettings.source.solidColor = ::android::half3(mColor.r, mColor.g, mColor.b);
+ layerSettings.alpha = mAlpha * mColor.a;
return layerSettings;
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/include/ReadbackVts.h b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/include/ReadbackVts.h
index 60a036e..0fac2b3 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/include/ReadbackVts.h
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/include/ReadbackVts.h
@@ -41,13 +41,12 @@
using common::PixelFormat;
using IMapper2_1 = ::android::hardware::graphics::mapper::V2_1::IMapper;
-static const Color BLACK = {0, 0, 0, static_cast<int8_t>(0xff)};
-static const Color RED = {static_cast<int8_t>(0xff), 0, 0, static_cast<int8_t>(0xff)};
-static const Color TRANSLUCENT_RED = {static_cast<int8_t>(0xff), 0, 0, 0x33};
-static const Color GREEN = {0, static_cast<int8_t>(0xff), 0, static_cast<int8_t>(0xff)};
-static const Color BLUE = {0, 0, static_cast<int8_t>(0xff), static_cast<int8_t>(0xff)};
-static const Color WHITE = {static_cast<int8_t>(0xff), static_cast<int8_t>(0xff),
- static_cast<int8_t>(0xff), static_cast<int8_t>(0xff)};
+static const Color BLACK = {0.0f, 0.0f, 0.0f, 1.0f};
+static const Color RED = {1.0f, 0.0f, 0.0f, 1.0f};
+static const Color TRANSLUCENT_RED = {1.0f, 0.0f, 0.0f, 0.3f};
+static const Color GREEN = {0.0f, 1.0f, 0.0f, 1.0f};
+static const Color BLUE = {0.0f, 0.0f, 1.0f, 1.0f};
+static const Color WHITE = {1.0f, 1.0f, 1.0f, 1.0f};
class TestRenderEngine;
diff --git a/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientWriter.h b/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientWriter.h
index b6090d7..d3266e7 100644
--- a/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientWriter.h
+++ b/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientWriter.h
@@ -30,7 +30,6 @@
#include <aidl/android/hardware/graphics/composer3/Color.h>
#include <aidl/android/hardware/graphics/composer3/Composition.h>
#include <aidl/android/hardware/graphics/composer3/DisplayBrightness.h>
-#include <aidl/android/hardware/graphics/composer3/FloatColor.h>
#include <aidl/android/hardware/graphics/composer3/Luminance.h>
#include <aidl/android/hardware/graphics/composer3/PerFrameMetadata.h>
#include <aidl/android/hardware/graphics/composer3/PerFrameMetadataBlob.h>
@@ -210,10 +209,6 @@
.perFrameMetadataBlob.emplace(metadata.begin(), metadata.end());
}
- void setLayerFloatColor(int64_t display, int64_t layer, FloatColor color) {
- getLayerCommand(display, layer).floatColor.emplace(color);
- }
-
void setLayerWhitePointNits(int64_t display, int64_t layer, float whitePointNits) {
getLayerCommand(display, layer).whitePointNits.emplace(Luminance{.nits = whitePointNits});
}