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

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

Issue 2640983002: Rename paint data structures (Closed)
Patch Set: DrawingDisplayItem Created 3 years, 10 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/image/image_skia_operations.cc ('k') | ui/gfx/paint_throbber.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "third_party/skia/include/core/SkPaint.h" 12 #include "cc/paint/paint_flags.h"
13 #include "third_party/skia/include/core/SkRect.h" 13 #include "third_party/skia/include/core/SkRect.h"
14 #include "third_party/skia/include/core/SkScalar.h" 14 #include "third_party/skia/include/core/SkScalar.h"
15 #include "ui/gfx/canvas.h" 15 #include "ui/gfx/canvas.h"
16 #include "ui/gfx/geometry/insets.h" 16 #include "ui/gfx/geometry/insets.h"
17 #include "ui/gfx/geometry/rect.h" 17 #include "ui/gfx/geometry/rect.h"
18 #include "ui/gfx/geometry/rect_conversions.h" 18 #include "ui/gfx/geometry/rect_conversions.h"
19 #include "ui/gfx/geometry/safe_integer_conversions.h" 19 #include "ui/gfx/geometry/safe_integer_conversions.h"
20 #include "ui/gfx/image/image_skia_operations.h" 20 #include "ui/gfx/image/image_skia_operations.h"
21 #include "ui/gfx/scoped_canvas.h" 21 #include "ui/gfx/scoped_canvas.h"
22 #include "ui/gfx/skia_util.h" 22 #include "ui/gfx/skia_util.h"
(...skipping 13 matching lines...) Expand all
36 return 0; 36 return 0;
37 return rep.pixel_height(); 37 return rep.pixel_height();
38 } 38 }
39 39
40 void Fill(Canvas* c, 40 void Fill(Canvas* c,
41 const ImageSkiaRep& rep, 41 const ImageSkiaRep& rep,
42 int x, 42 int x,
43 int y, 43 int y,
44 int w, 44 int w,
45 int h, 45 int h,
46 const SkPaint& paint) { 46 const cc::PaintFlags& paint) {
47 if (rep.is_null()) 47 if (rep.is_null())
48 return; 48 return;
49 c->DrawImageIntInPixel(rep, x, y, w, h, false, paint); 49 c->DrawImageIntInPixel(rep, x, y, w, h, false, paint);
50 } 50 }
51 51
52 } // namespace 52 } // namespace
53 53
54 NineImagePainter::NineImagePainter(const std::vector<ImageSkia>& images) { 54 NineImagePainter::NineImagePainter(const std::vector<ImageSkia>& images) {
55 DCHECK_EQ(arraysize(images_), images.size()); 55 DCHECK_EQ(arraysize(images_), images.size());
56 for (size_t i = 0; i < arraysize(images_); ++i) 56 for (size_t i = 0; i < arraysize(images_); ++i)
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 i7h = std::min(i7h, height_in_pixels - i1h); 150 i7h = std::min(i7h, height_in_pixels - i1h);
151 i8h = std::min(i8h, height_in_pixels - i2h); 151 i8h = std::min(i8h, height_in_pixels - i2h);
152 152
153 int i4x = std::min(std::min(i0w, i3w), i6w); 153 int i4x = std::min(std::min(i0w, i3w), i6w);
154 int i4y = std::min(std::min(i0h, i1h), i2h); 154 int i4y = std::min(std::min(i0h, i1h), i2h);
155 int i4w = 155 int i4w =
156 std::max(width_in_pixels - i4x - std::min(std::min(i2w, i5w), i8w), 0); 156 std::max(width_in_pixels - i4x - std::min(std::min(i2w, i5w), i8w), 0);
157 int i4h = 157 int i4h =
158 std::max(height_in_pixels - i4y - std::min(std::min(i6h, i7h), i8h), 0); 158 std::max(height_in_pixels - i4y - std::min(std::min(i6h, i7h), i8h), 0);
159 159
160 SkPaint paint; 160 cc::PaintFlags paint;
161 paint.setAlpha(alpha); 161 paint.setAlpha(alpha);
162 162
163 Fill(canvas, image_reps[4], i4x, i4y, i4w, i4h, paint); 163 Fill(canvas, image_reps[4], i4x, i4y, i4w, i4h, paint);
164 Fill(canvas, image_reps[0], 0, 0, i0w, i0h, paint); 164 Fill(canvas, image_reps[0], 0, 0, i0w, i0h, paint);
165 Fill(canvas, image_reps[1], i0w, 0, width_in_pixels - i0w - i2w, i1h, paint); 165 Fill(canvas, image_reps[1], i0w, 0, width_in_pixels - i0w - i2w, i1h, paint);
166 Fill(canvas, image_reps[2], width_in_pixels - i2w, 0, i2w, i2h, paint); 166 Fill(canvas, image_reps[2], width_in_pixels - i2w, 0, i2w, i2h, paint);
167 Fill(canvas, image_reps[3], 0, i0h, i3w, height_in_pixels - i0h - i6h, paint); 167 Fill(canvas, image_reps[3], 0, i0h, i3w, height_in_pixels - i0h - i6h, paint);
168 Fill(canvas, image_reps[5], width_in_pixels - i5w, i2h, i5w, 168 Fill(canvas, image_reps[5], width_in_pixels - i5w, i2h, i5w,
169 height_in_pixels - i2h - i8h, paint); 169 height_in_pixels - i2h - i8h, paint);
170 Fill(canvas, image_reps[6], 0, height_in_pixels - i6h, i6w, i6h, paint); 170 Fill(canvas, image_reps[6], 0, height_in_pixels - i6h, i6w, i6h, paint);
(...skipping 19 matching lines...) Expand all
190 190
191 for (size_t j = 0; j < 3; ++j) { 191 for (size_t j = 0; j < 3; ++j) {
192 for (size_t i = 0; i < 3; ++i) { 192 for (size_t i = 0; i < 3; ++i) {
193 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]);
194 } 194 }
195 } 195 }
196 result.swap(*regions); 196 result.swap(*regions);
197 } 197 }
198 198
199 } // namespace gfx 199 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/image/image_skia_operations.cc ('k') | ui/gfx/paint_throbber.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698