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

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

Issue 2877483003: Implements core logic for Pixel Canvas (Closed)
Patch Set: Unittest update Created 3 years, 5 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 <memory> 8 #include <memory>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 11 matching lines...) Expand all
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 float device_scale_factor() const { return device_scale_factor_; }
danakj 2017/07/25 17:58:56 Can you document these accessors?
malaykeshav 2017/07/25 22:57:58 Done
51 bool is_pixel_canvas() const { return is_pixel_canvas_; }
52
49 // When true, the |bounds| touches an invalidated area, so should be 53 // 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 54 // 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. 55 // the local space with offsets up to the painting root in the PaintContext.
52 bool IsRectInvalid(const gfx::Rect& bounds) const { 56 bool IsRectInvalid(const gfx::Rect& bounds) const {
53 DCHECK(CanCheckInvalid()); 57 DCHECK(CanCheckInvalid());
54 return invalidation_.Intersects(bounds + offset_); 58 return invalidation_.Intersects(bounds + offset_);
55 } 59 }
56 60
57 #if DCHECK_IS_ON() 61 #if DCHECK_IS_ON()
58 void Visited(void* visited) const { 62 void Visited(void* visited) const {
(...skipping 28 matching lines...) Expand all
87 cc::DisplayItemList* list_; 91 cc::DisplayItemList* list_;
88 // The device scale of the frame being painted. Used to determine which bitmap 92 // The device scale of the frame being painted. Used to determine which bitmap
89 // resources to use in the frame. 93 // resources to use in the frame.
90 float device_scale_factor_; 94 float device_scale_factor_;
91 // Invalidation in the space of the paint root (ie the space of the layer 95 // Invalidation in the space of the paint root (ie the space of the layer
92 // backing the paint taking place). 96 // backing the paint taking place).
93 gfx::Rect invalidation_; 97 gfx::Rect invalidation_;
94 // Offset from the PaintContext to the space of the paint root and the 98 // Offset from the PaintContext to the space of the paint root and the
95 // |invalidation_|. 99 // |invalidation_|.
96 gfx::Vector2d offset_; 100 gfx::Vector2d offset_;
101 // If enabled, the paint commands are recorded at pixel size.
102 bool is_pixel_canvas_;
danakj 2017/07/25 17:58:56 const
malaykeshav 2017/07/25 22:57:58 Done
97 103
98 #if DCHECK_IS_ON() 104 #if DCHECK_IS_ON()
99 // Used to verify that the |invalidation_| is only used to compare against 105 // Used to verify that the |invalidation_| is only used to compare against
100 // rects in the same space. 106 // rects in the same space.
101 mutable void* root_visited_; 107 mutable void* root_visited_;
102 // Used to verify that paint recorders are not nested. True while a paint 108 // Used to verify that paint recorders are not nested. True while a paint
103 // recorder is active. 109 // recorder is active.
104 mutable bool inside_paint_recorder_; 110 mutable bool inside_paint_recorder_;
105 #endif 111 #endif
106 112
107 DISALLOW_COPY_AND_ASSIGN(PaintContext); 113 DISALLOW_COPY_AND_ASSIGN(PaintContext);
108 }; 114 };
109 115
110 } // namespace ui 116 } // namespace ui
111 117
112 #endif // UI_COMPOSITOR_PAINT_CONTEXT_H_ 118 #endif // UI_COMPOSITOR_PAINT_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698