OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CC_MANAGED_TILE_STATE_H_ |
| 6 #define CC_MANAGED_TILE_STATE_H_ |
| 7 |
| 8 #include <list> |
| 9 |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "cc/resource_pool.h" |
| 12 #include "cc/resource_provider.h" |
| 13 #include "cc/tile_manager.h" |
| 14 |
| 15 namespace cc { |
| 16 |
| 17 // This is state that is specific to a tile that is |
| 18 // managed by the TileManager. |
| 19 class CC_EXPORT ManagedTileState { |
| 20 public: |
| 21 class CC_EXPORT DrawingInfo { |
| 22 public: |
| 23 enum Mode { |
| 24 TEXTURE_MODE, |
| 25 SOLID_COLOR_MODE, |
| 26 TRANSPARENT_MODE, |
| 27 PICTURE_PILE_MODE, |
| 28 NUM_MODES |
| 29 }; |
| 30 |
| 31 DrawingInfo(); |
| 32 ~DrawingInfo(); |
| 33 |
| 34 Mode mode() const { |
| 35 return mode_; |
| 36 } |
| 37 |
| 38 bool IsReadyToDraw() const; |
| 39 |
| 40 ResourceProvider::ResourceId get_resource_id() const { |
| 41 DCHECK(mode_ == TEXTURE_MODE); |
| 42 DCHECK(resource_); |
| 43 DCHECK(!resource_is_being_initialized_); |
| 44 return resource_->id(); |
| 45 } |
| 46 |
| 47 SkColor get_solid_color() const { |
| 48 DCHECK(mode_ == SOLID_COLOR_MODE); |
| 49 |
| 50 return solid_color_; |
| 51 } |
| 52 |
| 53 bool contents_swizzled() const { |
| 54 return contents_swizzled_; |
| 55 } |
| 56 |
| 57 bool requires_resource() const { |
| 58 return mode_ == TEXTURE_MODE || |
| 59 mode_ == PICTURE_PILE_MODE; |
| 60 } |
| 61 |
| 62 scoped_ptr<ResourcePool::Resource>& GetResourceForTesting() { |
| 63 return resource_; |
| 64 } |
| 65 |
| 66 private: |
| 67 friend class TileManager; |
| 68 friend class ManagedTileState; |
| 69 |
| 70 void set_transparent() { |
| 71 mode_ = TRANSPARENT_MODE; |
| 72 } |
| 73 |
| 74 void set_solid_color(const SkColor& color) { |
| 75 mode_ = SOLID_COLOR_MODE; |
| 76 solid_color_ = color; |
| 77 } |
| 78 |
| 79 Mode mode_; |
| 80 SkColor solid_color_; |
| 81 |
| 82 scoped_ptr<ResourcePool::Resource> resource_; |
| 83 bool resource_is_being_initialized_; |
| 84 bool can_be_freed_; |
| 85 bool contents_swizzled_; |
| 86 }; |
| 87 |
| 88 |
| 89 ManagedTileState(); |
| 90 ~ManagedTileState(); |
| 91 scoped_ptr<base::Value> AsValue() const; |
| 92 |
| 93 // Persisted state: valid all the time. |
| 94 bool can_use_gpu_memory; |
| 95 bool need_to_gather_pixel_refs; |
| 96 std::list<skia::LazyPixelRef*> pending_pixel_refs; |
| 97 TileRasterState raster_state; |
| 98 DrawingInfo drawing_info; |
| 99 PicturePileImpl::Analysis picture_pile_analysis; |
| 100 bool picture_pile_analyzed; |
| 101 |
| 102 // Ephemeral state, valid only during TileManager::ManageTiles. |
| 103 TileManagerBin bin[NUM_BIN_PRIORITIES]; |
| 104 TileManagerBin tree_bin[NUM_TREES]; |
| 105 |
| 106 // The bin that the tile would have if the GPU memory manager had |
| 107 // a maximally permissive policy, send to the GPU memory manager |
| 108 // to determine policy. |
| 109 TileManagerBin gpu_memmgr_stats_bin; |
| 110 TileResolution resolution; |
| 111 float time_to_needed_in_seconds; |
| 112 float distance_to_visible_in_pixels; |
| 113 }; |
| 114 |
| 115 } // namespace cc |
| 116 |
| 117 #endif |
OLD | NEW |