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

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: 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') | cc/resources/tile_manager.cc » ('J')
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);
48 DCHECK(resource_id_); 41 DCHECK(resource_id_);
49 DCHECK(memory_state_ == USING_RELEASABLE_MEMORY || forced_upload_); 42 DCHECK(resource_ || (resource_id_ && forced_upload_));
50 return resource_id_; 43 return (resource_ ? resource_->id() : resource_id_);
51 } 44 }
52 45
53 SkColor get_solid_color() const { 46 SkColor get_solid_color() const {
54 DCHECK(mode_ == SOLID_COLOR_MODE); 47 DCHECK(mode_ == SOLID_COLOR_MODE);
55 48
56 return solid_color_; 49 return solid_color_;
57 } 50 }
58 51
59 bool contents_swizzled() const { 52 bool contents_swizzled() const {
60 return !PlatformColor::SameComponentOrder(resource_format_); 53 return !PlatformColor::SameComponentOrder(resource_format_);
61 } 54 }
62 55
63 bool requires_resource() const { 56 bool requires_resource() const {
64 return mode_ == RESOURCE_MODE || 57 return mode_ == RESOURCE_MODE ||
65 mode_ == PICTURE_PILE_MODE; 58 mode_ == PICTURE_PILE_MODE;
66 } 59 }
67 60
68 size_t GPUMemoryUsageInBytes() const; 61 size_t GPUMemoryUsageInBytes() const;
69 62
63 void SetResourceForTesting(scoped_ptr<ResourcePool::Resource> resource) {
64 resource_ = resource.Pass();
65 resource_id_ = resource_->id();
66 }
67
70 scoped_ptr<ResourcePool::Resource>& GetResourceForTesting() { 68 scoped_ptr<ResourcePool::Resource>& GetResourceForTesting() {
71 return resource_; 69 return resource_;
72 } 70 }
73 71
74 void SetMemoryStateForTesting(TileVersionMemoryState state) {
75 memory_state_ = state;
76 }
77
78 private: 72 private:
79 friend class TileManager; 73 friend class TileManager;
80 friend class Tile; 74 friend class Tile;
81 friend class ManagedTileState; 75 friend class ManagedTileState;
82 76
83 void set_use_resource() { 77 void set_use_resource() {
84 mode_ = RESOURCE_MODE; 78 mode_ = RESOURCE_MODE;
85 if (memory_state_ == NOT_ALLOWED_TO_USE_MEMORY)
86 memory_state_ = CAN_USE_MEMORY;
87 } 79 }
88 80
89 void set_solid_color(const SkColor& color) { 81 void set_solid_color(const SkColor& color) {
90 mode_ = SOLID_COLOR_MODE; 82 mode_ = SOLID_COLOR_MODE;
91 solid_color_ = color; 83 solid_color_ = color;
92 memory_state_ = NOT_ALLOWED_TO_USE_MEMORY;
93 resource_id_ = 0; 84 resource_id_ = 0;
94 } 85 }
95 86
96 void set_rasterize_on_demand() { 87 void set_rasterize_on_demand() {
97 mode_ = PICTURE_PILE_MODE; 88 mode_ = PICTURE_PILE_MODE;
98 memory_state_ = NOT_ALLOWED_TO_USE_MEMORY;
99 resource_id_ = 0; 89 resource_id_ = 0;
100 } 90 }
101 91
102 Mode mode_; 92 Mode mode_;
103 SkColor solid_color_; 93 SkColor solid_color_;
104 94
105 ResourceProvider::ResourceId resource_id_; 95 ResourceProvider::ResourceId resource_id_;
106 scoped_ptr<ResourcePool::Resource> resource_; 96 scoped_ptr<ResourcePool::Resource> resource_;
107 GLenum resource_format_; 97 GLenum resource_format_;
108 TileVersionMemoryState memory_state_;
109 bool forced_upload_; 98 bool forced_upload_;
110 }; 99 };
111 100
112 101
113 ManagedTileState(); 102 ManagedTileState();
114 ~ManagedTileState(); 103 ~ManagedTileState();
115 104
116 scoped_ptr<base::Value> AsValue() const; 105 scoped_ptr<base::Value> AsValue() const;
117 106
118 // Persisted state: valid all the time. 107 // Persisted state: valid all the time.
(...skipping 21 matching lines...) Expand all
140 TileManagerBin gpu_memmgr_stats_bin; 129 TileManagerBin gpu_memmgr_stats_bin;
141 TileResolution resolution; 130 TileResolution resolution;
142 bool required_for_activation; 131 bool required_for_activation;
143 float time_to_needed_in_seconds; 132 float time_to_needed_in_seconds;
144 float distance_to_visible_in_pixels; 133 float distance_to_visible_in_pixels;
145 }; 134 };
146 135
147 } // namespace cc 136 } // namespace cc
148 137
149 #endif // CC_RESOURCES_MANAGED_TILE_STATE_H_ 138 #endif // CC_RESOURCES_MANAGED_TILE_STATE_H_
OLDNEW
« no previous file with comments | « no previous file | cc/resources/managed_tile_state.cc » ('j') | cc/resources/tile_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698