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 bool ManagedTileState::DrawingInfo::IsReadyToDraw() const { | |
26 switch(mode_) { | |
reveman
2013/03/12 22:47:02
nit: space between switch and (
| |
27 case TEXTURE_MODE: | |
28 return resource_ && | |
29 !resource_is_being_initialized_ && | |
30 resource_->id(); | |
31 case SOLID_COLOR_MODE: | |
32 case TRANSPARENT_MODE: | |
33 case PICTURE_PILE_MODE: | |
34 return true; | |
35 default: | |
36 NOTREACHED(); | |
37 return false; | |
38 } | |
39 } | |
40 | |
41 ManagedTileState::~ManagedTileState() { | |
42 DCHECK(!drawing_info.resource_); | |
43 DCHECK(!drawing_info.resource_is_being_initialized_); | |
44 } | |
45 | |
46 scoped_ptr<base::Value> ManagedTileState::AsValue() const { | |
47 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | |
48 state->SetBoolean("can_use_gpu_memory", can_use_gpu_memory); | |
49 state->SetBoolean("can_be_freed", drawing_info.can_be_freed_); | |
50 state->SetBoolean("has_resource", drawing_info.resource_.get() != 0); | |
51 state->SetBoolean("resource_is_being_initialized", | |
52 drawing_info.resource_is_being_initialized_); | |
53 state->Set("raster_state", TileRasterStateAsValue(raster_state).release()); | |
54 state->Set("bin.0", TileManagerBinAsValue(bin[ACTIVE_TREE]).release()); | |
55 state->Set("bin.1", TileManagerBinAsValue(bin[PENDING_TREE]).release()); | |
56 state->Set("gpu_memmgr_stats_bin", | |
57 TileManagerBinAsValue(bin[ACTIVE_TREE]).release()); | |
58 state->Set("resolution", TileResolutionAsValue(resolution).release()); | |
59 state->Set("time_to_needed_in_seconds", | |
60 MathUtil::asValueSafely(time_to_needed_in_seconds).release()); | |
61 state->Set("distance_to_visible_in_pixels", | |
62 MathUtil::asValueSafely(distance_to_visible_in_pixels).release()); | |
63 state->SetBoolean("is_picture_pile_analyzed", picture_pile_analyzed); | |
64 state->SetBoolean("is_cheap_to_raster", | |
65 picture_pile_analysis.is_cheap_to_raster); | |
66 state->SetBoolean("is_transparent", picture_pile_analysis.is_transparent); | |
67 state->SetBoolean("is_solid_color", picture_pile_analysis.is_solid_color); | |
68 return state.PassAs<base::Value>(); | |
69 } | |
70 | |
71 } // namespace cc | |
72 | |
OLD | NEW |