Diff
Modified: trunk/Source/WebCore/ChangeLog (194024 => 194025)
--- trunk/Source/WebCore/ChangeLog 2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/ChangeLog 2015-12-14 05:27:45 UTC (rev 194025)
@@ -1,3 +1,54 @@
+2015-12-13 Tim Horton <[email protected]>
+
+ Adopt CGIOSurfaceContextCreateImageReference to avoid unnecessary readback
+ https://bugs.webkit.org/show_bug.cgi?id=150988
+ <rdar://problem/18993594>
+
+ Reviewed by Darin Adler.
+
+ * platform/graphics/GraphicsContext.cpp:
+ (WebCore::GraphicsContext::drawConsumingImageBuffer):
+ * platform/graphics/GraphicsContext.h:
+ * platform/graphics/ImageBuffer.h:
+ * platform/graphics/cg/ImageBufferCG.cpp:
+ (WebCore::createBitmapImageAfterScalingIfNeeded):
+ (WebCore::ImageBuffer::copyImage):
+ (WebCore::ImageBuffer::sinkIntoImage):
+ (WebCore::ImageBuffer::sinkIntoNativeImage):
+ (WebCore::ImageBuffer::drawConsuming):
+ * platform/graphics/cocoa/IOSurface.h:
+ * platform/graphics/cocoa/IOSurface.mm:
+ (IOSurface::createFromImageBuffer):
+ (IOSurface::sinkIntoImage):
+ Add sinkIntoImage, sinkIntoNativeImage, and drawConsuming to ImageBuffer,
+ which all consume the ImageBuffer and allow us to tell the system to
+ make a CGImage that references the IOSurface, which is in many cases
+ more efficient than making an image with a "copy" of the IOSurface.
+ (The copy is done lazily, but we often hit a corner case that causes
+ it to happen unnecessarily.)
+
+ * html/shadow/MediaControlElements.cpp:
+ (WebCore::MediaControlTextTrackContainerElement::createTextTrackRepresentationImage):
+ * page/TextIndicator.cpp:
+ (WebCore::takeSnapshot):
+ * platform/DragImage.cpp:
+ (WebCore::createDragImageFromSnapshot):
+ * platform/graphics/filters/FETile.cpp:
+ (WebCore::FETile::platformApplySoftware):
+ * platform/mac/ThemeMac.mm:
+ (WebCore::ThemeMac::drawCellOrFocusRingWithViewIntoContext):
+ * platform/mediastream/mac/AVVideoCaptureSource.mm:
+ (WebCore::AVVideoCaptureSource::currentFrameImage):
+ * rendering/RenderBoxModelObject.cpp:
+ (WebCore::RenderBoxModelObject::paintFillLayerExtended):
+ * rendering/RenderThemeMac.mm:
+ (WebCore::RenderThemeMac::paintProgressBar):
+ * rendering/svg/RenderSVGResourcePattern.cpp:
+ (WebCore::RenderSVGResourcePattern::buildPattern):
+ * svg/graphics/SVGImage.cpp:
+ (WebCore::SVGImage::drawPatternForContainer):
+ Adopt sinkIntoImage and drawConsumingImageBuffer in a few places.
+
2015-12-13 Andreas Kling <[email protected]>
CachedScript could have a copy-free path for all-ASCII scripts.
Modified: trunk/Source/WebCore/html/shadow/MediaControlElements.cpp (194024 => 194025)
--- trunk/Source/WebCore/html/shadow/MediaControlElements.cpp 2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/html/shadow/MediaControlElements.cpp 2015-12-14 05:27:45 UTC (rev 194025)
@@ -1374,7 +1374,7 @@
layer->paint(buffer->context(), paintingRect, LayoutSize(), PaintBehaviorFlattenCompositingLayers, nullptr, RenderLayer::PaintLayerPaintingCompositingAllPhases);
- return buffer->copyImage();
+ return ImageBuffer::sinkIntoImage(WTF::move(buffer));
}
void MediaControlTextTrackContainerElement::textTrackRepresentationBoundsChanged(const IntRect&)
Modified: trunk/Source/WebCore/page/TextIndicator.cpp (194024 => 194025)
--- trunk/Source/WebCore/page/TextIndicator.cpp 2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/page/TextIndicator.cpp 2015-12-14 05:27:45 UTC (rev 194025)
@@ -155,7 +155,7 @@
if (!buffer)
return nullptr;
scaleFactor = buffer->resolutionScale();
- return buffer->copyImage(CopyBackingStore, Unscaled);
+ return ImageBuffer::sinkIntoImage(WTF::move(buffer), Unscaled);
}
static bool takeSnapshots(TextIndicatorData& data, Frame& frame, IntRect snapshotRect)
Modified: trunk/Source/WebCore/platform/DragImage.cpp (194024 => 194025)
--- trunk/Source/WebCore/platform/DragImage.cpp 2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/platform/DragImage.cpp 2015-12-14 05:27:45 UTC (rev 194025)
@@ -106,7 +106,7 @@
#else
UNUSED_PARAM(node);
#endif
- RefPtr<Image> image = snapshot->copyImage(ImageBuffer::fastCopyImageMode(), Unscaled);
+ RefPtr<Image> image = ImageBuffer::sinkIntoImage(WTF::move(snapshot), Unscaled);
if (!image)
return nullptr;
return createDragImageFromImage(image.get(), orientation);
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (194024 => 194025)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2015-12-14 05:27:45 UTC (rev 194025)
@@ -443,6 +443,33 @@
image.draw(*this, destination, source, imagePaintingOptions.m_compositeOperator, imagePaintingOptions.m_blendMode, imagePaintingOptions.m_useLowQualityScale);
}
+void GraphicsContext::drawConsumingImageBuffer(std::unique_ptr<ImageBuffer> image, const FloatPoint& destination, const ImagePaintingOptions& imagePaintingOptions)
+{
+ if (!image)
+ return;
+ IntSize imageLogicalSize = image->logicalSize();
+ drawConsumingImageBuffer(WTF::move(image), FloatRect(destination, imageLogicalSize), FloatRect(FloatPoint(), imageLogicalSize), imagePaintingOptions);
+}
+
+void GraphicsContext::drawConsumingImageBuffer(std::unique_ptr<ImageBuffer> image, const FloatRect& destination, const ImagePaintingOptions& imagePaintingOptions)
+{
+ if (!image)
+ return;
+ IntSize imageLogicalSize = image->logicalSize();
+ drawConsumingImageBuffer(WTF::move(image), destination, FloatRect(FloatPoint(), FloatSize(imageLogicalSize)), imagePaintingOptions);
+}
+
+void GraphicsContext::drawConsumingImageBuffer(std::unique_ptr<ImageBuffer> image, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& imagePaintingOptions)
+{
+ if (paintingDisabled() || !image)
+ return;
+
+ // FIXME (49002): Should be InterpolationLow
+ InterpolationQualityMaintainer interpolationQualityForThisScope(*this, imagePaintingOptions.m_useLowQualityScale ? InterpolationNone : imageInterpolationQuality());
+
+ ImageBuffer::drawConsuming(WTF::move(image), *this, destination, source, imagePaintingOptions.m_compositeOperator, imagePaintingOptions.m_blendMode, imagePaintingOptions.m_useLowQualityScale);
+}
+
void GraphicsContext::clip(const IntRect& rect)
{
clip(FloatRect(rect));
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (194024 => 194025)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2015-12-14 05:27:45 UTC (rev 194025)
@@ -315,6 +315,10 @@
void drawPattern(Image&, const FloatRect& srcRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator, const FloatRect& destRect, BlendMode = BlendModeNormal);
+ WEBCORE_EXPORT void drawConsumingImageBuffer(std::unique_ptr<ImageBuffer>, const FloatPoint& destination, const ImagePaintingOptions& = ImagePaintingOptions());
+ void drawConsumingImageBuffer(std::unique_ptr<ImageBuffer>, const FloatRect& destination, const ImagePaintingOptions& = ImagePaintingOptions());
+ void drawConsumingImageBuffer(std::unique_ptr<ImageBuffer>, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& = ImagePaintingOptions());
+
WEBCORE_EXPORT void setImageInterpolationQuality(InterpolationQuality);
InterpolationQuality imageInterpolationQuality() const { return m_state.imageInterpolationQuality; }
Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.h (194024 => 194025)
--- trunk/Source/WebCore/platform/graphics/ImageBuffer.h 2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.h 2015-12-14 05:27:45 UTC (rev 194025)
@@ -67,6 +67,7 @@
class ImageBuffer {
WTF_MAKE_NONCOPYABLE(ImageBuffer); WTF_MAKE_FAST_ALLOCATED;
+ friend class IOSurface;
public:
// Will return a null pointer on allocation failure.
static std::unique_ptr<ImageBuffer> create(const FloatSize& size, RenderingMode renderingMode, float resolutionScale = 1, ColorSpace colorSpace = ColorSpaceSRGB)
@@ -91,6 +92,7 @@
WEBCORE_EXPORT GraphicsContext& context() const;
WEBCORE_EXPORT RefPtr<Image> copyImage(BackingStoreCopy = CopyBackingStore, ScaleBehavior = Scaled) const;
+ WEBCORE_EXPORT static RefPtr<Image> sinkIntoImage(std::unique_ptr<ImageBuffer>, ScaleBehavior = Scaled);
// Give hints on the faster copyImage Mode, return DontCopyBackingStore if it supports the DontCopyBackingStore behavior
// or return CopyBackingStore if it doesn't.
static BackingStoreCopy fastCopyImageMode();
@@ -130,6 +132,7 @@
// The returned image might be larger than the internalSize(). If you want the smaller
// image, crop the result.
RetainPtr<CGImageRef> copyNativeImage(BackingStoreCopy = CopyBackingStore) const;
+ static RetainPtr<CGImageRef> sinkIntoNativeImage(std::unique_ptr<ImageBuffer>);
void flushContext() const;
#endif
void clip(GraphicsContext&, const FloatRect&) const;
@@ -137,6 +140,8 @@
void draw(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect = FloatRect(0, 0, -1, -1), CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, bool useLowQualityScale = false);
void drawPattern(GraphicsContext&, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator, const FloatRect& destRect, BlendMode = BlendModeNormal);
+ static void drawConsuming(std::unique_ptr<ImageBuffer>, GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect = FloatRect(0, 0, -1, -1), CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, bool useLowQualityScale = false);
+
inline void genericConvertToLuminanceMask();
friend class GraphicsContext;
Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp (194024 => 194025)
--- trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp 2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp 2015-12-14 05:27:45 UTC (rev 194025)
@@ -195,6 +195,11 @@
return *m_data.m_context;
}
+RefPtr<Image> ImageBuffer::sinkIntoImage(std::unique_ptr<ImageBuffer> imageBuffer, ScaleBehavior scaleBehavior)
+{
+ return imageBuffer->copyImage(DontCopyBackingStore, scaleBehavior);
+}
+
RefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy copyBehavior, ScaleBehavior) const
{
if (copyBehavior == CopyBackingStore)
@@ -214,6 +219,11 @@
context.platformContext()->pushImageMask(m_data.m_surface.get(), maskRect);
}
+void ImageBuffer::drawConsuming(std::unique_ptr<ImageBuffer> imageBuffer, GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, BlendMode blendMode, bool useLowQualityScale)
+{
+ imageBuffer->draw(destContext, destRect, srcRect, op, blendMode, useLowQualityScale);
+}
+
void ImageBuffer::draw(GraphicsContext& destinationContext, const FloatRect& destRect, const FloatRect& srcRect,
CompositeOperator op, BlendMode blendMode, bool useLowQualityScale)
{
Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp (194024 => 194025)
--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp 2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp 2015-12-14 05:27:45 UTC (rev 194025)
@@ -43,6 +43,7 @@
#include <wtf/RetainPtr.h>
#include <wtf/text/Base64.h>
#include <wtf/text/WTFString.h>
+
#if PLATFORM(COCOA)
#include "WebCoreSystemInterface.h"
#endif
@@ -177,18 +178,15 @@
return image;
}
-RefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy copyBehavior, ScaleBehavior scaleBehavior) const
+static RefPtr<Image> createBitmapImageAfterScalingIfNeeded(RetainPtr<CGImageRef>&& image, IntSize internalSize, IntSize logicalSize, IntSize backingStoreSize, float resolutionScale, ScaleBehavior scaleBehavior)
{
- RetainPtr<CGImageRef> image;
- if (m_resolutionScale == 1 || scaleBehavior == Unscaled) {
- image = copyNativeImage(copyBehavior);
- image = createCroppedImageIfNecessary(image.get(), internalSize());
- } else {
- image = copyNativeImage(DontCopyBackingStore);
- RetainPtr<CGContextRef> context = adoptCF(CGBitmapContextCreate(0, logicalSize().width(), logicalSize().height(), 8, 4 * logicalSize().width(), sRGBColorSpaceRef(), kCGImageAlphaPremultipliedLast));
+ if (resolutionScale == 1 || scaleBehavior == Unscaled)
+ image = createCroppedImageIfNecessary(image.get(), internalSize);
+ else {
+ RetainPtr<CGContextRef> context = adoptCF(CGBitmapContextCreate(0, logicalSize.width(), logicalSize.height(), 8, 4 * logicalSize.width(), sRGBColorSpaceRef(), kCGImageAlphaPremultipliedLast));
CGContextSetBlendMode(context.get(), kCGBlendModeCopy);
- CGContextClipToRect(context.get(), FloatRect(FloatPoint::zero(), logicalSize()));
- FloatSize imageSizeInUserSpace = scaleSizeToUserSpace(logicalSize(), m_data.backingStoreSize, internalSize());
+ CGContextClipToRect(context.get(), FloatRect(FloatPoint::zero(), logicalSize));
+ FloatSize imageSizeInUserSpace = scaleSizeToUserSpace(logicalSize, backingStoreSize, internalSize);
CGContextDrawImage(context.get(), FloatRect(FloatPoint::zero(), imageSizeInUserSpace), image.get());
image = adoptCF(CGBitmapContextCreateImage(context.get()));
}
@@ -199,11 +197,44 @@
return BitmapImage::create(image.get());
}
+RefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy copyBehavior, ScaleBehavior scaleBehavior) const
+{
+ RetainPtr<CGImageRef> image;
+ if (m_resolutionScale == 1 || scaleBehavior == Unscaled)
+ image = copyNativeImage(copyBehavior);
+ else
+ image = copyNativeImage(DontCopyBackingStore);
+
+ return createBitmapImageAfterScalingIfNeeded(WTF::move(image), internalSize(), logicalSize(), m_data.backingStoreSize, m_resolutionScale, scaleBehavior);
+}
+
+RefPtr<Image> ImageBuffer::sinkIntoImage(std::unique_ptr<ImageBuffer> imageBuffer, ScaleBehavior scaleBehavior)
+{
+ IntSize internalSize = imageBuffer->internalSize();
+ IntSize logicalSize = imageBuffer->logicalSize();
+ IntSize backingStoreSize = imageBuffer->m_data.backingStoreSize;
+ float resolutionScale = imageBuffer->m_resolutionScale;
+
+ return createBitmapImageAfterScalingIfNeeded(sinkIntoNativeImage(WTF::move(imageBuffer)), internalSize, logicalSize, backingStoreSize, resolutionScale, scaleBehavior);
+}
+
BackingStoreCopy ImageBuffer::fastCopyImageMode()
{
return DontCopyBackingStore;
}
+RetainPtr<CGImageRef> ImageBuffer::sinkIntoNativeImage(std::unique_ptr<ImageBuffer> imageBuffer)
+{
+#if USE(IOSURFACE_CANVAS_BACKING_STORE)
+ if (!imageBuffer->m_data.surface)
+ return imageBuffer->copyNativeImage(DontCopyBackingStore);
+
+ return IOSurface::sinkIntoImage(IOSurface::createFromImageBuffer(WTF::move(imageBuffer)));
+#else
+ return imageBuffer->copyNativeImage(DontCopyBackingStore);
+#endif
+}
+
RetainPtr<CGImageRef> ImageBuffer::copyNativeImage(BackingStoreCopy copyBehavior) const
{
RetainPtr<CGImageRef> image;
@@ -228,6 +259,29 @@
return image;
}
+void ImageBuffer::drawConsuming(std::unique_ptr<ImageBuffer> imageBuffer, GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, BlendMode blendMode, bool useLowQualityScale)
+{
+#if USE(IOSURFACE_CANVAS_BACKING_STORE)
+ if (!imageBuffer->m_data.surface) {
+ imageBuffer->draw(destContext, destRect, srcRect, op, blendMode, useLowQualityScale);
+ return;
+ }
+
+ ASSERT(destContext.isAcceleratedContext());
+
+ float resolutionScale = imageBuffer->m_resolutionScale;
+ IntSize backingStoreSize = imageBuffer->m_data.backingStoreSize;
+
+ RetainPtr<CGImageRef> image = IOSurface::sinkIntoImage(IOSurface::createFromImageBuffer(WTF::move(imageBuffer)));
+
+ FloatRect adjustedSrcRect = srcRect;
+ adjustedSrcRect.scale(resolutionScale, resolutionScale);
+ destContext.drawNativeImage(image.get(), backingStoreSize, destRect, adjustedSrcRect, op, blendMode);
+#else
+ imageBuffer->draw(destContext, destRect, srcRect, op, blendMode, useLowQualityScale);
+#endif
+}
+
void ImageBuffer::draw(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, BlendMode blendMode, bool)
{
RetainPtr<CGImageRef> image;
Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h (194024 => 194025)
--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h 2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h 2015-12-14 05:27:45 UTC (rev 194025)
@@ -50,6 +50,8 @@
WEBCORE_EXPORT static std::unique_ptr<IOSurface> createFromSendRight(const MachSendRight&, ColorSpace);
static std::unique_ptr<IOSurface> createFromSurface(IOSurfaceRef, ColorSpace);
WEBCORE_EXPORT static std::unique_ptr<IOSurface> createFromImage(CGImageRef);
+
+ static std::unique_ptr<IOSurface> createFromImageBuffer(std::unique_ptr<ImageBuffer>);
WEBCORE_EXPORT static void moveToPool(std::unique_ptr<IOSurface>&&);
@@ -60,6 +62,7 @@
// Any images created from a surface need to be released before releasing
// the surface, or an expensive GPU readback can result.
WEBCORE_EXPORT RetainPtr<CGImageRef> createImage();
+ static RetainPtr<CGImageRef> sinkIntoImage(std::unique_ptr<IOSurface>);
IOSurfaceRef surface() const { return m_surface.get(); }
WEBCORE_EXPORT GraphicsContext& ensureGraphicsContext();
Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm (194024 => 194025)
--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm 2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm 2015-12-14 05:27:45 UTC (rev 194025)
@@ -31,12 +31,15 @@
#import "GraphicsContextCG.h"
#import "IOSurfacePool.h"
#import "IOSurfaceSPI.h"
+#import "ImageBuffer.h"
+#import "ImageBufferDataCG.h"
#import "MachSendRight.h"
#import <wtf/Assertions.h>
extern "C" {
CGContextRef CGIOSurfaceContextCreate(IOSurfaceRef, size_t, size_t, size_t, size_t, CGColorSpaceRef, CGBitmapInfo);
CGImageRef CGIOSurfaceContextCreateImage(CGContextRef);
+CGImageRef CGIOSurfaceContextCreateImageReference(CGContextRef);
}
using namespace WebCore;
@@ -98,6 +101,11 @@
IOSurfacePool::sharedPool().addSurface(WTF::move(surface));
}
+std::unique_ptr<IOSurface> IOSurface::createFromImageBuffer(std::unique_ptr<ImageBuffer> imageBuffer)
+{
+ return WTF::move(imageBuffer->m_data.surface);
+}
+
IOSurface::IOSurface(IntSize size, ColorSpace colorSpace, Format format)
: m_colorSpace(colorSpace)
, m_size(size)
@@ -244,6 +252,15 @@
return adoptCF(CGIOSurfaceContextCreateImage(ensurePlatformContext()));
}
+RetainPtr<CGImageRef> IOSurface::sinkIntoImage(std::unique_ptr<IOSurface> surface)
+{
+#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
+ return adoptCF(CGIOSurfaceContextCreateImageReference(surface->ensurePlatformContext()));
+#else
+ return surface->createImage();
+#endif
+}
+
void IOSurface::setContextSize(IntSize contextSize)
{
if (contextSize == m_contextSize)
Modified: trunk/Source/WebCore/platform/graphics/filters/FETile.cpp (194024 => 194025)
--- trunk/Source/WebCore/platform/graphics/filters/FETile.cpp 2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/platform/graphics/filters/FETile.cpp 2015-12-14 05:27:45 UTC (rev 194025)
@@ -72,7 +72,7 @@
tileImageContext.translate(-inMaxEffectLocation.x(), -inMaxEffectLocation.y());
tileImageContext.drawImageBuffer(*inBuffer, in->absolutePaintRect().location());
- auto tileImageCopy = tileImage->copyImage(CopyBackingStore);
+ auto tileImageCopy = ImageBuffer::sinkIntoImage(WTF::move(tileImage));
if (!tileImageCopy)
return;
Modified: trunk/Source/WebCore/platform/mac/ThemeMac.mm (194024 => 194025)
--- trunk/Source/WebCore/platform/mac/ThemeMac.mm 2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/platform/mac/ThemeMac.mm 2015-12-14 05:27:45 UTC (rev 194025)
@@ -692,7 +692,7 @@
LocalCurrentGraphicsContext localContext(imageBuffer->context());
needsRepaint = drawCellOrFocusRingIntoRectWithView(cell, imageBufferDrawRect, view, drawButtonCell, drawFocusRing);
}
- context.drawImageBuffer(*imageBuffer, rect.location() - FloatSize(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth));
+ context.drawConsumingImageBuffer(WTF::move(imageBuffer), rect.location() - FloatSize(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth));
return needsRepaint;
}
if (drawButtonCell)
Modified: trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm (194024 => 194025)
--- trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm 2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm 2015-12-14 05:27:45 UTC (rev 194025)
@@ -334,7 +334,7 @@
paintCurrentFrameInContext(imageBuffer->context(), imageRect);
- return imageBuffer->copyImage();
+ return ImageBuffer::sinkIntoImage(WTF::move(imageBuffer));
}
RetainPtr<CGImageRef> AVVideoCaptureSource::currentFrameCGImage()
Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (194024 => 194025)
--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2015-12-14 05:27:45 UTC (rev 194025)
@@ -840,7 +840,7 @@
}
if (maskImage && bgLayer->clip() == TextFillBox) {
- context.drawImageBuffer(*maskImage, maskRect, CompositeDestinationIn);
+ context.drawConsumingImageBuffer(WTF::move(maskImage), maskRect, CompositeDestinationIn);
context.endTransparencyLayer();
}
}
Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (194024 => 194025)
--- trunk/Source/WebCore/rendering/RenderThemeMac.mm 2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm 2015-12-14 05:27:45 UTC (rev 194025)
@@ -1156,7 +1156,7 @@
paintInfo.context().scale(FloatSize(-1, 1));
}
- paintInfo.context().drawImageBuffer(*imageBuffer, inflatedRect.location());
+ paintInfo.context().drawConsumingImageBuffer(WTF::move(imageBuffer), inflatedRect.location());
return false;
}
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp (194024 => 194025)
--- trunk/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp 2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp 2015-12-14 05:27:45 UTC (rev 194025)
@@ -113,7 +113,9 @@
if (!tileImage)
return nullptr;
- RefPtr<Image> copiedImage = tileImage->copyImage(CopyBackingStore);
+ const IntSize tileImageSize = tileImage->logicalSize();
+
+ RefPtr<Image> copiedImage = ImageBuffer::sinkIntoImage(WTF::move(tileImage));
if (!copiedImage)
return nullptr;
@@ -122,7 +124,7 @@
patternData->pattern = Pattern::create(copiedImage, true, true);
// Compute pattern space transformation.
- const IntSize tileImageSize = tileImage->logicalSize();
+
patternData->transform.translate(tileBoundaries.x(), tileBoundaries.y());
patternData->transform.scale(tileBoundaries.width() / tileImageSize.width(), tileBoundaries.height() / tileImageSize.height());
Modified: trunk/Source/WebCore/svg/graphics/SVGImage.cpp (194024 => 194025)
--- trunk/Source/WebCore/svg/graphics/SVGImage.cpp 2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/svg/graphics/SVGImage.cpp 2015-12-14 05:27:45 UTC (rev 194025)
@@ -208,7 +208,7 @@
if (context.drawLuminanceMask())
buffer->convertToLuminanceMask();
- RefPtr<Image> image = buffer->copyImage(DontCopyBackingStore, Unscaled);
+ RefPtr<Image> image = ImageBuffer::sinkIntoImage(WTF::move(buffer), Unscaled);
if (!image)
return;
Modified: trunk/Source/WebKit/mac/ChangeLog (194024 => 194025)
--- trunk/Source/WebKit/mac/ChangeLog 2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebKit/mac/ChangeLog 2015-12-14 05:27:45 UTC (rev 194025)
@@ -1,3 +1,15 @@
+2015-12-13 Tim Horton <[email protected]>
+
+ Adopt CGIOSurfaceContextCreateImageReference to avoid unnecessary readback
+ https://bugs.webkit.org/show_bug.cgi?id=150988
+ <rdar://problem/18993594>
+
+ Reviewed by Darin Adler.
+
+ * WebCoreSupport/WebContextMenuClient.mm:
+ (WebContextMenuClient::imageForCurrentSharingServicePickerItem):
+ Adopt sinkIntoImage and drawConsumingImageBuffer in a few places.
+
2015-12-11 Eric Carlson <[email protected]>
[MediaStream] Add a setting to allow the mock media capture devices to be enabled and disabled
Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm (194024 => 194025)
--- trunk/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm 2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm 2015-12-14 05:27:45 UTC (rev 194025)
@@ -220,7 +220,7 @@
frameView->frame().selection().setSelection(oldSelection);
frameView->setPaintBehavior(oldPaintBehavior);
- RefPtr<Image> image = buffer->copyImage(DontCopyBackingStore);
+ RefPtr<Image> image = ImageBuffer::sinkIntoImage(WTF::move(buffer));
if (!image)
return nil;
Modified: trunk/Source/WebKit2/ChangeLog (194024 => 194025)
--- trunk/Source/WebKit2/ChangeLog 2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebKit2/ChangeLog 2015-12-14 05:27:45 UTC (rev 194025)
@@ -1,3 +1,15 @@
+2015-12-13 Tim Horton <[email protected]>
+
+ Adopt CGIOSurfaceContextCreateImageReference to avoid unnecessary readback
+ https://bugs.webkit.org/show_bug.cgi?id=150988
+ <rdar://problem/18993594>
+
+ Reviewed by Darin Adler.
+
+ * WebProcess/WebPage/WebFrame.cpp:
+ (WebKit::WebFrame::createSelectionSnapshot):
+ Adopt sinkIntoImage and drawConsumingImageBuffer in a few places.
+
2015-12-13 Dan Bernstein <[email protected]>
Another fix after r194018.
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp (194024 => 194025)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp 2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp 2015-12-14 05:27:45 UTC (rev 194025)
@@ -826,7 +826,7 @@
auto graphicsContext = sharedSnapshot->createGraphicsContext();
float deviceScaleFactor = coreFrame()->page()->deviceScaleFactor();
graphicsContext->scale(FloatSize(deviceScaleFactor, deviceScaleFactor));
- graphicsContext->drawImageBuffer(*snapshot, FloatPoint());
+ graphicsContext->drawConsumingImageBuffer(WTF::move(snapshot), FloatPoint());
return sharedSnapshot.release();
}