| 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_TILES_TILE_DRAW_INFO_H_ | 5 #ifndef CC_TILES_TILE_DRAW_INFO_H_ |
| 6 #define CC_TILES_TILE_DRAW_INFO_H_ | 6 #define CC_TILES_TILE_DRAW_INFO_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/trace_event/trace_event_argument.h" | 10 #include "base/trace_event/trace_event_argument.h" |
| 11 #include "cc/resources/platform_color.h" | 11 #include "cc/resources/platform_color.h" |
| 12 #include "cc/resources/resource_provider.h" | 12 #include "cc/resources/resource_provider.h" |
| 13 #include "cc/resources/scoped_resource.h" | 13 #include "cc/resources/scoped_resource.h" |
| 14 | 14 |
| 15 namespace cc { | 15 namespace cc { |
| 16 | 16 |
| 17 // This class holds all the state relevant to drawing a tile. | 17 // This class holds all the state relevant to drawing a tile. |
| 18 class CC_EXPORT TileDrawInfo { | 18 class CC_EXPORT TileDrawInfo { |
| 19 public: | 19 public: |
| 20 enum Mode { RESOURCE_MODE, SOLID_COLOR_MODE, OOM_MODE }; | 20 enum Mode { RESOURCE_MODE, SOLID_COLOR_MODE, OOM_MODE }; |
| 21 | 21 |
| 22 TileDrawInfo(); | 22 TileDrawInfo(); |
| 23 ~TileDrawInfo(); | 23 ~TileDrawInfo(); |
| 24 | 24 |
| 25 Mode mode() const { return mode_; } | 25 Mode mode() const { return mode_; } |
| 26 | 26 |
| 27 bool IsReadyToDraw() const { | 27 bool IsReadyToDraw() const { |
| 28 switch (mode_) { | 28 switch (mode_) { |
| 29 case RESOURCE_MODE: | 29 case RESOURCE_MODE: |
| 30 return !!resource_; | 30 return is_resource_ready_to_draw_; |
| 31 case SOLID_COLOR_MODE: | 31 case SOLID_COLOR_MODE: |
| 32 case OOM_MODE: | 32 case OOM_MODE: |
| 33 return true; | 33 return true; |
| 34 } | 34 } |
| 35 NOTREACHED(); | 35 NOTREACHED(); |
| 36 return false; | 36 return false; |
| 37 } | 37 } |
| 38 bool NeedsRaster() const { | 38 bool NeedsRaster() const { |
| 39 switch (mode_) { | 39 switch (mode_) { |
| 40 case RESOURCE_MODE: | 40 case RESOURCE_MODE: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 inline bool has_resource() const { return !!resource_; } | 74 inline bool has_resource() const { return !!resource_; } |
| 75 | 75 |
| 76 inline bool has_compressed_resource() const { | 76 inline bool has_compressed_resource() const { |
| 77 return resource_ ? IsResourceFormatCompressed(resource_->format()) : false; | 77 return resource_ ? IsResourceFormatCompressed(resource_->format()) : false; |
| 78 } | 78 } |
| 79 | 79 |
| 80 void SetSolidColorForTesting(SkColor color) { set_solid_color(color); } | 80 void SetSolidColorForTesting(SkColor color) { set_solid_color(color); } |
| 81 | 81 |
| 82 void AsValueInto(base::trace_event::TracedValue* state) const; | 82 void AsValueInto(base::trace_event::TracedValue* state) const; |
| 83 | 83 |
| 84 void set_was_ever_ready_to_draw() { was_ever_ready_to_draw_ = true; } | |
| 85 void set_was_ever_used_to_draw() { was_ever_used_to_draw_ = true; } | 84 void set_was_ever_used_to_draw() { was_ever_used_to_draw_ = true; } |
| 86 void set_was_a_prepaint_tile() { was_a_prepaint_tile_ = true; } | 85 void set_was_a_prepaint_tile() { was_a_prepaint_tile_ = true; } |
| 87 | 86 |
| 88 private: | 87 private: |
| 89 friend class Tile; | 88 friend class Tile; |
| 90 friend class TileManager; | 89 friend class TileManager; |
| 91 | 90 |
| 92 void set_use_resource() { mode_ = RESOURCE_MODE; } | 91 const Resource* resource() const { return resource_; } |
| 92 |
| 93 void set_resource(Resource* resource) { |
| 94 mode_ = RESOURCE_MODE; |
| 95 is_resource_ready_to_draw_ = false; |
| 96 resource_ = resource; |
| 97 } |
| 98 |
| 99 void set_resource_ready_for_draw() { |
| 100 is_resource_ready_to_draw_ = true; |
| 101 was_ever_ready_to_draw_ = true; |
| 102 } |
| 103 |
| 104 Resource* TakeResource(); |
| 93 | 105 |
| 94 void set_solid_color(const SkColor& color) { | 106 void set_solid_color(const SkColor& color) { |
| 95 mode_ = SOLID_COLOR_MODE; | 107 mode_ = SOLID_COLOR_MODE; |
| 96 solid_color_ = color; | 108 solid_color_ = color; |
| 109 was_ever_ready_to_draw_ = true; |
| 97 } | 110 } |
| 98 | 111 |
| 99 void set_oom() { mode_ = OOM_MODE; } | 112 void set_oom() { mode_ = OOM_MODE; } |
| 100 | 113 |
| 101 Mode mode_; | 114 Mode mode_ = RESOURCE_MODE; |
| 102 SkColor solid_color_; | 115 SkColor solid_color_ = SK_ColorWHITE; |
| 103 Resource* resource_; | 116 Resource* resource_ = nullptr; |
| 104 bool contents_swizzled_; | 117 bool contents_swizzled_ = false; |
| 118 bool is_resource_ready_to_draw_ = false; |
| 105 | 119 |
| 106 // Used for gathering UMA stats. | 120 // Used for gathering UMA stats. |
| 107 bool was_ever_ready_to_draw_ : 1; | 121 bool was_ever_ready_to_draw_ : 1; |
| 108 bool was_ever_used_to_draw_ : 1; | 122 bool was_ever_used_to_draw_ : 1; |
| 109 bool was_a_prepaint_tile_ : 1; | 123 bool was_a_prepaint_tile_ : 1; |
| 110 }; | 124 }; |
| 111 | 125 |
| 112 } // namespace cc | 126 } // namespace cc |
| 113 | 127 |
| 114 #endif // CC_TILES_TILE_DRAW_INFO_H_ | 128 #endif // CC_TILES_TILE_DRAW_INFO_H_ |
| OLD | NEW |