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