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

Side by Side Diff: ui/views/controls/progress_bar.cc

Issue 291843003: use simpler gradient factories (in prep for removing SkUnitMapper param) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/menu/menu_image_util.cc ('k') | ui/views/painter.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 (c) 2012 The Chromium Authors. All rights reserved. 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 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/views/controls/progress_bar.h" 5 #include "ui/views/controls/progress_bar.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 paint.setFlags(SkPaint::kAntiAlias_Flag); 74 paint.setFlags(SkPaint::kAntiAlias_Flag);
75 75
76 SkPoint p[2]; 76 SkPoint p[2];
77 p[0].iset(x, y); 77 p[0].iset(x, y);
78 if (gradient_horizontal) { 78 if (gradient_horizontal) {
79 p[1].iset(x + w, y); 79 p[1].iset(x + w, y);
80 } else { 80 } else {
81 p[1].iset(x, y + h); 81 p[1].iset(x, y + h);
82 } 82 }
83 skia::RefPtr<SkShader> s = skia::AdoptRef(SkGradientShader::CreateLinear( 83 skia::RefPtr<SkShader> s = skia::AdoptRef(SkGradientShader::CreateLinear(
84 p, colors, points, count, SkShader::kClamp_TileMode, NULL)); 84 p, colors, points, count, SkShader::kClamp_TileMode));
85 paint.setShader(s.get()); 85 paint.setShader(s.get());
86 86
87 canvas->DrawPath(path, paint); 87 canvas->DrawPath(path, paint);
88 } 88 }
89 89
90 void FillRoundRect(gfx::Canvas* canvas, 90 void FillRoundRect(gfx::Canvas* canvas,
91 int x, int y, 91 int x, int y,
92 int w, int h, 92 int w, int h,
93 int corner_radius, 93 int corner_radius,
94 SkColor gradient_start_color, 94 SkColor gradient_start_color,
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 paint.setFlags(SkPaint::kAntiAlias_Flag); 293 paint.setFlags(SkPaint::kAntiAlias_Flag);
294 294
295 SkPoint p[2]; 295 SkPoint p[2];
296 int highlight_left = 296 int highlight_left =
297 std::max(0, progress_width - kHighlightWidth - kBorderWidth); 297 std::max(0, progress_width - kHighlightWidth - kBorderWidth);
298 p[0].iset(highlight_left, 0); 298 p[0].iset(highlight_left, 0);
299 p[1].iset(progress_width, 0); 299 p[1].iset(progress_width, 0);
300 skia::RefPtr<SkShader> s = 300 skia::RefPtr<SkShader> s =
301 skia::AdoptRef(SkGradientShader::CreateLinear( 301 skia::AdoptRef(SkGradientShader::CreateLinear(
302 p, highlight_colors, highlight_points, 302 p, highlight_colors, highlight_points,
303 arraysize(highlight_colors), SkShader::kClamp_TileMode, NULL)); 303 arraysize(highlight_colors), SkShader::kClamp_TileMode));
304 paint.setShader(s.get()); 304 paint.setShader(s.get());
305 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); 305 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
306 canvas->DrawRect(gfx::Rect(highlight_left, 0, 306 canvas->DrawRect(gfx::Rect(highlight_left, 0,
307 kHighlightWidth + kBorderWidth, bar_height), 307 kHighlightWidth + kBorderWidth, bar_height),
308 paint); 308 paint);
309 } 309 }
310 310
311 canvas->Restore(); 311 canvas->Restore();
312 } 312 }
313 313
314 // Draw bar stroke 314 // Draw bar stroke
315 StrokeRoundRect(canvas, 315 StrokeRoundRect(canvas,
316 bar_left, bar_top, progress_width, bar_height, 316 bar_left, bar_top, progress_width, bar_height,
317 kCornerRadius, 317 kCornerRadius,
318 enabled() ? kBarBorderColor : kDisabledBarBorderColor, 318 enabled() ? kBarBorderColor : kDisabledBarBorderColor,
319 kBorderWidth); 319 kBorderWidth);
320 } 320 }
321 } 321 }
322 322
323 } // namespace views 323 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_image_util.cc ('k') | ui/views/painter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698