Index: third_party/WebKit/Source/platform/graphics/paint/TransformPaintPropertyNode.cpp |
diff --git a/third_party/WebKit/Source/platform/graphics/paint/TransformPaintPropertyNode.cpp b/third_party/WebKit/Source/platform/graphics/paint/TransformPaintPropertyNode.cpp |
index 14211fc303085b4f0df91543f71aa0f768526f08..9b767c8c8fced39bc0557e95fa50d4cdf6821f9d 100644 |
--- a/third_party/WebKit/Source/platform/graphics/paint/TransformPaintPropertyNode.cpp |
+++ b/third_party/WebKit/Source/platform/graphics/paint/TransformPaintPropertyNode.cpp |
@@ -8,6 +8,11 @@ |
namespace blink { |
+// All transform caches invalidate themselves by tracking a local cache |
+// generation, and invalidating their cache if their cache generation disagrees |
+// with s_clipCacheGeneration. |
+static unsigned s_transformCacheGeneration = 0; |
+ |
// The root of the transform tree. The root transform node references the root |
// scroll node. |
TransformPaintPropertyNode* TransformPaintPropertyNode::root() { |
@@ -59,4 +64,46 @@ String TransformPaintPropertyNode::toTreeString() const { |
#endif |
+void TransformPaintPropertyNode::clearCache() { |
+ s_transformCacheGeneration++; |
+} |
+ |
+Vector<TransformPaintPropertyNode::TransformCacheEntry>* |
+TransformPaintPropertyNode::getTransformCacheEntries() { |
+ if (m_cacheGeneration != s_transformCacheGeneration || !m_transformCache) { |
+ m_transformCache.reset(new Vector<TransformCacheEntry>); |
+ m_cacheGeneration = s_transformCacheGeneration; |
+ } |
+ |
+ return m_transformCache.get(); |
+} |
+ |
+const TransformationMatrix* TransformPaintPropertyNode::getCachedTransform( |
+ const TransformPaintPropertyNode* ancestorTransform) const { |
+ auto* transformCacheEntries = |
+ const_cast<TransformPaintPropertyNode*>(this)->getTransformCacheEntries(); |
+ |
+ for (const auto& entry : *transformCacheEntries) { |
+ if (entry.ancestorNode == ancestorTransform) { |
+ return &entry.toAncestor; |
+ } |
+ } |
+ return nullptr; |
+} |
+ |
+void TransformPaintPropertyNode::setCachedTransform( |
+ const TransformPaintPropertyNode* ancestorTransform, |
+ const TransformationMatrix& toAncestor) const { |
+ auto* transformCacheEntries = |
+ const_cast<TransformPaintPropertyNode*>(this)->getTransformCacheEntries(); |
+#if DCHECK_IS_ON |
+ for (const auto& entry : transformCacheEntries) { |
+ if (entry.ancestorNode == ancestorTransform) |
+ DCHECK(false); // There should be no existing entry. |
+ } |
+#endif |
+ transformCacheEntries->push_back( |
+ TransformCacheEntry(ancestorTransform, toAncestor)); |
Xianzhu
2017/03/07 23:19:06
Should we check similar to ClipPaintPropertyNode::
chrishtr
2017/03/07 23:21:25
ditto
|
+} |
+ |
} // namespace blink |