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

Side by Side Diff: cc/CCPriorityCalculator.cpp

Issue 10917281: Adjust texture priorities in preparation of impl-thread eviction of only some textures (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove spurious .gitmodules Created 8 years, 3 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/TiledLayerChromium.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 6
7 #include "CCPriorityCalculator.h" 7 #include "CCPriorityCalculator.h"
8 8
9 using namespace std; 9 using namespace std;
10 10
11 namespace cc { 11 namespace cc {
12 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
13 // static 31 // static
14 int CCPriorityCalculator::uiPriority(bool drawsToRootSurface) 32 int CCPriorityCalculator::uiPriority(bool drawsToRootSurface)
15 { 33 {
16 return drawsToRootSurface ? -1 : 2; 34 return drawsToRootSurface ? uiDrawsToRootSurfacePriority : uiDoesNotDrawToRo otSurfacePriority;
17 } 35 }
18 36
19 // static 37 // static
20 int CCPriorityCalculator::visiblePriority(bool drawsToRootSurface) 38 int CCPriorityCalculator::visiblePriority(bool drawsToRootSurface)
21 { 39 {
22 return drawsToRootSurface ? 0 : 3; 40 return drawsToRootSurface ? visibleDrawsToRootSurfacePriority : visibleDoesN otDrawToRootSurfacePriority;
23 } 41 }
24 42
25 // static 43 // static
26 int CCPriorityCalculator::renderSurfacePriority() 44 int CCPriorityCalculator::renderSurfacePriority()
27 { 45 {
28 return 1; 46 return renderSurfacesPriority;
29 } 47 }
30 48
31 // static 49 // static
32 int CCPriorityCalculator::lingeringPriority(int previousPriority) 50 int CCPriorityCalculator::lingeringPriority(int previousPriority)
33 { 51 {
34 // FIXME: We should remove this once we have priorities for all 52 // FIXME: We should remove this once we have priorities for all
35 // textures (we can't currently calculate distances for 53 // textures (we can't currently calculate distances for
36 // off-screen textures). 54 // off-screen textures).
37 int lingeringPriority = 1000000; 55 return min(lingeringLimitPriority,
38 return min(numeric_limits<int>::max() - 1, 56 max(lingeringBasePriority, previousPriority + 1));
39 max(lingeringPriority, previousPriority)) + 1;
40 } 57 }
41 58
42 namespace { 59 namespace {
43 unsigned manhattanDistance(const IntRect& a, const IntRect& b) 60 int manhattanDistance(const IntRect& a, const IntRect& b)
44 { 61 {
45 IntRect c = unionRect(a, b); 62 IntRect c = unionRect(a, b);
46 int x = max(0, c.width() - a.width() - b.width() + 1); 63 int x = max(0, c.width() - a.width() - b.width() + 1);
47 int y = max(0, c.height() - a.height() - b.height() + 1); 64 int y = max(0, c.height() - a.height() - b.height() + 1);
48 return (x + y); 65 return (x + y);
49 } 66 }
50 } 67 }
51 68
52 int CCPriorityCalculator::priorityFromDistance(const IntRect& visibleRect, const IntRect& textureRect, bool drawsToRootSurface) const 69 // static
70 int CCPriorityCalculator::priorityFromDistance(const IntRect& visibleRect, const IntRect& textureRect, bool drawsToRootSurface)
53 { 71 {
54 unsigned distance = manhattanDistance(visibleRect, textureRect); 72 int distance = manhattanDistance(visibleRect, textureRect);
55 if (!distance) 73 if (!distance)
56 return visiblePriority(drawsToRootSurface); 74 return visiblePriority(drawsToRootSurface);
57 return visiblePriority(false) + distance; 75 return min(notVisibleLimitPriority, notVisibleBasePriority + distance);
58 } 76 }
59 77
60 int CCPriorityCalculator::priorityFromDistance(unsigned pixels, bool drawsToRoot Surface) const 78 // static
79 int CCPriorityCalculator::smallAnimatedLayerMinPriority()
61 { 80 {
62 if (!pixels) 81 return smallAnimatedLayerPriority;
63 return visiblePriority(drawsToRootSurface);
64 return visiblePriority(false) + pixels;
65 }
66
67 int CCPriorityCalculator::priorityFromVisibility(bool visible, bool drawsToRootS urface) const
68 {
69 return visible ? visiblePriority(drawsToRootSurface) : lowestPriority();
70 } 82 }
71 83
72 } // cc 84 } // cc
OLDNEW
« no previous file with comments | « cc/CCPriorityCalculator.h ('k') | cc/TiledLayerChromium.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698