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

Unified Diff: Source/core/html/canvas/CanvasRenderingContext2D.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: Fixes from review comments; remove WebPreferences.h changes; fix comment. 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
Index: Source/core/html/canvas/CanvasRenderingContext2D.cpp
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.cpp b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
index b5476f00e5af475c8425e7e033fdca5f6a88b8b1..18662e7fb791d45cb8871366ecec9f292e6cfae6 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);
}
@@ -2250,4 +2252,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.
jamesr 2013/04/26 18:30:09 i don't follow - what is the 'user' here? javascri
Stephen White 2013/04/26 18:53:18 This comment was lifted from WebGLRenderingContext
+ RefPtr<Canvas2DContextAttributes> attributes = Canvas2DContextAttributes::create();
+ attributes->setAlpha(m_hasAlpha);
+ return attributes.release();
+}
+
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698