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

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

Issue 1069183002: ui: Remove the canvas() member from PaintContext. (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/compositing_recorder.cc ('k') | ui/compositor/paint_recorder.cc » ('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 "ui/gfx/geometry/rect.h" 9 #include "ui/gfx/geometry/rect.h"
10 10
11 namespace gfx { 11 namespace gfx {
12 class Canvas; 12 class Canvas;
13 } 13 }
14 14
15 namespace ui { 15 namespace ui {
16 class ClipTransformRecorder;
17 class CompositingRecorder;
16 class PaintRecorder; 18 class PaintRecorder;
17 19
18 class PaintContext { 20 class PaintContext {
19 public: 21 public:
20 // Construct a PaintContext that can only re-paint the area in the 22 // Construct a PaintContext that can only re-paint the area in the
21 // |invalidation|. 23 // |invalidation|.
22 PaintContext(gfx::Canvas* canvas, const gfx::Rect& invalidation) 24 PaintContext(gfx::Canvas* canvas, const gfx::Rect& invalidation)
23 : canvas_(canvas), invalidation_(invalidation) { 25 : canvas_(canvas), invalidation_(invalidation) {
24 #if DCHECK_IS_ON() 26 #if DCHECK_IS_ON()
25 root_visited_ = nullptr; 27 root_visited_ = nullptr;
(...skipping 10 matching lines...) Expand all
36 // Clone a PaintContext with an additional |offset|. 38 // Clone a PaintContext with an additional |offset|.
37 PaintContext CloneWithPaintOffset(const gfx::Vector2d& offset) const { 39 PaintContext CloneWithPaintOffset(const gfx::Vector2d& offset) const {
38 return PaintContext(*this, offset); 40 return PaintContext(*this, offset);
39 } 41 }
40 42
41 // Clone a PaintContext that has no consideration for invalidation. 43 // Clone a PaintContext that has no consideration for invalidation.
42 PaintContext CloneWithoutInvalidation() const { 44 PaintContext CloneWithoutInvalidation() const {
43 return PaintContext(canvas_); 45 return PaintContext(canvas_);
44 } 46 }
45 47
46 // TODO(danakj): Remove this once everything is painting to display lists.
47 gfx::Canvas* canvas() const { return canvas_; }
48
49 // When true, IsRectInvalidated() can be called, otherwise its result would be 48 // When true, IsRectInvalidated() can be called, otherwise its result would be
50 // invalid. 49 // invalid.
51 bool CanCheckInvalidated() const { return !invalidation_.IsEmpty(); } 50 bool CanCheckInvalidated() const { return !invalidation_.IsEmpty(); }
52 51
53 // When true, the |bounds| touches an invalidated area, so should be 52 // When true, the |bounds| touches an invalidated area, so should be
54 // re-painted. When false, re-painting can be skipped. Bounds should be in 53 // re-painted. When false, re-painting can be skipped. Bounds should be in
55 // the local space with offsets up to the painting root in the PaintContext. 54 // the local space with offsets up to the painting root in the PaintContext.
56 bool IsRectInvalidated(const gfx::Rect& bounds) const { 55 bool IsRectInvalidated(const gfx::Rect& bounds) const {
57 DCHECK(CanCheckInvalidated()); 56 DCHECK(CanCheckInvalidated());
58 return invalidation_.Intersects(bounds + offset_); 57 return invalidation_.Intersects(bounds + offset_);
59 } 58 }
60 59
61 #if DCHECK_IS_ON() 60 #if DCHECK_IS_ON()
62 void Visited(void* visited) const { 61 void Visited(void* visited) const {
63 if (!root_visited_) 62 if (!root_visited_)
64 root_visited_ = visited; 63 root_visited_ = visited;
65 } 64 }
66 void* RootVisited() const { return root_visited_; } 65 void* RootVisited() const { return root_visited_; }
67 const gfx::Vector2d& PaintOffset() const { return offset_; } 66 const gfx::Vector2d& PaintOffset() const { return offset_; }
68 #endif 67 #endif
69 68
70 const gfx::Rect& InvalidationForTesting() const { return invalidation_; } 69 const gfx::Rect& InvalidationForTesting() const { return invalidation_; }
71 70
72 private: 71 private:
73 // The PaintRecorder needs access to the internal canvas and friends, but we 72 // The Recorder classes need access to the internal canvas and friends, but we
74 // don't want to expose them on this class so that people must go through the 73 // don't want to expose them on this class so that people must go through the
75 // recorder to access them. 74 // recorders to access them.
75 friend class ClipTransformRecorder;
76 friend class CompositingRecorder;
76 friend class PaintRecorder; 77 friend class PaintRecorder;
77 78
78 // Clone a PaintContext with an additional |offset|. 79 // Clone a PaintContext with an additional |offset|.
79 PaintContext(const PaintContext& other, const gfx::Vector2d& offset) 80 PaintContext(const PaintContext& other, const gfx::Vector2d& offset)
80 : canvas_(other.canvas_), 81 : canvas_(other.canvas_),
81 invalidation_(other.invalidation_), 82 invalidation_(other.invalidation_),
82 offset_(other.offset_ + offset) { 83 offset_(other.offset_ + offset) {
83 #if DCHECK_IS_ON() 84 #if DCHECK_IS_ON()
84 root_visited_ = other.root_visited_; 85 root_visited_ = other.root_visited_;
85 #endif 86 #endif
(...skipping 10 matching lines...) Expand all
96 #if DCHECK_IS_ON() 97 #if DCHECK_IS_ON()
97 // Used to verify that the |invalidation_| is only used to compare against 98 // Used to verify that the |invalidation_| is only used to compare against
98 // rects in the same space. 99 // rects in the same space.
99 mutable void* root_visited_; 100 mutable void* root_visited_;
100 #endif 101 #endif
101 }; 102 };
102 103
103 } // namespace ui 104 } // namespace ui
104 105
105 #endif // UI_COMPOSITOR_PAINT_CONTEXT_H_ 106 #endif // UI_COMPOSITOR_PAINT_CONTEXT_H_
OLDNEW
« no previous file with comments | « ui/compositor/compositing_recorder.cc ('k') | ui/compositor/paint_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698