Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Side by Side Diff: cc/resources/managed_tile_state.h

Issue 16190002: cc: Add new RasterWorkerPool interface. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/image_raster_worker_pool.cc ('k') | cc/resources/managed_tile_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_RESOURCES_MANAGED_TILE_STATE_H_ 5 #ifndef CC_RESOURCES_MANAGED_TILE_STATE_H_
6 #define CC_RESOURCES_MANAGED_TILE_STATE_H_ 6 #define CC_RESOURCES_MANAGED_TILE_STATE_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "cc/resources/platform_color.h" 9 #include "cc/resources/platform_color.h"
10 #include "cc/resources/raster_worker_pool.h" 10 #include "cc/resources/raster_worker_pool.h"
(...skipping 27 matching lines...) Expand all
38 ~TileVersion(); 38 ~TileVersion();
39 39
40 Mode mode() const { 40 Mode mode() const {
41 return mode_; 41 return mode_;
42 } 42 }
43 43
44 bool IsReadyToDraw() const; 44 bool IsReadyToDraw() const;
45 45
46 ResourceProvider::ResourceId get_resource_id() const { 46 ResourceProvider::ResourceId get_resource_id() const {
47 DCHECK(mode_ == RESOURCE_MODE); 47 DCHECK(mode_ == RESOURCE_MODE);
48 DCHECK(resource_); 48 DCHECK(resource_id_);
49 DCHECK(memory_state_ == USING_RELEASABLE_MEMORY || forced_upload_); 49 DCHECK(memory_state_ == USING_RELEASABLE_MEMORY || forced_upload_);
50 return resource_->id(); 50 return resource_id_;
51 } 51 }
52 52
53 SkColor get_solid_color() const { 53 SkColor get_solid_color() const {
54 DCHECK(mode_ == SOLID_COLOR_MODE); 54 DCHECK(mode_ == SOLID_COLOR_MODE);
55 55
56 return solid_color_; 56 return solid_color_;
57 } 57 }
58 58
59 bool contents_swizzled() const { 59 bool contents_swizzled() const {
60 return !PlatformColor::SameComponentOrder(resource_format_); 60 return !PlatformColor::SameComponentOrder(resource_format_);
61 } 61 }
62 62
63 bool requires_resource() const { 63 bool requires_resource() const {
64 return mode_ == RESOURCE_MODE || 64 return mode_ == RESOURCE_MODE ||
65 mode_ == PICTURE_PILE_MODE; 65 mode_ == PICTURE_PILE_MODE;
66 } 66 }
67 67
68 size_t GPUMemoryUsageInBytes() const; 68 size_t GPUMemoryUsageInBytes() const;
69 69
70 void SetResourceForTesting(scoped_ptr<ResourcePool::Resource> resource) {
71 resource_ = resource.Pass();
72 resource_id_ = resource_->id();
73 }
74
70 scoped_ptr<ResourcePool::Resource>& GetResourceForTesting() { 75 scoped_ptr<ResourcePool::Resource>& GetResourceForTesting() {
71 return resource_; 76 return resource_;
72 } 77 }
73 78
74 void SetMemoryStateForTesting(TileVersionMemoryState state) { 79 void SetMemoryStateForTesting(TileVersionMemoryState state) {
75 memory_state_ = state; 80 memory_state_ = state;
76 } 81 }
77 82
78 private: 83 private:
79 friend class TileManager; 84 friend class TileManager;
80 friend class Tile; 85 friend class Tile;
81 friend class ManagedTileState; 86 friend class ManagedTileState;
82 87
83 void set_use_resource() { 88 void set_use_resource() {
84 mode_ = RESOURCE_MODE; 89 mode_ = RESOURCE_MODE;
85 if (memory_state_ == NOT_ALLOWED_TO_USE_MEMORY) 90 if (memory_state_ == NOT_ALLOWED_TO_USE_MEMORY)
86 memory_state_ = CAN_USE_MEMORY; 91 memory_state_ = CAN_USE_MEMORY;
87 } 92 }
88 93
89 void set_solid_color(const SkColor& color) { 94 void set_solid_color(const SkColor& color) {
90 mode_ = SOLID_COLOR_MODE; 95 mode_ = SOLID_COLOR_MODE;
91 solid_color_ = color; 96 solid_color_ = color;
92 memory_state_ = NOT_ALLOWED_TO_USE_MEMORY; 97 memory_state_ = NOT_ALLOWED_TO_USE_MEMORY;
98 resource_id_ = 0;
93 } 99 }
94 100
95 void set_rasterize_on_demand() { 101 void set_rasterize_on_demand() {
96 mode_ = PICTURE_PILE_MODE; 102 mode_ = PICTURE_PILE_MODE;
97 memory_state_ = NOT_ALLOWED_TO_USE_MEMORY; 103 memory_state_ = NOT_ALLOWED_TO_USE_MEMORY;
104 resource_id_ = 0;
98 } 105 }
99 106
100 Mode mode_; 107 Mode mode_;
101 SkColor solid_color_; 108 SkColor solid_color_;
102 109
110 // TODO(reveman): Eliminate the need for both |resource_id_|
111 // and |resource| by re-factoring the "force upload"
112 // mechanism. crbug.com/245767
113 ResourceProvider::ResourceId resource_id_;
103 scoped_ptr<ResourcePool::Resource> resource_; 114 scoped_ptr<ResourcePool::Resource> resource_;
104 GLenum resource_format_; 115 GLenum resource_format_;
105 TileVersionMemoryState memory_state_; 116 TileVersionMemoryState memory_state_;
106 bool forced_upload_; 117 bool forced_upload_;
107 }; 118 };
108 119
109 120
110 ManagedTileState(); 121 ManagedTileState();
111 ~ManagedTileState(); 122 ~ManagedTileState();
112 123
113 scoped_ptr<base::Value> AsValue() const; 124 scoped_ptr<base::Value> AsValue() const;
114 125
115 // Persisted state: valid all the time. 126 // Persisted state: valid all the time.
116 TileVersion tile_version; 127 TileVersion tile_version;
117 bool picture_pile_analyzed; 128 bool picture_pile_analyzed;
118 PicturePileImpl::Analysis picture_pile_analysis; 129 PicturePileImpl::Analysis picture_pile_analysis;
119 RasterWorkerPool::Task raster_task; 130 RasterWorkerPool::RasterTask raster_task;
120 131
121 // Ephemeral state, valid only during TileManager::ManageTiles. 132 // Ephemeral state, valid only during TileManager::ManageTiles.
122 bool is_in_never_bin_on_both_trees() const { 133 bool is_in_never_bin_on_both_trees() const {
123 return bin[HIGH_PRIORITY_BIN] == NEVER_BIN && 134 return bin[HIGH_PRIORITY_BIN] == NEVER_BIN &&
124 bin[LOW_PRIORITY_BIN] == NEVER_BIN; 135 bin[LOW_PRIORITY_BIN] == NEVER_BIN;
125 } 136 }
126 bool is_in_now_bin_on_either_tree() const { 137 bool is_in_now_bin_on_either_tree() const {
127 return bin[HIGH_PRIORITY_BIN] == NOW_BIN || 138 return bin[HIGH_PRIORITY_BIN] == NOW_BIN ||
128 bin[LOW_PRIORITY_BIN] == NOW_BIN; 139 bin[LOW_PRIORITY_BIN] == NOW_BIN;
129 } 140 }
130 141
131 TileManagerBin bin[NUM_BIN_PRIORITIES]; 142 TileManagerBin bin[NUM_BIN_PRIORITIES];
132 TileManagerBin tree_bin[NUM_TREES]; 143 TileManagerBin tree_bin[NUM_TREES];
133 144
134 // The bin that the tile would have if the GPU memory manager had 145 // The bin that the tile would have if the GPU memory manager had
135 // a maximally permissive policy, send to the GPU memory manager 146 // a maximally permissive policy, send to the GPU memory manager
136 // to determine policy. 147 // to determine policy.
137 TileManagerBin gpu_memmgr_stats_bin; 148 TileManagerBin gpu_memmgr_stats_bin;
138 TileResolution resolution; 149 TileResolution resolution;
139 bool required_for_activation; 150 bool required_for_activation;
140 float time_to_needed_in_seconds; 151 float time_to_needed_in_seconds;
141 float distance_to_visible_in_pixels; 152 float distance_to_visible_in_pixels;
142 }; 153 };
143 154
144 } // namespace cc 155 } // namespace cc
145 156
146 #endif // CC_RESOURCES_MANAGED_TILE_STATE_H_ 157 #endif // CC_RESOURCES_MANAGED_TILE_STATE_H_
OLDNEW
« no previous file with comments | « cc/resources/image_raster_worker_pool.cc ('k') | cc/resources/managed_tile_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698