Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(838)

Unified Diff: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp

Issue 2820823004: Make Canvas2DLayerBridge use SkColorSpaceXformCanvas (Closed)
Patch Set: Add comment Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
index cf7ef93a9808be5ba8a74d1d40058b64c998be26..1cef1ac82054c64522dbc3563e3a1868df015d50 100644
--- a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
@@ -48,6 +48,7 @@
#include "public/platform/WebScheduler.h"
#include "public/platform/WebTraceLocation.h"
#include "skia/ext/texture_handle.h"
+#include "third_party/skia/include/core/SkColorSpaceXformCanvas.h"
#include "third_party/skia/include/core/SkData.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/GrContext.h"
@@ -779,8 +780,20 @@ void Canvas2DLayerBridge::FlushRecordingOnly() {
if (have_recorded_draw_commands_ && GetOrCreateSurface()) {
TRACE_EVENT0("cc", "Canvas2DLayerBridge::flushRecordingOnly");
- recorder_->finishRecordingAsPicture()->playback(
- GetOrCreateSurface()->getCanvas());
+
+ // For legacy canvases, transform all input colors and images to the target
+ // space using a SkCreateColorSpaceXformCanvas. This ensures blending will
+ // be done using target space pixel values.
+ SkCanvas* canvas = GetOrCreateSurface()->getCanvas();
+ std::unique_ptr<SkCanvas> color_transform_canvas;
+ if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled() &&
+ !sk_surfaces_use_color_space_) {
+ color_transform_canvas =
+ SkCreateColorSpaceXformCanvas(canvas, color_space_.ToSkColorSpace());
+ canvas = color_transform_canvas.get();
+ }
+
+ recorder_->finishRecordingAsPicture()->playback(canvas);
if (is_deferral_enabled_)
StartRecording();
have_recorded_draw_commands_ = false;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698