1 // Copyright 2012 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/tiles/tile_priority.h"
7 #include "base/numerics/safe_conversions.h"
8 #include "base/trace_event/trace_event_argument.h"
9 #include "base/values.h"
10 #include "cc/base/math_util.h"
14 std::string
WhichTreeToString(WhichTree tree
) {
19 return "PENDING_TREE";
21 DCHECK(false) << "Unrecognized WhichTree value " << tree
;
22 return "<unknown WhichTree value>";
26 std::string
TileResolutionToString(TileResolution resolution
) {
29 return "LOW_RESOLUTION";
31 return "HIGH_RESOLUTION";
32 case NON_IDEAL_RESOLUTION
:
33 return "NON_IDEAL_RESOLUTION";
35 DCHECK(false) << "Unrecognized TileResolution value " << resolution
;
36 return "<unknown TileResolution value>";
39 std::string
TilePriorityBinToString(TilePriority::PriorityBin bin
) {
41 case TilePriority::NOW
:
43 case TilePriority::SOON
:
45 case TilePriority::EVENTUALLY
:
48 DCHECK(false) << "Unrecognized TilePriority::PriorityBin value " << bin
;
49 return "<unknown TilePriority::PriorityBin value>";
52 void TilePriority::AsValueInto(base::trace_event::TracedValue
* state
) const {
53 state
->SetString("resolution", TileResolutionToString(resolution
));
54 state
->SetString("priority_bin", TilePriorityBinToString(priority_bin
));
55 state
->SetDouble("distance_to_visible",
56 MathUtil::AsDoubleSafely(distance_to_visible
));
59 std::string
TileMemoryLimitPolicyToString(TileMemoryLimitPolicy policy
) {
62 return "ALLOW_NOTHING";
63 case ALLOW_ABSOLUTE_MINIMUM
:
64 return "ALLOW_ABSOLUTE_MINIMUM";
65 case ALLOW_PREPAINT_ONLY
:
66 return "ALLOW_PREPAINT_ONLY";
68 return "ALLOW_ANYTHING";
70 DCHECK(false) << "Unrecognized policy value";
75 std::string
TreePriorityToString(TreePriority prio
) {
77 case SAME_PRIORITY_FOR_BOTH_TREES
:
78 return "SAME_PRIORITY_FOR_BOTH_TREES";
79 case SMOOTHNESS_TAKES_PRIORITY
:
80 return "SMOOTHNESS_TAKES_PRIORITY";
81 case NEW_CONTENT_TAKES_PRIORITY
:
82 return "NEW_CONTENT_TAKES_PRIORITY";
84 DCHECK(false) << "Unrecognized priority value " << prio
;
89 void GlobalStateThatImpactsTilePriority::AsValueInto(
90 base::trace_event::TracedValue
* state
) const {
91 state
->SetString("memory_limit_policy",
92 TileMemoryLimitPolicyToString(memory_limit_policy
));
93 state
->SetInteger("soft_memory_limit_in_bytes",
94 base::saturated_cast
<int>(soft_memory_limit_in_bytes
));
95 state
->SetInteger("hard_memory_limit_in_bytes",
96 base::saturated_cast
<int>(hard_memory_limit_in_bytes
));
97 state
->SetInteger("num_resources_limit",
98 base::saturated_cast
<int>(num_resources_limit
));
99 state
->SetString("tree_priority", TreePriorityToString(tree_priority
));