Index: Source/core/html/canvas/CanvasRenderingContext2D.cpp |
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.cpp b/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
index 2067504e491a6c4565e9d3b4778494a9e1b952b9..37654778905538f58433a0a989f75f79db14542e 100644 |
--- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
@@ -36,6 +36,7 @@ |
#include "CSSFontSelector.h" |
#include "CSSParser.h" |
#include "CSSPropertyNames.h" |
+#include "Canvas2DContextAttributes.h" |
#include "CanvasGradient.h" |
#include "CanvasPattern.h" |
#include "CanvasStyle.h" |
@@ -117,11 +118,12 @@ private: |
CanvasRenderingContext2D* m_canvasContext; |
}; |
-CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, bool usesCSSCompatibilityParseMode) |
+CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, const Canvas2DContextAttributes* attrs, bool usesCSSCompatibilityParseMode) |
: CanvasRenderingContext(canvas) |
, m_stateStack(1) |
, m_unrealizedSaveCount(0) |
, m_usesCSSCompatibilityParseMode(usesCSSCompatibilityParseMode) |
+ , m_hasAlpha(!attrs || attrs->alpha()) |
{ |
ScriptWrappable::init(this); |
} |
@@ -2251,4 +2253,13 @@ void CanvasRenderingContext2D::setWebkitImageSmoothingEnabled(bool enabled) |
c->setImageInterpolationQuality(enabled ? DefaultInterpolationQuality : InterpolationNone); |
} |
+PassRefPtr<Canvas2DContextAttributes> CanvasRenderingContext2D::getContextAttributes() const |
+{ |
+ // We always need to return a new Canvas2DContextAttributes object to |
+ // prevent the user from mutating any cached version. |
+ RefPtr<Canvas2DContextAttributes> attributes = Canvas2DContextAttributes::create(); |
+ attributes->setAlpha(m_hasAlpha); |
+ return attributes.release(); |
+} |
+ |
} // namespace WebCore |