OLD | NEW |
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 <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 void Visited(void* visited) const { | 58 void Visited(void* visited) const { |
59 if (!root_visited_) | 59 if (!root_visited_) |
60 root_visited_ = visited; | 60 root_visited_ = visited; |
61 } | 61 } |
62 void* RootVisited() const { return root_visited_; } | 62 void* RootVisited() const { return root_visited_; } |
63 const gfx::Vector2d& PaintOffset() const { return offset_; } | 63 const gfx::Vector2d& PaintOffset() const { return offset_; } |
64 #endif | 64 #endif |
65 | 65 |
66 const gfx::Rect& InvalidationForTesting() const { return invalidation_; } | 66 const gfx::Rect& InvalidationForTesting() const { return invalidation_; } |
67 | 67 |
| 68 float device_scale_factor() const { return device_scale_factor_; } |
| 69 |
| 70 gfx::Rect GetPixelBounds(const gfx::Rect& bounds) const; |
| 71 |
| 72 gfx::Vector2dF CanvasScale() const; |
| 73 |
| 74 void UpdateSizeAndDSF(const gfx::Size& pixel_size, const gfx::Size& size); |
| 75 |
| 76 const gfx::Size& pixel_size() const { return pixel_size_; } |
| 77 |
| 78 const gfx::Size& size() const { return size_; } |
| 79 |
68 private: | 80 private: |
69 // The Recorder classes need access to the internal canvas and friends, but we | 81 // The Recorder classes need access to the internal canvas and friends, but we |
70 // don't want to expose them on this class so that people must go through the | 82 // don't want to expose them on this class so that people must go through the |
71 // recorders to access them. | 83 // recorders to access them. |
72 friend class ClipRecorder; | 84 friend class ClipRecorder; |
73 friend class CompositingRecorder; | 85 friend class CompositingRecorder; |
74 friend class PaintRecorder; | 86 friend class PaintRecorder; |
75 friend class TransformRecorder; | 87 friend class TransformRecorder; |
76 // The Cache class also needs to access the DisplayItemList to append its | 88 // The Cache class also needs to access the DisplayItemList to append its |
77 // cache contents. | 89 // cache contents. |
78 friend class PaintCache; | 90 friend class PaintCache; |
79 | 91 |
80 // Returns a rect with the given size in the space of the context's | 92 // Returns a rect with the given size in the space of the context's |
81 // containing layer. | 93 // containing layer. |
82 gfx::Rect ToLayerSpaceBounds(const gfx::Size& size_in_context) const; | 94 gfx::Rect ToLayerSpaceBounds(const gfx::Size& size_in_context) const; |
83 | 95 |
84 // Returns the given rect translated by the layer space offset. | 96 // Returns the given rect translated by the layer space offset. |
85 gfx::Rect ToLayerSpaceRect(const gfx::Rect& rect) const; | 97 gfx::Rect ToLayerSpaceRect(const gfx::Rect& rect) const; |
86 | 98 |
87 cc::DisplayItemList* list_; | 99 cc::DisplayItemList* list_; |
88 std::unique_ptr<cc::PaintRecorder> owned_recorder_; | 100 std::unique_ptr<cc::PaintRecorder> owned_recorder_; |
89 // A pointer to the |owned_recorder_| in this PaintContext, or in another one | 101 // A pointer to the |owned_recorder_| in this PaintContext, or in another one |
90 // which this was copied from. We expect a copied-from PaintContext to outlive | 102 // which this was copied from. We expect a copied-from PaintContext to outlive |
91 // copies made from it. | 103 // copies made from it. |
92 cc::PaintRecorder* recorder_; | 104 cc::PaintRecorder* recorder_; |
93 // The device scale of the frame being painted. Used to determine which bitmap | |
94 // resources to use in the frame. | |
95 float device_scale_factor_; | |
96 // Invalidation in the space of the paint root (ie the space of the layer | 105 // Invalidation in the space of the paint root (ie the space of the layer |
97 // backing the paint taking place). | 106 // backing the paint taking place). |
98 gfx::Rect invalidation_; | 107 gfx::Rect invalidation_; |
99 // Offset from the PaintContext to the space of the paint root and the | 108 // Offset from the PaintContext to the space of the paint root and the |
100 // |invalidation_|. | 109 // |invalidation_|. |
101 gfx::Vector2d offset_; | 110 gfx::Vector2d offset_; |
102 | 111 |
| 112 gfx::Size pixel_size_; |
| 113 gfx::Size size_; |
| 114 |
| 115 // The device scale of the frame being painted. Used to determine which bitmap |
| 116 // resources to use in the frame. |
| 117 float device_scale_factor_; |
| 118 |
103 #if DCHECK_IS_ON() | 119 #if DCHECK_IS_ON() |
104 // Used to verify that the |invalidation_| is only used to compare against | 120 // Used to verify that the |invalidation_| is only used to compare against |
105 // rects in the same space. | 121 // rects in the same space. |
106 mutable void* root_visited_; | 122 mutable void* root_visited_; |
107 // Used to verify that paint recorders are not nested. True while a paint | 123 // Used to verify that paint recorders are not nested. True while a paint |
108 // recorder is active. | 124 // recorder is active. |
109 mutable bool inside_paint_recorder_; | 125 mutable bool inside_paint_recorder_; |
110 #endif | 126 #endif |
111 | 127 |
112 DISALLOW_COPY_AND_ASSIGN(PaintContext); | 128 DISALLOW_COPY_AND_ASSIGN(PaintContext); |
113 }; | 129 }; |
114 | 130 |
115 } // namespace ui | 131 } // namespace ui |
116 | 132 |
117 #endif // UI_COMPOSITOR_PAINT_CONTEXT_H_ | 133 #endif // UI_COMPOSITOR_PAINT_CONTEXT_H_ |
OLD | NEW |