Index: Source/core/html/HTMLCanvasElement.cpp |
diff --git a/Source/core/html/HTMLCanvasElement.cpp b/Source/core/html/HTMLCanvasElement.cpp |
index 0bbefb7132038931f62c17e0fbc5c1dc773dc6cf..f8fa78de4095cdd2e013d71345da109b8541f8e8 100644 |
--- a/Source/core/html/HTMLCanvasElement.cpp |
+++ b/Source/core/html/HTMLCanvasElement.cpp |
@@ -31,7 +31,7 @@ |
#include <math.h> |
#include <stdio.h> |
#include "Attribute.h" |
-#include "CanvasContextAttributes.h" |
+#include "Canvas2DContextAttributes.h" |
#include "CanvasGradient.h" |
#include "CanvasPattern.h" |
#include "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" |
@@ -160,11 +161,12 @@ CanvasRenderingContext* HTMLCanvasElement::getContext(const String& type, Canvas |
// FIXME - The code depends on the context not going away once created, to prevent JS from |
// seeing a dangling pointer. So for now we will disallow the context from being changed |
// once it is created. |
+ Settings* settings = document()->settings(); |
jamesr
2013/04/26 18:30:09
not sure why this moved, it doesn't appear to be u
Stephen White
2013/04/26 18:53:18
Leftover from an earlier change. Reverted.
|
if (type == "2d") { |
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); |
@@ -173,7 +175,6 @@ CanvasRenderingContext* HTMLCanvasElement::getContext(const String& type, Canvas |
return m_context.get(); |
} |
- Settings* settings = document()->settings(); |
if (settings && settings->webGLEnabled()) { |
// Accept the legacy "webkit-3d" name as well as the provisional "experimental-webgl" name. |
@@ -333,9 +334,9 @@ void HTMLCanvasElement::paint(GraphicsContext* context, const LayoutRect& r, boo |
ImageBuffer* imageBuffer = buffer(); |
if (imageBuffer) { |
if (m_presentedImage) |
- context->drawImage(m_presentedImage.get(), ColorSpaceDeviceRGB, pixelSnappedIntRect(r), CompositeSourceOver, DoNotRespectImageOrientation, useLowQualityScale); |
+ context->drawImage(m_presentedImage.get(), ColorSpaceDeviceRGB, pixelSnappedIntRect(r), !m_context || m_context->hasAlpha() ? CompositeSourceOver : CompositeCopy, DoNotRespectImageOrientation, useLowQualityScale); |
jamesr
2013/04/26 18:30:09
i'd suggest moving the ternary bit out to a local
Stephen White
2013/04/26 18:53:18
Done.
|
else |
- context->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, pixelSnappedIntRect(r), CompositeSourceOver, BlendModeNormal, useLowQualityScale); |
+ context->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, pixelSnappedIntRect(r), !m_context || m_context->hasAlpha() ? CompositeSourceOver : CompositeCopy, BlendModeNormal, useLowQualityScale); |
} |
} |
@@ -503,8 +504,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); |