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

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

Issue 15715031: cc: Remove memory state from tile management (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update 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 | « no previous file | 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"
11 #include "cc/resources/resource_pool.h" 11 #include "cc/resources/resource_pool.h"
12 #include "cc/resources/resource_provider.h" 12 #include "cc/resources/resource_provider.h"
13 #include "cc/resources/tile_manager.h" 13 #include "cc/resources/tile_manager.h"
14 14
15 namespace cc { 15 namespace cc {
16 16
17 enum TileVersionMemoryState {
18 NOT_ALLOWED_TO_USE_MEMORY,
19 CAN_USE_MEMORY,
20 USING_UNRELEASABLE_MEMORY,
21 USING_RELEASABLE_MEMORY
22 };
23
24 // This is state that is specific to a tile that is 17 // This is state that is specific to a tile that is
25 // managed by the TileManager. 18 // managed by the TileManager.
26 class CC_EXPORT ManagedTileState { 19 class CC_EXPORT ManagedTileState {
27 public: 20 public:
28 class CC_EXPORT TileVersion { 21 class CC_EXPORT TileVersion {
29 public: 22 public:
30 enum Mode { 23 enum Mode {
31 RESOURCE_MODE, 24 RESOURCE_MODE,
32 SOLID_COLOR_MODE, 25 SOLID_COLOR_MODE,
33 PICTURE_PILE_MODE, 26 PICTURE_PILE_MODE,
34 NUM_MODES 27 NUM_MODES
35 }; 28 };
36 29
37 TileVersion(); 30 TileVersion();
38 ~TileVersion(); 31 ~TileVersion();
39 32
40 Mode mode() const { 33 Mode mode() const {
41 return mode_; 34 return mode_;
42 } 35 }
43 36
44 bool IsReadyToDraw() const; 37 bool IsReadyToDraw() const;
45 38
46 ResourceProvider::ResourceId get_resource_id() const { 39 ResourceProvider::ResourceId get_resource_id() const {
47 DCHECK(mode_ == RESOURCE_MODE); 40 DCHECK(mode_ == RESOURCE_MODE);
41
42 // We have to have a resource ID here.
48 DCHECK(resource_id_); 43 DCHECK(resource_id_);
49 DCHECK(memory_state_ == USING_RELEASABLE_MEMORY || forced_upload_); 44 // If we have a resource, it implies IDs are equal.
45 DCHECK(!resource_ || (resource_id_ == resource_->id()));
46 // If we don't have a resource, it implies that we're in forced upload.
47 DCHECK(resource_ || (resource_id_ && forced_upload_));
48
50 return resource_id_; 49 return resource_id_;
51 } 50 }
52 51
53 SkColor get_solid_color() const { 52 SkColor get_solid_color() const {
54 DCHECK(mode_ == SOLID_COLOR_MODE); 53 DCHECK(mode_ == SOLID_COLOR_MODE);
55 54
56 return solid_color_; 55 return solid_color_;
57 } 56 }
58 57
59 bool contents_swizzled() const { 58 bool contents_swizzled() const {
60 return !PlatformColor::SameComponentOrder(resource_format_); 59 return !PlatformColor::SameComponentOrder(resource_format_);
61 } 60 }
62 61
63 bool requires_resource() const { 62 bool requires_resource() const {
64 return mode_ == RESOURCE_MODE || 63 return mode_ == RESOURCE_MODE ||
65 mode_ == PICTURE_PILE_MODE; 64 mode_ == PICTURE_PILE_MODE;
66 } 65 }
67 66
68 size_t GPUMemoryUsageInBytes() const; 67 size_t GPUMemoryUsageInBytes() const;
69 68
70 void SetResourceForTesting(scoped_ptr<ResourcePool::Resource> resource) { 69 void SetResourceForTesting(scoped_ptr<ResourcePool::Resource> resource) {
71 resource_ = resource.Pass(); 70 resource_ = resource.Pass();
72 resource_id_ = resource_->id(); 71 resource_id_ = resource_->id();
73 } 72 }
74 73
75 scoped_ptr<ResourcePool::Resource>& GetResourceForTesting() { 74 scoped_ptr<ResourcePool::Resource>& GetResourceForTesting() {
76 return resource_; 75 return resource_;
77 } 76 }
78 77
79 void SetMemoryStateForTesting(TileVersionMemoryState state) {
80 memory_state_ = state;
81 }
82
83 private: 78 private:
84 friend class TileManager; 79 friend class TileManager;
85 friend class Tile; 80 friend class Tile;
86 friend class ManagedTileState; 81 friend class ManagedTileState;
87 82
88 void set_use_resource() { 83 void set_use_resource() {
89 mode_ = RESOURCE_MODE; 84 mode_ = RESOURCE_MODE;
90 if (memory_state_ == NOT_ALLOWED_TO_USE_MEMORY)
91 memory_state_ = CAN_USE_MEMORY;
92 } 85 }
93 86
94 void set_solid_color(const SkColor& color) { 87 void set_solid_color(const SkColor& color) {
95 mode_ = SOLID_COLOR_MODE; 88 mode_ = SOLID_COLOR_MODE;
96 solid_color_ = color; 89 solid_color_ = color;
97 memory_state_ = NOT_ALLOWED_TO_USE_MEMORY;
98 resource_id_ = 0; 90 resource_id_ = 0;
99 } 91 }
100 92
101 void set_rasterize_on_demand() { 93 void set_rasterize_on_demand() {
102 mode_ = PICTURE_PILE_MODE; 94 mode_ = PICTURE_PILE_MODE;
103 memory_state_ = NOT_ALLOWED_TO_USE_MEMORY;
104 resource_id_ = 0; 95 resource_id_ = 0;
105 } 96 }
106 97
107 Mode mode_; 98 Mode mode_;
108 SkColor solid_color_; 99 SkColor solid_color_;
109 100
110 // TODO(reveman): Eliminate the need for both |resource_id_| 101 // TODO(reveman): Eliminate the need for both |resource_id_|
111 // and |resource| by re-factoring the "force upload" 102 // and |resource| by re-factoring the "force upload"
112 // mechanism. crbug.com/245767 103 // mechanism. crbug.com/245767
113 ResourceProvider::ResourceId resource_id_; 104 ResourceProvider::ResourceId resource_id_;
114 scoped_ptr<ResourcePool::Resource> resource_; 105 scoped_ptr<ResourcePool::Resource> resource_;
115 GLenum resource_format_; 106 GLenum resource_format_;
116 TileVersionMemoryState memory_state_;
117 bool forced_upload_; 107 bool forced_upload_;
118 }; 108 };
119 109
120 110
121 ManagedTileState(); 111 ManagedTileState();
122 ~ManagedTileState(); 112 ~ManagedTileState();
123 113
124 scoped_ptr<base::Value> AsValue() const; 114 scoped_ptr<base::Value> AsValue() const;
125 115
126 // Persisted state: valid all the time. 116 // Persisted state: valid all the time.
(...skipping 21 matching lines...) Expand all
148 TileManagerBin gpu_memmgr_stats_bin; 138 TileManagerBin gpu_memmgr_stats_bin;
149 TileResolution resolution; 139 TileResolution resolution;
150 bool required_for_activation; 140 bool required_for_activation;
151 float time_to_needed_in_seconds; 141 float time_to_needed_in_seconds;
152 float distance_to_visible_in_pixels; 142 float distance_to_visible_in_pixels;
153 }; 143 };
154 144
155 } // namespace cc 145 } // namespace cc
156 146
157 #endif // CC_RESOURCES_MANAGED_TILE_STATE_H_ 147 #endif // CC_RESOURCES_MANAGED_TILE_STATE_H_
OLDNEW
« no previous file with comments | « no previous file | cc/resources/managed_tile_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698