Changeset 277255 in webkit
- Timestamp:
- May 9, 2021, 6:48:09 PM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r277254 r277255 1 2021-05-09 Sam Weinig <weinig@apple.com> 2 3 Add back protection of the pixel buffer in ImageBufferCGBackend::toCFData removed in r277237 4 https://bugs.webkit.org/show_bug.cgi?id=225574 5 6 Reviewed by Darin Adler. 7 8 In r277237, I accidentally removed a `RefPtr<Uint8ClampedArray> protectedPixelArray` 9 in ImageBufferCGBackend::toCFData that was needed to avoided crashing in some cases 10 when running fast/canvas/canvas-toDataURL-jpeg-crash.html. 11 12 Since it wasn't super clear what it was doing, this switches to using the more idiomatic 13 method of keeping the data alive in a CGDataProviderRef by passing the leaked image data 14 as the context and derefing in the callback lambda. 15 16 Just to be consistent, I went to other callers of CGDataProviderCreateWithData and 17 updated them to be idiomatically consistent. 18 19 * platform/graphics/cg/GraphicsContextGLCG.cpp: 20 (WebCore::GraphicsContextGLOpenGL::paintToCanvas): 21 (WebCore::releaseImageData): Deleted. 22 * platform/graphics/cg/ImageBufferCGBackend.cpp: 23 (WebCore::ImageBufferCGBackend::toCFData const): 24 * platform/graphics/cg/ImageBufferCGBitmapBackend.cpp: 25 (WebCore::ImageBufferCGBitmapBackend::create): 26 1 27 2021-05-09 Lauro Moura <lmoura@igalia.com> 2 28 -
trunk/Source/WebCore/platform/graphics/cg/GraphicsContextGLCG.cpp
r277237 r277255 507 507 } 508 508 509 static void releaseImageData(void* imageData, const void*, size_t)510 {511 reinterpret_cast<ImageData*>(imageData)->deref();512 }513 514 509 void GraphicsContextGLOpenGL::paintToCanvas(const GraphicsContextGLAttributes& sourceContextAttributes, Ref<ImageData>&& imageData, const IntSize& canvasSize, GraphicsContext& context) 515 510 { … … 529 524 auto imageSize = imageData->size(); 530 525 int rowBytes = imageSize.width() * 4; 531 526 size_t dataSize = rowBytes * imageSize.height(); 532 527 uint8_t* imagePixels = imageData->data().data(); 533 verifyImageBufferIsBigEnough(imagePixels, dataSize); 534 RetainPtr<CGDataProviderRef> dataProvider = adoptCF(CGDataProviderCreateWithData(&imageData.leakRef(), imagePixels, dataSize, releaseImageData)); 535 536 auto image = NativeImage::create(adoptCF(CGImageCreate(imageSize.width(), imageSize.height(), 8, 32, rowBytes, sRGBColorSpaceRef(), bitmapInfo, 537 dataProvider.get(), 0, false, kCGRenderingIntentDefault))); 528 verifyImageBufferIsBigEnough(imagePixels, dataSize); 529 auto dataProvider = adoptCF(CGDataProviderCreateWithData(&imageData.leakRef(), imagePixels, dataSize, [] (void* context, const void*, size_t) { 530 reinterpret_cast<ImageData*>(context)->deref(); 531 })); 532 533 auto image = NativeImage::create(adoptCF(CGImageCreate(imageSize.width(), imageSize.height(), 8, 32, rowBytes, sRGBColorSpaceRef(), bitmapInfo, dataProvider.get(), 0, false, kCGRenderingIntentDefault))); 538 534 539 535 // CSS styling may cause the canvas's content to be resized on -
trunk/Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.cpp
r277237 r277255 192 192 return nullptr; 193 193 194 auto protectedPixelArray = makeRef(imageData->data()); 195 size_t dataSize = protectedPixelArray->byteLength(); 196 IntSize pixelArrayDimensions = imageData->size(); 197 198 verifyImageBufferIsBigEnough(protectedPixelArray->data(), dataSize); 199 auto dataProvider = adoptCF(CGDataProviderCreateWithData(nullptr, protectedPixelArray->data(), dataSize, nullptr)); 194 auto& pixelArray = imageData->data(); 195 auto dataSize = pixelArray.byteLength(); 196 auto pixelArrayDimensions = imageData->size(); 197 198 verifyImageBufferIsBigEnough(pixelArray.data(), dataSize); 199 200 auto dataProvider = adoptCF(CGDataProviderCreateWithData(imageData.leakRef(), pixelArray.data(), dataSize, [] (void* context, const void*, size_t) { 201 reinterpret_cast<ImageData*>(context)->deref(); 202 })); 203 200 204 if (!dataProvider) 201 205 return nullptr; -
trunk/Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.cpp
r275905 r277255 88 88 auto context = makeUnique<GraphicsContext>(cgContext.get()); 89 89 90 const auto releaseImageData =[] (void*, const void* data, size_t) {90 auto dataProvider = adoptCF(CGDataProviderCreateWithData(nullptr, data, numBytes, [] (void*, const void* data, size_t) { 91 91 fastFree(const_cast<void*>(data)); 92 }; 93 94 auto dataProvider = adoptCF(CGDataProviderCreateWithData(0, data, numBytes, releaseImageData)); 92 })); 95 93 96 94 return std::unique_ptr<ImageBufferCGBitmapBackend>(new ImageBufferCGBitmapBackend(parameters, data, WTFMove(dataProvider), WTFMove(context)));
Note:
See TracChangeset
for help on using the changeset viewer.