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_RESOURCES_TILE_DRAW_INFO_H_ |
| 6 #define CC_RESOURCES_TILE_DRAW_INFO_H_ |
| 7 |
| 8 #include "base/debug/trace_event_argument.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "cc/resources/platform_color.h" |
| 11 #include "cc/resources/resource_provider.h" |
| 12 #include "cc/resources/scoped_resource.h" |
| 13 #include "cc/resources/tile_task_runner.h" |
| 14 |
| 15 namespace cc { |
| 16 |
| 17 // This class holds all the state relevant to drawing a tile. |
| 18 class CC_EXPORT TileDrawInfo { |
| 19 public: |
| 20 enum Mode { RESOURCE_MODE, SOLID_COLOR_MODE, PICTURE_PILE_MODE }; |
| 21 |
| 22 TileDrawInfo(); |
| 23 ~TileDrawInfo(); |
| 24 |
| 25 Mode mode() const { return mode_; } |
| 26 |
| 27 bool IsReadyToDraw() const; |
| 28 |
| 29 ResourceProvider::ResourceId get_resource_id() const { |
| 30 DCHECK(mode_ == RESOURCE_MODE); |
| 31 DCHECK(resource_); |
| 32 |
| 33 return resource_->id(); |
| 34 } |
| 35 |
| 36 SkColor get_solid_color() const { |
| 37 DCHECK(mode_ == SOLID_COLOR_MODE); |
| 38 |
| 39 return solid_color_; |
| 40 } |
| 41 |
| 42 bool contents_swizzled() const { |
| 43 DCHECK(resource_); |
| 44 return !PlatformColor::SameComponentOrder(resource_->format()); |
| 45 } |
| 46 |
| 47 bool requires_resource() const { |
| 48 return mode_ == RESOURCE_MODE || mode_ == PICTURE_PILE_MODE; |
| 49 } |
| 50 |
| 51 inline bool has_resource() const { return !!resource_; } |
| 52 |
| 53 void SetSolidColorForTesting(SkColor color) { set_solid_color(color); } |
| 54 void SetResourceForTesting(scoped_ptr<ScopedResource> resource) { |
| 55 resource_ = resource.Pass(); |
| 56 } |
| 57 |
| 58 void AsValueInto(base::debug::TracedValue* state) const; |
| 59 |
| 60 private: |
| 61 friend class Tile; |
| 62 friend class TileManager; |
| 63 |
| 64 void set_use_resource() { mode_ = RESOURCE_MODE; } |
| 65 |
| 66 void set_solid_color(const SkColor& color) { |
| 67 mode_ = SOLID_COLOR_MODE; |
| 68 solid_color_ = color; |
| 69 } |
| 70 |
| 71 void set_rasterize_on_demand() { mode_ = PICTURE_PILE_MODE; } |
| 72 |
| 73 Mode mode_; |
| 74 SkColor solid_color_; |
| 75 scoped_ptr<ScopedResource> resource_; |
| 76 }; |
| 77 |
| 78 } // namespace cc |
| 79 |
| 80 #endif // CC_RESOURCES_TILE_DRAW_INFO_H_ |
OLD | NEW |