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.
5 #ifndef CC_TILES_TILE_H_
6 #define CC_TILES_TILE_H_
8 #include "base/memory/ref_counted.h"
9 #include "cc/tiles/tile_draw_info.h"
10 #include "ui/gfx/geometry/rect.h"
11 #include "ui/gfx/geometry/size.h"
15 class PrioritizedTile
;
19 class CC_EXPORT Tile
{
21 class CC_EXPORT Deleter
{
23 void operator()(Tile
* tile
) const;
26 enum TileRasterFlags
{ USE_PICTURE_ANALYSIS
= 1 << 0 };
34 // TODO(vmpstr): Move this to the iterators.
35 bool required_for_activation() const { return required_for_activation_
; }
36 void set_required_for_activation(bool is_required
) {
37 required_for_activation_
= is_required
;
39 bool required_for_draw() const { return required_for_draw_
; }
40 void set_required_for_draw(bool is_required
) {
41 required_for_draw_
= is_required
;
44 bool use_picture_analysis() const {
45 return !!(flags_
& USE_PICTURE_ANALYSIS
);
48 void AsValueInto(base::trace_event::TracedValue
* value
) const;
50 const TileDrawInfo
& draw_info() const { return draw_info_
; }
51 TileDrawInfo
& draw_info() { return draw_info_
; }
53 float contents_scale() const { return contents_scale_
; }
54 gfx::Rect
content_rect() const { return content_rect_
; }
56 int layer_id() const { return layer_id_
; }
58 int source_frame_number() const { return source_frame_number_
; }
60 size_t GPUMemoryUsageInBytes() const;
62 gfx::Size
desired_texture_size() const { return desired_texture_size_
; }
64 void set_tiling_index(int i
, int j
) {
68 int tiling_i_index() const { return tiling_i_index_
; }
69 int tiling_j_index() const { return tiling_j_index_
; }
72 friend class TileManager
;
73 friend class FakeTileManager
;
74 friend class FakePictureLayerImpl
;
76 // Methods called by by tile manager.
77 Tile(TileManager
* tile_manager
,
78 const gfx::Size
& desired_texture_size
,
79 const gfx::Rect
& content_rect
,
82 int source_frame_number
,
86 bool HasRasterTask() const { return !!raster_task_
.get(); }
88 TileManager
* tile_manager_
;
89 gfx::Size desired_texture_size_
;
90 gfx::Rect content_rect_
;
91 float contents_scale_
;
93 TileDrawInfo draw_info_
;
96 int source_frame_number_
;
100 bool required_for_activation_
: 1;
101 bool required_for_draw_
: 1;
104 static Id s_next_id_
;
106 unsigned scheduled_priority_
;
108 scoped_refptr
<RasterTask
> raster_task_
;
110 DISALLOW_COPY_AND_ASSIGN(Tile
);
113 using ScopedTilePtr
= scoped_ptr
<Tile
, Tile::Deleter
>;
117 #endif // CC_TILES_TILE_H_