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 11 matching lines...) Expand all Loading... |
22 class CompositingRecorder; | 22 class CompositingRecorder; |
23 class PaintRecorder; | 23 class PaintRecorder; |
24 class TransformRecorder; | 24 class TransformRecorder; |
25 | 25 |
26 class COMPOSITOR_EXPORT PaintContext { | 26 class COMPOSITOR_EXPORT PaintContext { |
27 public: | 27 public: |
28 // Construct a PaintContext that may only re-paint the area in the | 28 // Construct a PaintContext that may only re-paint the area in the |
29 // |invalidation|. | 29 // |invalidation|. |
30 PaintContext(cc::DisplayItemList* list, | 30 PaintContext(cc::DisplayItemList* list, |
31 float device_scale_factor, | 31 float device_scale_factor, |
32 const gfx::Rect& invalidation); | 32 const gfx::Rect& invalidation, |
| 33 bool is_pixel_canvas); |
33 | 34 |
34 // Clone a PaintContext with an additional |offset|. | 35 // Clone a PaintContext with an additional |offset|. |
35 PaintContext(const PaintContext& other, const gfx::Vector2d& offset); | 36 PaintContext(const PaintContext& other, const gfx::Vector2d& offset); |
36 | 37 |
37 // Clone a PaintContext that has no consideration for invalidation. | 38 // Clone a PaintContext that has no consideration for invalidation. |
38 enum CloneWithoutInvalidation { | 39 enum CloneWithoutInvalidation { |
39 CLONE_WITHOUT_INVALIDATION, | 40 CLONE_WITHOUT_INVALIDATION, |
40 }; | 41 }; |
41 PaintContext(const PaintContext& other, CloneWithoutInvalidation c); | 42 PaintContext(const PaintContext& other, CloneWithoutInvalidation c); |
42 | 43 |
43 ~PaintContext(); | 44 ~PaintContext(); |
44 | 45 |
45 // When true, IsRectInvalid() can be called, otherwise its result would be | 46 // When true, IsRectInvalid() can be called, otherwise its result would be |
46 // invalid. | 47 // invalid. |
47 bool CanCheckInvalid() const { return !invalidation_.IsEmpty(); } | 48 bool CanCheckInvalid() const { return !invalidation_.IsEmpty(); } |
48 | 49 |
| 50 // The device scale of the frame being painted. |
| 51 float device_scale_factor() const { return device_scale_factor_; } |
| 52 |
| 53 // Returns true if the paint commands are recorded at pixel size instead of |
| 54 // DIP. |
| 55 bool is_pixel_canvas() const { return is_pixel_canvas_; } |
| 56 |
49 // When true, the |bounds| touches an invalidated area, so should be | 57 // When true, the |bounds| touches an invalidated area, so should be |
50 // re-painted. When false, re-painting can be skipped. Bounds should be in | 58 // re-painted. When false, re-painting can be skipped. Bounds should be in |
51 // the local space with offsets up to the painting root in the PaintContext. | 59 // the local space with offsets up to the painting root in the PaintContext. |
52 bool IsRectInvalid(const gfx::Rect& bounds) const { | 60 bool IsRectInvalid(const gfx::Rect& bounds) const { |
53 DCHECK(CanCheckInvalid()); | 61 DCHECK(CanCheckInvalid()); |
54 return invalidation_.Intersects(bounds + offset_); | 62 return invalidation_.Intersects(bounds + offset_); |
55 } | 63 } |
56 | 64 |
57 #if DCHECK_IS_ON() | 65 #if DCHECK_IS_ON() |
58 void Visited(void* visited) const { | 66 void Visited(void* visited) const { |
(...skipping 28 matching lines...) Expand all Loading... |
87 cc::DisplayItemList* list_; | 95 cc::DisplayItemList* list_; |
88 // The device scale of the frame being painted. Used to determine which bitmap | 96 // The device scale of the frame being painted. Used to determine which bitmap |
89 // resources to use in the frame. | 97 // resources to use in the frame. |
90 float device_scale_factor_; | 98 float device_scale_factor_; |
91 // Invalidation in the space of the paint root (ie the space of the layer | 99 // Invalidation in the space of the paint root (ie the space of the layer |
92 // backing the paint taking place). | 100 // backing the paint taking place). |
93 gfx::Rect invalidation_; | 101 gfx::Rect invalidation_; |
94 // Offset from the PaintContext to the space of the paint root and the | 102 // Offset from the PaintContext to the space of the paint root and the |
95 // |invalidation_|. | 103 // |invalidation_|. |
96 gfx::Vector2d offset_; | 104 gfx::Vector2d offset_; |
| 105 // If enabled, the paint commands are recorded at pixel size. |
| 106 const bool is_pixel_canvas_; |
97 | 107 |
98 #if DCHECK_IS_ON() | 108 #if DCHECK_IS_ON() |
99 // Used to verify that the |invalidation_| is only used to compare against | 109 // Used to verify that the |invalidation_| is only used to compare against |
100 // rects in the same space. | 110 // rects in the same space. |
101 mutable void* root_visited_; | 111 mutable void* root_visited_; |
102 // Used to verify that paint recorders are not nested. True while a paint | 112 // Used to verify that paint recorders are not nested. True while a paint |
103 // recorder is active. | 113 // recorder is active. |
104 mutable bool inside_paint_recorder_; | 114 mutable bool inside_paint_recorder_; |
105 #endif | 115 #endif |
106 | 116 |
107 DISALLOW_COPY_AND_ASSIGN(PaintContext); | 117 DISALLOW_COPY_AND_ASSIGN(PaintContext); |
108 }; | 118 }; |
109 | 119 |
110 } // namespace ui | 120 } // namespace ui |
111 | 121 |
112 #endif // UI_COMPOSITOR_PAINT_CONTEXT_H_ | 122 #endif // UI_COMPOSITOR_PAINT_CONTEXT_H_ |
OLD | NEW |