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

Unified Diff: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp

Issue 2825183002: Plumb CanvasColorParams to canvas image classes (Closed)
Patch Set: Require both runtime flags 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
Index: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
index c16060de6f4197c7d5c35cbf256bb258931ed809..109f21e0f594c463946f4db5f073dee0bc9d1824 100644
--- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
@@ -892,10 +892,9 @@ class UnacceleratedSurfaceFactory
virtual std::unique_ptr<ImageBufferSurface> CreateSurface(
const IntSize& size,
OpacityMode opacity_mode,
- sk_sp<SkColorSpace> color_space,
- SkColorType color_type) {
+ const CanvasColorParams& color_params) {
return WTF::WrapUnique(new UnacceleratedImageBufferSurface(
- size, opacity_mode, kInitializeImagePixels, color_space, color_type));
+ size, opacity_mode, kInitializeImagePixels, color_params));
}
virtual ~UnacceleratedSurfaceFactory() {}
@@ -904,7 +903,10 @@ class UnacceleratedSurfaceFactory
} // namespace
bool HTMLCanvasElement::ShouldUseDisplayList() {
- if (context_->ColorSpace() != kLegacyCanvasColorSpace)
+ // Rasterization of web contents will blend in the output space. Only embed
+ // the canvas as a display list if it intended to do output space blending as
+ // well.
+ if (!context_->color_params().UsesOutputSpaceBlending())
return false;
if (RuntimeEnabledFeatures::forceDisplayList2dCanvasEnabled())
@@ -923,8 +925,7 @@ HTMLCanvasElement::CreateWebGLImageBufferSurface(OpacityMode opacity_mode) {
// then make a non-accelerated ImageBuffer. This means copying the internal
// Image will require a pixel readback, but that is unavoidable in this case.
auto surface = WTF::WrapUnique(new AcceleratedImageBufferSurface(
- size(), opacity_mode, context_->SkSurfaceColorSpace(),
- context_->ColorType()));
+ size(), opacity_mode, context_->color_params()));
if (surface->IsValid())
return std::move(surface);
return nullptr;
@@ -954,8 +955,7 @@ HTMLCanvasElement::CreateAcceleratedImageBufferSurface(OpacityMode opacity_mode,
std::unique_ptr<ImageBufferSurface> surface =
WTF::WrapUnique(new Canvas2DImageBufferSurface(
std::move(context_provider), size(), *msaa_sample_count, opacity_mode,
- Canvas2DLayerBridge::kEnableAcceleration, context_->GfxColorSpace(),
- context_->SkSurfacesUseColorSpace(), context_->ColorType()));
+ Canvas2DLayerBridge::kEnableAcceleration, context_->color_params()));
if (!surface->IsValid()) {
CanvasMetrics::CountCanvasContextUsage(
CanvasMetrics::kGPUAccelerated2DCanvasImageBufferCreationFailed);
@@ -973,7 +973,7 @@ HTMLCanvasElement::CreateUnacceleratedImageBufferSurface(
if (ShouldUseDisplayList()) {
auto surface = WTF::WrapUnique(new RecordingImageBufferSurface(
size(), WTF::WrapUnique(new UnacceleratedSurfaceFactory), opacity_mode,
- context_->SkSurfaceColorSpace(), context_->ColorType()));
+ context_->color_params()));
if (surface->IsValid()) {
CanvasMetrics::CountCanvasContextUsage(
CanvasMetrics::kDisplayList2DCanvasImageBufferCreated);
@@ -985,8 +985,7 @@ HTMLCanvasElement::CreateUnacceleratedImageBufferSurface(
auto surface_factory = WTF::MakeUnique<UnacceleratedSurfaceFactory>();
auto surface = surface_factory->CreateSurface(size(), opacity_mode,
- context_->SkSurfaceColorSpace(),
- context_->ColorType());
+ context_->color_params());
if (surface->IsValid()) {
CanvasMetrics::CountCanvasContextUsage(
CanvasMetrics::kUnaccelerated2DCanvasImageBufferCreated);

Powered by Google App Engine
This is Rietveld 408576698