blob: 94bbed25c9fae8c3a613d53f54e905c36db22c2c [file] [log] [blame]
[email protected]18134fc2012-11-08 22:42:341// 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
[email protected]ffaa2a632012-11-11 14:47:505#ifndef CC_TILE_PRIORITY_H_
6#define CC_TILE_PRIORITY_H_
[email protected]18134fc2012-11-08 22:42:347
8#include "base/memory/ref_counted.h"
9#include "cc/picture_pile.h"
[email protected]18134fc2012-11-08 22:42:3410#include "ui/gfx/rect.h"
11#include "ui/gfx/size.h"
12
13namespace cc {
14
[email protected]0f0609c2012-11-16 10:00:4715enum TileResolution {
16 LOW_RESOLUTION = 0 ,
17 HIGH_RESOLUTION = 1,
18 NON_IDEAL_RESOLUTION = 2
19};
20
[email protected]18134fc2012-11-08 22:42:3421struct TilePriority {
[email protected]0f0609c2012-11-16 10:00:4722 TilePriority()
23 : resolution(NON_IDEAL_RESOLUTION),
24 time_to_visible_in_seconds(std::numeric_limits<float>::max()),
25 time_to_ideal_resolution_in_seconds(std::numeric_limits<float>::max()),
26 distance_to_visible_in_pixels(std::numeric_limits<float>::max()) {}
[email protected]76858dd382012-11-10 09:38:0727
[email protected]0f0609c2012-11-16 10:00:4728 TilePriority(const TilePriority& active, const TilePriority& pending) {
29 if (active.resolution == HIGH_RESOLUTION ||
30 pending.resolution == HIGH_RESOLUTION)
31 resolution = HIGH_RESOLUTION;
32 else if (active.resolution == LOW_RESOLUTION ||
33 pending.resolution == LOW_RESOLUTION)
34 resolution = LOW_RESOLUTION;
35 else
36 resolution = NON_IDEAL_RESOLUTION;
[email protected]18134fc2012-11-08 22:42:3437
[email protected]0f0609c2012-11-16 10:00:4738 time_to_visible_in_seconds =
39 std::min(active.time_to_visible_in_seconds,
40 pending.time_to_visible_in_seconds);
41 time_to_ideal_resolution_in_seconds =
42 std::min(active.time_to_ideal_resolution_in_seconds,
43 pending.time_to_ideal_resolution_in_seconds);
44 distance_to_visible_in_pixels =
45 std::min(active.distance_to_visible_in_pixels,
46 pending.distance_to_visible_in_pixels);
47 }
[email protected]18134fc2012-11-08 22:42:3448
[email protected]0f0609c2012-11-16 10:00:4749 float time_to_needed_in_seconds() const {
50 return std::min(time_to_visible_in_seconds,
51 time_to_ideal_resolution_in_seconds);
52 }
[email protected]18134fc2012-11-08 22:42:3453
[email protected]0f0609c2012-11-16 10:00:4754 TileResolution resolution;
55 float time_to_visible_in_seconds;
56 float time_to_ideal_resolution_in_seconds;
57 float distance_to_visible_in_pixels;
[email protected]18134fc2012-11-08 22:42:3458};
59
[email protected]76858dd382012-11-10 09:38:0760enum TileMemoryLimitPolicy {
61 // Nothing.
62 ALLOW_NOTHING,
63
[email protected]0f0609c2012-11-16 10:00:4764 // You might be made visible, but you're not being interacted with.
65 ALLOW_ABSOLUTE_MINIMUM, // Tall.
[email protected]76858dd382012-11-10 09:38:0766
[email protected]0f0609c2012-11-16 10:00:4767 // You're being interacted with, but we're low on memory.
68 ALLOW_PREPAINT_ONLY, // Grande.
[email protected]76858dd382012-11-10 09:38:0769
[email protected]0f0609c2012-11-16 10:00:4770 // You're the only thing in town. Go crazy.
71 ALLOW_ANYTHING, // Venti.
[email protected]76858dd382012-11-10 09:38:0772};
73
74class GlobalStateThatImpactsTilePriority {
[email protected]ffaa2a632012-11-11 14:47:5075 public:
[email protected]76858dd382012-11-10 09:38:0776 GlobalStateThatImpactsTilePriority()
77 : memory_limit_policy(ALLOW_NOTHING)
78 , memory_limit_in_bytes(0)
[email protected]0f0609c2012-11-16 10:00:4779 , smoothness_takes_priority(false) {
[email protected]76858dd382012-11-10 09:38:0780 }
81
82 TileMemoryLimitPolicy memory_limit_policy;
83
84 size_t memory_limit_in_bytes;
85
86 // Set when scrolling.
87 bool smoothness_takes_priority;
[email protected]18134fc2012-11-08 22:42:3488};
89
90} // namespace cc
[email protected]ffaa2a632012-11-11 14:47:5091
92#endif // CC_TILE_PRIORITY_H_