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

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: rebase 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/compositor.gyp ('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 "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 PaintRecorder;
16 17
17 class PaintContext { 18 class PaintContext {
18 public: 19 public:
19 // Construct a PaintContext that can only re-paint the area in the 20 // Construct a PaintContext that can only re-paint the area in the
20 // |invalidation|. 21 // |invalidation|.
21 PaintContext(gfx::Canvas* canvas, const gfx::Rect& invalidation) 22 PaintContext(gfx::Canvas* canvas, const gfx::Rect& invalidation)
22 : canvas_(canvas), invalidation_(invalidation) { 23 : canvas_(canvas), invalidation_(invalidation) {
23 #if DCHECK_IS_ON() 24 #if DCHECK_IS_ON()
24 root_visited_ = nullptr; 25 root_visited_ = nullptr;
25 #endif 26 #endif
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #if DCHECK_IS_ON() 61 #if DCHECK_IS_ON()
61 void Visited(void* visited) const { 62 void Visited(void* visited) const {
62 if (!root_visited_) 63 if (!root_visited_)
63 root_visited_ = visited; 64 root_visited_ = visited;
64 } 65 }
65 void* RootVisited() const { return root_visited_; } 66 void* RootVisited() const { return root_visited_; }
66 const gfx::Vector2d& PaintOffset() const { return offset_; } 67 const gfx::Vector2d& PaintOffset() const { return offset_; }
67 #endif 68 #endif
68 69
69 private: 70 private:
71 // The PaintRecorder needs access to the internal canvas and friends, but we
72 // don't want to expose them on this class so that people must go through the
73 // recorder to access them.
74 friend class PaintRecorder;
75
70 // Clone a PaintContext with an additional |offset|. 76 // Clone a PaintContext with an additional |offset|.
71 PaintContext(const PaintContext& other, const gfx::Vector2d& offset) 77 PaintContext(const PaintContext& other, const gfx::Vector2d& offset)
72 : canvas_(other.canvas_), 78 : canvas_(other.canvas_),
73 invalidation_(other.invalidation_), 79 invalidation_(other.invalidation_),
74 offset_(other.offset_ + offset) { 80 offset_(other.offset_ + offset) {
75 #if DCHECK_IS_ON() 81 #if DCHECK_IS_ON()
76 root_visited_ = other.root_visited_; 82 root_visited_ = other.root_visited_;
77 #endif 83 #endif
78 } 84 }
79 85
80 gfx::Canvas* canvas_; 86 gfx::Canvas* canvas_;
81 // Invalidation in the space of the paint root (ie the space of the layer 87 // Invalidation in the space of the paint root (ie the space of the layer
82 // backing the paint taking place). 88 // backing the paint taking place).
83 gfx::Rect invalidation_; 89 gfx::Rect invalidation_;
84 // Offset from the PaintContext to the space of the paint root and the 90 // Offset from the PaintContext to the space of the paint root and the
85 // |invalidation_|. 91 // |invalidation_|.
86 gfx::Vector2d offset_; 92 gfx::Vector2d offset_;
87 93
88 #if DCHECK_IS_ON() 94 #if DCHECK_IS_ON()
89 // Used to verify that the |invalidation_| is only used to compare against 95 // Used to verify that the |invalidation_| is only used to compare against
90 // rects in the same space. 96 // rects in the same space.
91 mutable void* root_visited_; 97 mutable void* root_visited_;
92 #endif 98 #endif
93 }; 99 };
94 100
95 } // namespace ui 101 } // namespace ui
96 102
97 #endif // UI_COMPOSITOR_PAINT_CONTEXT_H_ 103 #endif // UI_COMPOSITOR_PAINT_CONTEXT_H_
OLDNEW
« no previous file with comments | « ui/compositor/compositor.gyp ('k') | ui/compositor/paint_recorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698