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

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

Issue 2680943002: ui: Clean up naming of paint-related identifiers (Closed)
Patch Set: 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
(...skipping 25 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 cc::PaintFlags& paint) { 46 const cc::PaintFlags& flags) {
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, flags);
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)
57 images_[i] = images[i]; 57 images_[i] = images[i];
58 } 58 }
59 59
(...skipping 90 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 cc::PaintFlags paint; 160 cc::PaintFlags flags;
161 paint.setAlpha(alpha); 161 flags.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, flags);
164 Fill(canvas, image_reps[0], 0, 0, i0w, i0h, paint); 164 Fill(canvas, image_reps[0], 0, 0, i0w, i0h, flags);
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, flags);
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, flags);
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, flags);
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, flags);
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, flags);
171 Fill(canvas, image_reps[7], i6w, height_in_pixels - i7h, 171 Fill(canvas, image_reps[7], i6w, height_in_pixels - i7h,
172 width_in_pixels - i6w - i8w, i7h, paint); 172 width_in_pixels - i6w - i8w, i7h, flags);
173 Fill(canvas, image_reps[8], width_in_pixels - i8w, height_in_pixels - i8h, 173 Fill(canvas, image_reps[8], width_in_pixels - i8w, height_in_pixels - i8h,
174 i8w, i8h, paint); 174 i8w, i8h, flags);
175 } 175 }
176 176
177 // static 177 // static
178 void NineImagePainter::GetSubsetRegions(const ImageSkia& image, 178 void NineImagePainter::GetSubsetRegions(const ImageSkia& image,
179 const Insets& insets, 179 const Insets& insets,
180 std::vector<Rect>* regions) { 180 std::vector<Rect>* regions) {
181 DCHECK_GE(image.width(), insets.width()); 181 DCHECK_GE(image.width(), insets.width());
182 DCHECK_GE(image.height(), insets.height()); 182 DCHECK_GE(image.height(), insets.height());
183 183
184 std::vector<Rect> result(9); 184 std::vector<Rect> result(9);
185 185
186 const int x[] = { 186 const int x[] = {
187 0, insets.left(), image.width() - insets.right(), image.width()}; 187 0, insets.left(), image.width() - insets.right(), image.width()};
188 const int y[] = { 188 const int y[] = {
189 0, insets.top(), image.height() - insets.bottom(), image.height()}; 189 0, insets.top(), image.height() - insets.bottom(), image.height()};
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