forked from crosswalk-project/chromium-crosswalk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tile_priority.cc
102 lines (91 loc) · 3.18 KB
/
tile_priority.cc
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Copyright 2012 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/tiles/tile_priority.h"
#include "base/numerics/safe_conversions.h"
#include "base/trace_event/trace_event_argument.h"
#include "base/values.h"
#include "cc/base/math_util.h"
namespace cc {
std::string WhichTreeToString(WhichTree tree) {
switch (tree) {
case ACTIVE_TREE:
return "ACTIVE_TREE";
case PENDING_TREE:
return "PENDING_TREE";
default:
DCHECK(false) << "Unrecognized WhichTree value " << tree;
return "<unknown WhichTree value>";
}
}
std::string TileResolutionToString(TileResolution resolution) {
switch (resolution) {
case LOW_RESOLUTION:
return "LOW_RESOLUTION";
case HIGH_RESOLUTION:
return "HIGH_RESOLUTION";
case NON_IDEAL_RESOLUTION:
return "NON_IDEAL_RESOLUTION";
}
DCHECK(false) << "Unrecognized TileResolution value " << resolution;
return "<unknown TileResolution value>";
}
std::string TilePriorityBinToString(TilePriority::PriorityBin bin) {
switch (bin) {
case TilePriority::NOW:
return "NOW";
case TilePriority::SOON:
return "SOON";
case TilePriority::EVENTUALLY:
return "EVENTUALLY";
}
DCHECK(false) << "Unrecognized TilePriority::PriorityBin value " << bin;
return "<unknown TilePriority::PriorityBin value>";
}
void TilePriority::AsValueInto(base::trace_event::TracedValue* state) const {
state->SetString("resolution", TileResolutionToString(resolution));
state->SetString("priority_bin", TilePriorityBinToString(priority_bin));
state->SetDouble("distance_to_visible",
MathUtil::AsDoubleSafely(distance_to_visible));
}
std::string TileMemoryLimitPolicyToString(TileMemoryLimitPolicy policy) {
switch (policy) {
case ALLOW_NOTHING:
return "ALLOW_NOTHING";
case ALLOW_ABSOLUTE_MINIMUM:
return "ALLOW_ABSOLUTE_MINIMUM";
case ALLOW_PREPAINT_ONLY:
return "ALLOW_PREPAINT_ONLY";
case ALLOW_ANYTHING:
return "ALLOW_ANYTHING";
default:
DCHECK(false) << "Unrecognized policy value";
return "<unknown>";
}
}
std::string TreePriorityToString(TreePriority prio) {
switch (prio) {
case SAME_PRIORITY_FOR_BOTH_TREES:
return "SAME_PRIORITY_FOR_BOTH_TREES";
case SMOOTHNESS_TAKES_PRIORITY:
return "SMOOTHNESS_TAKES_PRIORITY";
case NEW_CONTENT_TAKES_PRIORITY:
return "NEW_CONTENT_TAKES_PRIORITY";
default:
DCHECK(false) << "Unrecognized priority value " << prio;
return "<unknown>";
}
}
void GlobalStateThatImpactsTilePriority::AsValueInto(
base::trace_event::TracedValue* state) const {
state->SetString("memory_limit_policy",
TileMemoryLimitPolicyToString(memory_limit_policy));
state->SetInteger("soft_memory_limit_in_bytes",
base::saturated_cast<int>(soft_memory_limit_in_bytes));
state->SetInteger("hard_memory_limit_in_bytes",
base::saturated_cast<int>(hard_memory_limit_in_bytes));
state->SetInteger("num_resources_limit",
base::saturated_cast<int>(num_resources_limit));
state->SetString("tree_priority", TreePriorityToString(tree_priority));
}
} // namespace cc