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/gfx/nine_image_painter.h" | 5 #include "ui/gfx/nine_image_painter.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 |
7 #include <limits> | 9 #include <limits> |
8 | 10 |
| 11 #include "base/macros.h" |
9 #include "third_party/skia/include/core/SkPaint.h" | 12 #include "third_party/skia/include/core/SkPaint.h" |
10 #include "third_party/skia/include/core/SkRect.h" | 13 #include "third_party/skia/include/core/SkRect.h" |
11 #include "third_party/skia/include/core/SkScalar.h" | 14 #include "third_party/skia/include/core/SkScalar.h" |
12 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
13 #include "ui/gfx/geometry/insets.h" | 16 #include "ui/gfx/geometry/insets.h" |
14 #include "ui/gfx/geometry/rect.h" | 17 #include "ui/gfx/geometry/rect.h" |
15 #include "ui/gfx/geometry/rect_conversions.h" | 18 #include "ui/gfx/geometry/rect_conversions.h" |
16 #include "ui/gfx/geometry/safe_integer_conversions.h" | 19 #include "ui/gfx/geometry/safe_integer_conversions.h" |
17 #include "ui/gfx/image/image_skia_operations.h" | 20 #include "ui/gfx/image/image_skia_operations.h" |
18 #include "ui/gfx/scoped_canvas.h" | 21 #include "ui/gfx/scoped_canvas.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 } | 75 } |
73 | 76 |
74 Size NineImagePainter::GetMinimumSize() const { | 77 Size NineImagePainter::GetMinimumSize() const { |
75 return IsEmpty() ? Size() : Size( | 78 return IsEmpty() ? Size() : Size( |
76 images_[0].width() + images_[1].width() + images_[2].width(), | 79 images_[0].width() + images_[1].width() + images_[2].width(), |
77 images_[0].height() + images_[3].height() + images_[6].height()); | 80 images_[0].height() + images_[3].height() + images_[6].height()); |
78 } | 81 } |
79 | 82 |
80 void NineImagePainter::Paint(Canvas* canvas, const Rect& bounds) { | 83 void NineImagePainter::Paint(Canvas* canvas, const Rect& bounds) { |
81 // When no alpha value is specified, use default value of 100% opacity. | 84 // When no alpha value is specified, use default value of 100% opacity. |
82 Paint(canvas, bounds, std::numeric_limits<uint8>::max()); | 85 Paint(canvas, bounds, std::numeric_limits<uint8_t>::max()); |
83 } | 86 } |
84 | 87 |
85 void NineImagePainter::Paint(Canvas* canvas, | 88 void NineImagePainter::Paint(Canvas* canvas, |
86 const Rect& bounds, | 89 const Rect& bounds, |
87 const uint8 alpha) { | 90 const uint8_t alpha) { |
88 if (IsEmpty()) | 91 if (IsEmpty()) |
89 return; | 92 return; |
90 | 93 |
91 ScopedCanvas scoped_canvas(canvas); | 94 ScopedCanvas scoped_canvas(canvas); |
92 | 95 |
93 // Painting and doing layout at physical device pixels to avoid cracks or | 96 // Painting and doing layout at physical device pixels to avoid cracks or |
94 // overlap. | 97 // overlap. |
95 const float scale = canvas->UndoDeviceScaleFactor(); | 98 const float scale = canvas->UndoDeviceScaleFactor(); |
96 | 99 |
97 // Since the drawing from the following Fill() calls assumes the mapped origin | 100 // Since the drawing from the following Fill() calls assumes the mapped origin |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 190 |
188 for (size_t j = 0; j < 3; ++j) { | 191 for (size_t j = 0; j < 3; ++j) { |
189 for (size_t i = 0; i < 3; ++i) { | 192 for (size_t i = 0; i < 3; ++i) { |
190 result[i + j * 3] = Rect(x[i], y[j], x[i + 1] - x[i], y[j + 1] - y[j]); | 193 result[i + j * 3] = Rect(x[i], y[j], x[i + 1] - x[i], y[j + 1] - y[j]); |
191 } | 194 } |
192 } | 195 } |
193 result.swap(*regions); | 196 result.swap(*regions); |
194 } | 197 } |
195 | 198 |
196 } // namespace gfx | 199 } // namespace gfx |
OLD | NEW |