Supervised user import: Listen for profile creation/deletion
[chromium-blink-merge.git] / cc / resources / tile.h
blob45c2b0482fdd77414203a12d8e463c8e0b8f678d
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_RESOURCES_TILE_H_
6 #define CC_RESOURCES_TILE_H_
8 #include "base/memory/ref_counted.h"
9 #include "cc/base/ref_counted_managed.h"
10 #include "cc/resources/raster_source.h"
11 #include "cc/resources/tile_draw_info.h"
12 #include "cc/resources/tile_priority.h"
13 #include "ui/gfx/geometry/rect.h"
14 #include "ui/gfx/geometry/size.h"
16 namespace cc {
18 class TileManager;
20 class CC_EXPORT Tile : public RefCountedManaged<Tile> {
21 public:
22 enum TileRasterFlags { USE_PICTURE_ANALYSIS = 1 << 0 };
24 typedef uint64 Id;
26 Id id() const {
27 return id_;
30 RasterSource* raster_source() { return raster_source_.get(); }
32 const RasterSource* raster_source() const { return raster_source_.get(); }
34 const TilePriority& priority() const { return priority_; }
36 void set_priority(const TilePriority& priority) { priority_ = priority; }
38 // TODO(vmpstr): Move this to the iterators.
39 void set_is_occluded(bool is_occluded) { is_occluded_ = is_occluded; }
40 bool is_occluded() const { return is_occluded_; }
42 // TODO(vmpstr): Move this to the iterators.
43 bool required_for_activation() const { return required_for_activation_; }
44 void set_required_for_activation(bool is_required) {
45 required_for_activation_ = is_required;
47 bool required_for_draw() const { return required_for_draw_; }
48 void set_required_for_draw(bool is_required) {
49 required_for_draw_ = is_required;
52 bool use_picture_analysis() const {
53 return !!(flags_ & USE_PICTURE_ANALYSIS);
56 bool HasResource() const { return draw_info_.has_resource(); }
57 bool NeedsRaster() const {
58 return draw_info_.mode() == TileDrawInfo::OOM_MODE ||
59 !draw_info_.IsReadyToDraw();
62 void AsValueWithPriorityInto(const TilePriority& priority,
63 base::trace_event::TracedValue* dict) const;
65 inline bool IsReadyToDraw() const { return draw_info_.IsReadyToDraw(); }
67 const TileDrawInfo& draw_info() const { return draw_info_; }
69 TileDrawInfo& draw_info() { return draw_info_; }
71 float contents_scale() const { return contents_scale_; }
72 gfx::Rect content_rect() const { return content_rect_; }
74 int layer_id() const { return layer_id_; }
76 int source_frame_number() const { return source_frame_number_; }
78 void set_raster_source(RasterSource* raster_source) {
79 DCHECK(raster_source->CoversRect(content_rect_, contents_scale_))
80 << "Recording rect: "
81 << gfx::ScaleToEnclosingRect(content_rect_, 1.f / contents_scale_)
82 .ToString();
83 raster_source_ = raster_source;
86 size_t GPUMemoryUsageInBytes() const;
88 gfx::Size desired_texture_size() const { return desired_texture_size_; }
90 void set_tiling_index(int i, int j) {
91 tiling_i_index_ = i;
92 tiling_j_index_ = j;
94 int tiling_i_index() const { return tiling_i_index_; }
95 int tiling_j_index() const { return tiling_j_index_; }
97 private:
98 friend class TileManager;
99 friend class PrioritizedTileSet;
100 friend class FakeTileManager;
101 friend class BinComparator;
102 friend class FakePictureLayerImpl;
104 // Methods called by by tile manager.
105 Tile(TileManager* tile_manager,
106 RasterSource* raster_source,
107 const gfx::Size& desired_texture_size,
108 const gfx::Rect& content_rect,
109 float contents_scale,
110 int layer_id,
111 int source_frame_number,
112 int flags);
113 ~Tile();
115 bool HasRasterTask() const { return !!raster_task_.get(); }
117 scoped_refptr<RasterSource> raster_source_;
118 gfx::Size desired_texture_size_;
119 gfx::Rect content_rect_;
120 float contents_scale_;
121 bool is_occluded_;
123 TilePriority priority_;
124 TileDrawInfo draw_info_;
126 int layer_id_;
127 int source_frame_number_;
128 int flags_;
129 int tiling_i_index_;
130 int tiling_j_index_;
131 bool required_for_activation_ : 1;
132 bool required_for_draw_ : 1;
134 Id id_;
135 static Id s_next_id_;
137 unsigned scheduled_priority_;
139 scoped_refptr<RasterTask> raster_task_;
141 DISALLOW_COPY_AND_ASSIGN(Tile);
144 } // namespace cc
146 #endif // CC_RESOURCES_TILE_H_