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-58088-20110418110844.patch (text/plain), 6.71 KB, created by
Matthew Delaney
on 2011-04-18 11:08:45 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Matthew Delaney
Created:
2011-04-18 11:08:45 PDT
Size:
6.71 KB
patch
obsolete
>Index: Source/WebCore/ChangeLog >=================================================================== >--- Source/WebCore/ChangeLog (revision 83877) >+++ Source/WebCore/ChangeLog (working copy) >@@ -1,3 +1,17 @@ >+2011-04-14 Matthew Delaney <mdelaney@apple.com> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ [CG] Use vImage (un)premultiplyImageData functions for get/putImageData with IOSurfaces >+ https://bugs.webkit.org/show_bug.cgi?id=58088 >+ >+ * platform/graphics/cg/ImageBufferDataCG.cpp: >+ (WebCore::convertScanline): un/premultiplies and converts a scanline of image data from/to BGRA to/from RGBA >+ (WebCore::unpremultitplyScanline): >+ (WebCore::premultitplyScanline): >+ (WebCore::ImageBufferData::getData): >+ (WebCore::ImageBufferData::putData): >+ > 2011-04-14 Kenneth Russell <kbr@google.com> > > Reviewed by Dimitri Glazkov. >Index: Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp >=================================================================== >--- Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp (revision 83786) >+++ Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp (working copy) >@@ -34,6 +34,17 @@ > > #if USE(IOSURFACE_CANVAS_BACKING_STORE) > #include <IOSurface/IOSurface.h> >+#include <dispatch/dispatch.h> >+#endif >+ >+#if USE(ACCELERATE) >+struct vImageBufferPair { >+ vImagePixelCount scanlineWidth; >+ unsigned char* srcData; >+ size_t srcRowBytes; >+ unsigned char* destData; >+ size_t destRowBytes; >+}; > #endif > > namespace WebCore { >@@ -54,7 +65,48 @@ static bool haveVImageRoundingErrorFix() > static bool result = (Gestalt(gestaltSystemVersion, &version) == noErr && version > 0x1066); > return result; > } >-#endif >+ >+#if USE(IOSURFACE_CANVAS_BACKING_STORE) >+static void convertScanline(void* data, size_t tileNumber, bool premultiply) >+{ >+ vImageBufferPair* bufferPair = static_cast<vImageBufferPair*>(data); >+ >+ vImage_Buffer src; >+ src.data = bufferPair->srcData + tileNumber * bufferPair->srcRowBytes; >+ src.height = 1; >+ src.width = bufferPair->scanlineWidth; >+ src.rowBytes = bufferPair->srcRowBytes; >+ >+ vImage_Buffer dest; >+ dest.data = bufferPair->destData + tileNumber * bufferPair->destRowBytes; >+ dest.height = 1; >+ dest.width = bufferPair->scanlineWidth; >+ dest.rowBytes = bufferPair->destRowBytes; >+ >+ if (premultiply) { >+ if (kvImageNoError != vImagePremultiplyData_RGBA8888(&src, &dest, kvImageDoNotTile)) >+ return; >+ } else { >+ if (kvImageNoError != vImageUnpremultiplyData_RGBA8888(&src, &dest, kvImageDoNotTile)) >+ return; >+ } >+ >+ // Swap channels 1 and 3, to convert BGRA<->RGBA. IOSurfaces is BGRA, ImageData expects RGBA. >+ const uint8_t map[4] = { 2, 1, 0, 3 }; >+ vImagePermuteChannels_ARGB8888(&dest, &dest, map, kvImageDoNotTile); >+} >+ >+static void unpremultitplyScanline(void* data, size_t tileNumber) >+{ >+ convertScanline(data, tileNumber, false); >+} >+ >+static void premultitplyScanline(void* data, size_t tileNumber) >+{ >+ convertScanline(data, tileNumber, true); >+} >+#endif // USE(IOSURFACE_CANVAS_BACKING_STORE) >+#endif // USE(ACCELERATE) > > PassRefPtr<ByteArray> ImageBufferData::getData(const IntRect& rect, const IntSize& size, bool accelerateRendering, bool unmultiplied) const > { >@@ -138,7 +190,34 @@ PassRefPtr<ByteArray> ImageBufferData::g > IOSurfaceLock(surface, kIOSurfaceLockReadOnly, 0); > srcBytesPerRow = IOSurfaceGetBytesPerRow(surface); > srcRows = (unsigned char*)(IOSurfaceGetBaseAddress(surface)) + originy * srcBytesPerRow + originx * 4; >- >+ >+#if USE(ACCELERATE) >+ if (unmultiplied) { >+ vImageBufferPair buffPair; >+ buffPair.scanlineWidth = width; >+ buffPair.srcData = srcRows; >+ buffPair.srcRowBytes = srcBytesPerRow; >+ buffPair.destData = destRows; >+ buffPair.destRowBytes = destBytesPerRow; >+ >+ dispatch_apply_f(height, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), &buffPair, unpremultitplyScanline); >+ } else { >+ vImage_Buffer src; >+ src.height = height; >+ src.width = width; >+ src.rowBytes = srcBytesPerRow; >+ src.data = srcRows; >+ >+ vImage_Buffer dest; >+ dest.height = height; >+ dest.width = width; >+ dest.rowBytes = destBytesPerRow; >+ dest.data = destRows; >+ >+ const uint8_t map[4] = { 2, 1, 0, 3 }; >+ vImagePermuteChannels_ARGB8888(&src, &dest, map, kvImageNoFlags); >+ } >+#else > for (int y = 0; y < height; ++y) { > for (int x = 0; x < width; x++) { > int basex = x * 4; >@@ -158,10 +237,11 @@ PassRefPtr<ByteArray> ImageBufferData::g > srcRows += srcBytesPerRow; > destRows += destBytesPerRow; > } >+#endif // USE(ACCELERATE) > IOSurfaceUnlock(surface, kIOSurfaceLockReadOnly, 0); > #else > ASSERT_NOT_REACHED(); >-#endif >+#endif // USE(IOSURFACE_CANVAS_BACKING_STORE) > } > > return result.release(); >@@ -246,7 +326,34 @@ void ImageBufferData::putData(ByteArray* > IOSurfaceLock(surface, 0, 0); > destBytesPerRow = IOSurfaceGetBytesPerRow(surface); > destRows = (unsigned char*)(IOSurfaceGetBaseAddress(surface)) + desty * destBytesPerRow + destx * 4; >- >+ >+#if USE(ACCELERATE) >+ if (unmultiplied) { >+ vImageBufferPair buffPair; >+ buffPair.scanlineWidth = width; >+ buffPair.srcData = srcRows; >+ buffPair.srcRowBytes = srcBytesPerRow; >+ buffPair.destData = destRows; >+ buffPair.destRowBytes = destBytesPerRow; >+ >+ dispatch_apply_f(height, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), &buffPair, premultitplyScanline); >+ } else { >+ vImage_Buffer src; >+ src.height = height; >+ src.width = width; >+ src.rowBytes = srcBytesPerRow; >+ src.data = srcRows; >+ >+ vImage_Buffer dest; >+ dest.height = height; >+ dest.width = width; >+ dest.rowBytes = destBytesPerRow; >+ dest.data = destRows; >+ >+ const uint8_t map[4] = { 2, 1, 0, 3 }; >+ vImagePermuteChannels_ARGB8888(&src, &dest, map, kvImageNoFlags); >+ } >+#else > for (int y = 0; y < height; ++y) { > for (int x = 0; x < width; x++) { > int basex = x * 4; >@@ -266,10 +373,12 @@ void ImageBufferData::putData(ByteArray* > destRows += destBytesPerRow; > srcRows += srcBytesPerRow; > } >+#endif // USE(ACCELERATE) >+ > IOSurfaceUnlock(surface, 0, 0); > #else > ASSERT_NOT_REACHED(); >-#endif >+#endif // USE(IOSURFACE_CANVAS_BACKING_STORE) > } > } >
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 58088
:
89615
|
89636
|
89703
|
90054
|
90067