Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / android / resources / resource_manager.cc
blob2117572e9040f4ef56fbf92370128479dc5fa530
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
3 // found in the LICENSE file.
5 #include "ui/android/resources/resource_manager.h"
7 #include "ui/gfx/geometry/insets_f.h"
9 namespace ui {
11 ResourceManager::Resource::Resource() {
14 ResourceManager::Resource::~Resource() {
17 gfx::Rect ResourceManager::Resource::Border(const gfx::Size& bounds) const {
18 return Border(bounds, gfx::InsetsF(1.f, 1.f, 1.f, 1.f));
21 gfx::Rect ResourceManager::Resource::Border(const gfx::Size& bounds,
22 const gfx::InsetsF& scale) const {
23 // 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 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);
28 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 top_scale = std::min(y_scale * scale.top(), 1.f);
31 float bottom_scale = std::min(y_scale * scale.bottom(), 1.f);
33 return gfx::Rect(aperture.x() * left_scale, aperture.y() * top_scale,
34 (size.width() - aperture.width()) * right_scale,
35 (size.height() - aperture.height()) * bottom_scale);
38 } // namespace ui