OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "views/controls/progress_bar.h" | 5 #include "views/controls/progress_bar.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "gfx/canvas.h" | 13 #include "gfx/canvas_skia.h" |
14 #include "gfx/color_utils.h" | 14 #include "gfx/color_utils.h" |
15 #include "gfx/font.h" | 15 #include "gfx/font.h" |
16 #include "gfx/insets.h" | 16 #include "gfx/insets.h" |
17 #include "third_party/skia/include/effects/SkGradientShader.h" | 17 #include "third_party/skia/include/effects/SkGradientShader.h" |
18 #include "third_party/skia/include/effects/SkBlurMaskFilter.h" | 18 #include "third_party/skia/include/effects/SkBlurMaskFilter.h" |
19 #include "views/background.h" | 19 #include "views/background.h" |
20 #include "views/border.h" | 20 #include "views/border.h" |
21 #include "views/painter.h" | 21 #include "views/painter.h" |
22 | 22 |
23 namespace { | 23 namespace { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 68 } |
69 SkColor colors[2] = { gradient_start_color, gradient_end_color }; | 69 SkColor colors[2] = { gradient_start_color, gradient_end_color }; |
70 SkShader* s = SkGradientShader::CreateLinear( | 70 SkShader* s = SkGradientShader::CreateLinear( |
71 p, colors, NULL, 2, SkShader::kClamp_TileMode, NULL); | 71 p, colors, NULL, 2, SkShader::kClamp_TileMode, NULL); |
72 paint.setShader(s); | 72 paint.setShader(s); |
73 // Need to unref shader, otherwise never deleted. | 73 // Need to unref shader, otherwise never deleted. |
74 s->unref(); | 74 s->unref(); |
75 } else { | 75 } else { |
76 paint.setColor(gradient_start_color); | 76 paint.setColor(gradient_start_color); |
77 } | 77 } |
78 canvas->drawPath(path, paint); | 78 canvas->AsCanvasSkia()->drawPath(path, paint); |
79 } | 79 } |
80 | 80 |
81 static void StrokeRoundRect(gfx::Canvas* canvas, | 81 static void StrokeRoundRect(gfx::Canvas* canvas, |
82 int x, int y, | 82 int x, int y, |
83 int w, int h, | 83 int w, int h, |
84 int corner_radius, | 84 int corner_radius, |
85 SkColor stroke_color, | 85 SkColor stroke_color, |
86 int stroke_width) { | 86 int stroke_width) { |
87 SkPath path; | 87 SkPath path; |
88 AddRoundRectPath(x, y, w, h, corner_radius, &path); | 88 AddRoundRectPath(x, y, w, h, corner_radius, &path); |
89 SkPaint paint; | 89 SkPaint paint; |
90 paint.setShader(NULL); | 90 paint.setShader(NULL); |
91 paint.setColor(stroke_color); | 91 paint.setColor(stroke_color); |
92 paint.setStyle(SkPaint::kStroke_Style); | 92 paint.setStyle(SkPaint::kStroke_Style); |
93 paint.setFlags(SkPaint::kAntiAlias_Flag); | 93 paint.setFlags(SkPaint::kAntiAlias_Flag); |
94 paint.setStrokeWidth(SkIntToScalar(stroke_width)); | 94 paint.setStrokeWidth(SkIntToScalar(stroke_width)); |
95 canvas->drawPath(path, paint); | 95 canvas->AsCanvasSkia()->drawPath(path, paint); |
96 } | 96 } |
97 | 97 |
98 } // anonymous namespace | 98 } // anonymous namespace |
99 | 99 |
100 namespace views { | 100 namespace views { |
101 | 101 |
102 // static | 102 // static |
103 const char ProgressBar::kViewClassName[] = "views/ProgressBar"; | 103 const char ProgressBar::kViewClassName[] = "views/ProgressBar"; |
104 // static: progress bar's maximum value. | 104 // static: progress bar's maximum value. |
105 const int ProgressBar::kMaxProgress = 100; | 105 const int ProgressBar::kMaxProgress = 100; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 return true; | 191 return true; |
192 } | 192 } |
193 | 193 |
194 bool ProgressBar::GetAccessibleState(AccessibilityTypes::State* state) { | 194 bool ProgressBar::GetAccessibleState(AccessibilityTypes::State* state) { |
195 DCHECK(state); | 195 DCHECK(state); |
196 *state = AccessibilityTypes::STATE_READONLY; | 196 *state = AccessibilityTypes::STATE_READONLY; |
197 return true; | 197 return true; |
198 } | 198 } |
199 | 199 |
200 } // namespace views | 200 } // namespace views |
OLD | NEW |