summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/hwui/pipeline/skia/GLFunctorDrawable.cpp1
-rw-r--r--libs/hwui/pipeline/skia/VkInteropFunctorDrawable.cpp5
-rw-r--r--libs/hwui/private/hwui/DrawGlInfo.h5
-rw-r--r--native/webview/plat_support/draw_fn.h13
-rw-r--r--native/webview/plat_support/draw_functor.cpp14
5 files changed, 35 insertions, 3 deletions
diff --git a/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp b/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp
index 60c805741058..a1b2b18195bc 100644
--- a/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp
+++ b/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp
@@ -138,6 +138,7 @@ void GLFunctorDrawable::onDraw(SkCanvas* canvas) {
info.width = fboSize.width();
info.height = fboSize.height();
mat4.asColMajorf(&info.transform[0]);
+ info.color_space_ptr = canvas->imageInfo().colorSpace();
// ensure that the framebuffer that the webview will render into is bound before we clear
// the stencil and/or draw the functor.
diff --git a/libs/hwui/pipeline/skia/VkInteropFunctorDrawable.cpp b/libs/hwui/pipeline/skia/VkInteropFunctorDrawable.cpp
index c3563dbfd3cd..706325f00bd2 100644
--- a/libs/hwui/pipeline/skia/VkInteropFunctorDrawable.cpp
+++ b/libs/hwui/pipeline/skia/VkInteropFunctorDrawable.cpp
@@ -132,6 +132,7 @@ void VkInteropFunctorDrawable::onDraw(SkCanvas* canvas) {
info.width = mFBInfo.width();
info.height = mFBInfo.height();
mat4.asColMajorf(&info.transform[0]);
+ info.color_space_ptr = canvas->imageInfo().colorSpace();
glViewport(0, 0, info.width, info.height);
@@ -179,8 +180,8 @@ void VkInteropFunctorDrawable::onDraw(SkCanvas* canvas) {
canvas->resetMatrix();
auto functorImage = SkImage::MakeFromAHardwareBuffer(
- reinterpret_cast<AHardwareBuffer*>(mFrameBuffer.get()), kPremul_SkAlphaType, nullptr,
- kBottomLeft_GrSurfaceOrigin);
+ reinterpret_cast<AHardwareBuffer*>(mFrameBuffer.get()), kPremul_SkAlphaType,
+ canvas->imageInfo().refColorSpace(), kBottomLeft_GrSurfaceOrigin);
canvas->drawImage(functorImage, 0, 0, &paint);
canvas->restore();
}
diff --git a/libs/hwui/private/hwui/DrawGlInfo.h b/libs/hwui/private/hwui/DrawGlInfo.h
index 9e1bb8e8e548..501b8df9bc36 100644
--- a/libs/hwui/private/hwui/DrawGlInfo.h
+++ b/libs/hwui/private/hwui/DrawGlInfo.h
@@ -17,6 +17,8 @@
#ifndef ANDROID_HWUI_DRAW_GL_INFO_H
#define ANDROID_HWUI_DRAW_GL_INFO_H
+#include <SkColorSpace.h>
+
namespace android {
namespace uirenderer {
@@ -41,6 +43,9 @@ struct DrawGlInfo {
// Input: current transform matrix, in OpenGL format
float transform[16];
+ // Input: Color space.
+ const SkColorSpace* color_space_ptr;
+
// Output: dirty region to redraw
float dirtyLeft;
float dirtyTop;
diff --git a/native/webview/plat_support/draw_fn.h b/native/webview/plat_support/draw_fn.h
index 0490e650a7a4..e31ce195214f 100644
--- a/native/webview/plat_support/draw_fn.h
+++ b/native/webview/plat_support/draw_fn.h
@@ -20,7 +20,8 @@ extern "C" {
// android to chromium are versioned.
//
// 1 is Android Q. This matches kAwDrawGLInfoVersion version 3.
-static const int kAwDrawFnVersion = 1;
+// 2 Adds transfer_function_* and color_space_toXYZD50 to AwDrawFn_DrawGLParams.
+static const int kAwDrawFnVersion = 2;
struct AwDrawFn_OnSyncParams {
int version;
@@ -64,6 +65,16 @@ struct AwDrawFn_DrawGLParams {
// Input: current transformation matrix in surface pixels.
// Uses the column-based OpenGL matrix format.
float transform[16];
+
+ // Input: Color space parameters.
+ float transfer_function_g;
+ float transfer_function_a;
+ float transfer_function_b;
+ float transfer_function_c;
+ float transfer_function_d;
+ float transfer_function_e;
+ float transfer_function_f;
+ float color_space_toXYZD50[9];
};
struct AwDrawFn_InitVkParams {
diff --git a/native/webview/plat_support/draw_functor.cpp b/native/webview/plat_support/draw_functor.cpp
index b97bbc311624..afe103a25043 100644
--- a/native/webview/plat_support/draw_functor.cpp
+++ b/native/webview/plat_support/draw_functor.cpp
@@ -55,6 +55,8 @@ void onDestroyed(int functor, void* data) {
void draw_gl(int functor, void* data,
const uirenderer::DrawGlInfo& draw_gl_params) {
+ float gabcdef[7];
+ draw_gl_params.color_space_ptr->transferFn(gabcdef);
AwDrawFn_DrawGLParams params = {
.version = kAwDrawFnVersion,
.clip_left = draw_gl_params.clipLeft,
@@ -64,12 +66,24 @@ void draw_gl(int functor, void* data,
.width = draw_gl_params.width,
.height = draw_gl_params.height,
.is_layer = draw_gl_params.isLayer,
+ .transfer_function_g = gabcdef[0],
+ .transfer_function_a = gabcdef[1],
+ .transfer_function_b = gabcdef[2],
+ .transfer_function_c = gabcdef[3],
+ .transfer_function_d = gabcdef[4],
+ .transfer_function_e = gabcdef[5],
+ .transfer_function_f = gabcdef[6],
};
COMPILE_ASSERT(NELEM(params.transform) == NELEM(draw_gl_params.transform),
mismatched_transform_matrix_sizes);
for (int i = 0; i < NELEM(params.transform); ++i) {
params.transform[i] = draw_gl_params.transform[i];
}
+ COMPILE_ASSERT(sizeof(params.color_space_toXYZD50) == sizeof(skcms_Matrix3x3),
+ gamut_transform_size_mismatch);
+ draw_gl_params.color_space_ptr->toXYZD50(
+ reinterpret_cast<skcms_Matrix3x3*>(&params.color_space_toXYZD50));
+
SupportData* support = static_cast<SupportData*>(data);
support->callbacks.draw_gl(functor, support->data, &params);
}