diff options
author | Feng Qian <> | 2009-04-10 18:11:29 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-04-10 18:11:29 -0700 |
commit | 8f72e70a9fd78eec56623b3a62e68f16b7b27e28 (patch) | |
tree | 181bf9a400c30a1bf34ea6d72560e8d00111d549 /WebCore/platform/graphics/cg | |
parent | 7ed56f225e0ade046e1c2178977f72b2d896f196 (diff) | |
download | external_webkit-8f72e70a9fd78eec56623b3a62e68f16b7b27e28.zip external_webkit-8f72e70a9fd78eec56623b3a62e68f16b7b27e28.tar.gz external_webkit-8f72e70a9fd78eec56623b3a62e68f16b7b27e28.tar.bz2 |
AI 145796: Land the WebKit merge @r42026.
Automated import of CL 145796
Diffstat (limited to 'WebCore/platform/graphics/cg')
-rw-r--r-- | WebCore/platform/graphics/cg/ColorCG.cpp | 6 | ||||
-rw-r--r-- | WebCore/platform/graphics/cg/GraphicsContextCG.cpp | 8 | ||||
-rw-r--r-- | WebCore/platform/graphics/cg/ImageCG.cpp | 2 | ||||
-rw-r--r-- | WebCore/platform/graphics/cg/ImageSourceCG.cpp | 2 | ||||
-rw-r--r-- | WebCore/platform/graphics/cg/PatternCG.cpp | 7 | ||||
-rw-r--r-- | WebCore/platform/graphics/cg/TransformationMatrixCG.cpp | 184 |
6 files changed, 24 insertions, 185 deletions
diff --git a/WebCore/platform/graphics/cg/ColorCG.cpp b/WebCore/platform/graphics/cg/ColorCG.cpp index 48ce9f2..0465c0b 100644 --- a/WebCore/platform/graphics/cg/ColorCG.cpp +++ b/WebCore/platform/graphics/cg/ColorCG.cpp @@ -67,9 +67,9 @@ Color::Color(CGColorRef color) m_color = makeRGBA(r * 255, g * 255, b * 255, a * 255); } -#if !PLATFORM(MAC) +#if PLATFORM(WIN_OS) -CGColorRef cgColor(const Color& c) +CGColorRef createCGColor(const Color& c) { CGColorRef color = NULL; CMProfileRef prof = NULL; @@ -89,7 +89,7 @@ CGColorRef cgColor(const Color& c) return color; } -#endif // !PLATFORM(MAC) +#endif // PLATFORM(WIN_OS) } diff --git a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp index 1cc55a4..4b8a555 100644 --- a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp +++ b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp @@ -504,6 +504,7 @@ void GraphicsContext::fillPath() CGContextEOClip(context); else CGContextClip(context); + CGContextConcatCTM(context, m_common->state.fillGradient->gradientSpaceTransform()); CGContextDrawShading(context, m_common->state.fillGradient->platformGradient()); CGContextRestoreGState(context); break; @@ -529,6 +530,7 @@ void GraphicsContext::strokePath() CGContextSaveGState(context); CGContextReplacePathWithStrokedPath(context); CGContextClip(context); + CGContextConcatCTM(context, m_common->state.strokeGradient->gradientSpaceTransform()); CGContextDrawShading(context, m_common->state.strokeGradient->platformGradient()); CGContextRestoreGState(context); break; @@ -552,6 +554,7 @@ void GraphicsContext::fillRect(const FloatRect& rect) case GradientColorSpace: CGContextSaveGState(context); CGContextClipToRect(context, rect); + CGContextConcatCTM(context, m_common->state.fillGradient->gradientSpaceTransform()); CGContextDrawShading(context, m_common->state.fillGradient->platformGradient()); CGContextRestoreGState(context); break; @@ -734,7 +737,7 @@ void GraphicsContext::setPlatformShadow(const IntSize& size, int blur, const Col if (!color.isValid()) CGContextSetShadow(context, CGSizeMake(width, height), blurRadius); else { - CGColorRef colorCG = cgColor(color); + CGColorRef colorCG = createCGColor(color); CGContextSetShadowWithColor(context, CGSizeMake(width, height), blurRadius, @@ -907,7 +910,8 @@ void GraphicsContext::concatCTM(const TransformationMatrix& transform) TransformationMatrix GraphicsContext::getCTM() const { - return CGContextGetCTM(platformContext()); + CGAffineTransform t = CGContextGetCTM(platformContext()); + return TransformationMatrix(t.a, t.b, t.c, t.d, t.tx, t.ty); } FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect) diff --git a/WebCore/platform/graphics/cg/ImageCG.cpp b/WebCore/platform/graphics/cg/ImageCG.cpp index 13c8c07..dbf1d85 100644 --- a/WebCore/platform/graphics/cg/ImageCG.cpp +++ b/WebCore/platform/graphics/cg/ImageCG.cpp @@ -73,6 +73,7 @@ BitmapImage::BitmapImage(CGImageRef cgImage, ImageObserver* observer) , m_repetitionCountStatus(Unknown) , m_repetitionsComplete(0) , m_isSolidColor(false) + , m_checkedForSolidColor(false) , m_animationFinished(true) , m_allDataReceived(true) , m_haveSize(true) @@ -99,6 +100,7 @@ BitmapImage::BitmapImage(CGImageRef cgImage, ImageObserver* observer) void BitmapImage::checkForSolidColor() { + m_checkedForSolidColor = true; if (frameCount() > 1) m_isSolidColor = false; else { diff --git a/WebCore/platform/graphics/cg/ImageSourceCG.cpp b/WebCore/platform/graphics/cg/ImageSourceCG.cpp index 0b276cc..c059985 100644 --- a/WebCore/platform/graphics/cg/ImageSourceCG.cpp +++ b/WebCore/platform/graphics/cg/ImageSourceCG.cpp @@ -58,7 +58,7 @@ void ImageSource::clear(bool, size_t, SharedBuffer* data, bool allDataReceived) m_decoder = 0; } if (data) - setData(data, allDataReceived); + setData(data, allDataReceived); } static CFDictionaryRef imageSourceOptions() diff --git a/WebCore/platform/graphics/cg/PatternCG.cpp b/WebCore/platform/graphics/cg/PatternCG.cpp index 2b9c12f..697bc57 100644 --- a/WebCore/platform/graphics/cg/PatternCG.cpp +++ b/WebCore/platform/graphics/cg/PatternCG.cpp @@ -50,12 +50,13 @@ static void patternReleaseCallback(void* info) static_cast<Image*>(info)->deref(); } -CGPatternRef Pattern::createPlatformPattern(const TransformationMatrix& transform) const +CGPatternRef Pattern::createPlatformPattern(const TransformationMatrix& userSpaceTransformation) const { IntRect tileRect = tileImage()->rect(); - TransformationMatrix patternTransform = transform; - patternTransform.scale(1, -1); + TransformationMatrix patternTransform = m_patternSpaceTransformation; + patternTransform.multiply(userSpaceTransformation); + patternTransform.scaleNonUniform(1, -1); patternTransform.translate(0, -tileRect.height()); // If FLT_MAX should also be used for xStep or yStep, nothing is rendered. Using fractions of FLT_MAX also diff --git a/WebCore/platform/graphics/cg/TransformationMatrixCG.cpp b/WebCore/platform/graphics/cg/TransformationMatrixCG.cpp index 9b3181a..568a6b3 100644 --- a/WebCore/platform/graphics/cg/TransformationMatrixCG.cpp +++ b/WebCore/platform/graphics/cg/TransformationMatrixCG.cpp @@ -28,187 +28,19 @@ #if PLATFORM(CG) +#include <CoreGraphics/CGAffineTransform.h> #include "FloatConversion.h" -#include "FloatRect.h" -#include "IntRect.h" - -#include <wtf/MathExtras.h> namespace WebCore { -TransformationMatrix::TransformationMatrix() - : m_transform(CGAffineTransformIdentity) -{ -} - -TransformationMatrix::TransformationMatrix(double a, double b, double c, double d, double tx, double ty) -{ - m_transform = CGAffineTransformMake(narrowPrecisionToCGFloat(a), - narrowPrecisionToCGFloat(b), - narrowPrecisionToCGFloat(c), - narrowPrecisionToCGFloat(d), - narrowPrecisionToCGFloat(tx), - narrowPrecisionToCGFloat(ty)); -} - -TransformationMatrix::TransformationMatrix(const PlatformTransformationMatrix& t) - : m_transform(t) -{ -} - -void TransformationMatrix::setMatrix(double a, double b, double c, double d, double tx, double ty) -{ - m_transform = CGAffineTransformMake(narrowPrecisionToCGFloat(a), - narrowPrecisionToCGFloat(b), - narrowPrecisionToCGFloat(c), - narrowPrecisionToCGFloat(d), - narrowPrecisionToCGFloat(tx), - narrowPrecisionToCGFloat(ty)); -} - -void TransformationMatrix::map(double x, double y, double *x2, double *y2) const -{ - CGPoint result = CGPointApplyAffineTransform(CGPointMake(narrowPrecisionToCGFloat(x), narrowPrecisionToCGFloat(y)), m_transform); - *x2 = result.x; - *y2 = result.y; -} - -IntRect TransformationMatrix::mapRect(const IntRect &rect) const -{ - return enclosingIntRect(CGRectApplyAffineTransform(CGRect(rect), m_transform)); -} - -FloatRect TransformationMatrix::mapRect(const FloatRect &rect) const -{ - return FloatRect(CGRectApplyAffineTransform(CGRect(rect), m_transform)); -} - -bool TransformationMatrix::isIdentity() const -{ - return CGAffineTransformIsIdentity(m_transform); -} - -double TransformationMatrix::a() const -{ - return m_transform.a; -} - -void TransformationMatrix::setA(double a) -{ - m_transform.a = narrowPrecisionToCGFloat(a); -} - -double TransformationMatrix::b() const -{ - return m_transform.b; -} - -void TransformationMatrix::setB(double b) -{ - m_transform.b = narrowPrecisionToCGFloat(b); -} - -double TransformationMatrix::c() const -{ - return m_transform.c; -} - -void TransformationMatrix::setC(double c) -{ - m_transform.c = narrowPrecisionToCGFloat(c); -} - -double TransformationMatrix::d() const -{ - return m_transform.d; -} - -void TransformationMatrix::setD(double d) -{ - m_transform.d = narrowPrecisionToCGFloat(d); -} - -double TransformationMatrix::e() const -{ - return m_transform.tx; -} - -void TransformationMatrix::setE(double e) -{ - m_transform.tx = narrowPrecisionToCGFloat(e); -} - -double TransformationMatrix::f() const -{ - return m_transform.ty; -} - -void TransformationMatrix::setF(double f) -{ - m_transform.ty = narrowPrecisionToCGFloat(f); -} - -void TransformationMatrix::reset() -{ - m_transform = CGAffineTransformIdentity; -} - -TransformationMatrix &TransformationMatrix::scale(double sx, double sy) -{ - m_transform = CGAffineTransformScale(m_transform, narrowPrecisionToCGFloat(sx), narrowPrecisionToCGFloat(sy)); - return *this; -} - -TransformationMatrix &TransformationMatrix::rotate(double d) -{ - m_transform = CGAffineTransformRotate(m_transform, narrowPrecisionToCGFloat(deg2rad(d))); - return *this; -} - -TransformationMatrix &TransformationMatrix::translate(double tx, double ty) -{ - m_transform = CGAffineTransformTranslate(m_transform, narrowPrecisionToCGFloat(tx), narrowPrecisionToCGFloat(ty)); - return *this; -} - -TransformationMatrix &TransformationMatrix::shear(double sx, double sy) -{ - CGAffineTransform shear = CGAffineTransformMake(1.0f, narrowPrecisionToCGFloat(sy), narrowPrecisionToCGFloat(sx), 1.0f, 0.0f, 0.0f); - m_transform = CGAffineTransformConcat(shear, m_transform); - return *this; -} - -double TransformationMatrix::det() const -{ - return m_transform.a * m_transform.d - m_transform.b * m_transform.c; -} - -TransformationMatrix TransformationMatrix::inverse() const -{ - if (isInvertible()) - return TransformationMatrix(CGAffineTransformInvert(m_transform)); - return TransformationMatrix(); -} - -TransformationMatrix::operator PlatformTransformationMatrix() const -{ - return m_transform; -} - -bool TransformationMatrix::operator== (const TransformationMatrix &m2) const -{ - return CGAffineTransformEqualToTransform(m_transform, CGAffineTransform(m2)); -} - -TransformationMatrix &TransformationMatrix::operator*= (const TransformationMatrix &m2) -{ - m_transform = CGAffineTransformConcat(m_transform, CGAffineTransform(m2)); - return *this; -} - -TransformationMatrix TransformationMatrix::operator* (const TransformationMatrix &m2) +TransformationMatrix::operator CGAffineTransform() const { - return CGAffineTransformConcat(m_transform, CGAffineTransform(m2)); + return CGAffineTransformMake(narrowPrecisionToCGFloat(a()), + narrowPrecisionToCGFloat(b()), + narrowPrecisionToCGFloat(c()), + narrowPrecisionToCGFloat(d()), + narrowPrecisionToCGFloat(e()), + narrowPrecisionToCGFloat(f())); } } |