summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/android
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-04-29 05:36:44 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2009-04-29 05:36:44 -0700
commit6a813290b2f6bb173cda985d26b231d3c539696d (patch)
tree3dd4a83c173664beeb6c7d0d5666b8356c04748d /WebCore/platform/graphics/android
parent8ee0eadb00b2146116f05e730a8a5bd025f9b2af (diff)
parent156d9de035224a88b7848c553b1839a49f004e6c (diff)
downloadexternal_webkit-6a813290b2f6bb173cda985d26b231d3c539696d.zip
external_webkit-6a813290b2f6bb173cda985d26b231d3c539696d.tar.gz
external_webkit-6a813290b2f6bb173cda985d26b231d3c539696d.tar.bz2
Merge change 671
* changes: fix line dashing and patterns in svg
Diffstat (limited to 'WebCore/platform/graphics/android')
-rw-r--r--WebCore/platform/graphics/android/GraphicsContextAndroid.cpp20
-rw-r--r--WebCore/platform/graphics/android/PatternAndroid.cpp5
-rw-r--r--WebCore/platform/graphics/android/PlatformGraphicsContext.cpp7
-rw-r--r--WebCore/platform/graphics/android/PlatformGraphicsContext.h3
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; }