diff options
author | Kristian Monsen <kristianm@google.com> | 2010-06-28 16:42:48 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2010-07-02 10:29:56 +0100 |
commit | 06ea8e899e48f1f2f396b70e63fae369f2f23232 (patch) | |
tree | 20c1428cd05c76f32394ab354ea35ed99acd86d8 /WebCore/platform/graphics/cg | |
parent | 72aad67af14193199e29cdd5c4ddc095a8b9a8a8 (diff) | |
download | external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.zip external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.tar.gz external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.tar.bz2 |
Merge WebKit at r61871: Initial merge by git.
Change-Id: I6cff43abca9cc4782e088a469ad4f03f166a65d5
Diffstat (limited to 'WebCore/platform/graphics/cg')
-rw-r--r-- | WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp | 55 | ||||
-rw-r--r-- | WebCore/platform/graphics/cg/GraphicsContextCG.cpp | 2 |
2 files changed, 33 insertions, 24 deletions
diff --git a/WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp b/WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp index c6a8f83..5c03a86 100644 --- a/WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp +++ b/WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp @@ -39,11 +39,10 @@ namespace WebCore { bool GraphicsContext3D::getImageData(Image* image, - Vector<uint8_t>& outputVector, + unsigned int format, + unsigned int type, bool premultiplyAlpha, - bool* hasAlphaChannel, - AlphaOp* neededAlphaOp, - unsigned int* format) + Vector<uint8_t>& outputVector) { if (!image) return false; @@ -52,16 +51,10 @@ bool GraphicsContext3D::getImageData(Image* image, return false; int width = CGImageGetWidth(cgImage); int height = CGImageGetHeight(cgImage); - int rowBytes = width * 4; - CGImageAlphaInfo info = CGImageGetAlphaInfo(cgImage); - *hasAlphaChannel = (info != kCGImageAlphaNone - && info != kCGImageAlphaNoneSkipLast - && info != kCGImageAlphaNoneSkipFirst); - if (!premultiplyAlpha && *hasAlphaChannel) - // FIXME: must fetch the image data before the premultiplication step - *neededAlphaOp = kAlphaDoUnmultiply; - *format = RGBA; - outputVector.resize(height * rowBytes); + // FIXME: we should get rid of this temporary copy where possible. + int tempRowBytes = width * 4; + Vector<uint8_t> tempVector; + tempVector.resize(height * tempRowBytes); // Try to reuse the color space from the image to preserve its colors. // Some images use a color space (such as indexed) unsupported by the bitmap context. CGColorSpaceRef colorSpace = CGImageGetColorSpace(cgImage); @@ -79,20 +72,36 @@ bool GraphicsContext3D::getImageData(Image* image, releaseColorSpace = true; break; } - CGContextRef tmpContext = CGBitmapContextCreate(outputVector.data(), - width, height, 8, rowBytes, - colorSpace, - kCGImageAlphaPremultipliedLast); + CGContextRef tempContext = CGBitmapContextCreate(tempVector.data(), + width, height, 8, tempRowBytes, + colorSpace, + // FIXME: change this! + kCGImageAlphaPremultipliedLast); if (releaseColorSpace) CGColorSpaceRelease(colorSpace); - if (!tmpContext) + if (!tempContext) return false; - CGContextSetBlendMode(tmpContext, kCGBlendModeCopy); - CGContextDrawImage(tmpContext, + CGContextSetBlendMode(tempContext, kCGBlendModeCopy); + CGContextDrawImage(tempContext, CGRectMake(0, 0, static_cast<CGFloat>(width), static_cast<CGFloat>(height)), cgImage); - CGContextRelease(tmpContext); - return true; + CGContextRelease(tempContext); + // Pack the pixel data into the output vector. + unsigned long componentsPerPixel, bytesPerComponent; + if (!computeFormatAndTypeParameters(format, type, &componentsPerPixel, &bytesPerComponent)) + return false; + int rowBytes = width * componentsPerPixel * bytesPerComponent; + outputVector.resize(height * rowBytes); + CGImageAlphaInfo info = CGImageGetAlphaInfo(cgImage); + bool hasAlphaChannel = (info != kCGImageAlphaNone + && info != kCGImageAlphaNoneSkipLast + && info != kCGImageAlphaNoneSkipFirst); + AlphaOp neededAlphaOp = kAlphaDoNothing; + if (!premultiplyAlpha && hasAlphaChannel) + // FIXME: must fetch the image data before the premultiplication step. + neededAlphaOp = kAlphaDoUnmultiply; + return packPixels(tempVector.data(), kSourceFormatRGBA8, width, height, + format, type, neededAlphaOp, outputVector.data()); } diff --git a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp index c69f222..5a903dc 100644 --- a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp +++ b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp @@ -764,7 +764,7 @@ void GraphicsContext::endTransparencyLayer() m_data->m_userToDeviceTransformKnownToBeIdentity = false; } -void GraphicsContext::setPlatformShadow(const IntSize& offset, float blur, const Color& color, ColorSpace colorSpace) +void GraphicsContext::setPlatformShadow(const FloatSize& offset, float blur, const Color& color, ColorSpace colorSpace) { if (paintingDisabled()) return; |