Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(700)

Unified Diff: third_party/WebKit/Source/modules/canvas2d/ClipList.cpp

Issue 1690173003: Canvas2d: Make the intersection computation O(1) instead of O(n) in ClipList. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/canvas2d/ClipList.cpp
diff --git a/third_party/WebKit/Source/modules/canvas2d/ClipList.cpp b/third_party/WebKit/Source/modules/canvas2d/ClipList.cpp
index 7443df76139ab1d397f736ea4ea94cd9e9e761b8..37b07a42067387a5c3878e2caf1081c579d0626c 100644
--- a/third_party/WebKit/Source/modules/canvas2d/ClipList.cpp
+++ b/third_party/WebKit/Source/modules/canvas2d/ClipList.cpp
@@ -18,6 +18,10 @@ void ClipList::clipPath(const SkPath& path, AntiAliasingMode antiAliasingMode, c
newClip.m_antiAliasingMode = antiAliasingMode;
newClip.m_path = path;
newClip.m_path.transform(ctm);
+ if (m_clipList.isEmpty())
+ m_currentClipPath = path;
+ else
+ Op(m_currentClipPath, path, SkPathOp::kIntersect_SkPathOp, &m_currentClipPath);
m_clipList.append(newClip);
}
@@ -28,13 +32,9 @@ void ClipList::playback(SkCanvas* canvas) const
}
}
-SkPath ClipList::intersectPathWithClip(const SkPath& path) const
+const SkPath& ClipList::getCurrentClipPath() const
{
- SkPath total = path;
- for (const ClipOp* it = m_clipList.begin(); it < m_clipList.end(); it++) {
- Op(total, it->m_path, SkPathOp::kIntersect_SkPathOp, &total);
- }
- return total;
+ return m_currentClipPath;
}
ClipList::ClipOp::ClipOp()
« no previous file with comments | « third_party/WebKit/Source/modules/canvas2d/ClipList.h ('k') | third_party/WebKit/Source/platform/graphics/Path.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698