OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/android/resources/resource_manager.h" | 5 #include "ui/android/resources/resource_manager.h" |
6 | 6 |
7 #include "ui/gfx/geometry/insets_f.h" | 7 #include "ui/gfx/geometry/insets_f.h" |
8 | 8 |
9 namespace ui { | 9 namespace ui { |
10 | 10 |
11 ResourceManager::Resource::Resource() { | 11 ResourceManager::Resource::Resource() |
| 12 : tint(0) { |
12 } | 13 } |
13 | 14 |
14 ResourceManager::Resource::~Resource() { | 15 ResourceManager::Resource::~Resource() { |
15 } | 16 } |
16 | 17 |
17 gfx::Rect ResourceManager::Resource::Border(const gfx::Size& bounds) const { | 18 gfx::Rect ResourceManager::Resource::Border(const gfx::Size& bounds) const { |
18 return Border(bounds, gfx::InsetsF(1.f, 1.f, 1.f, 1.f)); | 19 return Border(bounds, gfx::InsetsF(1.f, 1.f, 1.f, 1.f)); |
19 } | 20 } |
20 | 21 |
21 gfx::Rect ResourceManager::Resource::Border(const gfx::Size& bounds, | 22 gfx::Rect ResourceManager::Resource::Border(const gfx::Size& bounds, |
22 const gfx::InsetsF& scale) const { | 23 const gfx::InsetsF& scale) const { |
23 // Calculate whether or not we need to scale down the border if the bounds of | 24 // Calculate whether or not we need to scale down the border if the bounds of |
24 // the layer are going to be smaller than the aperture padding. | 25 // the layer are going to be smaller than the aperture padding. |
25 float x_scale = std::min((float)bounds.width() / size.width(), 1.f); | 26 float x_scale = std::min((float)bounds.width() / size.width(), 1.f); |
26 float y_scale = std::min((float)bounds.height() / size.height(), 1.f); | 27 float y_scale = std::min((float)bounds.height() / size.height(), 1.f); |
27 | 28 |
28 float left_scale = std::min(x_scale * scale.left(), 1.f); | 29 float left_scale = std::min(x_scale * scale.left(), 1.f); |
29 float right_scale = std::min(x_scale * scale.right(), 1.f); | 30 float right_scale = std::min(x_scale * scale.right(), 1.f); |
30 float top_scale = std::min(y_scale * scale.top(), 1.f); | 31 float top_scale = std::min(y_scale * scale.top(), 1.f); |
31 float bottom_scale = std::min(y_scale * scale.bottom(), 1.f); | 32 float bottom_scale = std::min(y_scale * scale.bottom(), 1.f); |
32 | 33 |
33 return gfx::Rect(aperture.x() * left_scale, aperture.y() * top_scale, | 34 return gfx::Rect(aperture.x() * left_scale, aperture.y() * top_scale, |
34 (size.width() - aperture.width()) * right_scale, | 35 (size.width() - aperture.width()) * right_scale, |
35 (size.height() - aperture.height()) * bottom_scale); | 36 (size.height() - aperture.height()) * bottom_scale); |
36 } | 37 } |
37 | 38 |
38 } // namespace ui | 39 } // namespace ui |
OLD | NEW |