blob: 20e783e19638504e4b142e7921f56231ecc0d11f (
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
|
// Copyright 2013 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_MANAGED_TILE_STATE_H_
#define CC_MANAGED_TILE_STATE_H_
#include <list>
#include "base/memory/scoped_ptr.h"
#include "cc/resource_pool.h"
#include "cc/resource_provider.h"
#include "cc/tile_manager.h"
namespace cc {
// This is state that is specific to a tile that is
// managed by the TileManager.
class CC_EXPORT ManagedTileState {
public:
class CC_EXPORT DrawingInfo {
public:
enum Mode {
TEXTURE_MODE,
SOLID_COLOR_MODE,
TRANSPARENT_MODE,
PICTURE_PILE_MODE,
NUM_MODES
};
DrawingInfo();
~DrawingInfo();
Mode mode() const {
return mode_;
}
bool IsReadyToDraw() const;
ResourceProvider::ResourceId get_resource_id() const {
DCHECK(mode_ == TEXTURE_MODE);
DCHECK(resource_);
DCHECK(!resource_is_being_initialized_);
return resource_->id();
}
SkColor get_solid_color() const {
DCHECK(mode_ == SOLID_COLOR_MODE);
return solid_color_;
}
bool contents_swizzled() const {
return contents_swizzled_;
}
bool requires_resource() const {
return mode_ == TEXTURE_MODE ||
mode_ == PICTURE_PILE_MODE;
}
scoped_ptr<ResourcePool::Resource>& GetResourceForTesting() {
return resource_;
}
private:
friend class TileManager;
friend class ManagedTileState;
void set_transparent() {
mode_ = TRANSPARENT_MODE;
}
void set_solid_color(const SkColor& color) {
mode_ = SOLID_COLOR_MODE;
solid_color_ = color;
}
Mode mode_;
SkColor solid_color_;
scoped_ptr<ResourcePool::Resource> resource_;
bool resource_is_being_initialized_;
bool can_be_freed_;
bool contents_swizzled_;
};
ManagedTileState();
~ManagedTileState();
scoped_ptr<base::Value> AsValue() const;
// Persisted state: valid all the time.
bool can_use_gpu_memory;
bool need_to_gather_pixel_refs;
std::list<skia::LazyPixelRef*> pending_pixel_refs;
TileRasterState raster_state;
DrawingInfo drawing_info;
PicturePileImpl::Analysis picture_pile_analysis;
bool picture_pile_analyzed;
// Ephemeral state, valid only during TileManager::ManageTiles.
TileManagerBin bin[NUM_BIN_PRIORITIES];
TileManagerBin tree_bin[NUM_TREES];
// The bin that the tile would have if the GPU memory manager had
// a maximally permissive policy, send to the GPU memory manager
// to determine policy.
TileManagerBin gpu_memmgr_stats_bin;
TileResolution resolution;
float time_to_needed_in_seconds;
float distance_to_visible_in_pixels;
};
} // namespace cc
#endif
|