OLD | NEW |
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 "cc/priority_calculator.h" | 7 #include "cc/priority_calculator.h" |
| 8 #include "ui/gfx/rect.h" |
8 | 9 |
9 using namespace std; | 10 using namespace std; |
10 | 11 |
11 namespace cc { | 12 namespace cc { |
12 | 13 |
13 static const int nothingPriorityCutoff = -3; | 14 static const int nothingPriorityCutoff = -3; |
14 | 15 |
15 static const int mostHighPriority = -2; | 16 static const int mostHighPriority = -2; |
16 | 17 |
17 static const int uiDrawsToRootSurfacePriority = -1; | 18 static const int uiDrawsToRootSurfacePriority = -1; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 int PriorityCalculator::lingeringPriority(int previousPriority) | 65 int PriorityCalculator::lingeringPriority(int previousPriority) |
65 { | 66 { |
66 // FIXME: We should remove this once we have priorities for all | 67 // FIXME: We should remove this once we have priorities for all |
67 // textures (we can't currently calculate distances for | 68 // textures (we can't currently calculate distances for |
68 // off-screen textures). | 69 // off-screen textures). |
69 return min(lingeringLimitPriority, | 70 return min(lingeringLimitPriority, |
70 max(lingeringBasePriority, previousPriority + 1)); | 71 max(lingeringBasePriority, previousPriority + 1)); |
71 } | 72 } |
72 | 73 |
73 namespace { | 74 namespace { |
74 int manhattanDistance(const IntRect& a, const IntRect& b) | 75 int manhattanDistance(const gfx::Rect& a, const gfx::Rect& b) |
75 { | 76 { |
76 IntRect c = unionRect(a, b); | 77 gfx::Rect c = gfx::UnionRects(a, b); |
77 int x = max(0, c.width() - a.width() - b.width() + 1); | 78 int x = max(0, c.width() - a.width() - b.width() + 1); |
78 int y = max(0, c.height() - a.height() - b.height() + 1); | 79 int y = max(0, c.height() - a.height() - b.height() + 1); |
79 return (x + y); | 80 return (x + y); |
80 } | 81 } |
81 } | 82 } |
82 | 83 |
83 // static | 84 // static |
84 int PriorityCalculator::priorityFromDistance(const IntRect& visibleRect, const I
ntRect& textureRect, bool drawsToRootSurface) | 85 int PriorityCalculator::priorityFromDistance(const gfx::Rect& visibleRect, const
gfx::Rect& textureRect, bool drawsToRootSurface) |
85 { | 86 { |
86 int distance = manhattanDistance(visibleRect, textureRect); | 87 int distance = manhattanDistance(visibleRect, textureRect); |
87 if (!distance) | 88 if (!distance) |
88 return visiblePriority(drawsToRootSurface); | 89 return visiblePriority(drawsToRootSurface); |
89 return min(notVisibleLimitPriority, notVisibleBasePriority + distance); | 90 return min(notVisibleLimitPriority, notVisibleBasePriority + distance); |
90 } | 91 } |
91 | 92 |
92 // static | 93 // static |
93 int PriorityCalculator::smallAnimatedLayerMinPriority() | 94 int PriorityCalculator::smallAnimatedLayerMinPriority() |
94 { | 95 { |
(...skipping 30 matching lines...) Expand all Loading... |
125 return visibleAndNearbyPriorityCutoff; | 126 return visibleAndNearbyPriorityCutoff; |
126 } | 127 } |
127 | 128 |
128 // static | 129 // static |
129 int PriorityCalculator::allowEverythingCutoff() | 130 int PriorityCalculator::allowEverythingCutoff() |
130 { | 131 { |
131 return everythingPriorityCutoff; | 132 return everythingPriorityCutoff; |
132 } | 133 } |
133 | 134 |
134 } // cc | 135 } // cc |
OLD | NEW |