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.
5 #include "cc/resources/managed_tile_state.h"
10 #include "base/debug/trace_event_argument.h"
11 #include "cc/base/math_util.h"
15 std::string
ManagedTileBinToString(ManagedTileBin bin
) {
17 case NOW_AND_READY_TO_DRAW_BIN
:
18 return "NOW_AND_READY_TO_DRAW_BIN";
23 case EVENTUALLY_AND_ACTIVE_BIN
:
24 return "EVENTUALLY_AND_ACTIVE_BIN";
26 return "EVENTUALLY_BIN";
27 case AT_LAST_AND_ACTIVE_BIN
:
28 return "AT_LAST_AND_ACTIVE_BIN";
35 return "Invalid Bin (NUM_BINS)";
37 return "Invalid Bin (UNKNOWN)";
40 ManagedTileState::ManagedTileState()
42 resolution(NON_IDEAL_RESOLUTION
),
43 required_for_activation(false),
44 priority_bin(TilePriority::EVENTUALLY
),
45 distance_to_visible(std::numeric_limits
<float>::infinity()),
46 visible_and_ready_to_draw(false),
47 scheduled_priority(0) {
50 ManagedTileState::DrawInfo::DrawInfo()
51 : mode_(RESOURCE_MODE
), solid_color_(SK_ColorWHITE
) {
54 ManagedTileState::DrawInfo::~DrawInfo() {
58 bool ManagedTileState::DrawInfo::IsReadyToDraw() const {
62 case SOLID_COLOR_MODE
:
63 case PICTURE_PILE_MODE
:
70 ManagedTileState::~ManagedTileState() {}
72 void ManagedTileState::AsValueInto(base::debug::TracedValue
* state
) const {
73 bool has_resource
= (draw_info
.resource_
.get() != 0);
74 bool has_active_task
= (raster_task
.get() != 0);
76 bool is_using_gpu_memory
= has_resource
|| has_active_task
;
78 state
->SetBoolean("has_resource", has_resource
);
79 state
->SetBoolean("is_using_gpu_memory", is_using_gpu_memory
);
80 state
->SetString("bin", ManagedTileBinToString(bin
));
81 state
->SetString("resolution", TileResolutionToString(resolution
));
82 state
->SetString("priority_bin", TilePriorityBinToString(priority_bin
));
83 state
->SetDouble("distance_to_visible",
84 MathUtil::AsFloatSafely(distance_to_visible
));
85 state
->SetBoolean("required_for_activation", required_for_activation
);
86 state
->SetBoolean("is_solid_color",
87 draw_info
.mode_
== DrawInfo::SOLID_COLOR_MODE
);
88 state
->SetBoolean("is_transparent",
89 draw_info
.mode_
== DrawInfo::SOLID_COLOR_MODE
&&
90 !SkColorGetA(draw_info
.solid_color_
));
91 state
->SetInteger("scheduled_priority", scheduled_priority
);