diff options
author | Cary Clark <cary@android.com> | 2009-04-28 17:17:42 -0400 |
---|---|---|
committer | Cary Clark <cary@android.com> | 2009-04-28 17:34:39 -0400 |
commit | 156d9de035224a88b7848c553b1839a49f004e6c (patch) | |
tree | 25f452123309502483d295f6acd7d2c76b391a5f | |
parent | 0296aca4034b6c5c6509ad09d0144405f44c4ba1 (diff) | |
download | external_webkit-156d9de035224a88b7848c553b1839a49f004e6c.zip external_webkit-156d9de035224a88b7848c553b1839a49f004e6c.tar.gz external_webkit-156d9de035224a88b7848c553b1839a49f004e6c.tar.bz2 |
fix line dashing and patterns in svg
remove unused methods in PlatformGraphicsContext.h
make PlatformGraphicsContext constructors more similar
set local matrix in pattern
set dash path effect in graphics context
4 files changed, 18 insertions, 17 deletions
diff --git a/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp b/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp index 8800699..bd5baa0 100644 --- a/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp +++ b/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp @@ -84,6 +84,7 @@ public: struct State { SkPath* mPath; + SkPathEffect* mPathEffect; float mMiterLimit; float mAlpha; float mStrokeThickness; @@ -98,6 +99,7 @@ public: State() { mPath = NULL; // lazily allocated + mPathEffect = 0; mMiterLimit = 4; mAlpha = 1; mStrokeThickness = 0.0f; // Same as default in GraphicsContextPrivate.h @@ -114,10 +116,12 @@ public: State(const State& other) { memcpy(this, &other, sizeof(State)); mPath = deepCopyPtr<SkPath>(other.mPath); + mPathEffect->safeRef(); } ~State() { delete mPath; + mPathEffect->safeUnref(); } void setShadow(int radius, int dx, int dy, SkColor c) { @@ -269,6 +273,11 @@ public: rect->inset(-SK_ScalarHalf, -SK_ScalarHalf); } + SkPathEffect* pe = mState->mPathEffect; + if (pe) { + paint->setPathEffect(pe); + return false; + } switch (mCG->strokeStyle()) { case NoStroke: case SolidStroke: @@ -284,7 +293,7 @@ public: if (width > 0) { SkScalar intervals[] = { width, width }; - SkPathEffect* pe = new SkDashPathEffect(intervals, 2, 0); + pe = new SkDashPathEffect(intervals, 2, 0); paint->setPathEffect(pe)->unref(); // return true if we're basically a dotted dash of squares return RoundToInt(width) == RoundToInt(paint->getStrokeWidth()); @@ -963,8 +972,6 @@ void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset) if (paintingDisabled()) return; - // FIXME: This is lifted directly off SkiaSupport, lines 49-74 - // so it is not guaranteed to work correctly. size_t dashLength = dashes.size(); if (!dashLength) return; @@ -973,9 +980,10 @@ void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset) SkScalar* intervals = new SkScalar[count]; for (unsigned int i = 0; i < count; i++) - intervals[i] = dashes[i % dashLength]; -// FIXME: setDashPathEffect not defined -// platformContext()->setDashPathEffect(new SkDashPathEffect(intervals, count, dashOffset)); + intervals[i] = SkFloatToScalar(dashes[i % dashLength]); + SkPathEffect **effectPtr = &m_data->mState->mPathEffect; + (*effectPtr)->safeUnref(); + *effectPtr = new SkDashPathEffect(intervals, count, SkFloatToScalar(dashOffset)); delete[] intervals; } diff --git a/WebCore/platform/graphics/android/PatternAndroid.cpp b/WebCore/platform/graphics/android/PatternAndroid.cpp index ffdbbb1..ff2b522 100644 --- a/WebCore/platform/graphics/android/PatternAndroid.cpp +++ b/WebCore/platform/graphics/android/PatternAndroid.cpp @@ -40,14 +40,13 @@ static SkShader::TileMode toTileMode(bool doRepeat) { return doRepeat ? SkShader::kRepeat_TileMode : SkShader::kClamp_TileMode; } -SkShader* Pattern::createPlatformPattern(const TransformationMatrix& transform) const +SkShader* Pattern::createPlatformPattern(const TransformationMatrix& ) const { SkBitmapRef* ref = tileImage()->nativeImageForCurrentFrame(); SkShader* s = SkShader::CreateBitmapShader(ref->bitmap(), toTileMode(m_repeatX), toTileMode(m_repeatY)); - - // TODO: do I treat transform as a local matrix??? + s->setLocalMatrix(m_patternSpaceTransformation); return s; } diff --git a/WebCore/platform/graphics/android/PlatformGraphicsContext.cpp b/WebCore/platform/graphics/android/PlatformGraphicsContext.cpp index b13f45f..e0aecfa 100644 --- a/WebCore/platform/graphics/android/PlatformGraphicsContext.cpp +++ b/WebCore/platform/graphics/android/PlatformGraphicsContext.cpp @@ -35,12 +35,9 @@ PlatformGraphicsContext::PlatformGraphicsContext(SkCanvas* canvas, WTF::Vector<C { } -PlatformGraphicsContext::PlatformGraphicsContext() : m_deleteCanvas(true) +PlatformGraphicsContext::PlatformGraphicsContext() + : mCanvas(new SkCanvas), m_deleteCanvas(true), m_buttons(0) { - mCanvas = new SkCanvas; - // Since this is our own private SkCanvas, and has no relation to a picture - // storing button references would be meaningless. - m_buttons = NULL; } PlatformGraphicsContext::~PlatformGraphicsContext() diff --git a/WebCore/platform/graphics/android/PlatformGraphicsContext.h b/WebCore/platform/graphics/android/PlatformGraphicsContext.h index dce8ef3..546e4ef 100644 --- a/WebCore/platform/graphics/android/PlatformGraphicsContext.h +++ b/WebCore/platform/graphics/android/PlatformGraphicsContext.h @@ -149,9 +149,6 @@ public: PlatformGraphicsContext(SkCanvas* canvas, WTF::Vector<Container>* buttons); ~PlatformGraphicsContext(); - void setupFillPaint(GraphicsContext*, SkPaint*); - void setupStrokePaint(GraphicsContext*, SkPaint*); - SkCanvas* mCanvas; bool deleteUs() const { return m_deleteCanvas; } |