Upload upstream chromium 76.0.3809.146
[platform/framework/web/chromium-efl.git] / cc / tiles / tile.h
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CC_TILES_TILE_H_
6 #define CC_TILES_TILE_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include "base/memory/ref_counted.h"
12 #include "cc/paint/draw_image.h"
13 #include "cc/raster/tile_task.h"
14 #include "cc/tiles/tile_draw_info.h"
15 #include "ui/gfx/geometry/axis_transform2d.h"
16 #include "ui/gfx/geometry/rect.h"
17 #include "ui/gfx/geometry/size.h"
18
19 namespace cc {
20
21 class PictureLayerTiling;
22 class TileManager;
23
24 class CC_EXPORT Tile {
25  public:
26   class CC_EXPORT CreateInfo {
27    public:
28     const PictureLayerTiling* tiling;
29     int tiling_i_index;
30     int tiling_j_index;
31     gfx::Rect enclosing_layer_rect;
32     gfx::Rect content_rect;
33     gfx::AxisTransform2d raster_transform;
34
35     CreateInfo(const PictureLayerTiling* tiling,
36                int tiling_i_index,
37                int tiling_j_index,
38                const gfx::Rect& enclosing_layer_rect,
39                const gfx::Rect& content_rect,
40                const gfx::AxisTransform2d& raster_transform)
41         : tiling(tiling),
42           tiling_i_index(tiling_i_index),
43           tiling_j_index(tiling_j_index),
44           enclosing_layer_rect(enclosing_layer_rect),
45           content_rect(content_rect),
46           raster_transform(raster_transform) {}
47   };
48
49   enum TileRasterFlags { USE_PICTURE_ANALYSIS = 1 << 0, IS_OPAQUE = 1 << 1 };
50
51   typedef uint64_t Id;
52
53   Tile(const Tile&) = delete;
54   ~Tile();
55
56   Tile& operator=(const Tile&) = delete;
57
58   Id id() const {
59     return id_;
60   }
61
62   // TODO(vmpstr): Move this to the iterators.
63   bool required_for_activation() const { return required_for_activation_; }
64   void set_required_for_activation(bool is_required) {
65     required_for_activation_ = is_required;
66   }
67   bool required_for_draw() const { return required_for_draw_; }
68   void set_required_for_draw(bool is_required) {
69     required_for_draw_ = is_required;
70   }
71
72   bool is_prepaint() const {
73     return !required_for_activation() && !required_for_draw();
74   }
75
76   bool use_picture_analysis() const {
77     return !!(flags_ & USE_PICTURE_ANALYSIS);
78   }
79
80   bool is_opaque() const { return !!(flags_ & IS_OPAQUE); }
81
82   void AsValueInto(base::trace_event::TracedValue* value) const;
83
84   const TileDrawInfo& draw_info() const { return draw_info_; }
85   TileDrawInfo& draw_info() { return draw_info_; }
86
87   float contents_scale_key() const { return raster_transform_.scale(); }
88   const gfx::AxisTransform2d& raster_transform() const {
89     return raster_transform_;
90   }
91   const gfx::Rect& content_rect() const { return content_rect_; }
92   const gfx::Rect& enclosing_layer_rect() const {
93     return enclosing_layer_rect_;
94   }
95
96   int layer_id() const { return layer_id_; }
97
98   int source_frame_number() const { return source_frame_number_; }
99
100   size_t GPUMemoryUsageInBytes() const;
101
102   const gfx::Size& desired_texture_size() const { return content_rect_.size(); }
103
104   int tiling_i_index() const { return tiling_i_index_; }
105   int tiling_j_index() const { return tiling_j_index_; }
106
107   void SetInvalidated(const gfx::Rect& invalid_content_rect,
108                       Id previous_tile_id) {
109     invalidated_content_rect_ = invalid_content_rect;
110     invalidated_id_ = previous_tile_id;
111   }
112
113   Id invalidated_id() const { return invalidated_id_; }
114   const gfx::Rect& invalidated_content_rect() const {
115     return invalidated_content_rect_;
116   }
117
118   bool HasRasterTask() const { return !!raster_task_.get(); }
119
120   void set_solid_color_analysis_performed(bool performed) {
121     is_solid_color_analysis_performed_ = performed;
122   }
123   bool is_solid_color_analysis_performed() const {
124     return is_solid_color_analysis_performed_;
125   }
126   bool can_use_lcd_text() const { return can_use_lcd_text_; }
127
128   bool set_raster_task_scheduled_with_checker_images(bool has_checker_images) {
129     bool previous_value = raster_task_scheduled_with_checker_images_;
130     raster_task_scheduled_with_checker_images_ = has_checker_images;
131     return previous_value;
132   }
133   bool raster_task_scheduled_with_checker_images() const {
134     return raster_task_scheduled_with_checker_images_;
135   }
136
137   const PictureLayerTiling* tiling() const { return tiling_; }
138   void set_tiling(const PictureLayerTiling* tiling) { tiling_ = tiling; }
139
140  private:
141   friend class TileManager;
142   friend class FakeTileManager;
143   friend class FakePictureLayerImpl;
144
145   // Methods called by by tile manager.
146   Tile(TileManager* tile_manager,
147        const CreateInfo& info,
148        int layer_id,
149        int source_frame_number,
150        int flags,
151        bool can_use_lcd_text);
152
153   TileManager* const tile_manager_;
154   const PictureLayerTiling* tiling_;
155   const gfx::Rect content_rect_;
156   const gfx::Rect enclosing_layer_rect_;
157   const gfx::AxisTransform2d raster_transform_;
158
159   TileDrawInfo draw_info_;
160
161   const int layer_id_;
162   const int source_frame_number_;
163   const int flags_;
164   const int tiling_i_index_;
165   const int tiling_j_index_;
166   bool required_for_activation_ : 1;
167   bool required_for_draw_ : 1;
168   bool is_solid_color_analysis_performed_ : 1;
169   const bool can_use_lcd_text_ : 1;
170
171   Id id_;
172
173   // The rect bounding the changes in this Tile vs the previous tile it
174   // replaced.
175   gfx::Rect invalidated_content_rect_;
176   // The |id_| of the Tile that was invalidated and replaced by this tile.
177   Id invalidated_id_;
178
179   unsigned scheduled_priority_;
180
181   // Set to true if there is a raster task scheduled for this tile that will
182   // rasterize a resource with checker images.
183   bool raster_task_scheduled_with_checker_images_ = false;
184   scoped_refptr<TileTask> raster_task_;
185 };
186
187 }  // namespace cc
188
189 #endif  // CC_TILES_TILE_H_