Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | 5 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
| 6 | 6 |
| 7 #include "platform/graphics/paint/PropertyTreeState.h" | 7 #include "platform/graphics/paint/PropertyTreeState.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| 11 // All transform caches invalidate themselves by tracking a local cache | |
| 12 // generation, and invalidating their cache if their cache generation disagrees | |
| 13 // with s_clipCacheGeneration. | |
| 14 static unsigned s_transformCacheGeneration = 0; | |
| 15 | |
| 11 // The root of the transform tree. The root transform node references the root | 16 // The root of the transform tree. The root transform node references the root |
| 12 // scroll node. | 17 // scroll node. |
| 13 TransformPaintPropertyNode* TransformPaintPropertyNode::root() { | 18 TransformPaintPropertyNode* TransformPaintPropertyNode::root() { |
| 14 DEFINE_STATIC_REF(TransformPaintPropertyNode, root, | 19 DEFINE_STATIC_REF(TransformPaintPropertyNode, root, |
| 15 adoptRef(new TransformPaintPropertyNode( | 20 adoptRef(new TransformPaintPropertyNode( |
| 16 nullptr, TransformationMatrix(), FloatPoint3D(), false, | 21 nullptr, TransformationMatrix(), FloatPoint3D(), false, |
| 17 0, CompositingReasonNone, CompositorElementId(), | 22 0, CompositingReasonNone, CompositorElementId(), |
| 18 ScrollPaintPropertyNode::root()))); | 23 ScrollPaintPropertyNode::root()))); |
| 19 return root; | 24 return root; |
| 20 } | 25 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 | 57 |
| 53 #if DCHECK_IS_ON() | 58 #if DCHECK_IS_ON() |
| 54 | 59 |
| 55 String TransformPaintPropertyNode::toTreeString() const { | 60 String TransformPaintPropertyNode::toTreeString() const { |
| 56 return blink::PropertyTreeStatePrinter<blink::TransformPaintPropertyNode>() | 61 return blink::PropertyTreeStatePrinter<blink::TransformPaintPropertyNode>() |
| 57 .pathAsString(this); | 62 .pathAsString(this); |
| 58 } | 63 } |
| 59 | 64 |
| 60 #endif | 65 #endif |
| 61 | 66 |
| 67 void TransformPaintPropertyNode::clearCache() { | |
| 68 s_transformCacheGeneration++; | |
| 69 } | |
| 70 | |
| 71 Vector<TransformPaintPropertyNode::TransformCacheEntry>* | |
| 72 TransformPaintPropertyNode::getTransformCacheEntries() { | |
| 73 if (m_cacheGeneration != s_transformCacheGeneration || !m_transformCache) { | |
| 74 m_transformCache.reset(new Vector<TransformCacheEntry>); | |
| 75 m_cacheGeneration = s_transformCacheGeneration; | |
| 76 } | |
| 77 | |
| 78 return m_transformCache.get(); | |
| 79 } | |
| 80 | |
| 81 const TransformationMatrix* TransformPaintPropertyNode::getCachedTransform( | |
| 82 const TransformPaintPropertyNode* ancestorTransform) const { | |
| 83 auto* transformCacheEntries = | |
| 84 const_cast<TransformPaintPropertyNode*>(this)->getTransformCacheEntries(); | |
| 85 | |
| 86 for (const auto& entry : *transformCacheEntries) { | |
| 87 if (entry.ancestorNode == ancestorTransform) { | |
| 88 return &entry.toAncestor; | |
| 89 } | |
| 90 } | |
| 91 return nullptr; | |
| 92 } | |
| 93 | |
| 94 void TransformPaintPropertyNode::setCachedTransform( | |
| 95 const TransformPaintPropertyNode* ancestorTransform, | |
| 96 const TransformationMatrix& toAncestor) const { | |
| 97 auto* transformCacheEntries = | |
| 98 const_cast<TransformPaintPropertyNode*>(this)->getTransformCacheEntries(); | |
| 99 #if DCHECK_IS_ON | |
| 100 for (const auto& entry : transformCacheEntries) { | |
| 101 if (entry.ancestorNode == ancestorTransform) | |
| 102 DCHECK(false); // There should be no existing entry. | |
| 103 } | |
| 104 #endif | |
| 105 transformCacheEntries->push_back( | |
| 106 TransformCacheEntry(ancestorTransform, toAncestor)); | |
|
Xianzhu
2017/03/07 23:19:06
Should we check similar to ClipPaintPropertyNode::
chrishtr
2017/03/07 23:21:25
ditto
| |
| 107 } | |
| 108 | |
| 62 } // namespace blink | 109 } // namespace blink |
| OLD | NEW |