GPU workaround to simulate Out of Memory errors with large textures
[chromium-blink-merge.git] / cc / resources / tile_priority.cc
blob33dfcbe0dae6a8ec4764a92ea3e300d78617b1cc
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/resources/tile_priority.h"
7 #include "base/trace_event/trace_event_argument.h"
8 #include "base/values.h"
9 #include "cc/base/math_util.h"
11 namespace cc {
13 std::string WhichTreeToString(WhichTree tree) {
14 switch (tree) {
15 case ACTIVE_TREE:
16 return "ACTIVE_TREE";
17 case PENDING_TREE:
18 return "PENDING_TREE";
19 default:
20 DCHECK(false) << "Unrecognized WhichTree value " << tree;
21 return "<unknown WhichTree value>";
25 std::string TileResolutionToString(TileResolution resolution) {
26 switch (resolution) {
27 case LOW_RESOLUTION:
28 return "LOW_RESOLUTION";
29 case HIGH_RESOLUTION:
30 return "HIGH_RESOLUTION";
31 case NON_IDEAL_RESOLUTION:
32 return "NON_IDEAL_RESOLUTION";
34 DCHECK(false) << "Unrecognized TileResolution value " << resolution;
35 return "<unknown TileResolution value>";
38 std::string TilePriorityBinToString(TilePriority::PriorityBin bin) {
39 switch (bin) {
40 case TilePriority::NOW:
41 return "NOW";
42 case TilePriority::SOON:
43 return "SOON";
44 case TilePriority::EVENTUALLY:
45 return "EVENTUALLY";
47 DCHECK(false) << "Unrecognized TilePriority::PriorityBin value " << bin;
48 return "<unknown TilePriority::PriorityBin value>";
51 void TilePriority::AsValueInto(base::trace_event::TracedValue* state) const {
52 state->SetString("resolution", TileResolutionToString(resolution));
53 state->SetString("priority_bin", TilePriorityBinToString(priority_bin));
54 state->SetDouble("distance_to_visible",
55 MathUtil::AsDoubleSafely(distance_to_visible));
58 std::string TileMemoryLimitPolicyToString(TileMemoryLimitPolicy policy) {
59 switch (policy) {
60 case ALLOW_NOTHING:
61 return "ALLOW_NOTHING";
62 case ALLOW_ABSOLUTE_MINIMUM:
63 return "ALLOW_ABSOLUTE_MINIMUM";
64 case ALLOW_PREPAINT_ONLY:
65 return "ALLOW_PREPAINT_ONLY";
66 case ALLOW_ANYTHING:
67 return "ALLOW_ANYTHING";
68 default:
69 DCHECK(false) << "Unrecognized policy value";
70 return "<unknown>";
74 std::string TreePriorityToString(TreePriority prio) {
75 switch (prio) {
76 case SAME_PRIORITY_FOR_BOTH_TREES:
77 return "SAME_PRIORITY_FOR_BOTH_TREES";
78 case SMOOTHNESS_TAKES_PRIORITY:
79 return "SMOOTHNESS_TAKES_PRIORITY";
80 case NEW_CONTENT_TAKES_PRIORITY:
81 return "NEW_CONTENT_TAKES_PRIORITY";
82 default:
83 DCHECK(false) << "Unrecognized priority value " << prio;
84 return "<unknown>";
88 void GlobalStateThatImpactsTilePriority::AsValueInto(
89 base::trace_event::TracedValue* state) const {
90 state->SetString("memory_limit_policy",
91 TileMemoryLimitPolicyToString(memory_limit_policy));
92 state->SetInteger("soft_memory_limit_in_bytes", soft_memory_limit_in_bytes);
93 state->SetInteger("hard_memory_limit_in_bytes", hard_memory_limit_in_bytes);
94 state->SetInteger("num_resources_limit", num_resources_limit);
95 state->SetString("tree_priority", TreePriorityToString(tree_priority));
98 } // namespace cc