Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "platform/graphics/paint/GeometryMapperTransformCache.h" | |
| 6 | |
| 7 namespace blink { | |
| 8 | |
| 9 // All transform caches invalidate themselves by tracking a local cache | |
| 10 // generation, and invalidating their cache if their cache generation disagrees | |
| 11 // with s_transformCacheGeneration. | |
| 12 static unsigned s_transformCacheGeneration = 0; | |
| 13 | |
| 14 void GeometryMapperTransformCache::clearCache() { | |
| 15 s_transformCacheGeneration++; | |
| 16 } | |
| 17 | |
| 18 Vector<GeometryMapperTransformCache::TransformCacheEntry>* | |
| 19 GeometryMapperTransformCache::getTransformCacheEntries() { | |
| 20 if (m_cacheGeneration != s_transformCacheGeneration || !m_transformCache) { | |
| 21 m_transformCache.reset(new Vector<TransformCacheEntry>); | |
| 22 m_cacheGeneration = s_transformCacheGeneration; | |
| 23 } | |
| 24 | |
| 25 return m_transformCache.get(); | |
| 26 } | |
| 27 | |
| 28 const TransformationMatrix* GeometryMapperTransformCache::getCachedTransform( | |
| 29 const TransformPaintPropertyNode* ancestorTransform) { | |
| 30 auto* transformCacheEntries = getTransformCacheEntries(); | |
| 31 for (const auto& entry : *transformCacheEntries) { | |
| 32 if (entry.ancestorNode == ancestorTransform) { | |
| 33 return &entry.toAncestor; | |
| 34 } | |
| 35 } | |
| 36 return nullptr; | |
| 37 } | |
| 38 | |
| 39 void GeometryMapperTransformCache::setCachedTransform( | |
| 40 const TransformPaintPropertyNode* ancestorTransform, | |
| 41 const TransformationMatrix& matrix) { | |
| 42 auto* transformCacheEntries = getTransformCacheEntries(); | |
| 43 #if DCHECK_IS_ON | |
|
pdr.
2017/03/08 02:34:55
DCHECK_IS_ON()
chrishtr
2017/03/08 02:59:28
Done.
| |
| 44 for (const auto& entry : transformCacheEntries) { | |
| 45 if (entry.ancestorNode == ancestorTransform) | |
| 46 DCHECK(false); // There should be no existing entry. | |
| 47 } | |
| 48 #endif | |
| 49 transformCacheEntries->push_back( | |
| 50 TransformCacheEntry(ancestorTransform, matrix)); | |
| 51 } | |
| 52 | |
| 53 } // namespace blink | |
| OLD | NEW |