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

Unified Diff: third_party/WebKit/Source/platform/graphics/paint/GeometryMapperTransformCache.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/GeometryMapperTransformCache.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/paint/GeometryMapperTransformCache.cpp b/third_party/WebKit/Source/platform/graphics/paint/GeometryMapperTransformCache.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ec0f7fffb960b79c926724873e0594d2b7001380
--- /dev/null
+++ b/third_party/WebKit/Source/platform/graphics/paint/GeometryMapperTransformCache.cpp
@@ -0,0 +1,53 @@
+// 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/GeometryMapperTransformCache.h"
+
+namespace blink {
+
+// All transform caches invalidate themselves by tracking a local cache
+// generation, and invalidating their cache if their cache generation disagrees
+// with s_transformCacheGeneration.
+static unsigned s_transformCacheGeneration = 0;
+
+void GeometryMapperTransformCache::clearCache() {
+ s_transformCacheGeneration++;
+}
+
+Vector<GeometryMapperTransformCache::TransformCacheEntry>*
+GeometryMapperTransformCache::getTransformCacheEntries() {
+ if (m_cacheGeneration != s_transformCacheGeneration || !m_transformCache) {
+ m_transformCache.reset(new Vector<TransformCacheEntry>);
+ m_cacheGeneration = s_transformCacheGeneration;
+ }
+
+ return m_transformCache.get();
+}
+
+const TransformationMatrix* GeometryMapperTransformCache::getCachedTransform(
+ const TransformPaintPropertyNode* ancestorTransform) {
+ auto* transformCacheEntries = getTransformCacheEntries();
+ for (const auto& entry : *transformCacheEntries) {
+ if (entry.ancestorNode == ancestorTransform) {
+ return &entry.toAncestor;
+ }
+ }
+ return nullptr;
+}
+
+void GeometryMapperTransformCache::setCachedTransform(
+ const TransformPaintPropertyNode* ancestorTransform,
+ const TransformationMatrix& matrix) {
+ auto* transformCacheEntries = getTransformCacheEntries();
+#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 : transformCacheEntries) {
+ if (entry.ancestorNode == ancestorTransform)
+ DCHECK(false); // There should be no existing entry.
+ }
+#endif
+ transformCacheEntries->push_back(
+ TransformCacheEntry(ancestorTransform, matrix));
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698