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

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

Issue 11418217: Add skia::RefPtr class to wrap ref counted classes from Skia. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Drop TNoRef Created 8 years 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
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 paint.setStyle(SkPaint::kFill_Style); 63 paint.setStyle(SkPaint::kFill_Style);
64 paint.setFlags(SkPaint::kAntiAlias_Flag); 64 paint.setFlags(SkPaint::kAntiAlias_Flag);
65 65
66 SkPoint p[2]; 66 SkPoint p[2];
67 p[0].iset(x, y); 67 p[0].iset(x, y);
68 if (gradient_horizontal) { 68 if (gradient_horizontal) {
69 p[1].iset(x + w, y); 69 p[1].iset(x + w, y);
70 } else { 70 } else {
71 p[1].iset(x, y + h); 71 p[1].iset(x, y + h);
72 } 72 }
73 SkShader* s = SkGradientShader::CreateLinear( 73 skia::RefPtr<SkShader> s = SkGradientShader::CreateLinear(
74 p, colors, points, count, SkShader::kClamp_TileMode, NULL); 74 p, colors, points, count, SkShader::kClamp_TileMode, NULL);
75 paint.setShader(s); 75 paint.setShader(s.get());
76 // Need to unref shader, otherwise never deleted.
77 s->unref();
78 76
79 canvas->DrawPath(path, paint); 77 canvas->DrawPath(path, paint);
80 } 78 }
81 79
82 void FillRoundRect(gfx::Canvas* canvas, 80 void FillRoundRect(gfx::Canvas* canvas,
83 int x, int y, 81 int x, int y,
84 int w, int h, 82 int w, int h,
85 int corner_radius, 83 int corner_radius,
86 SkColor gradient_start_color, 84 SkColor gradient_start_color,
87 SkColor gradient_end_color, 85 SkColor gradient_end_color,
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 if (progress_width > 1) { 280 if (progress_width > 1) {
283 FillRoundRect(canvas, 0, 0, progress_width, height(), kCornerRadius, 281 FillRoundRect(canvas, 0, 0, progress_width, height(), kCornerRadius,
284 kBarColorStart, kBarColorEnd, false); 282 kBarColorStart, kBarColorEnd, false);
285 } 283 }
286 StrokeRoundRect(canvas, 0, 0, width(), height(), kCornerRadius, 284 StrokeRoundRect(canvas, 0, 0, width(), height(), kCornerRadius,
287 kBorderColor, kBorderWidth); 285 kBorderColor, kBorderWidth);
288 #endif 286 #endif
289 } 287 }
290 288
291 } // namespace views 289 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698