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

Side by Side Diff: ui/android/resources/resource_manager.cc

Issue 2746483003: ui/android: Fix Resource meta-data sharing with ResourceManager. (Closed)
Patch Set: jni Created 3 years, 9 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
« no previous file with comments | « ui/android/resources/resource_manager.h ('k') | ui/android/resources/resource_manager_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "ui/android/resources/resource_manager.h"
6
7 #include "base/trace_event/memory_usage_estimator.h"
8 #include "ui/gfx/geometry/insets_f.h"
9
10 namespace ui {
11
12 ResourceManager::Resource::Resource() {
13 }
14
15 ResourceManager::Resource::~Resource() {
16 }
17
18 gfx::Rect ResourceManager::Resource::Border(const gfx::Size& bounds) const {
19 return Border(bounds, gfx::InsetsF(1.f, 1.f, 1.f, 1.f));
20 }
21
22 gfx::Rect ResourceManager::Resource::Border(const gfx::Size& bounds,
23 const gfx::InsetsF& scale) const {
24 // Calculate whether or not we need to scale down the border if the bounds of
25 // the layer are going to be smaller than the aperture padding.
26 float x_scale = std::min((float)bounds.width() / size.width(), 1.f);
27 float y_scale = std::min((float)bounds.height() / size.height(), 1.f);
28
29 float left_scale = std::min(x_scale * scale.left(), 1.f);
30 float right_scale = std::min(x_scale * scale.right(), 1.f);
31 float top_scale = std::min(y_scale * scale.top(), 1.f);
32 float bottom_scale = std::min(y_scale * scale.bottom(), 1.f);
33
34 return gfx::Rect(aperture.x() * left_scale, aperture.y() * top_scale,
35 (size.width() - aperture.width()) * right_scale,
36 (size.height() - aperture.height()) * bottom_scale);
37 }
38
39 size_t ResourceManager::Resource::EstimateMemoryUsage() const {
40 return base::trace_event::EstimateMemoryUsage(ui_resource);
41 }
42
43 } // namespace ui
OLDNEW
« no previous file with comments | « ui/android/resources/resource_manager.h ('k') | ui/android/resources/resource_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698