Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: cc/CCPriorityCalculator.cpp

Issue 11122003: [cc] Rename all cc/ filenames to Chromium style (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/CCPriorityCalculator.h ('k') | cc/CCProxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "config.h"
6
7 #include "CCPriorityCalculator.h"
8
9 using namespace std;
10
11 namespace cc {
12
13 static const int uiDrawsToRootSurfacePriority = -1;
14 static const int visibleDrawsToRootSurfacePriority = 0;
15 static const int renderSurfacesPriority = 1;
16 static const int uiDoesNotDrawToRootSurfacePriority = 2;
17 static const int visibleDoesNotDrawToRootSurfacePriority = 3;
18
19 // The lower digits are how far from being visible the texture is,
20 // in pixels.
21 static const int notVisibleBasePriority = 1000000;
22 static const int notVisibleLimitPriority = 1900000;
23
24 // Small animated layers are treated as though they are 512 pixels
25 // from being visible.
26 static const int smallAnimatedLayerPriority = notVisibleBasePriority + 512;
27
28 static const int lingeringBasePriority = 2000000;
29 static const int lingeringLimitPriority = 2900000;
30
31 // static
32 int CCPriorityCalculator::uiPriority(bool drawsToRootSurface)
33 {
34 return drawsToRootSurface ? uiDrawsToRootSurfacePriority : uiDoesNotDrawToRo otSurfacePriority;
35 }
36
37 // static
38 int CCPriorityCalculator::visiblePriority(bool drawsToRootSurface)
39 {
40 return drawsToRootSurface ? visibleDrawsToRootSurfacePriority : visibleDoesN otDrawToRootSurfacePriority;
41 }
42
43 // static
44 int CCPriorityCalculator::renderSurfacePriority()
45 {
46 return renderSurfacesPriority;
47 }
48
49 // static
50 int CCPriorityCalculator::lingeringPriority(int previousPriority)
51 {
52 // FIXME: We should remove this once we have priorities for all
53 // textures (we can't currently calculate distances for
54 // off-screen textures).
55 return min(lingeringLimitPriority,
56 max(lingeringBasePriority, previousPriority + 1));
57 }
58
59 namespace {
60 int manhattanDistance(const IntRect& a, const IntRect& b)
61 {
62 IntRect c = unionRect(a, b);
63 int x = max(0, c.width() - a.width() - b.width() + 1);
64 int y = max(0, c.height() - a.height() - b.height() + 1);
65 return (x + y);
66 }
67 }
68
69 // static
70 int CCPriorityCalculator::priorityFromDistance(const IntRect& visibleRect, const IntRect& textureRect, bool drawsToRootSurface)
71 {
72 int distance = manhattanDistance(visibleRect, textureRect);
73 if (!distance)
74 return visiblePriority(drawsToRootSurface);
75 return min(notVisibleLimitPriority, notVisibleBasePriority + distance);
76 }
77
78 // static
79 int CCPriorityCalculator::smallAnimatedLayerMinPriority()
80 {
81 return smallAnimatedLayerPriority;
82 }
83
84 } // cc
OLDNEW
« no previous file with comments | « cc/CCPriorityCalculator.h ('k') | cc/CCProxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698