WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-112628-20130318174117.patch (text/plain), 37.57 KB, created by
Stephen White
on 2013-03-18 14:45:26 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Stephen White
Created:
2013-03-18 14:45:26 PDT
Size:
37.57 KB
patch
obsolete
>Subversion Revision: 146122 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index ab531485970d953df8bf9038630f32da6ce27b87..123f27853fd864716777d3b85b718faab815304a 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,12 @@ >+2013-03-18 Stephen White <senorblanco@chromium.org> >+ >+ Implement canvas.getContext('2d', { alpha: none }) >+ https://bugs.webkit.org/show_bug.cgi?id=112628 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * wtf/FeatureDefines.h: >+ > 2013-03-18 Brent Fulgham <bfulgham@webkit.org> > > [WinCairo] Get build working under VS2010. >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 702acb933d7df8f244f8744ee289469b3d48779d..74e9a2213df7fdad37e4efe11ec60c4bed8df993 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,60 @@ >+2013-03-18 Stephen White <senorblanco@chromium.org> >+ >+ Implement canvas.getContext('2d', { alpha: none }) >+ https://bugs.webkit.org/show_bug.cgi?id=112628 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Test: fast/canvas/opaque.html >+ >+ * WebCore.gypi: >+ * bindings/v8/custom/V8HTMLCanvasElementCustom.cpp: >+ (WebCore::V8HTMLCanvasElement::getContextMethodCustom): >+ * html/HTMLCanvasElement.cpp: >+ (WebCore::HTMLCanvasElement::getContext): >+ (WebCore::HTMLCanvasElement::paint): >+ (WebCore::HTMLCanvasElement::createImageBuffer): >+ * html/HTMLCanvasElement.h: >+ * html/canvas/Canvas2DContextAttributes.cpp: Added. >+ (WebCore): >+ (WebCore::Canvas2DContextAttributes::Canvas2DContextAttributes): >+ (WebCore::Canvas2DContextAttributes::~Canvas2DContextAttributes): >+ (WebCore::Canvas2DContextAttributes::create): >+ (WebCore::Canvas2DContextAttributes::alpha): >+ (WebCore::Canvas2DContextAttributes::setAlpha): >+ * html/canvas/Canvas2DContextAttributes.h: Added. >+ (WebCore): >+ (Canvas2DContextAttributes): >+ * html/canvas/Canvas2DContextAttributes.idl: Added. >+ * html/canvas/CanvasRenderingContext.h: >+ (WebCore::CanvasRenderingContext::isOpaque): >+ * html/canvas/CanvasRenderingContext2D.cpp: >+ (WebCore::CanvasRenderingContext2D::CanvasRenderingContext2D): >+ * html/canvas/CanvasRenderingContext2D.h: >+ (WebCore::CanvasRenderingContext2D::create): >+ (CanvasRenderingContext2D): >+ * platform/graphics/ImageBuffer.h: >+ (WebCore::ImageBuffer::create): >+ (ImageBuffer): >+ * platform/graphics/cairo/ImageBufferCairo.cpp: >+ (WebCore::ImageBuffer::ImageBuffer): >+ * platform/graphics/cg/ImageBufferCG.cpp: >+ (WebCore::ImageBuffer::ImageBuffer): >+ * platform/graphics/chromium/Canvas2DLayerBridge.cpp: >+ (WebCore::Canvas2DLayerBridge::Canvas2DLayerBridge): >+ * platform/graphics/chromium/Canvas2DLayerBridge.h: >+ (WebCore::Canvas2DLayerBridge::create): >+ (Canvas2DLayerBridge): >+ * platform/graphics/qt/ImageBufferQt.cpp: >+ (WebCore::ImageBuffer::ImageBuffer): >+ * platform/graphics/skia/ImageBufferSkia.cpp: >+ (WebCore::createAcceleratedCanvas): >+ (WebCore::ImageBuffer::ImageBuffer): >+ * platform/graphics/wince/ImageBufferWinCE.cpp: >+ (WebCore::ImageBuffer::ImageBuffer): >+ * platform/graphics/wx/ImageBufferWx.cpp: >+ (WebCore::ImageBuffer::ImageBuffer): >+ > 2013-03-18 Hans Wennborg <hans@chromium.org> > > Fix GridTrackSize::operator== >diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog >index 0e784f7247c81c37f7e098254e4366cc69ab6072..e83e62e8c84a5f681306f08096b5312d74f4f039 100644 >--- a/Source/WebKit/chromium/ChangeLog >+++ b/Source/WebKit/chromium/ChangeLog >@@ -1,3 +1,12 @@ >+2013-03-18 Stephen White <senorblanco@chromium.org> >+ >+ Implement canvas.getContext('2d', { alpha: none }) >+ https://bugs.webkit.org/show_bug.cgi?id=112628 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * features.gypi: >+ > 2013-03-18 Mark Pilgrim <pilgrim@chromium.org> > > [Chromium] Create WebFileSystemType enum to allow easier filesystem refactoring >diff --git a/Source/WTF/wtf/FeatureDefines.h b/Source/WTF/wtf/FeatureDefines.h >index eb65735c2727522550938a2b0e59c9151e3e208a..f37136c4e1da0079fa0ed3fbc0de4259dd5742a4 100644 >--- a/Source/WTF/wtf/FeatureDefines.h >+++ b/Source/WTF/wtf/FeatureDefines.h >@@ -669,6 +669,10 @@ > #define ENABLE_OBJECT_MARK_LOGGING 0 > #endif > >+#if !defined(ENABLE_OPAQUE_CANVAS) >+#define ENABLE_OPAQUE_CANVAS 0 >+#endif >+ > #if !defined(ENABLE_OPENCL) > #define ENABLE_OPENCL 0 > #endif >diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi >index 9e08a93b95c9752c43bc49573b957111c13981be..121222db28e52bbbd5124a3d7c5efe287fe9bdc3 100644 >--- a/Source/WebCore/WebCore.gypi >+++ b/Source/WebCore/WebCore.gypi >@@ -457,6 +457,7 @@ > 'html/canvas/CanvasProxy.idl', > 'html/canvas/CanvasRenderingContext.idl', > 'html/canvas/CanvasRenderingContext2D.idl', >+ 'html/canvas/Canvas2DContextAttributes.idl', > 'html/canvas/DataView.idl', > 'html/canvas/DOMPath.idl', > 'html/canvas/EXTDrawBuffers.idl', >@@ -3419,6 +3420,8 @@ > 'html/WeekInputType.h', > 'html/TypeAhead.cpp', > 'html/TypeAhead.h', >+ 'html/canvas/Canvas2DContextAttributes.cpp', >+ 'html/canvas/Canvas2DContextAttributes.h', > 'html/canvas/CanvasContextAttributes.cpp', > 'html/canvas/CanvasContextAttributes.h', > 'html/canvas/CanvasGradient.cpp', >@@ -6392,6 +6395,8 @@ > '<(PRODUCT_DIR)/DerivedSources/WebCore/JSCSSValue.h', > '<(PRODUCT_DIR)/DerivedSources/WebCore/JSCSSValueList.cpp', > '<(PRODUCT_DIR)/DerivedSources/WebCore/JSCSSValueList.h', >+ '<(PRODUCT_DIR)/DerivedSources/WebCore/JSCanvas2DContextAttributes.cpp', >+ '<(PRODUCT_DIR)/DerivedSources/WebCore/JSCanvas2DContextAttributes.h', > '<(PRODUCT_DIR)/DerivedSources/WebCore/JSCanvasGradient.cpp', > '<(PRODUCT_DIR)/DerivedSources/WebCore/JSCanvasGradient.h', > '<(PRODUCT_DIR)/DerivedSources/WebCore/JSCanvasPattern.cpp', >diff --git a/Source/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp b/Source/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp >index 8bbb436eb009e875327d2517f4ac97412a3b3c6b..49580ec9a3890438e7f8cd4e2c35058aade7c80b 100644 >--- a/Source/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp >+++ b/Source/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp >@@ -32,7 +32,7 @@ > #include "config.h" > #include "V8HTMLCanvasElement.h" > >-#include "CanvasContextAttributes.h" >+#include "Canvas2DContextAttributes.h" > #include "CanvasRenderingContext.h" > #include "HTMLCanvasElement.h" > #include "InspectorCanvasInstrumentation.h" >@@ -79,6 +79,15 @@ v8::Handle<v8::Value> V8HTMLCanvasElement::getContextMethodCustom(const v8::Argu > if (jsAttrs->Has(preserveDrawingBuffer)) > webGLAttrs->setPreserveDrawingBuffer(jsAttrs->Get(preserveDrawingBuffer)->BooleanValue()); > } >+ } else { >+ attrs = Canvas2DContextAttributes::create(); >+ Canvas2DContextAttributes* canvas2DAttrs = static_cast<Canvas2DContextAttributes*>(attrs.get()); >+ if (args.Length() > 1 && args[1]->IsObject()) { >+ v8::Handle<v8::Object> jsAttrs = args[1]->ToObject(); >+ v8::Handle<v8::String> alpha = v8::String::NewSymbol("alpha"); >+ if (jsAttrs->Has(alpha)) >+ canvas2DAttrs->setAlpha(jsAttrs->Get(alpha)->BooleanValue()); >+ } > } > #endif > CanvasRenderingContext* result = imp->getContext(contextId, attrs.get()); >diff --git a/Source/WebCore/html/HTMLCanvasElement.cpp b/Source/WebCore/html/HTMLCanvasElement.cpp >index 3cc2c930a2ce58c91ee089d0bdbbeaa126df7a7e..c7a629a8734cbf6da040329745ceb0c9f04684a4 100644 >--- a/Source/WebCore/html/HTMLCanvasElement.cpp >+++ b/Source/WebCore/html/HTMLCanvasElement.cpp >@@ -29,7 +29,7 @@ > #include "HTMLCanvasElement.h" > > #include "Attribute.h" >-#include "CanvasContextAttributes.h" >+#include "Canvas2DContextAttributes.h" > #include "CanvasGradient.h" > #include "CanvasPattern.h" > #include "CanvasRenderingContext2D.h" >@@ -176,7 +176,7 @@ CanvasRenderingContext* HTMLCanvasElement::getContext(const String& type, Canvas > if (Settings* settings = document()->settings()) > usesDashbardCompatibilityMode = settings->usesDashboardBackwardCompatibilityMode(); > #endif >- m_context = CanvasRenderingContext2D::create(this, document()->inQuirksMode(), usesDashbardCompatibilityMode); >+ m_context = CanvasRenderingContext2D::create(this, static_cast<Canvas2DContextAttributes*>(attrs), document()->inQuirksMode(), usesDashbardCompatibilityMode); > #if USE(IOSURFACE_CANVAS_BACKING_STORE) || (ENABLE(ACCELERATED_2D_CANVAS) && USE(ACCELERATED_COMPOSITING)) > if (m_context) { > // Need to make sure a RenderLayer and compositing layer get created for the Canvas >@@ -353,9 +353,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->isOpaque() ? CompositeCopy : CompositeSourceOver, DoNotRespectImageOrientation, useLowQualityScale); > else >- context->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, pixelSnappedIntRect(r), CompositeSourceOver, BlendModeNormal, useLowQualityScale); >+ context->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, pixelSnappedIntRect(r), m_context && m_context->isOpaque() ? CompositeCopy : CompositeSourceOver, BlendModeNormal, useLowQualityScale); > } > } > >@@ -566,7 +566,8 @@ void HTMLCanvasElement::createImageBuffer() const > Unaccelerated; > #endif > DeferralMode deferralMode = shouldDefer() ? Deferred : NonDeferred; >- m_imageBuffer = ImageBuffer::create(size(), m_deviceScaleFactor, ColorSpaceDeviceRGB, renderingMode, deferralMode); >+ OpacityMode opacityMode = m_context && m_context->isOpaque() ? Opaque : NonOpaque; >+ m_imageBuffer = ImageBuffer::create(size(), m_deviceScaleFactor, ColorSpaceDeviceRGB, renderingMode, deferralMode, opacityMode); > if (!m_imageBuffer) > return; > m_imageBuffer->context()->setShadowsIgnoreTransforms(true); >diff --git a/Source/WebCore/html/HTMLCanvasElement.h b/Source/WebCore/html/HTMLCanvasElement.h >index cd9821c5c377b6713caa78bf9d56cad0fab4504a..f018a60ee678710d202fe76252851ef3388d7dea 100644 >--- a/Source/WebCore/html/HTMLCanvasElement.h >+++ b/Source/WebCore/html/HTMLCanvasElement.h >@@ -167,6 +167,7 @@ private: > HashSet<CanvasObserver*> m_observers; > > IntSize m_size; >+ bool m_opaque; > > OwnPtr<CanvasRenderingContext> m_context; > >diff --git a/Source/WebCore/html/canvas/Canvas2DContextAttributes.cpp b/Source/WebCore/html/canvas/Canvas2DContextAttributes.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..1e8c33e49aef09ca9d0924a254c5fcadf8f18820 >--- /dev/null >+++ b/Source/WebCore/html/canvas/Canvas2DContextAttributes.cpp >@@ -0,0 +1,57 @@ >+/* >+ * Copyright (c) 2013, Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions are >+ * met: >+ * * Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * * Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following disclaimer >+ * in the documentation and/or other materials provided with the >+ * distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+ >+#include "Canvas2DContextAttributes.h" >+ >+namespace WebCore { >+ >+Canvas2DContextAttributes::Canvas2DContextAttributes() >+ : m_alpha(true) >+{ >+} >+ >+Canvas2DContextAttributes::~Canvas2DContextAttributes() >+{ >+} >+ >+PassRefPtr<Canvas2DContextAttributes> Canvas2DContextAttributes::create() >+{ >+ return adoptRef(new Canvas2DContextAttributes()); >+} >+ >+bool Canvas2DContextAttributes::alpha() const >+{ >+ return m_alpha; >+} >+ >+void Canvas2DContextAttributes::setAlpha(bool alpha) >+{ >+ m_alpha = alpha; >+} >+ >+} // namespace WebCore >diff --git a/Source/WebCore/html/canvas/Canvas2DContextAttributes.h b/Source/WebCore/html/canvas/Canvas2DContextAttributes.h >new file mode 100644 >index 0000000000000000000000000000000000000000..dbf15864a60d216576bf37656f0861f5596addee >--- /dev/null >+++ b/Source/WebCore/html/canvas/Canvas2DContextAttributes.h >@@ -0,0 +1,54 @@ >+/* >+ * Copyright (c) 2013, Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions are >+ * met: >+ * * Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * * Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following disclaimer >+ * in the documentation and/or other materials provided with the >+ * distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef Canvas2DContextAttributes_h >+#define Canvas2DContextAttributes_h >+ >+#include "CanvasContextAttributes.h" >+#include <wtf/PassRefPtr.h> >+ >+namespace WebCore { >+ >+class Canvas2DContextAttributes : public CanvasContextAttributes { >+public: >+ virtual ~Canvas2DContextAttributes(); >+ >+ // Create a new attributes object >+ static PassRefPtr<Canvas2DContextAttributes> create(); >+ >+ // Whether or not the drawing buffer has an alpha channel; default=true >+ bool alpha() const; >+ void setAlpha(bool); >+ >+protected: >+ Canvas2DContextAttributes(); >+ >+ bool m_alpha; >+}; >+ >+} // namespace WebCore >+ >+#endif // Canvas2DContextAttributes_h >diff --git a/Source/WebCore/html/canvas/Canvas2DContextAttributes.idl b/Source/WebCore/html/canvas/Canvas2DContextAttributes.idl >new file mode 100644 >index 0000000000000000000000000000000000000000..0669174d460c271530f8ae3d6387a12e5d40dcb1 >--- /dev/null >+++ b/Source/WebCore/html/canvas/Canvas2DContextAttributes.idl >@@ -0,0 +1,31 @@ >+/* >+ * Copyright (c) 2013, Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions are >+ * met: >+ * * Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * * Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following disclaimer >+ * in the documentation and/or other materials provided with the >+ * distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+[ >+ OmitConstructor >+] interface Canvas2DContextAttributes { >+ attribute boolean alpha; >+}; >diff --git a/Source/WebCore/html/canvas/CanvasRenderingContext.h b/Source/WebCore/html/canvas/CanvasRenderingContext.h >index 8e849bde8fb1c4d80eea529bb572d6d93fe1bfbd..e8cd62d026564ea37422f4fa612498f8352eac20 100644 >--- a/Source/WebCore/html/canvas/CanvasRenderingContext.h >+++ b/Source/WebCore/html/canvas/CanvasRenderingContext.h >@@ -54,6 +54,7 @@ public: > virtual bool is2d() const { return false; } > virtual bool is3d() const { return false; } > virtual bool isAccelerated() const { return false; } >+ virtual bool isOpaque() const { return false; } > > virtual void paintRenderingResultsToCanvas() {} > >diff --git a/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp b/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp >index c14110e429aab543f0558174770215cc94fb3018..ffff738a635157550341061c2063f8933083cffd 100644 >--- a/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp >+++ b/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp >@@ -38,6 +38,7 @@ > #include "CSSParser.h" > #include "CSSPropertyNames.h" > #include "CachedImage.h" >+#include "Canvas2DContextAttributes.h" > #include "CanvasGradient.h" > #include "CanvasPattern.h" > #include "CanvasStyle.h" >@@ -124,7 +125,7 @@ private: > CanvasRenderingContext2D* m_canvasContext; > }; > >-CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode) >+CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, const Canvas2DContextAttributes* attrs, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode) > : CanvasRenderingContext(canvas) > , m_stateStack(1) > , m_unrealizedSaveCount(0) >@@ -132,6 +133,7 @@ CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, bo > #if ENABLE(DASHBOARD_SUPPORT) > , m_usesDashboardCompatibilityMode(usesDashboardCompatibilityMode) > #endif >+ , m_opaque(attrs && !attrs->alpha()) > { > #if !ENABLE(DASHBOARD_SUPPORT) > ASSERT_UNUSED(usesDashboardCompatibilityMode, !usesDashboardCompatibilityMode); >diff --git a/Source/WebCore/html/canvas/CanvasRenderingContext2D.h b/Source/WebCore/html/canvas/CanvasRenderingContext2D.h >index d4d21afa5fdb4a3c1d88173685572ac3f94ba096..29b5b256f706749e434d1d5df576872286767888 100644 >--- a/Source/WebCore/html/canvas/CanvasRenderingContext2D.h >+++ b/Source/WebCore/html/canvas/CanvasRenderingContext2D.h >@@ -27,6 +27,7 @@ > #define CanvasRenderingContext2D_h > > #include "AffineTransform.h" >+#include "Canvas2DContextAttributes.h" > #include "CanvasPathMethods.h" > #include "CanvasRenderingContext.h" > #include "Color.h" >@@ -64,9 +65,9 @@ typedef int ExceptionCode; > > class CanvasRenderingContext2D : public CanvasRenderingContext, public CanvasPathMethods { > public: >- static PassOwnPtr<CanvasRenderingContext2D> create(HTMLCanvasElement* canvas, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode) >+ static PassOwnPtr<CanvasRenderingContext2D> create(HTMLCanvasElement* canvas, const Canvas2DContextAttributes* attrs, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode) > { >- return adoptPtr(new CanvasRenderingContext2D(canvas, usesCSSCompatibilityParseMode, usesDashboardCompatibilityMode)); >+ return adoptPtr(new CanvasRenderingContext2D(canvas, attrs, usesCSSCompatibilityParseMode, usesDashboardCompatibilityMode)); > } > virtual ~CanvasRenderingContext2D(); > >@@ -275,7 +276,7 @@ private: > CanvasDidDrawApplyAll = 0xffffffff > }; > >- CanvasRenderingContext2D(HTMLCanvasElement*, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode); >+ CanvasRenderingContext2D(HTMLCanvasElement*, const Canvas2DContextAttributes* attrs, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode); > > State& modifiableState() { ASSERT(!m_unrealizedSaveCount); return m_stateStack.last(); } > const State& state() const { return m_stateStack.last(); } >@@ -330,6 +331,7 @@ private: > > virtual bool is2d() const OVERRIDE { return true; } > virtual bool isAccelerated() const OVERRIDE; >+ virtual bool isOpaque() const OVERRIDE { return m_opaque; } > > virtual bool isTransformInvertible() const { return state().m_invertibleCTM; } > >@@ -343,6 +345,7 @@ private: > #if ENABLE(DASHBOARD_SUPPORT) > bool m_usesDashboardCompatibilityMode; > #endif >+ bool m_opaque; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/ImageBuffer.h b/Source/WebCore/platform/graphics/ImageBuffer.h >index 9c5e63a9595e9a6099a52755d479633e21c89da7..a705ccf4ff05c3dd51fda96b2fd04b15f4527921 100644 >--- a/Source/WebCore/platform/graphics/ImageBuffer.h >+++ b/Source/WebCore/platform/graphics/ImageBuffer.h >@@ -80,14 +80,19 @@ namespace WebCore { > Unscaled > }; > >+ enum OpacityMode { >+ NonOpaque, >+ Opaque, >+ }; >+ > class ImageBuffer { > WTF_MAKE_NONCOPYABLE(ImageBuffer); WTF_MAKE_FAST_ALLOCATED; > public: > // Will return a null pointer on allocation failure. >- static PassOwnPtr<ImageBuffer> create(const IntSize& size, float resolutionScale = 1, ColorSpace colorSpace = ColorSpaceDeviceRGB, RenderingMode renderingMode = Unaccelerated, DeferralMode deferralMode = NonDeferred) >+ static PassOwnPtr<ImageBuffer> create(const IntSize& size, float resolutionScale = 1, ColorSpace colorSpace = ColorSpaceDeviceRGB, RenderingMode renderingMode = Unaccelerated, DeferralMode deferralMode = NonDeferred, OpacityMode opacityMode = NonOpaque) > { > bool success = false; >- OwnPtr<ImageBuffer> buf = adoptPtr(new ImageBuffer(size, resolutionScale, colorSpace, renderingMode, deferralMode, success)); >+ OwnPtr<ImageBuffer> buf = adoptPtr(new ImageBuffer(size, resolutionScale, colorSpace, renderingMode, deferralMode, opacityMode, success)); > if (!success) > return nullptr; > return buf.release(); >@@ -160,7 +165,7 @@ namespace WebCore { > > // This constructor will place its success into the given out-variable > // so that create() knows when it should return failure. >- ImageBuffer(const IntSize&, float resolutionScale, ColorSpace, RenderingMode, DeferralMode, bool& success); >+ ImageBuffer(const IntSize&, float resolutionScale, ColorSpace, RenderingMode, DeferralMode, OpacityMode, bool& success); > #if USE(SKIA) > ImageBuffer(const IntSize&, float resolutionScale, ColorSpace, const GraphicsContext*, bool hasAlpha, bool& success); > #endif >diff --git a/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp b/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp >index 69539327f130426e6a94f04d8803a447869f33f4..8c56201f4fdb435d44ffd59f6a40b88eb0d7f226 100644 >--- a/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp >+++ b/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp >@@ -54,7 +54,7 @@ ImageBufferData::ImageBufferData(const IntSize&) > { > } > >-ImageBuffer::ImageBuffer(const IntSize& size, float /* resolutionScale */, ColorSpace, RenderingMode, DeferralMode, bool& success) >+ImageBuffer::ImageBuffer(const IntSize& size, float /* resolutionScale */, ColorSpace, RenderingMode, DeferralMode, OpacityMode, bool& success) > : m_data(size) > , m_size(size) > , m_logicalSize(size) >diff --git a/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp b/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp >index 7e0434c36ac38ed396ee369509e0483e242d9ab1..4528c54d74310c21731fa6f0a00b08b946af8a49 100644 >--- a/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp >+++ b/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp >@@ -106,7 +106,7 @@ static void releaseImageData(void*, const void* data, size_t) > fastFree(const_cast<void*>(data)); > } > >-ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace imageColorSpace, RenderingMode renderingMode, DeferralMode, bool& success) >+ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace imageColorSpace, RenderingMode renderingMode, DeferralMode, OpacityMode, bool& success) > : m_data(size) // NOTE: The input here isn't important as ImageBufferDataCG's constructor just ignores it. > , m_logicalSize(size) > , m_resolutionScale(resolutionScale) >diff --git a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.cpp b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.cpp >index 66272fdb3829817e12051338c08be679c445bb69..06ae1c61ae9bfc7861ec96821f75383ee5a6a3a3 100644 >--- a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.cpp >+++ b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.cpp >@@ -43,7 +43,7 @@ using WebKit::WebTextureUpdater; > > namespace WebCore { > >-Canvas2DLayerBridge::Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context, const IntSize& size, DeferralMode deferralMode, ThreadMode threadMode, unsigned textureId) >+Canvas2DLayerBridge::Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context, const IntSize& size, DeferralMode deferralMode, OpacityMode opacityMode, ThreadMode threadMode, unsigned textureId) > : m_deferralMode(deferralMode) > , m_frontBufferTexture(0) > , m_backBufferTexture(textureId) >@@ -83,6 +83,7 @@ Canvas2DLayerBridge::Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context, > m_layer = adoptPtr(WebKit::Platform::current()->compositorSupport()->createExternalTextureLayer(this)); > m_layer->setTextureId(textureId); > m_layer->setRateLimitContext(threadMode == SingleThread || m_useDoubleBuffering); >+ m_layer->setOpaque(opacityMode == Opaque); > GraphicsLayerChromium::registerContentsLayer(m_layer->layer()); > } > >diff --git a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.h b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.h >index 8e442fd9177aa8283d2b0687a405839ceb65032d..3439980233046c9c05c18b10e7a1ed327b375964 100644 >--- a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.h >+++ b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.h >@@ -50,9 +50,9 @@ public: > Threaded > }; > >- static PassOwnPtr<Canvas2DLayerBridge> create(PassRefPtr<GraphicsContext3D> context, const IntSize& size, DeferralMode deferralMode, ThreadMode threading, unsigned textureId) >+ static PassOwnPtr<Canvas2DLayerBridge> create(PassRefPtr<GraphicsContext3D> context, const IntSize& size, DeferralMode deferralMode, OpacityMode opacityMode, ThreadMode threading, unsigned textureId) > { >- return adoptPtr(new Canvas2DLayerBridge(context, size, deferralMode, threading, textureId)); >+ return adoptPtr(new Canvas2DLayerBridge(context, size, deferralMode, opacityMode, threading, textureId)); > } > > virtual ~Canvas2DLayerBridge(); >@@ -81,7 +81,7 @@ public: > unsigned backBufferTexture(); > > protected: >- Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, const IntSize&, DeferralMode, ThreadMode, unsigned textureId); >+ Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, const IntSize&, DeferralMode, OpacityMode, ThreadMode, unsigned textureId); > SkDeferredCanvas* deferredCanvas(); > > DeferralMode m_deferralMode; >diff --git a/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp b/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp >index 43859cad1c7483543c07df18ad63e957a72858d4..f5f1269f6870aac5f4de729bb7724b366020c01b 100644 >--- a/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp >+++ b/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp >@@ -94,7 +94,7 @@ QImage ImageBufferData::toQImage() const > return image; > } > >-ImageBuffer::ImageBuffer(const IntSize& size, float /* resolutionScale */, ColorSpace, RenderingMode, DeferralMode, bool& success) >+ImageBuffer::ImageBuffer(const IntSize& size, float /* resolutionScale */, ColorSpace, RenderingMode, DeferralMode, OpacityMode, bool& success) > : m_data(size) > , m_size(size) > , m_logicalSize(size) >diff --git a/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp b/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp >index 742b011b802ee011a64dba7354ac1cd3e7e80465..1df2d37e0a9c862f7e31d94afb147bf5616d9cab 100644 >--- a/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp >+++ b/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp >@@ -72,7 +72,7 @@ ImageBufferData::ImageBufferData(const IntSize& size) > { > } > >-static SkCanvas* createAcceleratedCanvas(const IntSize& size, ImageBufferData* data, DeferralMode deferralMode) >+static SkCanvas* createAcceleratedCanvas(const IntSize& size, ImageBufferData* data, DeferralMode deferralMode, OpacityMode opacityMode) > { > RefPtr<GraphicsContext3D> context3D = SharedGraphicsContext3D::get(); > if (!context3D) >@@ -94,7 +94,7 @@ static SkCanvas* createAcceleratedCanvas(const IntSize& size, ImageBufferData* d > SkAutoTUnref<SkDevice> device(new SkGpuDevice(gr, texture.get())); > #if USE(ACCELERATED_COMPOSITING) > Canvas2DLayerBridge::ThreadMode threadMode = WebKit::Platform::current()->isThreadedCompositingEnabled() ? Canvas2DLayerBridge::Threaded : Canvas2DLayerBridge::SingleThread; >- data->m_layerBridge = Canvas2DLayerBridge::create(context3D.release(), size, deferralMode, threadMode, texture.get()->getTextureHandle()); >+ data->m_layerBridge = Canvas2DLayerBridge::create(context3D.release(), size, deferralMode, opacityMode, threadMode, texture.get()->getTextureHandle()); > canvas = data->m_layerBridge->skCanvas(device.get()); > #else > canvas = new SkCanvas(device.get()); >@@ -151,7 +151,7 @@ ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace, > success = true; > } > >-ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace, RenderingMode renderingMode, DeferralMode deferralMode, bool& success) >+ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace, RenderingMode renderingMode, DeferralMode deferralMode, OpacityMode opacityMode, bool& success) > : m_data(size) > , m_size(size) > , m_logicalSize(size) >@@ -160,7 +160,7 @@ ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace, > OwnPtr<SkCanvas> canvas; > > if (renderingMode == Accelerated) >- canvas = adoptPtr(createAcceleratedCanvas(size, &m_data, deferralMode)); >+ canvas = adoptPtr(createAcceleratedCanvas(size, &m_data, deferralMode, opacityMode)); > else if (renderingMode == UnacceleratedNonPlatformBuffer) > canvas = adoptPtr(createNonPlatformCanvas(size)); > >@@ -175,13 +175,16 @@ ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace, > m_data.m_canvas = canvas.release(); > m_data.m_platformContext.setCanvas(m_data.m_canvas.get()); > m_context = adoptPtr(new GraphicsContext(&m_data.m_platformContext)); >- m_context->setShouldSmoothFonts(false); >+ m_context->setShouldSmoothFonts(opacityMode == Opaque); > m_context->scale(FloatSize(m_resolutionScale, m_resolutionScale)); > >- // Make the background transparent. It would be nice if this wasn't >+ // Clear the background transparent or opaque, as required. It would be nice if this wasn't > // required, but the canvas is currently filled with the magic transparency > // color. Can we have another way to manage this? >- m_data.m_canvas->drawARGB(0, 0, 0, 0, SkXfermode::kClear_Mode); >+ if (opacityMode == Opaque) >+ m_data.m_canvas->drawARGB(255, 0, 0, 0, SkXfermode::kSrc_Mode); >+ else >+ m_data.m_canvas->drawARGB(0, 0, 0, 0, SkXfermode::kClear_Mode); > > success = true; > } >diff --git a/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp b/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp >index c3c4119f3c4da0d45d6f27f6ed5728daf29848d6..f194bf389ba7a9bb307c535c2e191a5cf9762ada 100644 >--- a/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp >+++ b/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp >@@ -71,7 +71,7 @@ ImageBufferData::ImageBufferData(const IntSize& size) > m_bitmap->setHasAlpha(true); > } > >-ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace colorSpace, RenderingMode, DeferralMode, bool& success) >+ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace colorSpace, RenderingMode, DeferralMode, OpacityMode, bool& success) > : m_data(size) > , m_size(size) > , m_logicalSize(size) >diff --git a/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp b/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp >index 4f41ed103cf7c19e3b34e595c02c9f7bae2a9b84..8d70b4ef4b9e0bce5878a319a61b2245dcf0b12a 100644 >--- a/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp >+++ b/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp >@@ -94,7 +94,7 @@ ImageBufferData::~ImageBufferData() > delete m_memDC; > } > >-ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace colorSpace, RenderingMode, DeferralMode, bool& success) >+ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace colorSpace, RenderingMode, DeferralMode, OpacityMode, bool& success) > : m_data(size) > , m_size(size) > , m_logicalSize(size) >diff --git a/Source/WebKit/chromium/features.gypi b/Source/WebKit/chromium/features.gypi >index 9a2acc298b0e4f780cbc6bc61ca33af51e480df3..932f6f1a6371619f89b01c725963eabae3b799e9 100644 >--- a/Source/WebKit/chromium/features.gypi >+++ b/Source/WebKit/chromium/features.gypi >@@ -98,6 +98,7 @@ > 'ENABLE_MICRODATA=0', > 'ENABLE_MOUSE_CURSOR_SCALE=1', > 'ENABLE_NOSNIFF=1', >+ 'ENABLE_OPAQUE_CANVAS=1', > 'ENABLE_PAGE_VISIBILITY_API=1', > 'ENABLE_PERFORMANCE_TIMELINE=1', > 'ENABLE_POINTER_LOCK=1', >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 05f62fd92fb558d6ed7e3cd6883f8a9a9791b835..e5fcae04fff6a1ea1a0bf55f98edee5ab2e0d522 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,14 @@ >+2013-03-18 Stephen White <senorblanco@chromium.org> >+ >+ Implement canvas.getContext('2d', { alpha: none }) >+ https://bugs.webkit.org/show_bug.cgi?id=112628 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * fast/canvas/opaque-expected.txt: Added. >+ * fast/canvas/opaque.html: Added. >+ * fast/canvas/opaque.js: Added. >+ > 2013-03-18 Simon Fraser <simon.fraser@apple.com> > > Skip some tests on Windows. >diff --git a/LayoutTests/fast/canvas/opaque-expected.txt b/LayoutTests/fast/canvas/opaque-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..b445ad0c801b8b5016a0207dd7aa33100db9f4de >--- /dev/null >+++ b/LayoutTests/fast/canvas/opaque-expected.txt >@@ -0,0 +1,17 @@ >+Series of tests for canvas.opaque >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS imgData.data[0] is 0 >+PASS imgData.data[1] is 0 >+PASS imgData.data[2] is 0 >+PASS imgData.data[3] is 0 >+PASS opaqueImgData.data[0] is 0 >+PASS opaqueImgData.data[1] is 0 >+PASS opaqueImgData.data[2] is 0 >+PASS opaqueImgData.data[3] is 255 >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/fast/canvas/opaque.html b/LayoutTests/fast/canvas/opaque.html >new file mode 100755 >index 0000000000000000000000000000000000000000..edae986cbfbde70668eca0553a78c2f4a8c61121 >--- /dev/null >+++ b/LayoutTests/fast/canvas/opaque.html >@@ -0,0 +1,12 @@ >+<!DOCTYPE HTML> >+<html> >+<head> >+<script src="../js/resources/js-test-pre.js"></script> >+</head> >+<body> >+<canvas id="canvas" width="8" height="8"></canvas> >+<canvas id="opaqueCanvas" width="8" height="8" opaque></canvas> >+<script src="opaque.js"></script> >+<script src="../js/resources/js-test-post.js"></script> >+</body> >+</html> >diff --git a/LayoutTests/fast/canvas/opaque.js b/LayoutTests/fast/canvas/opaque.js >new file mode 100755 >index 0000000000000000000000000000000000000000..f631f1c8778da1d25eedefc3105caba2c1995210 >--- /dev/null >+++ b/LayoutTests/fast/canvas/opaque.js >@@ -0,0 +1,17 @@ >+description("Series of tests for canvas.opaque"); >+var canvas = document.getElementById("canvas"); >+var opaqueCanvas = document.getElementById("opaqueCanvas"); >+var ctx = canvas.getContext("2d"); >+var opaqueCtx = opaqueCanvas.getContext("2d", { alpha: false } ); >+var imgData = ctx.getImageData(0, 0, 1, 1); >+// FIXME: do we have a way to query for alpha? >+shouldBe("imgData.data[0]", "0"); >+shouldBe("imgData.data[1]", "0"); >+shouldBe("imgData.data[2]", "0"); >+shouldBe("imgData.data[3]", "0"); >+var opaqueImgData = opaqueCtx.getImageData(0, 0, 1, 1); >+// FIXME: do we have a way to query for alpha? >+shouldBe("opaqueImgData.data[0]", "0"); >+shouldBe("opaqueImgData.data[1]", "0"); >+shouldBe("opaqueImgData.data[2]", "0"); >+shouldBe("opaqueImgData.data[3]", "255");
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 112628
:
193658
|
194676
|
194683
|
194692
|
194887
|
194965
|
196497