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

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

Issue 2559013002: Add ColorBehavior to blink::Image draw methods (Closed)
Patch Set: Rebase Created 4 years 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 142aeed0e4480d3f0133ad2a143ae2408516d452..a8768ff5c3cc732a020f6d9eb5d190d0d97cbb50 100644
--- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
@@ -490,7 +490,10 @@ void HTMLCanvasElement::notifyListenersCanvasChanged() {
FloatSize());
if (status != NormalSourceImageStatus)
return;
- sk_sp<SkImage> image = sourceImage->imageForCurrentFrame();
+ // TODO(ccameron): Canvas should produce sRGB images.
+ // https://crbug.com/672299
+ sk_sp<SkImage> image = sourceImage->imageForCurrentFrame(
+ ColorBehavior::transformToGlobalTarget());
for (CanvasDrawListener* listener : m_listeners) {
if (listener->needsNewFrame()) {
listener->sendNewFrame(image);
@@ -620,7 +623,10 @@ ImageData* HTMLCanvasElement::toImageData(SourceDrawingBuffer sourceBuffer,
if (hasImageBuffer()) {
snapshot = buffer()->newSkImageSnapshot(PreferNoAcceleration, reason);
} else if (placeholderFrame()) {
- snapshot = placeholderFrame()->imageForCurrentFrame();
+ // TODO(ccameron): Canvas should produce sRGB images.
+ // https://crbug.com/672299
+ snapshot = placeholderFrame()->imageForCurrentFrame(
+ ColorBehavior::transformToGlobalTarget());
}
if (snapshot) {
@@ -1207,6 +1213,8 @@ PassRefPtr<Image> HTMLCanvasElement::getSourceImageForCanvas(
return m_context->getImage(hint, reason);
sk_sp<SkImage> skImage;
+ // TODO(ccameron): Canvas should produce sRGB images.
+ // https://crbug.com/672299
if (m_context->is3d()) {
// Because WebGL sources always require making a copy of the back buffer, we
// use paintRenderingResultsToCanvas instead of getImage in order to keep a
@@ -1214,7 +1222,8 @@ PassRefPtr<Image> HTMLCanvasElement::getSourceImageForCanvas(
renderingContext()->paintRenderingResultsToCanvas(BackBuffer);
skImage = hasImageBuffer()
? buffer()->newSkImageSnapshot(hint, reason)
- : createTransparentImage(size())->imageForCurrentFrame();
+ : createTransparentImage(size())->imageForCurrentFrame(
+ ColorBehavior::transformToGlobalTarget());
} else {
if (ExpensiveCanvasHeuristicParameters::
DisableAccelerationToAvoidReadbacks &&
@@ -1223,8 +1232,11 @@ PassRefPtr<Image> HTMLCanvasElement::getSourceImageForCanvas(
hasImageBuffer())
buffer()->disableAcceleration();
RefPtr<blink::Image> image = renderingContext()->getImage(hint, reason);
- skImage = image ? image->imageForCurrentFrame()
- : createTransparentImage(size())->imageForCurrentFrame();
+ skImage = image
+ ? image->imageForCurrentFrame(
+ ColorBehavior::transformToGlobalTarget())
+ : createTransparentImage(size())->imageForCurrentFrame(
+ ColorBehavior::transformToGlobalTarget());
}
if (skImage) {

Powered by Google App Engine
This is Rietveld 408576698