diff options
author | Ben Murdoch <benm@google.com> | 2010-07-22 15:37:06 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-07-27 10:20:25 +0100 |
commit | 967717af5423377c967781471ee106e2bb4e11c8 (patch) | |
tree | 1e701dc0a12f7f07cce1df4a7681717de77a211b /WebCore/platform/graphics/cg | |
parent | dcc30a9fca45f634b1d3a12b276d3a0ccce99fc3 (diff) | |
download | external_webkit-967717af5423377c967781471ee106e2bb4e11c8.zip external_webkit-967717af5423377c967781471ee106e2bb4e11c8.tar.gz external_webkit-967717af5423377c967781471ee106e2bb4e11c8.tar.bz2 |
Merge WebKit at r63859 : Initial merge by git.
Change-Id: Ie8096c63ec7c991c9a9cba8bdd9c3b74a3b8ed62
Diffstat (limited to 'WebCore/platform/graphics/cg')
-rw-r--r-- | WebCore/platform/graphics/cg/ColorCG.cpp | 11 | ||||
-rw-r--r-- | WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp | 37 | ||||
-rw-r--r-- | WebCore/platform/graphics/cg/PathCG.cpp | 8 |
3 files changed, 53 insertions, 3 deletions
diff --git a/WebCore/platform/graphics/cg/ColorCG.cpp b/WebCore/platform/graphics/cg/ColorCG.cpp index e514fa3..9257642 100644 --- a/WebCore/platform/graphics/cg/ColorCG.cpp +++ b/WebCore/platform/graphics/cg/ColorCG.cpp @@ -73,10 +73,14 @@ Color::Color(CGColorRef color) CGColorRef createCGColor(const Color& c) { CGColorRef color = NULL; +#ifdef OBSOLETE_COLORSYNC_API CMProfileRef prof = NULL; CMGetSystemProfile(&prof); - RetainPtr<CGColorSpaceRef> rgbSpace(AdoptCF, CGColorSpaceCreateWithPlatformColorSpace(prof)); +#else + ColorSyncProfileRef prof = ColorSyncProfileCreateWithDisplayID(0); + RetainPtr<CGColorSpaceRef> rgbSpace(AdoptCF, CGColorSpaceCreateWithPlatformColorSpace(const_cast<void*>(reinterpret_cast<const void*>(prof)))); +#endif if (rgbSpace) { CGFloat components[4] = { static_cast<CGFloat>(c.red()) / 255, static_cast<CGFloat>(c.green()) / 255, @@ -84,7 +88,12 @@ CGColorRef createCGColor(const Color& c) color = CGColorCreate(rgbSpace.get(), components); } +#ifdef OBSOLETE_COLORSYNC_API CMCloseProfile(prof); +#else + if (prof) + CFRelease(prof); +#endif return color; } diff --git a/WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp b/WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp index 9f0f353..8af3d0e 100644 --- a/WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp +++ b/WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp @@ -36,6 +36,8 @@ #include <CoreGraphics/CGContext.h> #include <CoreGraphics/CGImage.h> +#include <wtf/RetainPtr.h> + namespace WebCore { bool GraphicsContext3D::getImageData(Image* image, @@ -104,6 +106,41 @@ bool GraphicsContext3D::getImageData(Image* image, format, type, neededAlphaOp, outputVector.data()); } +void GraphicsContext3D::paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight, int canvasWidth, int canvasHeight, CGContextRef context) +{ + if (!imagePixels || imageWidth <= 0 || imageHeight <= 0 || canvasWidth <= 0 || canvasHeight <= 0 || !context) + return; + int rowBytes = imageWidth * 4; + RetainPtr<CGDataProviderRef> dataProvider = CGDataProviderCreateWithData(0, imagePixels, rowBytes * imageHeight, 0); + RetainPtr<CGColorSpaceRef> colorSpace = CGColorSpaceCreateDeviceRGB(); + RetainPtr<CGImageRef> cgImage = CGImageCreate(imageWidth, + imageHeight, + 8, + 32, + rowBytes, + colorSpace.get(), + kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, + dataProvider.get(), + 0, + false, + kCGRenderingIntentDefault); + // CSS styling may cause the canvas's content to be resized on + // the page. Go back to the Canvas to figure out the correct + // width and height to draw. + CGRect rect = CGRectMake(0, 0, + canvasWidth, + canvasHeight); + // We want to completely overwrite the previous frame's + // rendering results. + CGContextSaveGState(context); + CGContextSetBlendMode(context, + kCGBlendModeCopy); + CGContextSetInterpolationQuality(context, + kCGInterpolationNone); + CGContextDrawImage(context, + rect, cgImage.get()); + CGContextRestoreGState(context); +} } // namespace WebCore diff --git a/WebCore/platform/graphics/cg/PathCG.cpp b/WebCore/platform/graphics/cg/PathCG.cpp index eb196d9..90d4b8a 100644 --- a/WebCore/platform/graphics/cg/PathCG.cpp +++ b/WebCore/platform/graphics/cg/PathCG.cpp @@ -213,8 +213,7 @@ void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius) void Path::closeSubpath() { - if (!CGPathIsEmpty(m_path)) // to silence a warning when trying to close an empty path - CGPathCloseSubpath(m_path); + CGPathCloseSubpath(m_path); } void Path::addArc(const FloatPoint& p, float r, float sa, float ea, bool clockwise) @@ -249,6 +248,11 @@ bool Path::hasCurrentPoint() const { return !isEmpty(); } + +FloatPoint Path::currentPoint() const +{ + return CGPathGetCurrentPoint(m_path); +} static void CGPathToCFStringApplierFunction(void* info, const CGPathElement *element) { |