OLD | NEW |
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 <list> | 8 #include <list> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.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 // This is state that is specific to a tile that is | 17 // This is state that is specific to a tile that is |
18 // managed by the TileManager. | 18 // managed by the TileManager. |
19 class CC_EXPORT ManagedTileState { | 19 class CC_EXPORT ManagedTileState { |
20 public: | 20 public: |
21 class CC_EXPORT DrawingInfo { | 21 class CC_EXPORT DrawingInfo { |
22 public: | 22 public: |
23 enum Mode { | 23 enum Mode { |
24 TEXTURE_MODE, | 24 RESOURCE_MODE, |
25 SOLID_COLOR_MODE, | 25 SOLID_COLOR_MODE, |
26 TRANSPARENT_MODE, | 26 TRANSPARENT_MODE, |
27 PICTURE_PILE_MODE, | 27 PICTURE_PILE_MODE, |
28 NUM_MODES | 28 NUM_MODES |
29 }; | 29 }; |
30 | 30 |
31 DrawingInfo(); | 31 DrawingInfo(); |
32 ~DrawingInfo(); | 32 ~DrawingInfo(); |
33 | 33 |
34 Mode mode() const { | 34 Mode mode() const { |
35 return mode_; | 35 return mode_; |
36 } | 36 } |
37 | 37 |
38 bool IsReadyToDraw() const; | 38 bool IsReadyToDraw() const; |
39 | 39 |
40 ResourceProvider::ResourceId get_resource_id() const { | 40 ResourceProvider::ResourceId get_resource_id() const { |
41 DCHECK(mode_ == TEXTURE_MODE); | 41 DCHECK(mode_ == RESOURCE_MODE); |
42 DCHECK(resource_); | 42 DCHECK(resource_); |
43 DCHECK(!resource_is_being_initialized_); | 43 DCHECK(!resource_is_being_initialized_); |
44 return resource_->id(); | 44 return resource_->id(); |
45 } | 45 } |
46 | 46 |
47 SkColor get_solid_color() const { | 47 SkColor get_solid_color() const { |
48 DCHECK(mode_ == SOLID_COLOR_MODE); | 48 DCHECK(mode_ == SOLID_COLOR_MODE); |
49 | 49 |
50 return solid_color_; | 50 return solid_color_; |
51 } | 51 } |
52 | 52 |
53 bool contents_swizzled() const { | 53 bool contents_swizzled() const { |
54 return contents_swizzled_; | 54 return contents_swizzled_; |
55 } | 55 } |
56 | 56 |
57 bool requires_resource() const { | 57 bool requires_resource() const { |
58 return mode_ == TEXTURE_MODE || | 58 return mode_ == RESOURCE_MODE || |
59 mode_ == PICTURE_PILE_MODE; | 59 mode_ == PICTURE_PILE_MODE; |
60 } | 60 } |
61 | 61 |
62 scoped_ptr<ResourcePool::Resource>& GetResourceForTesting() { | 62 scoped_ptr<ResourcePool::Resource>& GetResourceForTesting() { |
63 return resource_; | 63 return resource_; |
64 } | 64 } |
65 | 65 |
66 private: | 66 private: |
67 friend class TileManager; | 67 friend class TileManager; |
68 friend class ManagedTileState; | 68 friend class ManagedTileState; |
69 | 69 |
| 70 void set_use_resource() { |
| 71 mode_ = RESOURCE_MODE; |
| 72 } |
| 73 |
70 void set_transparent() { | 74 void set_transparent() { |
71 mode_ = TRANSPARENT_MODE; | 75 mode_ = TRANSPARENT_MODE; |
72 } | 76 } |
73 | 77 |
74 void set_solid_color(const SkColor& color) { | 78 void set_solid_color(const SkColor& color) { |
75 mode_ = SOLID_COLOR_MODE; | 79 mode_ = SOLID_COLOR_MODE; |
76 solid_color_ = color; | 80 solid_color_ = color; |
77 } | 81 } |
78 | 82 |
| 83 void set_rasterize_on_demand() { |
| 84 mode_ = PICTURE_PILE_MODE; |
| 85 } |
| 86 |
| 87 void set_contents_swizzled(bool contents_swizzled) { |
| 88 contents_swizzled_ = contents_swizzled; |
| 89 } |
| 90 |
79 Mode mode_; | 91 Mode mode_; |
80 SkColor solid_color_; | 92 SkColor solid_color_; |
81 | 93 |
82 scoped_ptr<ResourcePool::Resource> resource_; | 94 scoped_ptr<ResourcePool::Resource> resource_; |
83 bool resource_is_being_initialized_; | 95 bool resource_is_being_initialized_; |
84 bool can_be_freed_; | 96 bool can_be_freed_; |
85 bool contents_swizzled_; | 97 bool contents_swizzled_; |
86 }; | 98 }; |
87 | 99 |
88 | 100 |
(...skipping 19 matching lines...) Expand all Loading... |
108 // to determine policy. | 120 // to determine policy. |
109 TileManagerBin gpu_memmgr_stats_bin; | 121 TileManagerBin gpu_memmgr_stats_bin; |
110 TileResolution resolution; | 122 TileResolution resolution; |
111 float time_to_needed_in_seconds; | 123 float time_to_needed_in_seconds; |
112 float distance_to_visible_in_pixels; | 124 float distance_to_visible_in_pixels; |
113 }; | 125 }; |
114 | 126 |
115 } // namespace cc | 127 } // namespace cc |
116 | 128 |
117 #endif // CC_RESOURCES_MANAGED_TILE_STATE_H_ | 129 #endif // CC_RESOURCES_MANAGED_TILE_STATE_H_ |
OLD | NEW |