| 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 | 8 |
| 9 using namespace std; | 9 using namespace std; |
| 10 | 10 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 int PriorityCalculator::lingeringPriority(int previousPriority) | 60 int PriorityCalculator::lingeringPriority(int previousPriority) |
| 61 { | 61 { |
| 62 // FIXME: We should remove this once we have priorities for all | 62 // FIXME: We should remove this once we have priorities for all |
| 63 // textures (we can't currently calculate distances for | 63 // textures (we can't currently calculate distances for |
| 64 // off-screen textures). | 64 // off-screen textures). |
| 65 return min(lingeringLimitPriority, | 65 return min(lingeringLimitPriority, |
| 66 max(lingeringBasePriority, previousPriority + 1)); | 66 max(lingeringBasePriority, previousPriority + 1)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 namespace { | 69 namespace { |
| 70 int manhattanDistance(const IntRect& a, const IntRect& b) | 70 int manhattanDistance(const gfx::Rect& a, const gfx::Rect& b) |
| 71 { | 71 { |
| 72 IntRect c = unionRect(a, b); | 72 gfx::Rect c = gfx::UnionRects(a, b); |
| 73 int x = max(0, c.width() - a.width() - b.width() + 1); | 73 int x = max(0, c.width() - a.width() - b.width() + 1); |
| 74 int y = max(0, c.height() - a.height() - b.height() + 1); | 74 int y = max(0, c.height() - a.height() - b.height() + 1); |
| 75 return (x + y); | 75 return (x + y); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| 79 // static | 79 // static |
| 80 int PriorityCalculator::priorityFromDistance(const IntRect& visibleRect, const I
ntRect& textureRect, bool drawsToRootSurface) | 80 int PriorityCalculator::priorityFromDistance(const gfx::Rect& visibleRect, const
gfx::Rect& textureRect, bool drawsToRootSurface) |
| 81 { | 81 { |
| 82 int distance = manhattanDistance(visibleRect, textureRect); | 82 int distance = manhattanDistance(visibleRect, textureRect); |
| 83 if (!distance) | 83 if (!distance) |
| 84 return visiblePriority(drawsToRootSurface); | 84 return visiblePriority(drawsToRootSurface); |
| 85 return min(notVisibleLimitPriority, notVisibleBasePriority + distance); | 85 return min(notVisibleLimitPriority, notVisibleBasePriority + distance); |
| 86 } | 86 } |
| 87 | 87 |
| 88 // static | 88 // static |
| 89 int PriorityCalculator::smallAnimatedLayerMinPriority() | 89 int PriorityCalculator::smallAnimatedLayerMinPriority() |
| 90 { | 90 { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 115 return visibleOnlyPriorityCutoff; | 115 return visibleOnlyPriorityCutoff; |
| 116 } | 116 } |
| 117 | 117 |
| 118 // static | 118 // static |
| 119 int PriorityCalculator::allowEverythingCutoff() | 119 int PriorityCalculator::allowEverythingCutoff() |
| 120 { | 120 { |
| 121 return everythingPriorityCutoff; | 121 return everythingPriorityCutoff; |
| 122 } | 122 } |
| 123 | 123 |
| 124 } // cc | 124 } // cc |
| OLD | NEW |