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 #include "cc/managed_tile_state.h" |
| 6 #include "cc/math_util.h" |
| 7 |
| 8 namespace cc { |
| 9 |
| 10 ManagedTileState::ManagedTileState() |
| 11 : can_use_gpu_memory(false), |
| 12 need_to_gather_pixel_refs(true), |
| 13 gpu_memmgr_stats_bin(NEVER_BIN), |
| 14 raster_state(IDLE_STATE), |
| 15 resolution(NON_IDEAL_RESOLUTION), |
| 16 time_to_needed_in_seconds(std::numeric_limits<float>::infinity()), |
| 17 distance_to_visible_in_pixels(std::numeric_limits<float>::infinity()), |
| 18 picture_pile_analyzed(false) { |
| 19 for (int i = 0; i < NUM_TREES; ++i) { |
| 20 tree_bin[i] = NEVER_BIN; |
| 21 bin[i] = NEVER_BIN; |
| 22 } |
| 23 } |
| 24 |
| 25 ManagedTileState::DrawingInfo::DrawingInfo() |
| 26 : mode_(TEXTURE_MODE), |
| 27 resource_is_being_initialized_(false), |
| 28 can_be_freed_(true), |
| 29 contents_swizzled_(false) { |
| 30 } |
| 31 |
| 32 ManagedTileState::DrawingInfo::~DrawingInfo() { |
| 33 } |
| 34 |
| 35 bool ManagedTileState::DrawingInfo::IsReadyToDraw() const { |
| 36 switch (mode_) { |
| 37 case TEXTURE_MODE: |
| 38 return resource_ && |
| 39 !resource_is_being_initialized_ && |
| 40 resource_->id(); |
| 41 case SOLID_COLOR_MODE: |
| 42 case TRANSPARENT_MODE: |
| 43 case PICTURE_PILE_MODE: |
| 44 return true; |
| 45 default: |
| 46 NOTREACHED(); |
| 47 return false; |
| 48 } |
| 49 } |
| 50 |
| 51 ManagedTileState::~ManagedTileState() { |
| 52 DCHECK(!drawing_info.resource_); |
| 53 DCHECK(!drawing_info.resource_is_being_initialized_); |
| 54 } |
| 55 |
| 56 scoped_ptr<base::Value> ManagedTileState::AsValue() const { |
| 57 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 58 state->SetBoolean("can_use_gpu_memory", can_use_gpu_memory); |
| 59 state->SetBoolean("can_be_freed", drawing_info.can_be_freed_); |
| 60 state->SetBoolean("has_resource", drawing_info.resource_.get() != 0); |
| 61 state->SetBoolean("resource_is_being_initialized", |
| 62 drawing_info.resource_is_being_initialized_); |
| 63 state->Set("raster_state", TileRasterStateAsValue(raster_state).release()); |
| 64 state->Set("bin.0", TileManagerBinAsValue(bin[ACTIVE_TREE]).release()); |
| 65 state->Set("bin.1", TileManagerBinAsValue(bin[PENDING_TREE]).release()); |
| 66 state->Set("gpu_memmgr_stats_bin", |
| 67 TileManagerBinAsValue(bin[ACTIVE_TREE]).release()); |
| 68 state->Set("resolution", TileResolutionAsValue(resolution).release()); |
| 69 state->Set("time_to_needed_in_seconds", |
| 70 MathUtil::asValueSafely(time_to_needed_in_seconds).release()); |
| 71 state->Set("distance_to_visible_in_pixels", |
| 72 MathUtil::asValueSafely(distance_to_visible_in_pixels).release()); |
| 73 state->SetBoolean("is_picture_pile_analyzed", picture_pile_analyzed); |
| 74 state->SetBoolean("is_cheap_to_raster", |
| 75 picture_pile_analysis.is_cheap_to_raster); |
| 76 state->SetBoolean("is_transparent", picture_pile_analysis.is_transparent); |
| 77 state->SetBoolean("is_solid_color", picture_pile_analysis.is_solid_color); |
| 78 return state.PassAs<base::Value>(); |
| 79 } |
| 80 |
| 81 } // namespace cc |
| 82 |
OLD | NEW |