blob: 45c2b0482fdd77414203a12d8e463c8e0b8f678d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_RESOURCES_TILE_H_
#define CC_RESOURCES_TILE_H_
#include "base/memory/ref_counted.h"
#include "cc/base/ref_counted_managed.h"
#include "cc/resources/raster_source.h"
#include "cc/resources/tile_draw_info.h"
#include "cc/resources/tile_priority.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
namespace cc {
class TileManager;
class CC_EXPORT Tile : public RefCountedManaged<Tile> {
public:
enum TileRasterFlags { USE_PICTURE_ANALYSIS = 1 << 0 };
typedef uint64 Id;
Id id() const {
return id_;
}
RasterSource* raster_source() { return raster_source_.get(); }
const RasterSource* raster_source() const { return raster_source_.get(); }
const TilePriority& priority() const { return priority_; }
void set_priority(const TilePriority& priority) { priority_ = priority; }
// TODO(vmpstr): Move this to the iterators.
void set_is_occluded(bool is_occluded) { is_occluded_ = is_occluded; }
bool is_occluded() const { return is_occluded_; }
// TODO(vmpstr): Move this to the iterators.
bool required_for_activation() const { return required_for_activation_; }
void set_required_for_activation(bool is_required) {
required_for_activation_ = is_required;
}
bool required_for_draw() const { return required_for_draw_; }
void set_required_for_draw(bool is_required) {
required_for_draw_ = is_required;
}
bool use_picture_analysis() const {
return !!(flags_ & USE_PICTURE_ANALYSIS);
}
bool HasResource() const { return draw_info_.has_resource(); }
bool NeedsRaster() const {
return draw_info_.mode() == TileDrawInfo::OOM_MODE ||
!draw_info_.IsReadyToDraw();
}
void AsValueWithPriorityInto(const TilePriority& priority,
base::trace_event::TracedValue* dict) const;
inline bool IsReadyToDraw() const { return draw_info_.IsReadyToDraw(); }
const TileDrawInfo& draw_info() const { return draw_info_; }
TileDrawInfo& draw_info() { return draw_info_; }
float contents_scale() const { return contents_scale_; }
gfx::Rect content_rect() const { return content_rect_; }
int layer_id() const { return layer_id_; }
int source_frame_number() const { return source_frame_number_; }
void set_raster_source(RasterSource* raster_source) {
DCHECK(raster_source->CoversRect(content_rect_, contents_scale_))
<< "Recording rect: "
<< gfx::ScaleToEnclosingRect(content_rect_, 1.f / contents_scale_)
.ToString();
raster_source_ = raster_source;
}
size_t GPUMemoryUsageInBytes() const;
gfx::Size desired_texture_size() const { return desired_texture_size_; }
void set_tiling_index(int i, int j) {
tiling_i_index_ = i;
tiling_j_index_ = j;
}
int tiling_i_index() const { return tiling_i_index_; }
int tiling_j_index() const { return tiling_j_index_; }
private:
friend class TileManager;
friend class PrioritizedTileSet;
friend class FakeTileManager;
friend class BinComparator;
friend class FakePictureLayerImpl;
// Methods called by by tile manager.
Tile(TileManager* tile_manager,
RasterSource* raster_source,
const gfx::Size& desired_texture_size,
const gfx::Rect& content_rect,
float contents_scale,
int layer_id,
int source_frame_number,
int flags);
~Tile();
bool HasRasterTask() const { return !!raster_task_.get(); }
scoped_refptr<RasterSource> raster_source_;
gfx::Size desired_texture_size_;
gfx::Rect content_rect_;
float contents_scale_;
bool is_occluded_;
TilePriority priority_;
TileDrawInfo draw_info_;
int layer_id_;
int source_frame_number_;
int flags_;
int tiling_i_index_;
int tiling_j_index_;
bool required_for_activation_ : 1;
bool required_for_draw_ : 1;
Id id_;
static Id s_next_id_;
unsigned scheduled_priority_;
scoped_refptr<RasterTask> raster_task_;
DISALLOW_COPY_AND_ASSIGN(Tile);
};
} // namespace cc
#endif // CC_RESOURCES_TILE_H_
|