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

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

Issue 1331533002: [poc] curve-filter Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix CanvasRenderingContext2D::createPattern crash for #40 Created 4 years, 11 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 85f5d4e1e5d29d5ba45d9c62987d537e0bef5296..9641fac5dfff411b371f39311a67bab2f0f14f70 100644
--- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
@@ -50,7 +50,10 @@
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/graphics/Canvas2DImageBufferSurface.h"
#include "platform/graphics/CanvasMetrics.h"
+#include "platform/graphics/ColorSpaceFilter.h"
+#include "platform/graphics/ColorSpaceProfile.h"
#include "platform/graphics/ExpensiveCanvasHeuristicParameters.h"
+#include "platform/graphics/GraphicsScreen.h"
#include "platform/graphics/ImageBuffer.h"
#include "platform/graphics/RecordingImageBufferSurface.h"
#include "platform/graphics/StaticBitmapImage.h"
@@ -451,17 +454,27 @@ void HTMLCanvasElement::notifyListenersCanvasChanged()
void HTMLCanvasElement::paint(GraphicsContext& context, const LayoutRect& r)
{
+ RELEASE_ASSERT(currentScreenId()); // There should be an active graphics screen.
+
// FIXME: crbug.com/438240; there is a bug with the new CSS blending and compositing feature.
if (!m_context)
return;
+
if (!paintsIntoCanvasBuffer() && !document().printing())
return;
m_context->paintRenderingResultsToCanvas(FrontBuffer);
+
+ RefPtr<SkColorFilter> colorTransform;
+ if (RefPtr<ColorSpaceProfile> source = screenColorProfile(ScreenDevice::sRGB)) {
+ RefPtr<ColorSpaceProfile> target = screenColorProfile(currentScreenId());
+ colorTransform = createColorSpaceFilter(source.get(), target.get());
+ }
+
if (hasImageBuffer()) {
if (!context.contextDisabled()) {
SkXfermode::Mode compositeOperator = !m_context || m_context->hasAlpha() ? SkXfermode::kSrcOver_Mode : SkXfermode::kSrc_Mode;
- buffer()->draw(context, pixelSnappedIntRect(r), 0, compositeOperator);
+ buffer()->draw(context, pixelSnappedIntRect(r), 0, compositeOperator, colorTransform.get());
}
} else {
// When alpha is false, we should draw to opaque black.
@@ -737,12 +750,14 @@ PassOwnPtr<ImageBufferSurface> HTMLCanvasElement::createImageBufferSurface(const
}
surfaceFactory = adoptPtr(new UnacceleratedSurfaceFactory()); // recreate because previous one was released
}
+
auto surface = surfaceFactory->createSurface(deviceSize, opacityMode);
if (!surface->isValid()) {
CanvasMetrics::countCanvasContextUsage(CanvasMetrics::Unaccelerated2DCanvasImageBufferCreationFailed);
} else {
CanvasMetrics::countCanvasContextUsage(CanvasMetrics::Unaccelerated2DCanvasImageBufferCreated);
}
+
return surface;
}
« no previous file with comments | « third_party/WebKit/Source/core/frame/LocalFrame.cpp ('k') | third_party/WebKit/Source/core/html/HTMLVideoElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698