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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/GeometryMapperClipCache.h

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 unified diff | Download patch
OLDNEW
(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 #ifndef GeometryMapperClipCache_h
6 #define GeometryMapperClipCache_h
7
8 #include "platform/PlatformExport.h"
9 #include "platform/graphics/paint/FloatClipRect.h"
10 #include "wtf/Vector.h"
11
12 namespace blink {
13
14 class ClipPaintPropertyNode;
15 class FloatClipRect;
16 class TransformPaintPropertyNode;
17
18 // A GeometryMapperClipCache hangs off a ClipPaintPropertyNode. It stores
19 // cached "clip visual rects" (See GeometryMapper.h) from that node in
20 // ancestor spaces.
21 class PLATFORM_EXPORT GeometryMapperClipCache {
22 public:
23 GeometryMapperClipCache();
24
25 struct ClipAndTransform {
26 const ClipPaintPropertyNode* ancestorClip;
27 const TransformPaintPropertyNode* ancestorTransform;
28 bool operator==(const ClipAndTransform& other) const {
29 return ancestorClip == other.ancestorClip &&
30 ancestorTransform == other.ancestorTransform;
31 }
32 ClipAndTransform(const ClipPaintPropertyNode* ancestorClipArg,
33 const TransformPaintPropertyNode* ancestorTransformArg)
34 : ancestorClip(ancestorClipArg),
35 ancestorTransform(ancestorTransformArg) {}
36 };
37
38 // Returns the clip visual rect of the owning
39 // clip of |this| in the space of |ancestors|, if there is one cached.
40 // Otherwise returns null.
41 const FloatClipRect* getCachedClip(const ClipAndTransform& ancestors);
42 // Stores the "clip visual rect" of |this in the space of |ancestors|,
43 // into a local cache.
44
45 void setCachedClip(const ClipAndTransform&, const FloatClipRect&);
46
47 static void clearCache();
48
49 private:
50 struct ClipCacheEntry {
51 const ClipAndTransform clipAndTransform;
52 const FloatClipRect clipRect;
53 ClipCacheEntry(const ClipAndTransform& clipAndTransformArg,
54 const FloatClipRect& clipRectArg)
55 : clipAndTransform(clipAndTransformArg), clipRect(clipRectArg) {}
56 };
57
58 void invalidateCacheIfNeeded();
59
60 Vector<ClipCacheEntry> m_clipCache;
61 unsigned m_cacheGeneration;
62
63 DISALLOW_COPY_AND_ASSIGN(GeometryMapperClipCache);
64 };
65
66 } // namespace blink
67
68 #endif // GeometryMapperClipCache_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698