| Differences between
and this patch
- Source/WebCore/ChangeLog +47 lines
Lines 1-3 Source/WebCore/ChangeLog_sec1
1
2020-01-22  Said Abou-Hallawa  <sabouhallawa@apple.com>
2
3
        Remove ImageBuffer::sizeForDestinationSize()
4
        https://bugs.webkit.org/show_bug.cgi?id=206541
5
6
        Reviewed by Tim Horton.
7
8
        -- Remove ImageBuffer::sizeForDestinationSize() since it is currently
9
           doing nothing. For CG and D2D ports, it scales a rect by the ratio
10
           backingStoreSize / internalSize which is always 1. The constructor
11
           ImageBuffer::ImageBuffer() sets m_size and m_data.backingStoreSize
12
           to the same value always.
13
14
        -- Remove ImageBuffer::isCompatibleWithContext() since it is not used.
15
16
        -- Remove ImageBuffer::fastCopyImageMode() since it returns 
17
           DontCopyBackingStore on all ports.
18
19
        * html/CustomPaintCanvas.cpp:
20
        (WebCore::CustomPaintCanvas::copiedImage const):
21
        * html/canvas/WebGLRenderingContextBase.cpp:
22
        (WebCore::WebGLRenderingContextBase::texSubImage2D):
23
        (WebCore::WebGLRenderingContextBase::texImage2D):
24
        (WebCore::WebGLRenderingContextBase::drawImageIntoBuffer):
25
        * platform/graphics/ImageBuffer.cpp:
26
        (WebCore::ImageBuffer::sizeForDestinationSize const): Deleted.
27
        (WebCore::ImageBuffer::isCompatibleWithContext const): Deleted.
28
        * platform/graphics/ImageBuffer.h:
29
        (WebCore::ImageBuffer::logicalSize const):
30
        * platform/graphics/cairo/ImageBufferCairo.cpp:
31
        (WebCore::ImageBuffer::fastCopyImageMode): Deleted.
32
        * platform/graphics/cg/GraphicsContextCG.cpp:
33
        (WebCore::GraphicsContext::clipToImageBuffer):
34
        * platform/graphics/cg/ImageBufferCG.cpp:
35
        (WebCore::ImageBuffer::ImageBuffer):
36
        (WebCore::createBitmapImageAfterScalingIfNeeded):
37
        (WebCore::ImageBuffer::copyImage const):
38
        (WebCore::ImageBuffer::sinkIntoImage):
39
        (WebCore::ImageBuffer::toCFData const):
40
        (WebCore::scaleSizeToUserSpace): Deleted.
41
        (WebCore::ImageBuffer::sizeForDestinationSize const): Deleted.
42
        (WebCore::ImageBuffer::fastCopyImageMode): Deleted.
43
        * platform/graphics/win/ImageBufferDirect2D.cpp:
44
        (WebCore::scaleSizeToUserSpace): Deleted.
45
        (WebCore::ImageBuffer::sizeForDestinationSize const): Deleted.
46
        (WebCore::ImageBuffer::fastCopyImageMode): Deleted.
47
1
2020-01-22  Zalan Bujtas  <zalan@apple.com>
48
2020-01-22  Zalan Bujtas  <zalan@apple.com>
2
49
3
        [LFC] Do not create a FormattingContext to compute intrinsic width unless there's some content.
50
        [LFC] Do not create a FormattingContext to compute intrinsic width unless there's some content.
- Source/WebCore/html/CustomPaintCanvas.cpp -1 / +1 lines
Lines 102-108 Image* CustomPaintCanvas::copiedImage() Source/WebCore/html/CustomPaintCanvas.cpp_sec1
102
        m_context->paintRenderingResultsToCanvas();
102
        m_context->paintRenderingResultsToCanvas();
103
    m_destinationGraphicsContext = nullptr;
103
    m_destinationGraphicsContext = nullptr;
104
104
105
    m_copiedImage = m_copiedBuffer->copyImage(m_copiedBuffer->fastCopyImageMode(), PreserveResolution::Yes);
105
    m_copiedImage = m_copiedBuffer->copyImage(DontCopyBackingStore, PreserveResolution::Yes);
106
    return m_copiedImage.get();
106
    return m_copiedImage.get();
107
}
107
}
108
108
- Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp -5 / +5 lines
Lines 3982-3988 ExceptionOr<void> WebGLRenderingContextB Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp_sec1
3982
        if (!buffer)
3982
        if (!buffer)
3983
            return { };
3983
            return { };
3984
3984
3985
        RefPtr<Image> image = buffer->copyImage(ImageBuffer::fastCopyImageMode());
3985
        RefPtr<Image> image = buffer->copyImage(DontCopyBackingStore);
3986
        if (image)
3986
        if (image)
3987
            texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get(), GraphicsContextGL::DOMSource::Image, m_unpackFlipY, m_unpackPremultiplyAlpha);
3987
            texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get(), GraphicsContextGL::DOMSource::Image, m_unpackFlipY, m_unpackPremultiplyAlpha);
3988
        return { };
3988
        return { };
Lines 4104-4110 ExceptionOr<void> WebGLRenderingContextB Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp_sec2
4104
        if (!validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLVideoElement, target, level, internalFormat, video->videoWidth(), video->videoHeight(), 0, format, type, xoffset, yoffset))
4104
        if (!validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLVideoElement, target, level, internalFormat, video->videoWidth(), video->videoHeight(), 0, format, type, xoffset, yoffset))
4105
            return { };
4105
            return { };
4106
4106
4107
        RefPtr<Image> image = videoFrameToImage(video.get(), ImageBuffer::fastCopyImageMode());
4107
        RefPtr<Image> image = videoFrameToImage(video.get(), DontCopyBackingStore);
4108
        if (!image)
4108
        if (!image)
4109
            return { };
4109
            return { };
4110
        texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get(), GraphicsContextGL::DOMSource::Video, m_unpackFlipY, m_unpackPremultiplyAlpha);
4110
        texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get(), GraphicsContextGL::DOMSource::Video, m_unpackFlipY, m_unpackPremultiplyAlpha);
Lines 4551-4557 ExceptionOr<void> WebGLRenderingContextB Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp_sec3
4551
        }
4551
        }
4552
4552
4553
        // Normal pure SW path.
4553
        // Normal pure SW path.
4554
        RefPtr<Image> image = buffer->copyImage(ImageBuffer::fastCopyImageMode());
4554
        RefPtr<Image> image = buffer->copyImage(DontCopyBackingStore);
4555
        if (image)
4555
        if (image)
4556
            texImage2DImpl(target, level, internalformat, format, type, image.get(), GraphicsContextGL::DOMSource::Image, m_unpackFlipY, m_unpackPremultiplyAlpha);
4556
            texImage2DImpl(target, level, internalformat, format, type, image.get(), GraphicsContextGL::DOMSource::Image, m_unpackFlipY, m_unpackPremultiplyAlpha);
4557
        return { };
4557
        return { };
Lines 4665-4671 ExceptionOr<void> WebGLRenderingContextB Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp_sec4
4665
        }
4665
        }
4666
4666
4667
        // Normal pure SW path.
4667
        // Normal pure SW path.
4668
        RefPtr<Image> image = videoFrameToImage(video.get(), ImageBuffer::fastCopyImageMode());
4668
        RefPtr<Image> image = videoFrameToImage(video.get(), DontCopyBackingStore);
4669
        if (!image)
4669
        if (!image)
4670
            return { };
4670
            return { };
4671
        texImage2DImpl(target, level, internalformat, format, type, image.get(), GraphicsContextGL::DOMSource::Video, m_unpackFlipY, m_unpackPremultiplyAlpha);
4671
        texImage2DImpl(target, level, internalformat, format, type, image.get(), GraphicsContextGL::DOMSource::Video, m_unpackFlipY, m_unpackPremultiplyAlpha);
Lines 4690-4696 RefPtr<Image> WebGLRenderingContextBase: Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp_sec5
4690
    FloatRect srcRect(FloatPoint(), image.size());
4690
    FloatRect srcRect(FloatPoint(), image.size());
4691
    FloatRect destRect(FloatPoint(), size);
4691
    FloatRect destRect(FloatPoint(), size);
4692
    buf->context().drawImage(image, destRect, srcRect);
4692
    buf->context().drawImage(image, destRect, srcRect);
4693
    return buf->copyImage(ImageBuffer::fastCopyImageMode());
4693
    return buf->copyImage(DontCopyBackingStore);
4694
}
4694
}
4695
4695
4696
#if ENABLE(VIDEO)
4696
#if ENABLE(VIDEO)
- Source/WebCore/platform/graphics/ImageBuffer.cpp -11 lines
Lines 114-125 Vector<uint8_t> ImageBuffer::toBGRAData( Source/WebCore/platform/graphics/ImageBuffer.cpp_sec1
114
#endif
114
#endif
115
115
116
#if !(USE(CG) || USE(DIRECT2D))
116
#if !(USE(CG) || USE(DIRECT2D))
117
118
FloatSize ImageBuffer::sizeForDestinationSize(FloatSize size) const
119
{
120
    return size;
121
}
122
123
void ImageBuffer::transformColorSpace(ColorSpace srcColorSpace, ColorSpace dstColorSpace)
117
void ImageBuffer::transformColorSpace(ColorSpace srcColorSpace, ColorSpace dstColorSpace)
124
{
118
{
125
    if (srcColorSpace == dstColorSpace)
119
    if (srcColorSpace == dstColorSpace)
Lines 244-254 IntSize ImageBuffer::compatibleBufferSiz Source/WebCore/platform/graphics/ImageBuffer.cpp_sec2
244
    return expandedIntSize(size * context.scaleFactor());
238
    return expandedIntSize(size * context.scaleFactor());
245
}
239
}
246
240
247
bool ImageBuffer::isCompatibleWithContext(const GraphicsContext& context) const
248
{
249
    return areEssentiallyEqual(context.scaleFactor(), this->context().scaleFactor());
250
}
251
252
#if !USE(IOSURFACE_CANVAS_BACKING_STORE)
241
#if !USE(IOSURFACE_CANVAS_BACKING_STORE)
253
size_t ImageBuffer::memoryCost() const
242
size_t ImageBuffer::memoryCost() const
254
{
243
{
- Source/WebCore/platform/graphics/ImageBuffer.h -7 lines
Lines 85-109 public: Source/WebCore/platform/graphics/ImageBuffer.h_sec1
85
    static std::unique_ptr<ImageBuffer> createCompatibleBuffer(const FloatSize&, float resolutionScale, ColorSpace, const GraphicsContext&);
85
    static std::unique_ptr<ImageBuffer> createCompatibleBuffer(const FloatSize&, float resolutionScale, ColorSpace, const GraphicsContext&);
86
86
87
    static IntSize compatibleBufferSize(const FloatSize&, const GraphicsContext&);
87
    static IntSize compatibleBufferSize(const FloatSize&, const GraphicsContext&);
88
    bool isCompatibleWithContext(const GraphicsContext&) const;
89
88
90
    WEBCORE_EXPORT ~ImageBuffer();
89
    WEBCORE_EXPORT ~ImageBuffer();
91
90
92
    // The actual resolution of the backing store
91
    // The actual resolution of the backing store
93
    const IntSize& internalSize() const { return m_size; }
92
    const IntSize& internalSize() const { return m_size; }
94
    const IntSize& logicalSize() const { return m_logicalSize; }
93
    const IntSize& logicalSize() const { return m_logicalSize; }
95
96
    FloatSize sizeForDestinationSize(FloatSize) const;
97
98
    float resolutionScale() const { return m_resolutionScale; }
94
    float resolutionScale() const { return m_resolutionScale; }
99
95
100
    WEBCORE_EXPORT GraphicsContext& context() const;
96
    WEBCORE_EXPORT GraphicsContext& context() const;
101
97
102
    WEBCORE_EXPORT RefPtr<Image> copyImage(BackingStoreCopy = CopyBackingStore, PreserveResolution = PreserveResolution::No) const;
98
    WEBCORE_EXPORT RefPtr<Image> copyImage(BackingStoreCopy = CopyBackingStore, PreserveResolution = PreserveResolution::No) const;
103
    WEBCORE_EXPORT static RefPtr<Image> sinkIntoImage(std::unique_ptr<ImageBuffer>, PreserveResolution = PreserveResolution::No);
99
    WEBCORE_EXPORT static RefPtr<Image> sinkIntoImage(std::unique_ptr<ImageBuffer>, PreserveResolution = PreserveResolution::No);
104
    // Give hints on the faster copyImage Mode, return DontCopyBackingStore if it supports the DontCopyBackingStore behavior
105
    // or return CopyBackingStore if it doesn't.  
106
    static BackingStoreCopy fastCopyImageMode();
107
100
108
    enum CoordinateSystem { LogicalCoordinateSystem, BackingStoreCoordinateSystem };
101
    enum CoordinateSystem { LogicalCoordinateSystem, BackingStoreCoordinateSystem };
109
102
- Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp -5 lines
Lines 351-361 RefPtr<Image> ImageBuffer::copyImage(Bac Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp_sec1
351
    return BitmapImage::create(RefPtr<cairo_surface_t>(m_data.m_surface));
351
    return BitmapImage::create(RefPtr<cairo_surface_t>(m_data.m_surface));
352
}
352
}
353
353
354
BackingStoreCopy ImageBuffer::fastCopyImageMode()
355
{
356
    return DontCopyBackingStore;
357
}
358
359
void ImageBuffer::drawConsuming(std::unique_ptr<ImageBuffer> imageBuffer, GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
354
void ImageBuffer::drawConsuming(std::unique_ptr<ImageBuffer> imageBuffer, GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
360
{
355
{
361
    imageBuffer->draw(destContext, destRect, srcRect, options);
356
    imageBuffer->draw(destContext, destRect, srcRect, options);
- Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp -1 / +1 lines
Lines 512-518 void GraphicsContext::clipToImageBuffer( Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp_sec1
512
    if (paintingDisabled())
512
    if (paintingDisabled())
513
        return;
513
        return;
514
514
515
    FloatSize bufferDestinationSize = buffer.sizeForDestinationSize(destRect.size());
515
    FloatSize bufferDestinationSize = destRect.size();
516
    RetainPtr<CGImageRef> image = buffer.copyNativeImage(DontCopyBackingStore);
516
    RetainPtr<CGImageRef> image = buffer.copyNativeImage(DontCopyBackingStore);
517
517
518
    CGContextRef context = platformContext();
518
    CGContextRef context = platformContext();
- Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp -24 / +6 lines
Lines 66-78 namespace WebCore { Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp_sec1
66
DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(ImageBuffer);
66
DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(ImageBuffer);
67
DEFINE_ALLOCATOR_WITH_HEAP_IDENTIFIER(ImageBuffer);
67
DEFINE_ALLOCATOR_WITH_HEAP_IDENTIFIER(ImageBuffer);
68
68
69
static FloatSize scaleSizeToUserSpace(const FloatSize& logicalSize, const IntSize& backingStoreSize, const IntSize& internalSize)
70
{
71
    float xMagnification = static_cast<float>(backingStoreSize.width()) / internalSize.width();
72
    float yMagnification = static_cast<float>(backingStoreSize.height()) / internalSize.height();
73
    return FloatSize(logicalSize.width() * xMagnification, logicalSize.height() * yMagnification);
74
}
75
76
std::unique_ptr<ImageBuffer> ImageBuffer::createCompatibleBuffer(const FloatSize& size, const GraphicsContext& context)
69
std::unique_ptr<ImageBuffer> ImageBuffer::createCompatibleBuffer(const FloatSize& size, const GraphicsContext& context)
77
{
70
{
78
    if (size.isEmpty())
71
    if (size.isEmpty())
Lines 155-161 ImageBuffer::ImageBuffer(const FloatSize Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp_sec2
155
    RetainPtr<CGContextRef> cgContext;
148
    RetainPtr<CGContextRef> cgContext;
156
    if (accelerateRendering) {
149
    if (accelerateRendering) {
157
#if USE(IOSURFACE_CANVAS_BACKING_STORE)
150
#if USE(IOSURFACE_CANVAS_BACKING_STORE)
158
        FloatSize userBounds = sizeForDestinationSize(FloatSize(width.unsafeGet(), height.unsafeGet()));
151
        FloatSize userBounds = FloatSize(width.unsafeGet(), height.unsafeGet());
159
        m_data.surface = IOSurface::create(m_data.backingStoreSize, IntSize(userBounds), colorSpace);
152
        m_data.surface = IOSurface::create(m_data.backingStoreSize, IntSize(userBounds), colorSpace);
160
        if (m_data.surface) {
153
        if (m_data.surface) {
161
            cgContext = m_data.surface->ensurePlatformContext(hostWindow);
154
            cgContext = m_data.surface->ensurePlatformContext(hostWindow);
Lines 210-220 ImageBuffer::ImageBuffer(const FloatSize Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp_sec3
210
203
211
ImageBuffer::~ImageBuffer() = default;
204
ImageBuffer::~ImageBuffer() = default;
212
205
213
FloatSize ImageBuffer::sizeForDestinationSize(FloatSize destinationSize) const
214
{
215
    return scaleSizeToUserSpace(destinationSize, m_data.backingStoreSize, internalSize());
216
}
217
218
#if USE(IOSURFACE_CANVAS_BACKING_STORE)
206
#if USE(IOSURFACE_CANVAS_BACKING_STORE)
219
size_t ImageBuffer::memoryCost() const
207
size_t ImageBuffer::memoryCost() const
220
{
208
{
Lines 259-265 static RetainPtr<CGImageRef> createCropp Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp_sec4
259
    return image;
247
    return image;
260
}
248
}
261
249
262
static RefPtr<Image> createBitmapImageAfterScalingIfNeeded(RetainPtr<CGImageRef>&& image, IntSize internalSize, IntSize logicalSize, IntSize backingStoreSize, float resolutionScale, PreserveResolution preserveResolution)
250
static RefPtr<Image> createBitmapImageAfterScalingIfNeeded(RetainPtr<CGImageRef>&& image, IntSize logicalSize, IntSize internalSize, float resolutionScale, PreserveResolution preserveResolution)
263
{
251
{
264
    if (resolutionScale == 1 || preserveResolution == PreserveResolution::Yes)
252
    if (resolutionScale == 1 || preserveResolution == PreserveResolution::Yes)
265
        image = createCroppedImageIfNecessary(image.get(), internalSize);
253
        image = createCroppedImageIfNecessary(image.get(), internalSize);
Lines 267-273 static RefPtr<Image> createBitmapImageAf Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp_sec5
267
        auto context = adoptCF(CGBitmapContextCreate(0, logicalSize.width(), logicalSize.height(), 8, 4 * logicalSize.width(), sRGBColorSpaceRef(), kCGImageAlphaPremultipliedLast));
255
        auto context = adoptCF(CGBitmapContextCreate(0, logicalSize.width(), logicalSize.height(), 8, 4 * logicalSize.width(), sRGBColorSpaceRef(), kCGImageAlphaPremultipliedLast));
268
        CGContextSetBlendMode(context.get(), kCGBlendModeCopy);
256
        CGContextSetBlendMode(context.get(), kCGBlendModeCopy);
269
        CGContextClipToRect(context.get(), FloatRect(FloatPoint::zero(), logicalSize));
257
        CGContextClipToRect(context.get(), FloatRect(FloatPoint::zero(), logicalSize));
270
        FloatSize imageSizeInUserSpace = scaleSizeToUserSpace(logicalSize, backingStoreSize, internalSize);
258
        FloatSize imageSizeInUserSpace = logicalSize;
271
        CGContextDrawImage(context.get(), FloatRect(FloatPoint::zero(), imageSizeInUserSpace), image.get());
259
        CGContextDrawImage(context.get(), FloatRect(FloatPoint::zero(), imageSizeInUserSpace), image.get());
272
        image = adoptCF(CGBitmapContextCreateImage(context.get()));
260
        image = adoptCF(CGBitmapContextCreateImage(context.get()));
273
    }
261
    }
Lines 286-307 RefPtr<Image> ImageBuffer::copyImage(Bac Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp_sec6
286
    else
274
    else
287
        image = copyNativeImage(DontCopyBackingStore);
275
        image = copyNativeImage(DontCopyBackingStore);
288
276
289
    return createBitmapImageAfterScalingIfNeeded(WTFMove(image), internalSize(), logicalSize(), m_data.backingStoreSize, m_resolutionScale, preserveResolution);
277
    return createBitmapImageAfterScalingIfNeeded(WTFMove(image), logicalSize(), internalSize(), m_resolutionScale, preserveResolution);
290
}
278
}
291
279
292
RefPtr<Image> ImageBuffer::sinkIntoImage(std::unique_ptr<ImageBuffer> imageBuffer, PreserveResolution preserveResolution)
280
RefPtr<Image> ImageBuffer::sinkIntoImage(std::unique_ptr<ImageBuffer> imageBuffer, PreserveResolution preserveResolution)
293
{
281
{
294
    IntSize internalSize = imageBuffer->internalSize();
282
    IntSize internalSize = imageBuffer->internalSize();
295
    IntSize logicalSize = imageBuffer->logicalSize();
283
    IntSize logicalSize = imageBuffer->logicalSize();
296
    IntSize backingStoreSize = imageBuffer->m_data.backingStoreSize;
297
    float resolutionScale = imageBuffer->m_resolutionScale;
284
    float resolutionScale = imageBuffer->m_resolutionScale;
298
285
299
    return createBitmapImageAfterScalingIfNeeded(sinkIntoNativeImage(WTFMove(imageBuffer)), internalSize, logicalSize, backingStoreSize, resolutionScale, preserveResolution);
286
    return createBitmapImageAfterScalingIfNeeded(sinkIntoNativeImage(WTFMove(imageBuffer)), logicalSize, internalSize, resolutionScale, preserveResolution);
300
}
301
302
BackingStoreCopy ImageBuffer::fastCopyImageMode()
303
{
304
    return DontCopyBackingStore;
305
}
287
}
306
288
307
RetainPtr<CGImageRef> ImageBuffer::sinkIntoNativeImage(std::unique_ptr<ImageBuffer> imageBuffer)
289
RetainPtr<CGImageRef> ImageBuffer::sinkIntoNativeImage(std::unique_ptr<ImageBuffer> imageBuffer)
Lines 493-499 RetainPtr<CFDataRef> ImageBuffer::toCFDa Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp_sec7
493
        auto context = adoptCF(CGBitmapContextCreate(0, logicalSize().width(), logicalSize().height(), 8, 4 * logicalSize().width(), sRGBColorSpaceRef(), kCGImageAlphaPremultipliedLast));
475
        auto context = adoptCF(CGBitmapContextCreate(0, logicalSize().width(), logicalSize().height(), 8, 4 * logicalSize().width(), sRGBColorSpaceRef(), kCGImageAlphaPremultipliedLast));
494
        CGContextSetBlendMode(context.get(), kCGBlendModeCopy);
476
        CGContextSetBlendMode(context.get(), kCGBlendModeCopy);
495
        CGContextClipToRect(context.get(), CGRectMake(0, 0, logicalSize().width(), logicalSize().height()));
477
        CGContextClipToRect(context.get(), CGRectMake(0, 0, logicalSize().width(), logicalSize().height()));
496
        FloatSize imageSizeInUserSpace = sizeForDestinationSize(logicalSize());
478
        FloatSize imageSizeInUserSpace = logicalSize();
497
        CGContextDrawImage(context.get(), CGRectMake(0, 0, imageSizeInUserSpace.width(), imageSizeInUserSpace.height()), image.get());
479
        CGContextDrawImage(context.get(), CGRectMake(0, 0, imageSizeInUserSpace.width(), imageSizeInUserSpace.height()), image.get());
498
        image = adoptCF(CGBitmapContextCreateImage(context.get()));
480
        image = adoptCF(CGBitmapContextCreateImage(context.get()));
499
    }
481
    }
- Source/WebCore/platform/graphics/win/ImageBufferDirect2D.cpp -17 lines
Lines 51-63 Source/WebCore/platform/graphics/win/ImageBufferDirect2D.cpp_sec1
51
51
52
namespace WebCore {
52
namespace WebCore {
53
53
54
static FloatSize scaleSizeToUserSpace(const FloatSize& logicalSize, const IntSize& backingStoreSize, const IntSize& internalSize)
55
{
56
    float xMagnification = static_cast<float>(backingStoreSize.width()) / internalSize.width();
57
    float yMagnification = static_cast<float>(backingStoreSize.height()) / internalSize.height();
58
    return FloatSize(logicalSize.width() * xMagnification, logicalSize.height() * yMagnification);
59
}
60
61
std::unique_ptr<ImageBuffer> ImageBuffer::createCompatibleBuffer(const FloatSize& size, const GraphicsContext& context)
54
std::unique_ptr<ImageBuffer> ImageBuffer::createCompatibleBuffer(const FloatSize& size, const GraphicsContext& context)
62
{
55
{
63
    if (size.isEmpty())
56
    if (size.isEmpty())
Lines 132-142 ImageBuffer::ImageBuffer(const FloatSize Source/WebCore/platform/graphics/win/ImageBufferDirect2D.cpp_sec2
132
125
133
ImageBuffer::~ImageBuffer() = default;
126
ImageBuffer::~ImageBuffer() = default;
134
127
135
FloatSize ImageBuffer::sizeForDestinationSize(FloatSize destinationSize) const
136
{
137
    return scaleSizeToUserSpace(destinationSize, m_data.backingStoreSize, internalSize());
138
}
139
140
GraphicsContext& ImageBuffer::context() const
128
GraphicsContext& ImageBuffer::context() const
141
{
129
{
142
    return *m_data.context;
130
    return *m_data.context;
Lines 206-216 RefPtr<Image> ImageBuffer::sinkIntoImage Source/WebCore/platform/graphics/win/ImageBufferDirect2D.cpp_sec3
206
    return createBitmapImageAfterScalingIfNeeded(bitmapTarget.get(), sinkIntoNativeImage(WTFMove(imageBuffer)), internalSize, logicalSize, backingStoreSize, resolutionScale, preserveResolution);
194
    return createBitmapImageAfterScalingIfNeeded(bitmapTarget.get(), sinkIntoNativeImage(WTFMove(imageBuffer)), internalSize, logicalSize, backingStoreSize, resolutionScale, preserveResolution);
207
}
195
}
208
196
209
BackingStoreCopy ImageBuffer::fastCopyImageMode()
210
{
211
    return DontCopyBackingStore;
212
}
213
214
COMPtr<ID2D1Bitmap> ImageBuffer::sinkIntoNativeImage(std::unique_ptr<ImageBuffer> imageBuffer)
197
COMPtr<ID2D1Bitmap> ImageBuffer::sinkIntoNativeImage(std::unique_ptr<ImageBuffer> imageBuffer)
215
{
198
{
216
    // FIXME: See if we can reuse the on-hardware image.
199
    // FIXME: See if we can reuse the on-hardware image.

Return to Bug 206541