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

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

Issue 2380683006: SPv2: Add support for tracking raster paint invalidations in testing. (Closed)
Patch Set: none Created 4 years, 2 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 2016 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 PaintInvalidationTracking_h
6 #define PaintInvalidationTracking_h
7
8 #include "platform/geometry/IntRect.h"
9 #include "platform/geometry/Region.h"
10 #include "platform/graphics/PaintInvalidationReason.h"
11 #include "platform/json/JSONValues.h"
12 #include "third_party/skia/include/core/SkColor.h"
13 #include "third_party/skia/include/core/SkPicture.h"
14 #include "wtf/Allocator.h"
15 #include "wtf/text/WTFString.h"
16
17 namespace blink {
18
19 class DisplayItemClient;
20
21 struct PaintInvalidationInfo {
22 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
23 // This is for comparison only. Don't dereference because the client may hav e died.
24 const DisplayItemClient* client;
25 String clientDebugName;
26 IntRect rect;
27 PaintInvalidationReason reason;
28 PaintInvalidationInfo() : reason(PaintInvalidationFull) {}
29 };
30
31 inline bool operator==(const PaintInvalidationInfo& a, const PaintInvalidationIn fo& b)
32 {
33 return a.rect == b.rect;
34 }
35
36 struct UnderPaintInvalidation {
37 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
38 int x;
39 int y;
40 SkColor oldPixel;
41 SkColor newPixel;
42 };
43
44 struct PaintInvalidationTracking {
45 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
46 Vector<PaintInvalidationInfo> trackedPaintInvalidations;
47 sk_sp<SkPicture> lastPaintedPicture;
48 IntRect lastInterestRect;
49 Region paintInvalidationRegionSinceLastPaint;
50 Vector<UnderPaintInvalidation> underPaintInvalidations;
51
52 void asJSON(JSONObject*);
53 };
54
55 template <class TargetClass>
56 class PaintInvalidationTrackingMap {
57 public:
58 void asJSON(TargetClass* key, JSONObject* json)
59 {
60 auto it = m_invalidationTrackingMap.find(key);
61 if (it != m_invalidationTrackingMap.end())
62 it->value.asJSON(json);
63 }
64
65 void remove(TargetClass* key)
66 {
67 auto it = m_invalidationTrackingMap.find(key);
68 if (it != m_invalidationTrackingMap.end())
69 m_invalidationTrackingMap.remove(it);
70 }
71
72 PaintInvalidationTracking& add(TargetClass* key)
73 {
74 return m_invalidationTrackingMap.add(key, PaintInvalidationTracking()).s toredValue->value;
75 }
76
77 PaintInvalidationTracking* find(TargetClass* key)
78 {
79 auto it = m_invalidationTrackingMap.find(key);
80 if (it == m_invalidationTrackingMap.end())
81 return nullptr;
82 return &it->value;
83 }
84
85 private:
86 typedef HashMap<TargetClass*, PaintInvalidationTracking> InvalidationTrackin gMap;
87 InvalidationTrackingMap m_invalidationTrackingMap;
88 };
89
90 } // namespace blink
91
92 #endif // PaintInvalidationTracking_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698