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

Side by Side Diff: ui/gfx/shadow_value.cc

Issue 854713003: More old files deletion. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fix tryjobs? Created 5 years, 11 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/gfx/shadow_value.h ('k') | ui/gfx/shadow_value_unittest.cc » ('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 (c) 2012 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/gfx/shadow_value.h"
6
7 #include <algorithm>
8
9 #include "base/strings/stringprintf.h"
10 #include "ui/gfx/insets.h"
11 #include "ui/gfx/point_conversions.h"
12
13 namespace gfx {
14
15 ShadowValue::ShadowValue()
16 : blur_(0),
17 color_(0) {
18 }
19
20 ShadowValue::ShadowValue(const gfx::Point& offset,
21 double blur,
22 SkColor color)
23 : offset_(offset),
24 blur_(blur),
25 color_(color) {
26 }
27
28 ShadowValue::~ShadowValue() {
29 }
30
31 ShadowValue ShadowValue::Scale(float scale) const {
32 gfx::Point scaled_offset =
33 gfx::ToFlooredPoint(gfx::ScalePoint(offset_, scale));
34 return ShadowValue(scaled_offset, blur_ * scale, color_);
35 }
36
37 std::string ShadowValue::ToString() const {
38 return base::StringPrintf(
39 "(%d,%d),%.2f,rgba(%d,%d,%d,%d)",
40 offset_.x(), offset_.y(),
41 blur_,
42 SkColorGetR(color_),
43 SkColorGetG(color_),
44 SkColorGetB(color_),
45 SkColorGetA(color_));
46 }
47
48 // static
49 Insets ShadowValue::GetMargin(const ShadowValues& shadows) {
50 int left = 0;
51 int top = 0;
52 int right = 0;
53 int bottom = 0;
54
55 for (size_t i = 0; i < shadows.size(); ++i) {
56 const ShadowValue& shadow = shadows[i];
57
58 // Add 0.5 to round up to the next integer.
59 int blur = static_cast<int>(shadow.blur() / 2 + 0.5);
60
61 left = std::max(left, blur - shadow.x());
62 top = std::max(top, blur - shadow.y());
63 right = std::max(right, blur + shadow.x());
64 bottom = std::max(bottom, blur + shadow.y());
65 }
66
67 return Insets(-top, -left, -bottom, -right);
68 }
69
70 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/shadow_value.h ('k') | ui/gfx/shadow_value_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698