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