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

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

Issue 1053143002: Make View::Paint use ui::PaintRecorder to access PaintContext's canvas (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: paintrecorder: explicit 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
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/compositor/compositor_export.h" 9 #include "ui/compositor/compositor_export.h"
10 #include "ui/gfx/geometry/rect.h" 10 #include "ui/gfx/geometry/rect.h"
11 11
12 namespace gfx { 12 namespace gfx {
13 class Canvas; 13 class Canvas;
14 } 14 }
15 15
16 namespace ui { 16 namespace ui {
17 class PaintRecorder;
17 18
18 class COMPOSITOR_EXPORT PaintContext { 19 class COMPOSITOR_EXPORT PaintContext {
19 public: 20 public:
20 // Construct a PaintContext that can only re-paint the area in the 21 // Construct a PaintContext that can only re-paint the area in the
21 // |invalidation|. 22 // |invalidation|.
22 PaintContext(gfx::Canvas* canvas, const gfx::Rect& invalidation) 23 PaintContext(gfx::Canvas* canvas, const gfx::Rect& invalidation)
23 : canvas_(canvas), invalidation_(invalidation) { 24 : canvas_(canvas), invalidation_(invalidation) {
24 #if DCHECK_IS_ON() 25 #if DCHECK_IS_ON()
25 root_visited_ = nullptr; 26 root_visited_ = nullptr;
26 #endif 27 #endif
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 #if DCHECK_IS_ON() 62 #if DCHECK_IS_ON()
62 void Visited(void* visited) const { 63 void Visited(void* visited) const {
63 if (!root_visited_) 64 if (!root_visited_)
64 root_visited_ = visited; 65 root_visited_ = visited;
65 } 66 }
66 void* RootVisited() const { return root_visited_; } 67 void* RootVisited() const { return root_visited_; }
67 const gfx::Vector2d& PaintOffset() const { return offset_; } 68 const gfx::Vector2d& PaintOffset() const { return offset_; }
68 #endif 69 #endif
69 70
70 private: 71 private:
72 // The PaintRecorder needs access to the internal canvas and friends, but we
73 // don't want to expose them on this class so that people must go through the
74 // recorder to access them.
75 friend class PaintRecorder;
76
71 // Clone a PaintContext with an additional |offset|. 77 // Clone a PaintContext with an additional |offset|.
72 PaintContext(const PaintContext& other, const gfx::Vector2d& offset) 78 PaintContext(const PaintContext& other, const gfx::Vector2d& offset)
73 : canvas_(other.canvas_), 79 : canvas_(other.canvas_),
74 invalidation_(other.invalidation_), 80 invalidation_(other.invalidation_),
75 offset_(other.offset_ + offset) { 81 offset_(other.offset_ + offset) {
76 #if DCHECK_IS_ON() 82 #if DCHECK_IS_ON()
77 root_visited_ = other.root_visited_; 83 root_visited_ = other.root_visited_;
78 #endif 84 #endif
79 } 85 }
80 86
81 gfx::Canvas* canvas_; 87 gfx::Canvas* canvas_;
82 // Invalidation in the space of the paint root (ie the space of the layer 88 // Invalidation in the space of the paint root (ie the space of the layer
83 // backing the paint taking place). 89 // backing the paint taking place).
84 gfx::Rect invalidation_; 90 gfx::Rect invalidation_;
85 // Offset from the PaintContext to the space of the paint root and the 91 // Offset from the PaintContext to the space of the paint root and the
86 // |invalidation_|. 92 // |invalidation_|.
87 gfx::Vector2d offset_; 93 gfx::Vector2d offset_;
88 94
89 #if DCHECK_IS_ON() 95 #if DCHECK_IS_ON()
90 // Used to verify that the |invalidation_| is only used to compare against 96 // Used to verify that the |invalidation_| is only used to compare against
91 // rects in the same space. 97 // rects in the same space.
92 mutable void* root_visited_; 98 mutable void* root_visited_;
93 #endif 99 #endif
94 }; 100 };
95 101
96 } // namespace ui 102 } // namespace ui
97 103
98 #endif // UI_COMPOSITOR_PAINT_CONTEXT_H_ 104 #endif // UI_COMPOSITOR_PAINT_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698