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

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

Issue 14298018: This CL implements the first draft of Canvas 2D Context Attributes, aka getContext('2d', { alpha: f… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased to ToT; test cleanup Created 7 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 | « Source/core/core.gypi ('k') | Source/core/html/canvas/Canvas2DContextAttributes.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLCanvasElement.cpp
diff --git a/Source/core/html/HTMLCanvasElement.cpp b/Source/core/html/HTMLCanvasElement.cpp
index 72fc6c0c8257972699cd085ad5c3a3ae5b9d22b4..949fad9ff54b6854e81b84926295a884e3df57c1 100644
--- a/Source/core/html/HTMLCanvasElement.cpp
+++ b/Source/core/html/HTMLCanvasElement.cpp
@@ -37,7 +37,7 @@
#include "core/dom/ExceptionCode.h"
#include "core/dom/WebCoreMemoryInstrumentation.h"
#include "core/html/ImageData.h"
-#include "core/html/canvas/CanvasContextAttributes.h"
+#include "core/html/canvas/Canvas2DContextAttributes.h"
#include "core/html/canvas/CanvasGradient.h"
#include "core/html/canvas/CanvasPattern.h"
#include "core/html/canvas/CanvasRenderingContext2D.h"
@@ -45,6 +45,7 @@
#include "core/page/Chrome.h"
#include "core/page/Frame.h"
#include "core/page/Page.h"
+#include "core/page/RuntimeEnabledFeatures.h"
#include "core/page/Settings.h"
#include "core/platform/MIMETypeRegistry.h"
#include "core/platform/graphics/GraphicsContext.h"
@@ -164,7 +165,7 @@ CanvasRenderingContext* HTMLCanvasElement::getContext(const String& type, Canvas
if (m_context && !m_context->is2d())
return 0;
if (!m_context) {
- m_context = CanvasRenderingContext2D::create(this, document()->inQuirksMode());
+ m_context = CanvasRenderingContext2D::create(this, RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled() ? static_cast<Canvas2DContextAttributes*>(attrs) : 0, document()->inQuirksMode());
if (m_context) {
// Need to make sure a RenderLayer and compositing layer get created for the Canvas
setNeedsStyleRecalc(SyntheticStyleChange);
@@ -328,10 +329,11 @@ void HTMLCanvasElement::paint(GraphicsContext* context, const LayoutRect& r, boo
if (hasCreatedImageBuffer()) {
ImageBuffer* imageBuffer = buffer();
if (imageBuffer) {
+ CompositeOperator compositeOperator = !m_context || m_context->hasAlpha() ? CompositeSourceOver : CompositeCopy;
if (m_presentedImage)
- context->drawImage(m_presentedImage.get(), ColorSpaceDeviceRGB, pixelSnappedIntRect(r), CompositeSourceOver, DoNotRespectImageOrientation, useLowQualityScale);
+ context->drawImage(m_presentedImage.get(), ColorSpaceDeviceRGB, pixelSnappedIntRect(r), compositeOperator, DoNotRespectImageOrientation, useLowQualityScale);
else
- context->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, pixelSnappedIntRect(r), CompositeSourceOver, BlendModeNormal, useLowQualityScale);
+ context->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, pixelSnappedIntRect(r), compositeOperator, BlendModeNormal, useLowQualityScale);
}
}
@@ -499,8 +501,8 @@ void HTMLCanvasElement::createImageBuffer() const
return;
RenderingMode renderingMode = shouldAccelerate(bufferSize) ? Accelerated : UnacceleratedNonPlatformBuffer;
-
- m_imageBuffer = ImageBuffer::create(size(), m_deviceScaleFactor, ColorSpaceDeviceRGB, renderingMode);
+ OpacityMode opacityMode = !m_context || m_context->hasAlpha() ? NonOpaque : Opaque;
+ m_imageBuffer = ImageBuffer::create(size(), m_deviceScaleFactor, ColorSpaceDeviceRGB, renderingMode, opacityMode);
if (!m_imageBuffer)
return;
m_imageBuffer->context()->setShadowsIgnoreTransforms(true);
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/html/canvas/Canvas2DContextAttributes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698