summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author John Reck <jreck@google.com> 2023-05-09 14:33:53 -0400
committer John Reck <jreck@google.com> 2023-05-09 18:12:11 -0400
commitd13852e6646ea4b83e94e6facc06301626dd841d (patch)
tree94cad38614c56300cfe2fe6653339f5ac1f1c14e
parentdaa90f677427abd84fab401ad71826bab7bc56d2 (diff)
More WebView HDR plumbing
Pass through format for GL and shouldDither if HWUI wants dithering globally enabled Fixes: 279030860 Test: make Change-Id: Ic9e767fede8be9664bb87a340573e5f424d0de3e
-rw-r--r--libs/hwui/pipeline/skia/GLFunctorDrawable.cpp3
-rw-r--r--libs/hwui/pipeline/skia/VkFunctorDrawable.cpp8
-rw-r--r--libs/hwui/private/hwui/DrawGlInfo.h7
-rw-r--r--libs/hwui/private/hwui/DrawVkInfo.h3
-rw-r--r--libs/hwui/renderthread/CanvasContext.cpp6
-rw-r--r--libs/hwui/renderthread/CanvasContext.h2
6 files changed, 27 insertions, 2 deletions
diff --git a/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp b/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp
index c58ba6868eb5..8d5967bbd461 100644
--- a/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp
+++ b/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp
@@ -27,6 +27,7 @@
#include "include/gpu/GpuTypes.h" // from Skia
#include "utils/GLUtils.h"
#include <effects/GainmapRenderer.h>
+#include "renderthread/CanvasContext.h"
namespace android {
namespace uirenderer {
@@ -131,6 +132,8 @@ void GLFunctorDrawable::onDraw(SkCanvas* canvas) {
mat4.getColMajor(&info.transform[0]);
info.color_space_ptr = canvas->imageInfo().colorSpace();
info.currentHdrSdrRatio = getTargetHdrSdrRatio(info.color_space_ptr);
+ info.fboColorType = canvas->imageInfo().colorType();
+ info.shouldDither = renderthread::CanvasContext::shouldDither();
// 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/VkFunctorDrawable.cpp b/libs/hwui/pipeline/skia/VkFunctorDrawable.cpp
index e299d12b1d67..b62711f50c94 100644
--- a/libs/hwui/pipeline/skia/VkFunctorDrawable.cpp
+++ b/libs/hwui/pipeline/skia/VkFunctorDrawable.cpp
@@ -15,22 +15,25 @@
*/
#include "VkFunctorDrawable.h"
-#include <private/hwui/DrawVkInfo.h>
#include <GrBackendDrawableInfo.h>
#include <SkAndroidFrameworkUtils.h>
#include <SkImage.h>
#include <SkM44.h>
#include <gui/TraceUtils.h>
+#include <private/hwui/DrawVkInfo.h>
#include <utils/Color.h>
#include <utils/Trace.h>
#include <vk/GrVkTypes.h>
+
#include <thread>
+
+#include "effects/GainmapRenderer.h"
+#include "renderthread/CanvasContext.h"
#include "renderthread/RenderThread.h"
#include "renderthread/VulkanManager.h"
#include "thread/ThreadBase.h"
#include "utils/TimeUtils.h"
-#include "effects/GainmapRenderer.h"
namespace android {
namespace uirenderer {
@@ -75,6 +78,7 @@ void VkFunctorDrawHandler::draw(const GrBackendDrawableInfo& info) {
.clip_bottom = mClip.fBottom,
.is_layer = !vulkan_info.fFromSwapchainOrAndroidWindow,
.currentHdrSdrRatio = getTargetHdrSdrRatio(mImageInfo.colorSpace()),
+ .shouldDither = renderthread::CanvasContext::shouldDither(),
};
mat4.getColMajor(&params.transform[0]);
params.secondary_command_buffer = vulkan_info.fSecondaryCommandBuffer;
diff --git a/libs/hwui/private/hwui/DrawGlInfo.h b/libs/hwui/private/hwui/DrawGlInfo.h
index 7888c8719e88..eb1f9304a5c8 100644
--- a/libs/hwui/private/hwui/DrawGlInfo.h
+++ b/libs/hwui/private/hwui/DrawGlInfo.h
@@ -18,6 +18,7 @@
#define ANDROID_HWUI_DRAW_GL_INFO_H
#include <SkColorSpace.h>
+#include <SkColorType.h>
namespace android {
namespace uirenderer {
@@ -91,6 +92,12 @@ struct DrawGlInfo {
// be baked into the color_space_ptr, so this is just to indicate the amount of extended
// range is available if desired
float currentHdrSdrRatio;
+
+ // Whether or not dithering is globally enabled
+ bool shouldDither;
+
+ // The color type of the destination framebuffer
+ SkColorType fboColorType;
}; // struct DrawGlInfo
} // namespace uirenderer
diff --git a/libs/hwui/private/hwui/DrawVkInfo.h b/libs/hwui/private/hwui/DrawVkInfo.h
index 8f7063d72314..122080658927 100644
--- a/libs/hwui/private/hwui/DrawVkInfo.h
+++ b/libs/hwui/private/hwui/DrawVkInfo.h
@@ -76,6 +76,9 @@ struct VkFunctorDrawParams {
// be baked into the color_space_ptr, so this is just to indicate the amount of extended
// range is available if desired
float currentHdrSdrRatio;
+
+ // Whether or not dithering is globally enabled
+ bool shouldDither;
};
} // namespace uirenderer
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index f60c1f3c6ad8..a73d7e463214 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -1077,6 +1077,12 @@ void CanvasContext::startHintSession() {
mHintSessionWrapper.init();
}
+bool CanvasContext::shouldDither() {
+ CanvasContext* self = getActiveContext();
+ if (!self) return false;
+ return self->mColorMode != ColorMode::Default;
+}
+
} /* namespace renderthread */
} /* namespace uirenderer */
} /* namespace android */
diff --git a/libs/hwui/renderthread/CanvasContext.h b/libs/hwui/renderthread/CanvasContext.h
index d7215de92375..613381aeaefa 100644
--- a/libs/hwui/renderthread/CanvasContext.h
+++ b/libs/hwui/renderthread/CanvasContext.h
@@ -234,6 +234,8 @@ public:
void startHintSession();
+ static bool shouldDither();
+
private:
CanvasContext(RenderThread& thread, bool translucent, RenderNode* rootRenderNode,
IContextFactory* contextFactory, std::unique_ptr<IRenderPipeline> renderPipeline,