This source file includes following definitions.
- UIPriority
- VisiblePriority
- RenderSurfacePriority
- LingeringPriority
- PriorityFromDistance
- SmallAnimatedLayerMinPriority
- HighestPriority
- LowestPriority
- AllowNothingCutoff
- AllowVisibleOnlyCutoff
- AllowVisibleAndNearbyCutoff
- AllowEverythingCutoff
#include "cc/resources/priority_calculator.h"
#include <algorithm>
#include "ui/gfx/rect.h"
namespace cc {
static const int kNothingPriorityCutoff = -3;
static const int kMostHighPriority = -2;
static const int kUIDrawsToRootSurfacePriority = -1;
static const int kVisibleDrawsToRootSurfacePriority = 0;
static const int kRenderSurfacesPriority = 1;
static const int kUIDoesNotDrawToRootSurfacePriority = 2;
static const int kVisibleDoesNotDrawToRootSurfacePriority = 3;
static const int kVisibleOnlyPriorityCutoff = 4;
static const int kNotVisibleBasePriority = 1000000;
static const int kNotVisibleLimitPriority = 1900000;
static const int kVisibleAndNearbyPriorityCutoff =
kNotVisibleBasePriority + 2000;
static const int kSmallAnimatedLayerPriority = kNotVisibleBasePriority + 512;
static const int kLingeringBasePriority = 2000000;
static const int kLingeringLimitPriority = 2900000;
static const int kMostLowPriority = 3000000;
static const int kEverythingPriorityCutoff = 3000001;
int PriorityCalculator::UIPriority(bool draws_to_root_surface) {
return draws_to_root_surface ? kUIDrawsToRootSurfacePriority
: kUIDoesNotDrawToRootSurfacePriority;
}
int PriorityCalculator::VisiblePriority(bool draws_to_root_surface) {
return draws_to_root_surface ? kVisibleDrawsToRootSurfacePriority
: kVisibleDoesNotDrawToRootSurfacePriority;
}
int PriorityCalculator::RenderSurfacePriority() {
return kRenderSurfacesPriority;
}
int PriorityCalculator::LingeringPriority(int previous_priority) {
return std::min(kLingeringLimitPriority,
std::max(kLingeringBasePriority, previous_priority + 1));
}
int PriorityCalculator::PriorityFromDistance(const gfx::Rect& visible_rect,
const gfx::Rect& texture_rect,
bool draws_to_root_surface) {
int distance = visible_rect.ManhattanInternalDistance(texture_rect);
if (!distance)
return VisiblePriority(draws_to_root_surface);
return std::min(kNotVisibleLimitPriority, kNotVisibleBasePriority + distance);
}
int PriorityCalculator::SmallAnimatedLayerMinPriority() {
return kSmallAnimatedLayerPriority;
}
int PriorityCalculator::HighestPriority() {
return kMostHighPriority;
}
int PriorityCalculator::LowestPriority() {
return kMostLowPriority;
}
int PriorityCalculator::AllowNothingCutoff() {
return kNothingPriorityCutoff;
}
int PriorityCalculator::AllowVisibleOnlyCutoff() {
return kVisibleOnlyPriorityCutoff;
}
int PriorityCalculator::AllowVisibleAndNearbyCutoff() {
return kVisibleAndNearbyPriorityCutoff;
}
int PriorityCalculator::AllowEverythingCutoff() {
return kEverythingPriorityCutoff;
}
}