#include <algorithm>
#include <limits>
+#include <string>
-#include "base/memory/ref_counted.h"
+#include "base/debug/trace_event_argument.h"
#include "base/memory/scoped_ptr.h"
-#include "cc/resources/picture_pile.h"
-#include "ui/gfx/quad_f.h"
-#include "ui/gfx/rect.h"
-#include "ui/gfx/size.h"
+#include "cc/base/cc_export.h"
namespace base {
class Value;
NUM_TREES = 2
// Be sure to update WhichTreeAsValue when adding new fields.
};
-scoped_ptr<base::Value> WhichTreeAsValue(
- WhichTree tree);
+scoped_ptr<base::Value> WhichTreeAsValue(WhichTree tree);
enum TileResolution {
LOW_RESOLUTION = 0 ,
HIGH_RESOLUTION = 1,
NON_IDEAL_RESOLUTION = 2,
};
-scoped_ptr<base::Value> TileResolutionAsValue(
- TileResolution resolution);
+std::string TileResolutionToString(TileResolution resolution);
struct CC_EXPORT TilePriority {
+ enum PriorityBin { NOW, SOON, EVENTUALLY };
+
TilePriority()
: resolution(NON_IDEAL_RESOLUTION),
- required_for_activation(false),
- time_to_visible_in_seconds(std::numeric_limits<float>::infinity()),
- distance_to_visible_in_pixels(std::numeric_limits<float>::infinity()) {}
+ priority_bin(EVENTUALLY),
+ distance_to_visible(std::numeric_limits<float>::infinity()) {}
TilePriority(TileResolution resolution,
- float time_to_visible_in_seconds,
- float distance_to_visible_in_pixels)
+ PriorityBin bin,
+ float distance_to_visible)
: resolution(resolution),
- required_for_activation(false),
- time_to_visible_in_seconds(time_to_visible_in_seconds),
- distance_to_visible_in_pixels(distance_to_visible_in_pixels) {}
+ priority_bin(bin),
+ distance_to_visible(distance_to_visible) {}
TilePriority(const TilePriority& active, const TilePriority& pending) {
if (active.resolution == HIGH_RESOLUTION ||
else
resolution = NON_IDEAL_RESOLUTION;
- required_for_activation =
- active.required_for_activation || pending.required_for_activation;
-
- time_to_visible_in_seconds =
- std::min(active.time_to_visible_in_seconds,
- pending.time_to_visible_in_seconds);
- distance_to_visible_in_pixels =
- std::min(active.distance_to_visible_in_pixels,
- pending.distance_to_visible_in_pixels);
+ if (active.priority_bin < pending.priority_bin) {
+ priority_bin = active.priority_bin;
+ distance_to_visible = active.distance_to_visible;
+ } else if (active.priority_bin > pending.priority_bin) {
+ priority_bin = pending.priority_bin;
+ distance_to_visible = pending.distance_to_visible;
+ } else {
+ priority_bin = active.priority_bin;
+ distance_to_visible =
+ std::min(active.distance_to_visible, pending.distance_to_visible);
+ }
}
- scoped_ptr<base::Value> AsValue() const;
-
- static inline float manhattanDistance(const gfx::RectF& a,
- const gfx::RectF& b) {
- // Compute the union explicitly.
- gfx::RectF c = gfx::RectF(
- std::min(a.x(), b.x()),
- std::min(a.y(), b.y()),
- std::max(a.right(), b.right()) - std::min(a.x(), b.x()),
- std::max(a.bottom(), b.bottom()) - std::min(a.y(), b.y()));
-
- // Rects touching the edge of the screen should not be considered visible.
- // So we add 1 pixel here to avoid that situation.
- float x = std::max(0.0f, c.width() - a.width() - b.width() + 1.0f);
- float y = std::max(0.0f, c.height() - a.height() - b.height() + 1.0f);
- return (x + y);
- }
-
- // Calculate the time for the |current_bounds| to intersect with the
- // |target_bounds| given its previous location and time delta.
- // This function should work for both scaling and scrolling case.
- static float TimeForBoundsToIntersect(const gfx::RectF& previous_bounds,
- const gfx::RectF& current_bounds,
- float time_delta,
- const gfx::RectF& target_bounds);
+ void AsValueInto(base::debug::TracedValue* dict) const;
bool operator ==(const TilePriority& other) const {
return resolution == other.resolution &&
- time_to_visible_in_seconds == other.time_to_visible_in_seconds &&
- distance_to_visible_in_pixels == other.distance_to_visible_in_pixels &&
- required_for_activation == other.required_for_activation;
+ priority_bin == other.priority_bin &&
+ distance_to_visible == other.distance_to_visible;
}
bool operator !=(const TilePriority& other) const {
return !(*this == other);
}
+ bool IsHigherPriorityThan(const TilePriority& other) const {
+ return priority_bin < other.priority_bin ||
+ (priority_bin == other.priority_bin &&
+ distance_to_visible < other.distance_to_visible);
+ }
+
TileResolution resolution;
- bool required_for_activation;
- float time_to_visible_in_seconds;
- float distance_to_visible_in_pixels;
+ PriorityBin priority_bin;
+ float distance_to_visible;
};
+std::string TilePriorityBinToString(TilePriority::PriorityBin bin);
+
enum TileMemoryLimitPolicy {
- // Nothing.
+ // Nothing. This mode is used when visible is set to false.
ALLOW_NOTHING = 0,
// You might be made visible, but you're not being interacted with.
ALLOW_PREPAINT_ONLY = 2, // Grande.
// You're the only thing in town. Go crazy.
- ALLOW_ANYTHING = 3, // Venti.
-
- NUM_TILE_MEMORY_LIMIT_POLICIES = 4,
-
- // NOTE: Be sure to update TreePriorityAsValue and kBinPolicyMap when adding
- // or reordering fields.
+ ALLOW_ANYTHING = 3 // Venti.
};
-scoped_ptr<base::Value> TileMemoryLimitPolicyAsValue(
- TileMemoryLimitPolicy policy);
+std::string TileMemoryLimitPolicyToString(TileMemoryLimitPolicy policy);
enum TreePriority {
SAME_PRIORITY_FOR_BOTH_TREES,
SMOOTHNESS_TAKES_PRIORITY,
- NEW_CONTENT_TAKES_PRIORITY
-
+ NEW_CONTENT_TAKES_PRIORITY,
+ NUM_TREE_PRIORITIES
// Be sure to update TreePriorityAsValue when adding new fields.
};
-scoped_ptr<base::Value> TreePriorityAsValue(TreePriority prio);
+std::string TreePriorityToString(TreePriority prio);
class GlobalStateThatImpactsTilePriority {
public:
GlobalStateThatImpactsTilePriority()
: memory_limit_policy(ALLOW_NOTHING),
- memory_limit_in_bytes(0),
- unused_memory_limit_in_bytes(0),
+ soft_memory_limit_in_bytes(0),
+ hard_memory_limit_in_bytes(0),
num_resources_limit(0),
tree_priority(SAME_PRIORITY_FOR_BOTH_TREES) {}
TileMemoryLimitPolicy memory_limit_policy;
- size_t memory_limit_in_bytes;
- size_t unused_memory_limit_in_bytes;
+ size_t soft_memory_limit_in_bytes;
+ size_t hard_memory_limit_in_bytes;
size_t num_resources_limit;
TreePriority tree_priority;
bool operator==(const GlobalStateThatImpactsTilePriority& other) const {
- return memory_limit_policy == other.memory_limit_policy
- && memory_limit_in_bytes == other.memory_limit_in_bytes
- && unused_memory_limit_in_bytes == other.unused_memory_limit_in_bytes
- && num_resources_limit == other.num_resources_limit
- && tree_priority == other.tree_priority;
+ return memory_limit_policy == other.memory_limit_policy &&
+ soft_memory_limit_in_bytes == other.soft_memory_limit_in_bytes &&
+ hard_memory_limit_in_bytes == other.hard_memory_limit_in_bytes &&
+ num_resources_limit == other.num_resources_limit &&
+ tree_priority == other.tree_priority;
}
bool operator!=(const GlobalStateThatImpactsTilePriority& other) const {
return !(*this == other);
}
- scoped_ptr<base::Value> AsValue() const;
+ void AsValueInto(base::debug::TracedValue* dict) const;
};
} // namespace cc