Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / cc / tiles / tile_priority.h
blob184fc2dd181f2370c0a527cb92cad1649d3f187a
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 #ifndef CC_TILES_TILE_PRIORITY_H_
6 #define CC_TILES_TILE_PRIORITY_H_
8 #include <algorithm>
9 #include <limits>
10 #include <string>
12 #include "base/memory/scoped_ptr.h"
13 #include "base/trace_event/trace_event_argument.h"
14 #include "cc/base/cc_export.h"
16 namespace base {
17 class Value;
20 namespace cc {
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.
30 scoped_ptr<base::Value> WhichTreeAsValue(WhichTree tree);
32 enum TileResolution {
33 LOW_RESOLUTION = 0 ,
34 HIGH_RESOLUTION = 1,
35 NON_IDEAL_RESOLUTION = 2,
37 std::string TileResolutionToString(TileResolution resolution);
39 struct CC_EXPORT TilePriority {
40 enum PriorityBin { NOW, SOON, EVENTUALLY };
42 TilePriority()
43 : resolution(NON_IDEAL_RESOLUTION),
44 priority_bin(EVENTUALLY),
45 distance_to_visible(std::numeric_limits<float>::infinity()) {}
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) {}
54 void AsValueInto(base::trace_event::TracedValue* dict) const;
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);
62 TileResolution resolution;
63 PriorityBin priority_bin;
64 float distance_to_visible;
67 std::string TilePriorityBinToString(TilePriority::PriorityBin bin);
69 enum TileMemoryLimitPolicy {
70 // Nothing. This mode is used when visible is set to false.
71 ALLOW_NOTHING = 0,
73 // You might be made visible, but you're not being interacted with.
74 ALLOW_ABSOLUTE_MINIMUM = 1, // Tall.
76 // You're being interacted with, but we're low on memory.
77 ALLOW_PREPAINT_ONLY = 2, // Grande.
79 // You're the only thing in town. Go crazy.
80 ALLOW_ANYTHING = 3 // Venti.
82 std::string TileMemoryLimitPolicyToString(TileMemoryLimitPolicy policy);
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.
91 std::string TreePriorityToString(TreePriority prio);
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) {}
102 TileMemoryLimitPolicy memory_limit_policy;
104 size_t soft_memory_limit_in_bytes;
105 size_t hard_memory_limit_in_bytes;
106 size_t num_resources_limit;
108 TreePriority tree_priority;
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;
117 bool operator!=(const GlobalStateThatImpactsTilePriority& other) const {
118 return !(*this == other);
121 void AsValueInto(base::trace_event::TracedValue* dict) const;
124 } // namespace cc
126 #endif // CC_TILES_TILE_PRIORITY_H_