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

Unified Diff: third_party/WebKit/Source/platform/graphics/paint/GeometryMapperClipCache.cpp

Issue 2729243002: Improve performance of GeometryMapper cache. (Closed)
Patch Set: none Created 3 years, 9 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/platform/graphics/paint/GeometryMapperClipCache.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/paint/GeometryMapperClipCache.cpp b/third_party/WebKit/Source/platform/graphics/paint/GeometryMapperClipCache.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b65fe9cda15ea3dc3ceed9862d8f05e95dd00bcc
--- /dev/null
+++ b/third_party/WebKit/Source/platform/graphics/paint/GeometryMapperClipCache.cpp
@@ -0,0 +1,56 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "platform/graphics/paint/GeometryMapperClipCache.h"
+
+#include "platform/graphics/paint/FloatClipRect.h"
+
+namespace blink {
+
+// All clip caches invalidate themselves by tracking a local cache generation,
+// and invalidating their cache if their cache generation disagrees with
+// s_clipCacheGeneration.
+static unsigned s_clipCacheGeneration = 0;
+
+void GeometryMapperClipCache::clearCache() {
+ s_clipCacheGeneration++;
+}
+
+Vector<GeometryMapperClipCache::ClipCacheEntry>*
+GeometryMapperClipCache::getClipCacheEntries() {
+ if (m_cacheGeneration != s_clipCacheGeneration || !m_clipCache) {
+ m_clipCache.reset(new Vector<ClipCacheEntry>);
+ m_cacheGeneration = s_clipCacheGeneration;
+ }
+
+ return m_clipCache.get();
+}
+
+const FloatClipRect* GeometryMapperClipCache::getCachedClip(
+ const ClipAndTransform& clipAndTransform) {
+ auto* clipCacheEntries =
+ const_cast<GeometryMapperClipCache*>(this)->getClipCacheEntries();
+ for (const auto& entry : *clipCacheEntries) {
+ if (entry.clipAndTransform == clipAndTransform) {
+ return &entry.clipRect;
+ }
+ }
+ return nullptr;
+}
+
+void GeometryMapperClipCache::setCachedClip(
+ const ClipAndTransform& clipAndTransform,
+ const FloatClipRect& clip) {
+ auto* clipCacheEntries =
+ const_cast<GeometryMapperClipCache*>(this)->getClipCacheEntries();
+#if DCHECK_IS_ON
pdr. 2017/03/08 02:34:55 DCHECK_IS_ON()
chrishtr 2017/03/08 02:59:28 Done.
+ for (const auto& entry : clipCachEntries) {
+ if (entry.clipAndTransform == clipAndTransform)
+ DCHECK(false); // There should be no existing entry.
+ }
+#endif
+ clipCacheEntries->push_back(ClipCacheEntry(clipAndTransform, clip));
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698