summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/hwui/DeviceInfo.cpp13
-rw-r--r--libs/hwui/DeviceInfo.h8
-rw-r--r--libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp14
-rw-r--r--libs/hwui/pipeline/skia/SkiaOpenGLPipeline.h2
-rw-r--r--libs/hwui/pipeline/skia/SkiaPipeline.h5
-rw-r--r--libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp8
-rw-r--r--libs/hwui/pipeline/skia/SkiaVulkanPipeline.h2
-rw-r--r--libs/hwui/renderthread/CanvasContext.cpp3
-rw-r--r--libs/hwui/renderthread/EglManager.cpp23
-rw-r--r--libs/hwui/renderthread/EglManager.h6
-rw-r--r--libs/hwui/renderthread/IRenderPipeline.h11
-rw-r--r--libs/hwui/renderthread/VulkanManager.h4
-rw-r--r--libs/hwui/tests/unit/SkiaPipelineTests.cpp2
-rw-r--r--libs/hwui/utils/Color.cpp39
-rw-r--r--libs/hwui/utils/Color.h4
15 files changed, 17 insertions, 127 deletions
diff --git a/libs/hwui/DeviceInfo.cpp b/libs/hwui/DeviceInfo.cpp
index 21fbbdca7ad0..0b9d82b105a3 100644
--- a/libs/hwui/DeviceInfo.cpp
+++ b/libs/hwui/DeviceInfo.cpp
@@ -61,18 +61,6 @@ DisplayInfo QueryDisplayInfo() {
return displayInfo;
}
-void QueryCompositionPreference(ui::Dataspace* dataSpace,
- ui::PixelFormat* pixelFormat) {
- if (Properties::isolatedProcess) {
- *dataSpace = ui::Dataspace::V0_SRGB;
- *pixelFormat = ui::PixelFormat::RGBA_8888;
- }
-
- status_t status =
- SurfaceComposerClient::getCompositionPreference(dataSpace, pixelFormat);
- LOG_ALWAYS_FATAL_IF(status, "Failed to get composition preference, error %d", status);
-}
-
DeviceInfo::DeviceInfo() {
#if HWUI_NULL_GPU
mMaxTextureSize = NULL_GPU_MAX_TEXTURE_SIZE;
@@ -80,7 +68,6 @@ DeviceInfo::DeviceInfo() {
mMaxTextureSize = -1;
#endif
mDisplayInfo = QueryDisplayInfo();
- QueryCompositionPreference(&mTargetDataSpace, &mTargetPixelFormat);
}
int DeviceInfo::maxTextureSize() const {
diff --git a/libs/hwui/DeviceInfo.h b/libs/hwui/DeviceInfo.h
index 1d7477416077..595621573e6e 100644
--- a/libs/hwui/DeviceInfo.h
+++ b/libs/hwui/DeviceInfo.h
@@ -17,7 +17,6 @@
#define DEVICEINFO_H
#include <ui/DisplayInfo.h>
-#include <ui/GraphicTypes.h>
#include "utils/Macros.h"
@@ -37,9 +36,6 @@ public:
// this value is only valid after the GPU has been initialized and there is a valid graphics
// context or if you are using the HWUI_NULL_GPU
int maxTextureSize() const;
-
- ui::Dataspace getTargetDataSpace() const { return mTargetDataSpace; }
- ui::PixelFormat getTargetPixelFormat() const { return mTargetPixelFormat; }
const DisplayInfo& displayInfo() const { return mDisplayInfo; }
private:
@@ -50,10 +46,6 @@ private:
int mMaxTextureSize;
DisplayInfo mDisplayInfo;
-
- // TODO(lpy) Replace below with android_ prefix types.
- ui::Dataspace mTargetDataSpace;
- ui::PixelFormat mTargetPixelFormat;
};
} /* namespace uirenderer */
diff --git a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
index e8bf4922cd46..d401b385075e 100644
--- a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
+++ b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
@@ -167,6 +167,12 @@ bool SkiaOpenGLPipeline::setSurface(Surface* surface, SwapBehavior swapBehavior,
mEglSurface = mEglManager.createSurface(surface, colorMode);
}
+ if (colorMode == ColorMode::SRGB) {
+ mSurfaceColorType = SkColorType::kN32_SkColorType;
+ } else if (colorMode == ColorMode::WideColorGamut) {
+ mSurfaceColorType = SkColorType::kRGBA_F16_SkColorType;
+ }
+
if (mEglSurface != EGL_NO_SURFACE) {
const bool preserveBuffer = (swapBehavior != SwapBehavior::kSwap_discardBuffer);
mBufferPreserved = mEglManager.setPreserveBuffer(mEglSurface, preserveBuffer);
@@ -184,14 +190,6 @@ bool SkiaOpenGLPipeline::isContextReady() {
return CC_LIKELY(mEglManager.hasEglContext());
}
-SkColorType SkiaOpenGLPipeline::getSurfaceColorType() const {
- return mEglManager.getSurfaceColorType();
-}
-
-sk_sp<SkColorSpace> SkiaOpenGLPipeline::getSurfaceColorSpace() {
- return mEglManager.getSurfaceColorSpace();
-}
-
void SkiaOpenGLPipeline::invokeFunctor(const RenderThread& thread, Functor* functor) {
DrawGlInfo::Mode mode = DrawGlInfo::kModeProcessNoContext;
if (thread.eglManager().hasEglContext()) {
diff --git a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.h b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.h
index 086a76088a75..4ab3541d447b 100644
--- a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.h
+++ b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.h
@@ -47,8 +47,6 @@ public:
void onStop() override;
bool isSurfaceReady() override;
bool isContextReady() override;
- SkColorType getSurfaceColorType() const override;
- sk_sp<SkColorSpace> getSurfaceColorSpace() override;
static void invokeFunctor(const renderthread::RenderThread& thread, Functor* functor);
diff --git a/libs/hwui/pipeline/skia/SkiaPipeline.h b/libs/hwui/pipeline/skia/SkiaPipeline.h
index ee9158c5ffc1..42a411a6808c 100644
--- a/libs/hwui/pipeline/skia/SkiaPipeline.h
+++ b/libs/hwui/pipeline/skia/SkiaPipeline.h
@@ -48,6 +48,9 @@ public:
bool createOrUpdateLayer(RenderNode* node, const DamageAccumulator& damageAccumulator,
ErrorHandler* errorHandler) override;
+ SkColorType getSurfaceColorType() const { return mSurfaceColorType; }
+ sk_sp<SkColorSpace> getSurfaceColorSpace() override { return mSurfaceColorSpace; }
+
void renderFrame(const LayerUpdateQueue& layers, const SkRect& clip,
const std::vector<sp<RenderNode>>& nodes, bool opaque,
const Rect& contentDrawBounds, sk_sp<SkSurface> surface);
@@ -106,6 +109,8 @@ protected:
void dumpResourceCacheUsage() const;
renderthread::RenderThread& mRenderThread;
+ SkColorType mSurfaceColorType;
+ sk_sp<SkColorSpace> mSurfaceColorSpace;
private:
void renderFrameImpl(const LayerUpdateQueue& layers, const SkRect& clip,
diff --git a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp
index e34f160467af..8e15b8af82a7 100644
--- a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp
+++ b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp
@@ -138,14 +138,6 @@ bool SkiaVulkanPipeline::isContextReady() {
return CC_LIKELY(mVkManager.hasVkContext());
}
-SkColorType SkiaVulkanPipeline::getSurfaceColorType() const {
- return mVkManager.getSurfaceColorType();
-}
-
-sk_sp<SkColorSpace> SkiaVulkanPipeline::getSurfaceColorSpace() {
- return mVkManager.getSurfaceColorSpace();
-}
-
void SkiaVulkanPipeline::invokeFunctor(const RenderThread& thread, Functor* functor) {
VkFunctorDrawable::vkInvokeFunctor(functor);
}
diff --git a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.h b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.h
index 6e723a8373e1..14c0d69dba33 100644
--- a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.h
+++ b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.h
@@ -43,8 +43,6 @@ public:
void onStop() override;
bool isSurfaceReady() override;
bool isContextReady() override;
- SkColorType getSurfaceColorType() const override;
- sk_sp<SkColorSpace> getSurfaceColorSpace() override;
static void invokeFunctor(const renderthread::RenderThread& thread, Functor* functor);
static sk_sp<Bitmap> allocateHardwareBitmap(renderthread::RenderThread& thread,
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index c8c394a72541..92a749f3da33 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -144,8 +144,7 @@ void CanvasContext::setSurface(sp<Surface>&& surface) {
mNativeSurface = std::move(surface);
- // TODO(b/111436479) Introduce a way for app to specify DisplayColorGamut mode.
- ColorMode colorMode = mWideColorGamut ? ColorMode::WideColorGamut : ColorMode::Legacy;
+ ColorMode colorMode = mWideColorGamut ? ColorMode::WideColorGamut : ColorMode::SRGB;
bool hasSurface = mRenderPipeline->setSurface(mNativeSurface.get(), mSwapBehavior, colorMode);
mFrameNumber = -1;
diff --git a/libs/hwui/renderthread/EglManager.cpp b/libs/hwui/renderthread/EglManager.cpp
index 0cb23e532064..d4ffddde8def 100644
--- a/libs/hwui/renderthread/EglManager.cpp
+++ b/libs/hwui/renderthread/EglManager.cpp
@@ -126,17 +126,6 @@ void EglManager::initialize() {
createContext();
createPBufferSurface();
makeCurrent(mPBufferSurface, nullptr, /* force */ true);
-
- mSurfaceColorGamut = DataSpaceToColorGamut(
- static_cast<android_dataspace>(DeviceInfo::get()->getTargetDataSpace()));
-
- LOG_ALWAYS_FATAL_IF(mSurfaceColorGamut == SkColorSpace::kDCIP3_D65_Gamut &&
- !EglExtensions.displayP3, "EGL doesn't support Display P3.");
-
- mSurfaceColorType = PixelFormatToColorType(
- static_cast<android_pixel_format>(DeviceInfo::get()->getTargetPixelFormat()));
- mSurfaceColorSpace = DataSpaceToColorSpace(
- static_cast<android_dataspace>(DeviceInfo::get()->getTargetDataSpace()));
}
void EglManager::initExtensions() {
@@ -309,21 +298,13 @@ EGLSurface EglManager::createSurface(EGLNativeWindowType window, ColorMode color
if (wideColorGamut) {
attribs[1] = EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT;
} else {
- if (mSurfaceColorGamut == SkColorSpace::kDCIP3_D65_Gamut) {
- attribs[1] = EGL_GL_COLORSPACE_DISPLAY_P3_EXT;
- } else {
- attribs[1] = EGL_GL_COLORSPACE_SRGB_KHR;
- }
+ attribs[1] = EGL_GL_COLORSPACE_SRGB_KHR;
}
#else
if (wideColorGamut) {
attribs[1] = EGL_GL_COLORSPACE_SCRGB_EXT;
} else {
- if (mSurfaceColorGamut == SkColorSpace::kDCIP3_D65_Gamut) {
- attribs[1] = EGL_GL_COLORSPACE_DISPLAY_P3_EXT;
- } else {
- attribs[1] = EGL_GL_COLORSPACE_LINEAR_KHR;
- }
+ attribs[1] = EGL_GL_COLORSPACE_LINEAR_KHR;
}
#endif
}
diff --git a/libs/hwui/renderthread/EglManager.h b/libs/hwui/renderthread/EglManager.h
index e97228cd0a39..55c81d42d8a0 100644
--- a/libs/hwui/renderthread/EglManager.h
+++ b/libs/hwui/renderthread/EglManager.h
@@ -78,9 +78,6 @@ public:
// Depending on installed extensions, the result is either Android native fence or EGL fence.
status_t createReleaseFence(bool useFenceSync, EGLSyncKHR* eglFence, sp<Fence>& nativeFence);
- SkColorType getSurfaceColorType() const { return mSurfaceColorType; }
- sk_sp<SkColorSpace> getSurfaceColorSpace() { return mSurfaceColorSpace; }
-
private:
void initExtensions();
@@ -95,9 +92,6 @@ private:
EGLContext mEglContext;
EGLSurface mPBufferSurface;
EGLSurface mCurrentSurface;
- SkColorSpace::Gamut mSurfaceColorGamut;
- SkColorType mSurfaceColorType;
- sk_sp<SkColorSpace> mSurfaceColorSpace;
enum class SwapBehavior {
Discard,
diff --git a/libs/hwui/renderthread/IRenderPipeline.h b/libs/hwui/renderthread/IRenderPipeline.h
index 0297c9c141ff..4972554c65cc 100644
--- a/libs/hwui/renderthread/IRenderPipeline.h
+++ b/libs/hwui/renderthread/IRenderPipeline.h
@@ -43,15 +43,8 @@ namespace renderthread {
enum class MakeCurrentResult { AlreadyCurrent, Failed, Succeeded };
enum class ColorMode {
- // Legacy means HWUI will produce buffer with whatever platform prefers
- // HWUI to produce, however, HWUI doesn't accurately convert color from
- // source color space to destination color space, instead HWUI will take
- // the pixel value directly and interpret it destination color space.
- Legacy,
- // DisplayColorGamut means HWUI will produce buffer with whatever platform
- // prefers HWUI to produce and accurately convert color from source color
- // space to destination color space.
- DisplayColorGamut,
+ // SRGB means HWUI will produce buffer in SRGB color space.
+ SRGB,
// WideColorGamut means HWUI would support rendering scRGB non-linear into
// a signed buffer with enough range to support the wide color gamut of the
// display.
diff --git a/libs/hwui/renderthread/VulkanManager.h b/libs/hwui/renderthread/VulkanManager.h
index 7a539ae42605..ebc11a50685e 100644
--- a/libs/hwui/renderthread/VulkanManager.h
+++ b/libs/hwui/renderthread/VulkanManager.h
@@ -118,10 +118,6 @@ public:
// Creates a fence that is signaled, when all the pending Vulkan commands are flushed.
status_t createReleaseFence(sp<Fence>& nativeFence);
- // TODO(b/115636873): Handle composition preference.
- SkColorType getSurfaceColorType() const { return SkColorType::kN32_SkColorType; }
- sk_sp<SkColorSpace> getSurfaceColorSpace() { return SkColorSpace::MakeSRGB(); }
-
private:
friend class RenderThread;
diff --git a/libs/hwui/tests/unit/SkiaPipelineTests.cpp b/libs/hwui/tests/unit/SkiaPipelineTests.cpp
index 680fcb3a732b..cdf31da37074 100644
--- a/libs/hwui/tests/unit/SkiaPipelineTests.cpp
+++ b/libs/hwui/tests/unit/SkiaPipelineTests.cpp
@@ -386,7 +386,7 @@ RENDERTHREAD_SKIA_PIPELINE_TEST(SkiaPipeline, clip_replace) {
RENDERTHREAD_SKIA_PIPELINE_TEST(SkiaPipeline, context_lost) {
auto pipeline = std::make_unique<SkiaOpenGLPipeline>(renderThread);
EXPECT_FALSE(pipeline->isSurfaceReady());
- EXPECT_TRUE(pipeline->setSurface((Surface*)0x01, SwapBehavior::kSwap_default, ColorMode::Legacy));
+ EXPECT_TRUE(pipeline->setSurface((Surface*)0x01, SwapBehavior::kSwap_default, ColorMode::SRGB));
EXPECT_TRUE(pipeline->isSurfaceReady());
renderThread.destroyGlContext();
EXPECT_FALSE(pipeline->isSurfaceReady());
diff --git a/libs/hwui/utils/Color.cpp b/libs/hwui/utils/Color.cpp
index 9f71e91629fb..3fb6a31a7d97 100644
--- a/libs/hwui/utils/Color.cpp
+++ b/libs/hwui/utils/Color.cpp
@@ -57,21 +57,6 @@ bool transferFunctionCloseToSRGB(const SkColorSpace* colorSpace) {
return false;
}
-SkColorType PixelFormatToColorType(android_pixel_format pixelFormat) {
- switch (pixelFormat) {
- case HAL_PIXEL_FORMAT_RGBA_8888:
- case HAL_PIXEL_FORMAT_BGRA_8888:
- return SkColorType::kN32_SkColorType;
- case HAL_PIXEL_FORMAT_RGBA_FP16:
- return SkColorType::kRGBA_F16_SkColorType;
- case HAL_PIXEL_FORMAT_RGBA_1010102:
- return SkColorType::kRGBA_1010102_SkColorType;
- default:
- ALOGW("Unsupported pixel format: %d, return kN32 by default", pixelFormat);
- return SkColorType::kN32_SkColorType;
- }
-}
-
android::PixelFormat ColorTypeToPixelFormat(SkColorType colorType) {
switch (colorType) {
case kRGBA_8888_SkColorType:
@@ -92,30 +77,6 @@ android::PixelFormat ColorTypeToPixelFormat(SkColorType colorType) {
}
}
-SkColorSpace::Gamut DataSpaceToColorGamut(android_dataspace dataSpace) {
- switch (dataSpace & HAL_DATASPACE_STANDARD_MASK) {
- case HAL_DATASPACE_STANDARD_BT709:
- return SkColorSpace::kSRGB_Gamut;
- case HAL_DATASPACE_STANDARD_BT2020:
- return SkColorSpace::kRec2020_Gamut;
- case HAL_DATASPACE_STANDARD_DCI_P3:
- return SkColorSpace::kDCIP3_D65_Gamut;
- case HAL_DATASPACE_STANDARD_ADOBE_RGB:
- return SkColorSpace::kAdobeRGB_Gamut;
- case HAL_DATASPACE_STANDARD_UNSPECIFIED:
- case HAL_DATASPACE_STANDARD_BT601_625:
- case HAL_DATASPACE_STANDARD_BT601_625_UNADJUSTED:
- case HAL_DATASPACE_STANDARD_BT601_525:
- case HAL_DATASPACE_STANDARD_BT601_525_UNADJUSTED:
- case HAL_DATASPACE_STANDARD_BT2020_CONSTANT_LUMINANCE:
- case HAL_DATASPACE_STANDARD_BT470M:
- case HAL_DATASPACE_STANDARD_FILM:
- default:
- ALOGW("Unsupported Gamut: %d, return SRGB gamut by default", dataSpace);
- return SkColorSpace::kSRGB_Gamut;
- }
-}
-
sk_sp<SkColorSpace> DataSpaceToColorSpace(android_dataspace dataspace) {
SkColorSpace::Gamut gamut;
diff --git a/libs/hwui/utils/Color.h b/libs/hwui/utils/Color.h
index e935a0d5ec8b..4daccda78e23 100644
--- a/libs/hwui/utils/Color.h
+++ b/libs/hwui/utils/Color.h
@@ -115,12 +115,8 @@ static constexpr float EOCF(float srgb) {
// returns true for sRGB, gamma 2.2 and Display P3 for instance
bool transferFunctionCloseToSRGB(const SkColorSpace* colorSpace);
-SkColorType PixelFormatToColorType(android_pixel_format pixelFormat);
-
android::PixelFormat ColorTypeToPixelFormat(SkColorType colorType);
-SkColorSpace::Gamut DataSpaceToColorGamut(android_dataspace dataSpace);
-
sk_sp<SkColorSpace> DataSpaceToColorSpace(android_dataspace dataspace);
struct Lab {