cc: Clean-up of ManageTileState
[chromium-blink-merge.git] / cc / resources / managed_tile_state.cc
bloba60c28af82e2d3a34851d3d6d49948b8314d342b
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"
7 #include <limits>
8 #include <string>
10 #include "base/debug/trace_event_argument.h"
11 #include "cc/base/math_util.h"
13 namespace cc {
15 ManagedTileState::ManagedTileState()
16 : resolution(NON_IDEAL_RESOLUTION),
17 priority_bin(TilePriority::EVENTUALLY),
18 scheduled_priority(0) {
21 ManagedTileState::DrawInfo::DrawInfo()
22 : mode_(RESOURCE_MODE), solid_color_(SK_ColorWHITE) {
25 ManagedTileState::DrawInfo::~DrawInfo() {
26 DCHECK(!resource_);
29 bool ManagedTileState::DrawInfo::IsReadyToDraw() const {
30 switch (mode_) {
31 case RESOURCE_MODE:
32 return !!resource_;
33 case SOLID_COLOR_MODE:
34 case PICTURE_PILE_MODE:
35 return true;
37 NOTREACHED();
38 return false;
41 ManagedTileState::~ManagedTileState() {}
43 void ManagedTileState::AsValueInto(base::debug::TracedValue* state) const {
44 bool has_resource = (draw_info.resource_.get() != 0);
45 bool has_active_task = (raster_task.get() != 0);
47 bool is_using_gpu_memory = has_resource || has_active_task;
49 state->SetBoolean("has_resource", has_resource);
50 state->SetBoolean("is_using_gpu_memory", is_using_gpu_memory);
51 state->SetString("resolution", TileResolutionToString(resolution));
52 state->SetString("priority_bin", TilePriorityBinToString(priority_bin));
53 state->SetBoolean("is_solid_color",
54 draw_info.mode_ == DrawInfo::SOLID_COLOR_MODE);
55 state->SetBoolean("is_transparent",
56 draw_info.mode_ == DrawInfo::SOLID_COLOR_MODE &&
57 !SkColorGetA(draw_info.solid_color_));
58 state->SetInteger("scheduled_priority", scheduled_priority);
61 } // namespace cc