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_TILE_PRIORITY_H_
6 #define CC_TILE_PRIORITY_H_
8 #include "base/memory/ref_counted.h"
9 #include "cc/picture_pile.h"
10 #include "ui/gfx/rect.h"
11 #include "ui/gfx/size.h"
16 // Note: these must be 0 and 1 because we index with them in various places,
17 // e.g. in Tile::priority_.
25 NON_IDEAL_RESOLUTION
= 2
30 : resolution(NON_IDEAL_RESOLUTION
),
31 time_to_visible_in_seconds(std::numeric_limits
<float>::max()),
32 time_to_ideal_resolution_in_seconds(std::numeric_limits
<float>::max()),
33 distance_to_visible_in_pixels(std::numeric_limits
<float>::max()) {}
35 TilePriority(const TilePriority
& active
, const TilePriority
& pending
) {
36 if (active
.resolution
== HIGH_RESOLUTION
||
37 pending
.resolution
== HIGH_RESOLUTION
)
38 resolution
= HIGH_RESOLUTION
;
39 else if (active
.resolution
== LOW_RESOLUTION
||
40 pending
.resolution
== LOW_RESOLUTION
)
41 resolution
= LOW_RESOLUTION
;
43 resolution
= NON_IDEAL_RESOLUTION
;
45 time_to_visible_in_seconds
=
46 std::min(active
.time_to_visible_in_seconds
,
47 pending
.time_to_visible_in_seconds
);
48 time_to_ideal_resolution_in_seconds
=
49 std::min(active
.time_to_ideal_resolution_in_seconds
,
50 pending
.time_to_ideal_resolution_in_seconds
);
51 distance_to_visible_in_pixels
=
52 std::min(active
.distance_to_visible_in_pixels
,
53 pending
.distance_to_visible_in_pixels
);
56 float time_to_needed_in_seconds() const {
57 return std::min(time_to_visible_in_seconds
,
58 time_to_ideal_resolution_in_seconds
);
61 TileResolution resolution
;
62 float time_to_visible_in_seconds
;
63 float time_to_ideal_resolution_in_seconds
;
64 float distance_to_visible_in_pixels
;
67 enum TileMemoryLimitPolicy
{
71 // You might be made visible, but you're not being interacted with.
72 ALLOW_ABSOLUTE_MINIMUM
, // Tall.
74 // You're being interacted with, but we're low on memory.
75 ALLOW_PREPAINT_ONLY
, // Grande.
77 // You're the only thing in town. Go crazy.
78 ALLOW_ANYTHING
, // Venti.
81 class GlobalStateThatImpactsTilePriority
{
83 GlobalStateThatImpactsTilePriority()
84 : memory_limit_policy(ALLOW_NOTHING
)
85 , memory_limit_in_bytes(0)
86 , smoothness_takes_priority(false) {
89 TileMemoryLimitPolicy memory_limit_policy
;
91 size_t memory_limit_in_bytes
;
93 // Set when scrolling.
94 bool smoothness_takes_priority
;
99 #endif // CC_TILE_PRIORITY_H_