summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/cg
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-02-15 12:23:52 +0000
committerSteve Block <steveblock@google.com>2010-02-16 11:48:32 +0000
commit8a0914b749bbe7da7768e07a7db5c6d4bb09472b (patch)
tree73f9065f370435d6fde32ae129d458a8c77c8dff /WebCore/platform/graphics/cg
parentbf14be70295513b8076f3fa47a268a7e42b2c478 (diff)
downloadexternal_webkit-8a0914b749bbe7da7768e07a7db5c6d4bb09472b.zip
external_webkit-8a0914b749bbe7da7768e07a7db5c6d4bb09472b.tar.gz
external_webkit-8a0914b749bbe7da7768e07a7db5c6d4bb09472b.tar.bz2
Merge webkit.org at r54731 : Initial merge by git
Change-Id: Ia79977b6cf3b0b00c06ef39419989b28e57e4f4a
Diffstat (limited to 'WebCore/platform/graphics/cg')
-rw-r--r--WebCore/platform/graphics/cg/GraphicsContextCG.cpp35
-rw-r--r--WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h19
-rw-r--r--WebCore/platform/graphics/cg/ImageBufferCG.cpp29
-rw-r--r--WebCore/platform/graphics/cg/ImageCG.cpp4
-rw-r--r--WebCore/platform/graphics/cg/PathCG.cpp10
-rw-r--r--WebCore/platform/graphics/cg/PatternCG.cpp6
6 files changed, 32 insertions, 71 deletions
diff --git a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
index a339982..2e3f829 100644
--- a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
+++ b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
@@ -36,7 +36,6 @@
#include "KURL.h"
#include "Path.h"
#include "Pattern.h"
-#include "TransformationMatrix.h"
#include <CoreGraphics/CGBitmapContext.h>
#include <CoreGraphics/CGPDFContext.h>
@@ -126,6 +125,23 @@ static void setCGStrokeColorSpace(CGContextRef context, ColorSpace colorSpace)
}
}
+CGColorSpaceRef deviceRGBColorSpaceRef()
+{
+ static CGColorSpaceRef deviceSpace = CGColorSpaceCreateDeviceRGB();
+ return deviceSpace;
+}
+
+CGColorSpaceRef sRGBColorSpaceRef()
+{
+ // FIXME: Windows should be able to use kCGColorSpaceSRGB, this is tracked by http://webkit.org/b/31363.
+#if PLATFORM(WIN) || defined(BUILDING_ON_TIGER)
+ return deviceRGBColorSpaceRef();
+#else
+ static CGColorSpaceRef sRGBSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
+ return sRGBSpace;
+#endif
+}
+
GraphicsContext::GraphicsContext(CGContextRef cgContext)
: m_common(createGraphicsContextPrivate())
, m_data(new GraphicsContextPlatformPrivate(cgContext))
@@ -968,27 +984,12 @@ void GraphicsContext::concatCTM(const AffineTransform& transform)
m_data->m_userToDeviceTransformKnownToBeIdentity = false;
}
-void GraphicsContext::concatCTM(const TransformationMatrix& transform)
-{
- if (paintingDisabled())
- return;
- CGContextConcatCTM(platformContext(), transform);
- m_data->concatCTM(transform);
- m_data->m_userToDeviceTransformKnownToBeIdentity = false;
-}
-
-AffineTransform GraphicsContext::getAffineCTM() const
+AffineTransform GraphicsContext::getCTM() const
{
CGAffineTransform t = CGContextGetCTM(platformContext());
return AffineTransform(t.a, t.b, t.c, t.d, t.tx, t.ty);
}
-TransformationMatrix GraphicsContext::getCTM() const
-{
- CGAffineTransform t = CGContextGetCTM(platformContext());
- return TransformationMatrix(t.a, t.b, t.c, t.d, t.tx, t.ty);
-}
-
FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect)
{
// It is not enough just to round to pixels in device space. The rotation part of the
diff --git a/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h b/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h
index 7b80d5b..b1efba1 100644
--- a/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h
+++ b/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h
@@ -28,23 +28,10 @@
namespace WebCore {
// FIXME: This would be in GraphicsContextCG.h if that existed.
-inline CGColorSpaceRef deviceRGBColorSpaceRef()
-{
- static CGColorSpaceRef deviceSpace = CGColorSpaceCreateDeviceRGB();
- return deviceSpace;
-}
+CGColorSpaceRef deviceRGBColorSpaceRef();
// FIXME: This would be in GraphicsContextCG.h if that existed.
-inline CGColorSpaceRef sRGBColorSpaceRef()
-{
- // FIXME: Windows should be able to use kCGColorSpaceSRGB, this is tracked by http://webkit.org/b/31363.
-#if PLATFORM(WIN) || defined(BUILDING_ON_TIGER)
- return deviceRGBColorSpaceRef();
-#else
- static CGColorSpaceRef sRGBSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
- return sRGBSpace;
-#endif
-}
+CGColorSpaceRef sRGBColorSpaceRef();
class GraphicsContextPlatformPrivate {
public:
@@ -74,7 +61,6 @@ public:
void rotate(float) {}
void translate(float, float) {}
void concatCTM(const AffineTransform&) {}
- void concatCTM(const TransformationMatrix&) {}
void beginTransparencyLayer() {}
void endTransparencyLayer() {}
#endif
@@ -90,7 +76,6 @@ public:
void rotate(float);
void translate(float, float);
void concatCTM(const AffineTransform&);
- void concatCTM(const TransformationMatrix&);
void beginTransparencyLayer() { m_transparencyCount++; }
void endTransparencyLayer() { m_transparencyCount--; }
diff --git a/WebCore/platform/graphics/cg/ImageBufferCG.cpp b/WebCore/platform/graphics/cg/ImageBufferCG.cpp
index b1896f8..0dc7a53 100644
--- a/WebCore/platform/graphics/cg/ImageBufferCG.cpp
+++ b/WebCore/platform/graphics/cg/ImageBufferCG.cpp
@@ -280,34 +280,19 @@ String ImageBuffer::toDataURL(const String& mimeType) const
if (!image)
return "data:,";
- size_t width = CGImageGetWidth(image.get());
- size_t height = CGImageGetHeight(image.get());
-
- OwnArrayPtr<uint32_t> imageData(new uint32_t[width * height]);
- if (!imageData)
- return "data:,";
-
- RetainPtr<CGImageRef> transformedImage(AdoptCF, CGBitmapContextCreateImage(context()->platformContext()));
- if (!transformedImage)
+ RetainPtr<CFMutableDataRef> data(AdoptCF, CFDataCreateMutable(kCFAllocatorDefault, 0));
+ if (!data)
return "data:,";
- RetainPtr<CFMutableDataRef> transformedImageData(AdoptCF, CFDataCreateMutable(kCFAllocatorDefault, 0));
- if (!transformedImageData)
+ RetainPtr<CGImageDestinationRef> destination(AdoptCF, CGImageDestinationCreateWithData(data.get(), utiFromMIMEType(mimeType).get(), 1, 0));
+ if (!destination)
return "data:,";
- RetainPtr<CGImageDestinationRef> imageDestination(AdoptCF, CGImageDestinationCreateWithData(transformedImageData.get(),
- utiFromMIMEType(mimeType).get(), 1, 0));
- if (!imageDestination)
- return "data:,";
-
- CGImageDestinationAddImage(imageDestination.get(), transformedImage.get(), 0);
- CGImageDestinationFinalize(imageDestination.get());
-
- Vector<char> in;
- in.append(CFDataGetBytePtr(transformedImageData.get()), CFDataGetLength(transformedImageData.get()));
+ CGImageDestinationAddImage(destination.get(), image.get(), 0);
+ CGImageDestinationFinalize(destination.get());
Vector<char> out;
- base64Encode(in, out);
+ base64Encode(reinterpret_cast<const char*>(CFDataGetBytePtr(data.get())), CFDataGetLength(data.get()), out);
out.append('\0');
return String::format("data:%s;base64,%s", mimeType.utf8().data(), out.data());
diff --git a/WebCore/platform/graphics/cg/ImageCG.cpp b/WebCore/platform/graphics/cg/ImageCG.cpp
index 2e372e2..70a80a0 100644
--- a/WebCore/platform/graphics/cg/ImageCG.cpp
+++ b/WebCore/platform/graphics/cg/ImageCG.cpp
@@ -28,7 +28,7 @@
#if PLATFORM(CG)
-#include "TransformationMatrix.h"
+#include "AffineTransform.h"
#include "FloatConversion.h"
#include "FloatRect.h"
#include "GraphicsContext.h"
@@ -244,7 +244,7 @@ static void drawPatternCallback(void* info, CGContextRef context)
CGContextDrawImage(context, GraphicsContext(context).roundToDevicePixels(FloatRect(0, 0, CGImageGetWidth(image), CGImageGetHeight(image))), image);
}
-void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const TransformationMatrix& patternTransform,
+void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const AffineTransform& patternTransform,
const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect)
{
if (!nativeImageForCurrentFrame())
diff --git a/WebCore/platform/graphics/cg/PathCG.cpp b/WebCore/platform/graphics/cg/PathCG.cpp
index 01680df..81454b3 100644
--- a/WebCore/platform/graphics/cg/PathCG.cpp
+++ b/WebCore/platform/graphics/cg/PathCG.cpp
@@ -30,7 +30,6 @@
#if PLATFORM(CG)
#include "AffineTransform.h"
-#include "TransformationMatrix.h"
#include <ApplicationServices/ApplicationServices.h>
#include "FloatRect.h"
#include "GraphicsContext.h"
@@ -356,15 +355,6 @@ void Path::transform(const AffineTransform& transform)
m_path = path;
}
-void Path::transform(const TransformationMatrix& transform)
-{
- CGMutablePathRef path = CGPathCreateMutable();
- CGAffineTransform transformCG = transform;
- CGPathAddPath(path, &transformCG, m_path);
- CGPathRelease(m_path);
- m_path = path;
-}
-
}
#endif // PLATFORM(CG)
diff --git a/WebCore/platform/graphics/cg/PatternCG.cpp b/WebCore/platform/graphics/cg/PatternCG.cpp
index 26f402b..94f37b2 100644
--- a/WebCore/platform/graphics/cg/PatternCG.cpp
+++ b/WebCore/platform/graphics/cg/PatternCG.cpp
@@ -27,7 +27,7 @@
#include "config.h"
#include "Pattern.h"
-#include "TransformationMatrix.h"
+#include "AffineTransform.h"
#include "GraphicsContext.h"
#include <ApplicationServices/ApplicationServices.h>
@@ -50,11 +50,11 @@ static void patternReleaseCallback(void* info)
static_cast<Image*>(info)->deref();
}
-CGPatternRef Pattern::createPlatformPattern(const TransformationMatrix& userSpaceTransformation) const
+CGPatternRef Pattern::createPlatformPattern(const AffineTransform& userSpaceTransformation) const
{
IntRect tileRect = tileImage()->rect();
- TransformationMatrix patternTransform = m_patternSpaceTransformation;
+ AffineTransform patternTransform = m_patternSpaceTransformation;
patternTransform.multiply(userSpaceTransformation);
patternTransform.scaleNonUniform(1, -1);
patternTransform.translate(0, -tileRect.height());