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

Side by Side Diff: ui/compositor/paint_context.h

Issue 1108463002: Revert of ui: Cache the output of View::OnPaint when the View isn't invalid. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « ui/compositor/paint_cache.cc ('k') | ui/compositor/paint_recorder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef UI_COMPOSITOR_PAINT_CONTEXT_H_ 5 #ifndef UI_COMPOSITOR_PAINT_CONTEXT_H_
6 #define UI_COMPOSITOR_PAINT_CONTEXT_H_ 6 #define UI_COMPOSITOR_PAINT_CONTEXT_H_
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "ui/compositor/compositor_export.h" 10 #include "ui/compositor/compositor_export.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // Clone a PaintContext with an additional |offset|. 49 // Clone a PaintContext with an additional |offset|.
50 PaintContext CloneWithPaintOffset(const gfx::Vector2d& offset) const { 50 PaintContext CloneWithPaintOffset(const gfx::Vector2d& offset) const {
51 return PaintContext(*this, offset); 51 return PaintContext(*this, offset);
52 } 52 }
53 53
54 // Clone a PaintContext that has no consideration for invalidation. 54 // Clone a PaintContext that has no consideration for invalidation.
55 PaintContext CloneWithoutInvalidation() const { 55 PaintContext CloneWithoutInvalidation() const {
56 return PaintContext(canvas_); 56 return PaintContext(canvas_);
57 } 57 }
58 58
59 // When true, IsRectInvalid() can be called, otherwise its result would be 59 // When true, IsRectInvalidated() can be called, otherwise its result would be
60 // invalid. 60 // invalid.
61 bool CanCheckInvalid() const { return !invalidation_.IsEmpty(); } 61 bool CanCheckInvalidated() const { return !invalidation_.IsEmpty(); }
62
63 // When true, if a thing is not invalidated it does not need to paint itself.
64 // When false, everything should provide an output when painting regardless of
65 // being invalidated in order to remain visible.
66 bool ShouldEarlyOutOfPaintingWhenValid() const { return !!canvas_; }
67 62
68 // When true, the |bounds| touches an invalidated area, so should be 63 // When true, the |bounds| touches an invalidated area, so should be
69 // re-painted. When false, re-painting can be skipped. Bounds should be in 64 // re-painted. When false, re-painting can be skipped. Bounds should be in
70 // the local space with offsets up to the painting root in the PaintContext. 65 // the local space with offsets up to the painting root in the PaintContext.
71 bool IsRectInvalid(const gfx::Rect& bounds) const { 66 bool IsRectInvalidated(const gfx::Rect& bounds) const {
72 DCHECK(CanCheckInvalid()); 67 DCHECK(CanCheckInvalidated());
73 return invalidation_.Intersects(bounds + offset_); 68 return invalidation_.Intersects(bounds + offset_);
74 } 69 }
75 70
76 #if DCHECK_IS_ON() 71 #if DCHECK_IS_ON()
77 void Visited(void* visited) const { 72 void Visited(void* visited) const {
78 if (!root_visited_) 73 if (!root_visited_)
79 root_visited_ = visited; 74 root_visited_ = visited;
80 } 75 }
81 void* RootVisited() const { return root_visited_; } 76 void* RootVisited() const { return root_visited_; }
82 const gfx::Vector2d& PaintOffset() const { return offset_; } 77 const gfx::Vector2d& PaintOffset() const { return offset_; }
83 #endif 78 #endif
84 79
85 const gfx::Rect& InvalidationForTesting() const { return invalidation_; } 80 const gfx::Rect& InvalidationForTesting() const { return invalidation_; }
86 81
87 private: 82 private:
88 // The Recorder classes need access to the internal canvas and friends, but we 83 // The Recorder classes need access to the internal canvas and friends, but we
89 // don't want to expose them on this class so that people must go through the 84 // don't want to expose them on this class so that people must go through the
90 // recorders to access them. 85 // recorders to access them.
91 friend class ClipTransformRecorder; 86 friend class ClipTransformRecorder;
92 friend class CompositingRecorder; 87 friend class CompositingRecorder;
93 friend class PaintRecorder; 88 friend class PaintRecorder;
94 // The Cache class also needs to access the DisplayItemList to append its
95 // cache contents.
96 friend class PaintCache;
97 89
98 PaintContext& operator=(const PaintContext& other) = delete; 90 PaintContext& operator=(const PaintContext& other) = delete;
99 91
100 // Clone a PaintContext with an additional |offset|. 92 // Clone a PaintContext with an additional |offset|.
101 PaintContext(const PaintContext& other, const gfx::Vector2d& offset); 93 PaintContext(const PaintContext& other, const gfx::Vector2d& offset);
102 94
103 gfx::Canvas* canvas_; 95 gfx::Canvas* canvas_;
104 cc::DisplayItemList* list_; 96 cc::DisplayItemList* list_;
105 scoped_ptr<SkPictureRecorder> recorder_; 97 scoped_ptr<SkPictureRecorder> recorder_;
106 // The device scale of the frame being painted. Used to determine which bitmap 98 // The device scale of the frame being painted. Used to determine which bitmap
(...skipping 15 matching lines...) Expand all
122 mutable void* root_visited_; 114 mutable void* root_visited_;
123 // Used to verify that paint recorders are not nested. True while a paint 115 // Used to verify that paint recorders are not nested. True while a paint
124 // recorder is active. 116 // recorder is active.
125 mutable bool inside_paint_recorder_; 117 mutable bool inside_paint_recorder_;
126 #endif 118 #endif
127 }; 119 };
128 120
129 } // namespace ui 121 } // namespace ui
130 122
131 #endif // UI_COMPOSITOR_PAINT_CONTEXT_H_ 123 #endif // UI_COMPOSITOR_PAINT_CONTEXT_H_
OLDNEW
« no previous file with comments | « ui/compositor/paint_cache.cc ('k') | ui/compositor/paint_recorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698