Make it more obvious when using an unaccelerated image buffer, and fix a few callers...
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Sep 2015 18:45:54 +0000 (18:45 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Sep 2015 18:45:54 +0000 (18:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=149428

Reviewed by Simon Fraser and Darin Adler.

* platform/graphics/ImageBuffer.cpp:
(WebCore::ImageBuffer::createCompatibleBuffer):
* platform/graphics/ImageBuffer.h:
(WebCore::ImageBuffer::create):
Make the RenderingMode parameter to ImageBuffer::create non-optional.

* platform/graphics/GraphicsContext.h:
(WebCore::GraphicsContext::renderingMode):
* platform/graphics/GraphicsTypes.h:
Add renderingMode() getter so that every caller doesn't need to do the conversion to RenderingMode.

* css/CSSFilterImageValue.cpp:
(WebCore::CSSFilterImageValue::image):
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::LRUImageBufferCache::imageBuffer):
* rendering/shapes/Shape.cpp:
(WebCore::Shape::createRasterShape):
* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlTextTrackContainerElement::createTextTrackRepresentationImage):
* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::ImageBuffer::putByteArray):
These five callers create unconditionally unaccelerated ImageBuffers which
should probably instead respect the acceleration bit from the context
that the ImageBuffer will eventually be painted into. Bugs have been filed.

* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::createImageBuffer):
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::createCompositingBuffer):
* platform/graphics/CrossfadeGeneratedImage.cpp:
(WebCore::CrossfadeGeneratedImage::drawPattern):
Adjust the argument order and remove defaults which are passed explicitly.

* page/FrameSnapshotting.cpp:
(WebCore::snapshotFrameRect):
Snapshots are (currently) meant to be taken without accelerated drawing.
Make this explicit.

* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::drawPattern):
Make use of createCompatibleBuffer. This caller was previously creating
an unconditionally unaccelerated context!

* platform/graphics/NamedImageGeneratedImage.cpp:
(WebCore::NamedImageGeneratedImage::drawPattern):
Remove a comment.

* platform/graphics/ShadowBlur.cpp:
(WebCore::ScratchBuffer::getScratchBuffer):
ShadowBlur is only used with unaccelerated contexts, so it's OK to hardcode Unaccelerated here.

* platform/graphics/filters/FilterEffect.cpp:
(WebCore::FilterEffect::asImageBuffer):
(WebCore::FilterEffect::createImageBufferResult):
Flip the order of the arguments.

(WebCore::FilterEffect::openCLImageToImageBuffer):
This caller was previously creating an unaccelerated buffer; instead, match the destination buffer.

* rendering/FilterEffectRenderer.cpp:
(WebCore::FilterEffectRenderer::allocateBackingStoreIfNeeded):
Adjust the argument order and remove defaults which are passed explicitly.

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::calculateClipRects):
Get rid of the unneeded renderingMode local, and factor out retrieval of Frame.

* rendering/svg/RenderSVGResourceClipper.cpp:
(WebCore::RenderSVGResourceClipper::applyClippingToContext):
* rendering/svg/RenderSVGResourceMasker.cpp:
(WebCore::RenderSVGResourceMasker::applyResource):
These two callers are unconditionally creating unaccelerated buffers,
and changing this to match the destination context seems to actually
break things. This needs further investigation.

* rendering/svg/RenderSVGResourceGradient.cpp:
(WebCore::createMaskAndSwapContextForTextGradient):
This caller was previously creating an unaccelerated buffer; instead, match the destination buffer.

* rendering/svg/RenderSVGResourcePattern.cpp:
(WebCore::RenderSVGResourcePattern::buildPattern):
Make use of renderingMode().

* rendering/svg/SVGRenderingContext.cpp:
(WebCore::SVGRenderingContext::createImageBuffer):
Adjust the argument order.

* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::nativeImageForCurrentFrame):

* WebCoreSupport/WebContextMenuClient.mm:
(WebContextMenuClient::imageForCurrentSharingServicePickerItem):

* Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.cpp:
(WebKit::ThreadSafeCoordinatedSurface::create):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190124 268f45cc-cd09-0410-ab3c-d52691b4dbfc

31 files changed:
Source/WebCore/ChangeLog
Source/WebCore/css/CSSFilterImageValue.cpp
Source/WebCore/html/HTMLCanvasElement.cpp
Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
Source/WebCore/html/shadow/MediaControlElements.cpp
Source/WebCore/page/FrameSnapshotting.cpp
Source/WebCore/platform/graphics/BitmapImage.cpp
Source/WebCore/platform/graphics/CrossfadeGeneratedImage.cpp
Source/WebCore/platform/graphics/GraphicsContext.h
Source/WebCore/platform/graphics/GraphicsTypes.h
Source/WebCore/platform/graphics/ImageBuffer.cpp
Source/WebCore/platform/graphics/ImageBuffer.h
Source/WebCore/platform/graphics/NamedImageGeneratedImage.cpp
Source/WebCore/platform/graphics/ShadowBlur.cpp
Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
Source/WebCore/platform/graphics/filters/FilterEffect.cpp
Source/WebCore/platform/graphics/texmap/BitmapTexture.cpp
Source/WebCore/rendering/FilterEffectRenderer.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/shapes/Shape.cpp
Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp
Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp
Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp
Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp
Source/WebCore/rendering/svg/SVGRenderingContext.cpp
Source/WebCore/svg/graphics/SVGImage.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.cpp

index 88390b8..8723283 100644 (file)
@@ -1,3 +1,100 @@
+2015-09-22  Tim Horton  <timothy_horton@apple.com>
+
+        Make it more obvious when using an unaccelerated image buffer, and fix a few callers who do
+        https://bugs.webkit.org/show_bug.cgi?id=149428
+
+        Reviewed by Simon Fraser and Darin Adler.
+
+        * platform/graphics/ImageBuffer.cpp:
+        (WebCore::ImageBuffer::createCompatibleBuffer):
+        * platform/graphics/ImageBuffer.h:
+        (WebCore::ImageBuffer::create):
+        Make the RenderingMode parameter to ImageBuffer::create non-optional.
+
+        * platform/graphics/GraphicsContext.h:
+        (WebCore::GraphicsContext::renderingMode):
+        * platform/graphics/GraphicsTypes.h:
+        Add renderingMode() getter so that every caller doesn't need to do the conversion to RenderingMode.
+
+        * css/CSSFilterImageValue.cpp:
+        (WebCore::CSSFilterImageValue::image):
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::WebGLRenderingContextBase::LRUImageBufferCache::imageBuffer):
+        * rendering/shapes/Shape.cpp:
+        (WebCore::Shape::createRasterShape):
+        * html/shadow/MediaControlElements.cpp:
+        (WebCore::MediaControlTextTrackContainerElement::createTextTrackRepresentationImage):
+        * platform/graphics/cg/ImageBufferCG.cpp:
+        (WebCore::ImageBuffer::putByteArray):
+        These five callers create unconditionally unaccelerated ImageBuffers which
+        should probably instead respect the acceleration bit from the context
+        that the ImageBuffer will eventually be painted into. Bugs have been filed.
+
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::createImageBuffer):
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::createCompositingBuffer):
+        * platform/graphics/CrossfadeGeneratedImage.cpp:
+        (WebCore::CrossfadeGeneratedImage::drawPattern):
+        Adjust the argument order and remove defaults which are passed explicitly.
+
+        * page/FrameSnapshotting.cpp:
+        (WebCore::snapshotFrameRect):
+        Snapshots are (currently) meant to be taken without accelerated drawing.
+        Make this explicit.
+
+        * platform/graphics/BitmapImage.cpp:
+        (WebCore::BitmapImage::drawPattern):
+        Make use of createCompatibleBuffer. This caller was previously creating
+        an unconditionally unaccelerated context!
+
+        * platform/graphics/NamedImageGeneratedImage.cpp:
+        (WebCore::NamedImageGeneratedImage::drawPattern):
+        Remove a comment.
+
+        * platform/graphics/ShadowBlur.cpp:
+        (WebCore::ScratchBuffer::getScratchBuffer):
+        ShadowBlur is only used with unaccelerated contexts, so it's OK to hardcode Unaccelerated here.
+
+        * platform/graphics/filters/FilterEffect.cpp:
+        (WebCore::FilterEffect::asImageBuffer):
+        (WebCore::FilterEffect::createImageBufferResult):
+        Flip the order of the arguments.
+
+        (WebCore::FilterEffect::openCLImageToImageBuffer):
+        This caller was previously creating an unaccelerated buffer; instead, match the destination buffer.
+
+        * rendering/FilterEffectRenderer.cpp:
+        (WebCore::FilterEffectRenderer::allocateBackingStoreIfNeeded):
+        Adjust the argument order and remove defaults which are passed explicitly.
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::calculateClipRects):
+        Get rid of the unneeded renderingMode local, and factor out retrieval of Frame.
+
+        * rendering/svg/RenderSVGResourceClipper.cpp:
+        (WebCore::RenderSVGResourceClipper::applyClippingToContext):
+        * rendering/svg/RenderSVGResourceMasker.cpp:
+        (WebCore::RenderSVGResourceMasker::applyResource):
+        These two callers are unconditionally creating unaccelerated buffers,
+        and changing this to match the destination context seems to actually
+        break things. This needs further investigation.
+
+        * rendering/svg/RenderSVGResourceGradient.cpp:
+        (WebCore::createMaskAndSwapContextForTextGradient):
+        This caller was previously creating an unaccelerated buffer; instead, match the destination buffer.
+
+        * rendering/svg/RenderSVGResourcePattern.cpp:
+        (WebCore::RenderSVGResourcePattern::buildPattern):
+        Make use of renderingMode().
+
+        * rendering/svg/SVGRenderingContext.cpp:
+        (WebCore::SVGRenderingContext::createImageBuffer):
+        Adjust the argument order.
+
+        * svg/graphics/SVGImage.cpp:
+        (WebCore::SVGImage::nativeImageForCurrentFrame):
+
 2015-09-22  Chris Dumez  <cdumez@apple.com>
 
         XMLHttpRequest properties should be on the prototype
index 90f55d4..7fff4c4 100644 (file)
@@ -120,7 +120,8 @@ RefPtr<Image> CSSFilterImageValue::image(RenderElement* renderer, const FloatSiz
         return Image::nullImage();
 
     // Transform Image into ImageBuffer.
-    std::unique_ptr<ImageBuffer> texture = ImageBuffer::create(size);
+    // FIXME (149424): This buffer should not be unconditionally unaccelerated.
+    std::unique_ptr<ImageBuffer> texture = ImageBuffer::create(size, Unaccelerated);
     if (!texture)
         return Image::nullImage();
     FloatRect imageRect = FloatRect(FloatPoint(), size);
index bbff762..44df93c 100644 (file)
@@ -577,7 +577,7 @@ void HTMLCanvasElement::createImageBuffer() const
         return;
 
     RenderingMode renderingMode = shouldAccelerate(bufferSize) ? Accelerated : Unaccelerated;
-    m_imageBuffer = ImageBuffer::create(size(), 1, ColorSpaceDeviceRGB, renderingMode);
+    m_imageBuffer = ImageBuffer::create(size(), renderingMode);
     if (!m_imageBuffer)
         return;
     m_imageBuffer->context().setShadowsIgnoreTransforms(true);
index 2a77b91..9c1097b 100644 (file)
@@ -1684,8 +1684,7 @@ template<class T> IntRect CanvasRenderingContext2D::calculateCompositingBufferRe
 
 std::unique_ptr<ImageBuffer> CanvasRenderingContext2D::createCompositingBuffer(const IntRect& bufferRect)
 {
-    RenderingMode renderMode = isAccelerated() ? Accelerated : Unaccelerated;
-    return ImageBuffer::create(bufferRect.size(), 1, ColorSpaceDeviceRGB, renderMode);
+    return ImageBuffer::create(bufferRect.size(), isAccelerated() ? Accelerated : Unaccelerated);
 }
 
 void CanvasRenderingContext2D::compositeBuffer(ImageBuffer* buffer, const IntRect& bufferRect, CompositeOperator op)
index 16e7731..614da43 100644 (file)
@@ -4880,7 +4880,8 @@ ImageBuffer* WebGLRenderingContextBase::LRUImageBufferCache::imageBuffer(const I
         return buf;
     }
 
-    std::unique_ptr<ImageBuffer> temp = ImageBuffer::create(size, 1);
+    // FIXME (149423): Should this ImageBuffer be unconditionally unaccelerated?
+    std::unique_ptr<ImageBuffer> temp = ImageBuffer::create(size, Unaccelerated);
     if (!temp)
         return nullptr;
     i = std::min(m_capacity - 1, i);
index 22ce339..be967d7 100644 (file)
@@ -1371,7 +1371,8 @@ RefPtr<Image> MediaControlTextTrackContainerElement::createTextTrackRepresentati
 
     IntRect paintingRect = IntRect(IntPoint(), layer->size());
 
-    std::unique_ptr<ImageBuffer> buffer(ImageBuffer::create(paintingRect.size(), deviceScaleFactor, ColorSpaceDeviceRGB));
+    // FIXME (149422): This buffer should not be unconditionally unaccelerated.
+    std::unique_ptr<ImageBuffer> buffer(ImageBuffer::create(paintingRect.size(), Unaccelerated, deviceScaleFactor));
     if (!buffer)
         return nullptr;
 
index d85147d..4714dc6 100644 (file)
@@ -99,7 +99,7 @@ std::unique_ptr<ImageBuffer> snapshotFrameRect(Frame& frame, const IntRect& imag
     if (frame.settings().delegatesPageScaling())
         scaleFactor *= frame.page()->pageScaleFactor();
 
-    std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(imageRect.size(), scaleFactor, ColorSpaceDeviceRGB);
+    std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(imageRect.size(), Unaccelerated, scaleFactor);
     if (!buffer)
         return nullptr;
     buffer->context().translate(-imageRect.x(), -imageRect.y());
index 9422f94..cd0bfee 100644 (file)
@@ -616,7 +616,7 @@ void BitmapImage::drawPattern(GraphicsContext& ctxt, const FloatRect& tileRect,
         return;
     }
     if (!m_cachedImage) {
-        std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(expandedIntSize(tileRect.size()));
+        std::unique_ptr<ImageBuffer> buffer = ctxt.createCompatibleBuffer(expandedIntSize(tileRect.size()));
         if (!buffer)
             return;
 
index d2e5215..75b20d3 100644 (file)
@@ -97,7 +97,7 @@ void CrossfadeGeneratedImage::draw(GraphicsContext& context, const FloatRect& ds
 
 void CrossfadeGeneratedImage::drawPattern(GraphicsContext& context, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& dstRect, BlendMode blendMode)
 {
-    std::unique_ptr<ImageBuffer> imageBuffer = ImageBuffer::create(size(), 1, ColorSpaceDeviceRGB, context.isAcceleratedContext() ? Accelerated : Unaccelerated);
+    std::unique_ptr<ImageBuffer> imageBuffer = ImageBuffer::create(size(), context.renderingMode());
     if (!imageBuffer)
         return;
 
index c1a0475..a80bc5e 100644 (file)
@@ -32,6 +32,7 @@
 #include "FloatRect.h"
 #include "FontCascade.h"
 #include "Gradient.h"
+#include "GraphicsTypes.h"
 #include "Image.h"
 #include "ImageOrientation.h"
 #include "Path.h"
@@ -270,6 +271,7 @@ namespace WebCore {
         WEBCORE_EXPORT void setIsAcceleratedContext(bool);
 #endif
         bool isAcceleratedContext() const;
+        RenderingMode renderingMode() const { return isAcceleratedContext() ? Accelerated : Unaccelerated; }
 
         WEBCORE_EXPORT void save();
         WEBCORE_EXPORT void restore();
index afb6173..00521b6 100644 (file)
@@ -84,6 +84,12 @@ namespace WebCore {
     
     enum TextAlign { StartTextAlign, EndTextAlign, LeftTextAlign, CenterTextAlign, RightTextAlign };
 
+    enum RenderingMode {
+        Unaccelerated,
+        UnacceleratedNonPlatformBuffer, // Use plain memory allocation rather than platform API to allocate backing store.
+        Accelerated
+    };
+
     String compositeOperatorName(CompositeOperator, BlendMode);
     bool parseBlendMode(const String&, BlendMode&);
     bool parseCompositeAndBlendOperator(const String&, CompositeOperator&, BlendMode&);
index 157a3dd..dd14649 100644 (file)
@@ -160,7 +160,7 @@ bool ImageBuffer::copyToPlatformTexture(GraphicsContext3D&, GC3Denum, Platform3D
 
 std::unique_ptr<ImageBuffer> ImageBuffer::createCompatibleBuffer(const FloatSize& size, float resolutionScale, ColorSpace colorSpace, const GraphicsContext& context, bool)
 {
-    return create(size, resolutionScale, colorSpace, context.isAcceleratedContext() ? Accelerated : Unaccelerated);
+    return create(size, context.renderingMode(), resolutionScale, colorSpace);
 }
 
 }
index b978c4c..4840cd5 100644 (file)
@@ -55,12 +55,6 @@ enum Multiply {
     Unmultiplied
 };
 
-enum RenderingMode {
-    Unaccelerated,
-    UnacceleratedNonPlatformBuffer, // Use plain memory allocation rather than platform API to allocate backing store.
-    Accelerated
-};
-
 enum BackingStoreCopy {
     CopyBackingStore, // Guarantee subsequent draws don't affect the copy.
     DontCopyBackingStore // Subsequent draws may affect the copy.
@@ -75,7 +69,7 @@ class ImageBuffer {
     WTF_MAKE_NONCOPYABLE(ImageBuffer); WTF_MAKE_FAST_ALLOCATED;
 public:
     // Will return a null pointer on allocation failure.
-    static std::unique_ptr<ImageBuffer> create(const FloatSize& size, float resolutionScale = 1, ColorSpace colorSpace = ColorSpaceDeviceRGB, RenderingMode renderingMode = Unaccelerated)
+    static std::unique_ptr<ImageBuffer> create(const FloatSize& size, RenderingMode renderingMode, float resolutionScale = 1, ColorSpace colorSpace = ColorSpaceDeviceRGB)
     {
         bool success = false;
         std::unique_ptr<ImageBuffer> buffer(new ImageBuffer(size, resolutionScale, colorSpace, renderingMode, success));
index 24e37c6..1b297bd 100644 (file)
@@ -63,7 +63,6 @@ void NamedImageGeneratedImage::draw(GraphicsContext& context, const FloatRect& d
 void NamedImageGeneratedImage::drawPattern(GraphicsContext& context, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& dstRect, BlendMode blendMode)
 {
 #if USE(NEW_THEME)
-//    std::unique_ptr<ImageBuffer> imageBuffer = ImageBuffer::create(size(), 1, ColorSpaceDeviceRGB, context->isAcceleratedContext() ? Accelerated : Unaccelerated);
     std::unique_ptr<ImageBuffer> imageBuffer = context.createCompatibleBuffer(size(), true);
     if (!imageBuffer)
         return;
index 623e9cc..d6620c7 100644 (file)
@@ -79,7 +79,9 @@ public:
         IntSize roundedSize(roundUpToMultipleOf32(size.width()), roundUpToMultipleOf32(size.height()));
 
         clearScratchBuffer();
-        m_imageBuffer = ImageBuffer::create(roundedSize, 1);
+
+        // ShadowBlur is not used with accelerated drawing, so it's OK to make an unconditionally unaccelerated buffer.
+        m_imageBuffer = ImageBuffer::create(roundedSize, Unaccelerated, 1);
         return m_imageBuffer.get();
     }
 
index a093014..5b62262 100644 (file)
@@ -322,7 +322,8 @@ void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, c
 #if USE(IOSURFACE_CANVAS_BACKING_STORE)
     // Make a copy of the source to ensure the bits don't change before being drawn
     IntSize sourceCopySize(sourceRect.width(), sourceRect.height());
-    std::unique_ptr<ImageBuffer> sourceCopy = ImageBuffer::create(sourceCopySize, 1, ColorSpaceDeviceRGB, Unaccelerated);
+    // FIXME (149431): Should this ImageBuffer be unconditionally unaccelerated? Making it match the context seems to break putData().
+    std::unique_ptr<ImageBuffer> sourceCopy = ImageBuffer::create(sourceCopySize, Unaccelerated, 1, ColorSpaceDeviceRGB);
     if (!sourceCopy)
         return;
 
index ba14712..39bc30d 100644 (file)
@@ -276,7 +276,7 @@ ImageBuffer* FilterEffect::asImageBuffer()
     if (m_openCLImageResult)
         return openCLImageToImageBuffer();
 #endif
-    m_imageBufferResult = ImageBuffer::create(m_absolutePaintRect.size(), m_filter.filterScale(), m_resultColorSpace, m_filter.renderingMode());
+    m_imageBufferResult = ImageBuffer::create(m_absolutePaintRect.size(), m_filter.renderingMode(), m_filter.filterScale(), m_resultColorSpace);
     if (!m_imageBufferResult)
         return nullptr;
 
@@ -308,7 +308,7 @@ ImageBuffer* FilterEffect::openCLImageToImageBuffer()
     if (context->isFailed(clEnqueueReadImage(context->commandQueue(), m_openCLImageResult, CL_TRUE, origin, region, 0, 0, destinationPixelArray->data(), 0, 0, 0)))
         return nullptr;
 
-    m_imageBufferResult = ImageBuffer::create(m_absolutePaintRect.size());
+    m_imageBufferResult = ImageBuffer::create(m_absolutePaintRect.size(), m_filter.renderingMode());
     if (!m_imageBufferResult)
         return nullptr;
 
@@ -462,7 +462,7 @@ ImageBuffer* FilterEffect::createImageBufferResult()
         return nullptr;
 
     FloatSize clampedSize = ImageBuffer::clampedSize(m_absolutePaintRect.size());
-    m_imageBufferResult = ImageBuffer::create(clampedSize, m_filter.filterScale(), m_resultColorSpace, m_filter.renderingMode());
+    m_imageBufferResult = ImageBuffer::create(clampedSize, m_filter.renderingMode(), m_filter.filterScale(), m_resultColorSpace);
     if (!m_imageBufferResult)
         return nullptr;
 
index 68ce313..a47089f 100644 (file)
@@ -35,7 +35,9 @@ namespace WebCore {
 
 void BitmapTexture::updateContents(TextureMapper* textureMapper, GraphicsLayer* sourceLayer, const IntRect& targetRect, const IntPoint& offset, UpdateContentsFlag updateContentsFlag)
 {
-    std::unique_ptr<ImageBuffer> imageBuffer = ImageBuffer::create(targetRect.size());
+    // Making an unconditionally unaccelerated buffer here is OK because this code
+    // isn't used by any platforms that respect the accelerated bit.
+    std::unique_ptr<ImageBuffer> imageBuffer = ImageBuffer::create(targetRect.size(), Unaccelerated);
 
     if (!imageBuffer)
         return;
index 5757e9a..25ed1d5 100644 (file)
@@ -323,7 +323,7 @@ void FilterEffectRenderer::allocateBackingStoreIfNeeded()
     if (!m_graphicsBufferAttached) {
         IntSize logicalSize(m_sourceDrawingRegion.width(), m_sourceDrawingRegion.height());
         if (!sourceImage() || sourceImage()->logicalSize() != logicalSize)
-            setSourceImage(ImageBuffer::create(logicalSize, filterScale(), ColorSpaceDeviceRGB, renderingMode()));
+            setSourceImage(ImageBuffer::create(logicalSize, renderingMode(), filterScale()));
         m_graphicsBufferAttached = true;
     }
 }
index 153e36d..7ea1da4 100644 (file)
@@ -6891,17 +6891,17 @@ void RenderLayer::updateOrRemoveFilterEffectRenderer()
     }
     
     FilterInfo& filterInfo = FilterInfo::get(*this);
+    Frame& frame = renderer().frame();
     if (!filterInfo.renderer()) {
         RefPtr<FilterEffectRenderer> filterRenderer = FilterEffectRenderer::create();
-        filterRenderer->setFilterScale(renderer().frame().page()->deviceScaleFactor());
-        RenderingMode renderingMode = renderer().frame().settings().acceleratedFiltersEnabled() ? Accelerated : Unaccelerated;
-        filterRenderer->setRenderingMode(renderingMode);
+        filterRenderer->setFilterScale(frame.page()->deviceScaleFactor());
+        filterRenderer->setRenderingMode(frame.settings().acceleratedFiltersEnabled() ? Accelerated : Unaccelerated);
         filterInfo.setRenderer(WTF::move(filterRenderer));
         
         // We can optimize away code paths in other places if we know that there are no software filters.
         renderer().view().setHasSoftwareFilters(true);
-    } else if (filterInfo.renderer()->filterScale() != renderer().frame().page()->deviceScaleFactor()) {
-        filterInfo.renderer()->setFilterScale(renderer().frame().page()->deviceScaleFactor());
+    } else if (filterInfo.renderer()->filterScale() != frame.page()->deviceScaleFactor()) {
+        filterInfo.renderer()->setFilterScale(frame.page()->deviceScaleFactor());
         filterInfo.renderer()->clearIntermediateResults();
     }
 
index 6922281..2d47582 100644 (file)
@@ -179,7 +179,8 @@ std::unique_ptr<Shape> Shape::createRasterShape(Image* image, float threshold, c
     IntRect imageRect = snappedIntRect(imageR);
     IntRect marginRect = snappedIntRect(marginR);
     auto intervals = std::make_unique<RasterShapeIntervals>(marginRect.height(), -marginRect.y());
-    std::unique_ptr<ImageBuffer> imageBuffer = ImageBuffer::create(imageRect.size());
+    // FIXME (149420): This buffer should not be unconditionally unaccelerated.
+    std::unique_ptr<ImageBuffer> imageBuffer = ImageBuffer::create(imageRect.size(), Unaccelerated);
 
     if (imageBuffer) {
         GraphicsContext& graphicsContext = imageBuffer->context();
index 5e4775b..5f63f56 100644 (file)
@@ -140,6 +140,7 @@ bool RenderSVGResourceClipper::applyClippingToContext(RenderElement& renderer, c
     AffineTransform absoluteTransform = SVGRenderingContext::calculateTransformationToOutermostCoordinateSystem(renderer);
 
     if (shouldCreateClipperMaskImage && !repaintRect.isEmpty()) {
+        // FIXME (149469): This image buffer should not be unconditionally unaccelerated. Making it match the context breaks nested clipping, though.
         clipperMaskImage = SVGRenderingContext::createImageBuffer(repaintRect, absoluteTransform, ColorSpaceDeviceRGB, Unaccelerated);
         if (!clipperMaskImage)
             return false;
index acea230..dc5d275 100644 (file)
@@ -61,7 +61,7 @@ static inline bool createMaskAndSwapContextForTextGradient(GraphicsContext*& con
     AffineTransform absoluteTransform = SVGRenderingContext::calculateTransformationToOutermostCoordinateSystem(*textRootBlock);
     FloatRect repaintRect = textRootBlock->repaintRectInLocalCoordinates();
 
-    auto maskImage = SVGRenderingContext::createImageBuffer(repaintRect, absoluteTransform, ColorSpaceDeviceRGB, Unaccelerated);
+    auto maskImage = SVGRenderingContext::createImageBuffer(repaintRect, absoluteTransform, ColorSpaceDeviceRGB, context->renderingMode());
     if (!maskImage)
         return false;
 
index ad37d47..9b7b9ac 100644 (file)
@@ -69,6 +69,7 @@ bool RenderSVGResourceMasker::applyResource(RenderElement& renderer, const Rende
     if (!maskerData->maskImage && !repaintRect.isEmpty()) {
         const SVGRenderStyle& svgStyle = style().svgStyle();
         ColorSpace colorSpace = svgStyle.colorInterpolation() == CI_LINEARRGB ? ColorSpaceLinearRGB : ColorSpaceDeviceRGB;
+        // FIXME (149470): This image buffer should not be unconditionally unaccelerated. Making it match the context breaks alpha masking, though.
         maskerData->maskImage = SVGRenderingContext::createImageBuffer(repaintRect, absoluteTransform, colorSpace, Unaccelerated);
         if (!maskerData->maskImage)
             return false;
index b4f4d23..bd5e13d 100644 (file)
@@ -94,7 +94,7 @@ PatternData* RenderSVGResourcePattern::buildPattern(RenderElement& renderer, uns
         static_cast<float>(m_attributes.patternTransform().yScale()));
 
     // Build tile image.
-    auto tileImage = createTileImage(m_attributes, tileBoundaries, absoluteTileBoundaries, tileImageTransform, clampedAbsoluteTileBoundaries, context.isAcceleratedContext() ? Accelerated : Unaccelerated);
+    auto tileImage = createTileImage(m_attributes, tileBoundaries, absoluteTileBoundaries, tileImageTransform, clampedAbsoluteTileBoundaries, context.renderingMode());
     if (!tileImage)
         return nullptr;
 
index fb9a03c..89b8e38 100644 (file)
@@ -257,7 +257,7 @@ std::unique_ptr<ImageBuffer> SVGRenderingContext::createImageBuffer(const FloatR
     FloatSize scale;
     FloatSize clampedSize = ImageBuffer::clampedSize(paintRect.size(), scale);
 
-    auto imageBuffer = ImageBuffer::create(clampedSize, 1, colorSpace, renderingMode);
+    auto imageBuffer = ImageBuffer::create(clampedSize, renderingMode, 1, colorSpace);
     if (!imageBuffer)
         return nullptr;
 
@@ -279,7 +279,7 @@ std::unique_ptr<ImageBuffer> SVGRenderingContext::createImageBuffer(const FloatR
     if (clampedSize.isEmpty())
         return nullptr;
 
-    auto imageBuffer = ImageBuffer::create(clampedSize, 1, colorSpace, renderingMode);
+    auto imageBuffer = ImageBuffer::create(clampedSize, renderingMode, 1, colorSpace);
     if (!imageBuffer)
         return nullptr;
 
index 08153c1..63eb0ef 100644 (file)
@@ -173,7 +173,8 @@ PassNativeImagePtr SVGImage::nativeImageForCurrentFrame()
     if (!m_page)
         return 0;
 
-    std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(size(), 1);
+    // Cairo does not use the accelerated drawing flag, so it's OK to make an unconditionally unaccelerated buffer.
+    std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(size(), Unaccelerated);
     if (!buffer) // failed to allocate image
         return 0;
 
index 0282e5a..2a86acd 100644 (file)
@@ -1,3 +1,13 @@
+2015-09-22  Tim Horton  <timothy_horton@apple.com>
+
+        Make it more obvious when using an unaccelerated image buffer, and fix a few callers who do
+        https://bugs.webkit.org/show_bug.cgi?id=149428
+
+        Reviewed by Simon Fraser and Darin Adler.
+
+        * WebCoreSupport/WebContextMenuClient.mm:
+        (WebContextMenuClient::imageForCurrentSharingServicePickerItem):
+
 2015-09-21  Alexey Proskuryakov  <ap@apple.com>
 
         REGRESSION (r182648): UIWebView does not set location.hash synchronously
index cfccd3c..99e348b 100644 (file)
@@ -471,7 +471,8 @@ RetainPtr<NSImage> WebContextMenuClient::imageForCurrentSharingServicePickerItem
     if (!clientFloatRectForNode(*node, rect))
         return nil;
 
-    std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(rect.size());
+    // This is effectively a snapshot, and will be painted in an unaccelerated fashion in line with FrameSnapshotting.
+    std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(rect.size(), Unaccelerated);
     if (!buffer)
         return nil;
 
index bc82b5c..11be314 100644 (file)
@@ -1,3 +1,13 @@
+2015-09-22  Tim Horton  <timothy_horton@apple.com>
+
+        Make it more obvious when using an unaccelerated image buffer, and fix a few callers who do
+        https://bugs.webkit.org/show_bug.cgi?id=149428
+
+        Reviewed by Simon Fraser and Darin Adler.
+
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.cpp:
+        (WebKit::ThreadSafeCoordinatedSurface::create):
+
 2015-09-22  Andreas Kling  <akling@apple.com>
 
         [WK2][NetworkCache] New entry bodies remain in dirty memory after being written to disk.
index bcdc6a6..c2a96ca 100644 (file)
@@ -37,7 +37,9 @@ namespace WebKit {
 
 Ref<ThreadSafeCoordinatedSurface> ThreadSafeCoordinatedSurface::create(const IntSize& size, CoordinatedSurface::Flags flags)
 {
-    return adoptRef(*new ThreadSafeCoordinatedSurface(size, flags, ImageBuffer::create(size)));
+    // Making an unconditionally unaccelerated buffer here is OK because this code
+    // isn't used by any platforms that respect the accelerated bit.
+    return adoptRef(*new ThreadSafeCoordinatedSurface(size, flags, ImageBuffer::create(size, Unaccelerated)));
 }
 
 Ref<ThreadSafeCoordinatedSurface> ThreadSafeCoordinatedSurface::create(const IntSize& size, CoordinatedSurface::Flags flags, std::unique_ptr<ImageBuffer> buffer)