Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Side by Side Diff: cc/resources/tile_priority.h

Issue 1144693002: cc: Move files out of cc/resources/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: resources: android Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/tile_manager_unittest.cc ('k') | cc/resources/tile_priority.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #ifndef CC_RESOURCES_TILE_PRIORITY_H_
6 #define CC_RESOURCES_TILE_PRIORITY_H_
7
8 #include <algorithm>
9 #include <limits>
10 #include <string>
11
12 #include "base/memory/scoped_ptr.h"
13 #include "base/trace_event/trace_event_argument.h"
14 #include "cc/base/cc_export.h"
15
16 namespace base {
17 class Value;
18 }
19
20 namespace cc {
21
22 enum WhichTree {
23 // Note: these must be 0 and 1 because we index with them in various places,
24 // e.g. in Tile::priority_.
25 ACTIVE_TREE = 0,
26 PENDING_TREE = 1,
27 LAST_TREE = 1
28 // Be sure to update WhichTreeAsValue when adding new fields.
29 };
30 scoped_ptr<base::Value> WhichTreeAsValue(WhichTree tree);
31
32 enum TileResolution {
33 LOW_RESOLUTION = 0 ,
34 HIGH_RESOLUTION = 1,
35 NON_IDEAL_RESOLUTION = 2,
36 };
37 std::string TileResolutionToString(TileResolution resolution);
38
39 struct CC_EXPORT TilePriority {
40 enum PriorityBin { NOW, SOON, EVENTUALLY };
41
42 TilePriority()
43 : resolution(NON_IDEAL_RESOLUTION),
44 priority_bin(EVENTUALLY),
45 distance_to_visible(std::numeric_limits<float>::infinity()) {}
46
47 TilePriority(TileResolution resolution,
48 PriorityBin bin,
49 float distance_to_visible)
50 : resolution(resolution),
51 priority_bin(bin),
52 distance_to_visible(distance_to_visible) {}
53
54 void AsValueInto(base::trace_event::TracedValue* dict) const;
55
56 bool IsHigherPriorityThan(const TilePriority& other) const {
57 return priority_bin < other.priority_bin ||
58 (priority_bin == other.priority_bin &&
59 distance_to_visible < other.distance_to_visible);
60 }
61
62 TileResolution resolution;
63 PriorityBin priority_bin;
64 float distance_to_visible;
65 };
66
67 std::string TilePriorityBinToString(TilePriority::PriorityBin bin);
68
69 enum TileMemoryLimitPolicy {
70 // Nothing. This mode is used when visible is set to false.
71 ALLOW_NOTHING = 0,
72
73 // You might be made visible, but you're not being interacted with.
74 ALLOW_ABSOLUTE_MINIMUM = 1, // Tall.
75
76 // You're being interacted with, but we're low on memory.
77 ALLOW_PREPAINT_ONLY = 2, // Grande.
78
79 // You're the only thing in town. Go crazy.
80 ALLOW_ANYTHING = 3 // Venti.
81 };
82 std::string TileMemoryLimitPolicyToString(TileMemoryLimitPolicy policy);
83
84 enum TreePriority {
85 SAME_PRIORITY_FOR_BOTH_TREES,
86 SMOOTHNESS_TAKES_PRIORITY,
87 NEW_CONTENT_TAKES_PRIORITY,
88 LAST_TREE_PRIORITY = NEW_CONTENT_TAKES_PRIORITY
89 // Be sure to update TreePriorityAsValue when adding new fields.
90 };
91 std::string TreePriorityToString(TreePriority prio);
92
93 class GlobalStateThatImpactsTilePriority {
94 public:
95 GlobalStateThatImpactsTilePriority()
96 : memory_limit_policy(ALLOW_NOTHING),
97 soft_memory_limit_in_bytes(0),
98 hard_memory_limit_in_bytes(0),
99 num_resources_limit(0),
100 tree_priority(SAME_PRIORITY_FOR_BOTH_TREES) {}
101
102 TileMemoryLimitPolicy memory_limit_policy;
103
104 size_t soft_memory_limit_in_bytes;
105 size_t hard_memory_limit_in_bytes;
106 size_t num_resources_limit;
107
108 TreePriority tree_priority;
109
110 bool operator==(const GlobalStateThatImpactsTilePriority& other) const {
111 return memory_limit_policy == other.memory_limit_policy &&
112 soft_memory_limit_in_bytes == other.soft_memory_limit_in_bytes &&
113 hard_memory_limit_in_bytes == other.hard_memory_limit_in_bytes &&
114 num_resources_limit == other.num_resources_limit &&
115 tree_priority == other.tree_priority;
116 }
117 bool operator!=(const GlobalStateThatImpactsTilePriority& other) const {
118 return !(*this == other);
119 }
120
121 void AsValueInto(base::trace_event::TracedValue* dict) const;
122 };
123
124 } // namespace cc
125
126 #endif // CC_RESOURCES_TILE_PRIORITY_H_
OLDNEW
« no previous file with comments | « cc/resources/tile_manager_unittest.cc ('k') | cc/resources/tile_priority.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698