diff options
author | Derek Sollenberger <djsollen@google.com> | 2012-02-07 08:02:53 -0500 |
---|---|---|
committer | Derek Sollenberger <djsollen@google.com> | 2012-02-07 08:02:53 -0500 |
commit | 147c05c95f0affb04bf16d4e293a54e8957aa42e (patch) | |
tree | ec53f20aaf4e8522d50aa0ac788f71085a886314 /Source/WebCore/platform/graphics/android | |
parent | faf2b5dab67cbe9c5a9244f3912e916d0184f765 (diff) | |
download | external_webkit-147c05c95f0affb04bf16d4e293a54e8957aa42e.zip external_webkit-147c05c95f0affb04bf16d4e293a54e8957aa42e.tar.gz external_webkit-147c05c95f0affb04bf16d4e293a54e8957aa42e.tar.bz2 |
Improve performance of rounded corners (i.e. path anti-aliasing)
bug: 4439195
Change-Id: Id1792d60ceec8ecf56b99bcbd898e2f36812b87d
Diffstat (limited to 'Source/WebCore/platform/graphics/android')
-rw-r--r-- | Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp | 55 |
1 files changed, 2 insertions, 53 deletions
diff --git a/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp index a490d5f..848b713 100644 --- a/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp @@ -127,9 +127,6 @@ public: SkColor fillColor; SkColor strokeColor; bool useAA; - // This is a list of clipping paths which are currently active, in the - // order in which they were pushed. - WTF::Vector<SkPath> antiAliasClipPaths; State() : pathEffect(0) @@ -246,9 +243,6 @@ public: void restore() { - if (!m_state->antiAliasClipPaths.isEmpty()) - applyAntiAliasedClipPaths(m_state->antiAliasClipPaths); - m_state->~State(); m_stateStack.pop_back(); m_state = static_cast<State*>(m_stateStack.back()); @@ -370,51 +364,6 @@ public: return false; } - void clipPathAntiAliased(const SkPath& clipPath) - { - // If we are currently tracking any anti-alias clip paths, then we already - // have a layer in place and don't need to add another. - bool haveLayerOutstanding = m_state->antiAliasClipPaths.size(); - - // See comments in applyAntiAliasedClipPaths about how this works. - m_state->antiAliasClipPaths.append(clipPath); - if (!haveLayerOutstanding) { - SkRect bounds = clipPath.getBounds(); - if (m_platformGfxCtx && m_platformGfxCtx->mCanvas) { - m_platformGfxCtx->mCanvas->saveLayerAlpha(&bounds, 255, - static_cast<SkCanvas::SaveFlags>(SkCanvas::kHasAlphaLayer_SaveFlag - | SkCanvas::kFullColorLayer_SaveFlag - | SkCanvas::kClipToLayer_SaveFlag)); - m_platformGfxCtx->mCanvas->save(); - } else - ASSERT(0); - } - } - - void applyAntiAliasedClipPaths(WTF::Vector<SkPath>& paths) - { - // Anti-aliased clipping: - // - // Refer to PlatformContextSkia.cpp's applyAntiAliasedClipPaths() for more details - - if (m_platformGfxCtx && m_platformGfxCtx->mCanvas) - m_platformGfxCtx->mCanvas->restore(); - - SkPaint paint; - paint.setXfermodeMode(SkXfermode::kClear_Mode); - paint.setAntiAlias(true); - paint.setStyle(SkPaint::kFill_Style); - - if (m_platformGfxCtx && m_platformGfxCtx->mCanvas) { - for (size_t i = paths.size() - 1; i < paths.size(); --i) { - paths[i].setFillType(SkPath::kInverseWinding_FillType); - m_platformGfxCtx->mCanvas->drawPath(paths[i], paint); - } - m_platformGfxCtx->mCanvas->restore(); - } else - ASSERT(0); - } - PlatformGraphicsContext* getPlatformGfxCtx() { return m_platformGfxCtx; @@ -848,7 +797,7 @@ void GraphicsContext::clip(const Path& path) if (paintingDisabled()) return; - m_data->clipPathAntiAliased(*path.platformPath()); + GC2CANVAS(this)->clipPath(*path.platformPath(), SkRegion::kIntersect_Op, true); } void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness) @@ -868,7 +817,7 @@ void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness r.inset(SkIntToScalar(thickness + 1), SkIntToScalar(thickness + 1)); path.addOval(r, SkPath::kCCW_Direction); } - m_data->clipPathAntiAliased(path); + GC2CANVAS(this)->clipPath(path, SkRegion::kIntersect_Op, true); } void GraphicsContext::canvasClip(const Path& path) |