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

Side by Side Diff: ui/views/controls/menu/menu_image_util.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/native_theme/native_theme_base.cc ('k') | ui/views/controls/progress_bar.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/menu/menu_image_util.h" 5 #include "ui/views/controls/menu/menu_image_util.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "grit/ui_resources.h" 9 #include "grit/ui_resources.h"
10 #include "third_party/skia/include/effects/SkGradientShader.h" 10 #include "third_party/skia/include/effects/SkGradientShader.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 SkPoint gradient_points[3]; 48 SkPoint gradient_points[3];
49 gradient_points[0].iset(0, 0); 49 gradient_points[0].iset(0, 0);
50 gradient_points[1].iset(0, 50 gradient_points[1].iset(0,
51 static_cast<int>(kIndicatorSize * kGradientStop)); 51 static_cast<int>(kIndicatorSize * kGradientStop));
52 gradient_points[2].iset(0, kIndicatorSize); 52 gradient_points[2].iset(0, kIndicatorSize);
53 SkColor gradient_colors[3] = { kGradient0, kGradient1, kGradient2 }; 53 SkColor gradient_colors[3] = { kGradient0, kGradient1, kGradient2 };
54 skia::RefPtr<SkShader> shader = skia::AdoptRef( 54 skia::RefPtr<SkShader> shader = skia::AdoptRef(
55 SkGradientShader::CreateLinear( 55 SkGradientShader::CreateLinear(
56 gradient_points, gradient_colors, NULL, arraysize(gradient_points), 56 gradient_points, gradient_colors, NULL, arraysize(gradient_points),
57 SkShader::kClamp_TileMode, NULL)); 57 SkShader::kClamp_TileMode));
58 SkPaint paint; 58 SkPaint paint;
59 paint.setStyle(SkPaint::kFill_Style); 59 paint.setStyle(SkPaint::kFill_Style);
60 paint.setAntiAlias(true); 60 paint.setAntiAlias(true);
61 paint.setShader(shader.get()); 61 paint.setShader(shader.get());
62 int radius = kIndicatorSize / 2; 62 int radius = kIndicatorSize / 2;
63 canvas->sk_canvas()->drawCircle(radius, radius, radius, paint); 63 canvas->sk_canvas()->drawCircle(radius, radius, radius, paint);
64 paint.setStrokeWidth(SkIntToScalar(0)); 64 paint.setStrokeWidth(SkIntToScalar(0));
65 paint.setShader(NULL); 65 paint.setShader(NULL);
66 paint.setStyle(SkPaint::kStroke_Style); 66 paint.setStyle(SkPaint::kStroke_Style);
67 paint.setColor(kBaseStroke); 67 paint.setColor(kBaseStroke);
68 canvas->sk_canvas()->drawCircle(radius, radius, radius, paint); 68 canvas->sk_canvas()->drawCircle(radius, radius, radius, paint);
69 69
70 if (selected_) { 70 if (selected_) {
71 SkPoint selected_gradient_points[2]; 71 SkPoint selected_gradient_points[2];
72 selected_gradient_points[0].iset(0, 0); 72 selected_gradient_points[0].iset(0, 0);
73 selected_gradient_points[1].iset(0, kSelectedIndicatorSize); 73 selected_gradient_points[1].iset(0, kSelectedIndicatorSize);
74 SkColor selected_gradient_colors[2] = { kRadioButtonIndicatorGradient0, 74 SkColor selected_gradient_colors[2] = { kRadioButtonIndicatorGradient0,
75 kRadioButtonIndicatorGradient1 }; 75 kRadioButtonIndicatorGradient1 };
76 shader = skia::AdoptRef( 76 shader = skia::AdoptRef(
77 SkGradientShader::CreateLinear( 77 SkGradientShader::CreateLinear(
78 selected_gradient_points, selected_gradient_colors, NULL, 78 selected_gradient_points, selected_gradient_colors, NULL,
79 arraysize(selected_gradient_points), 79 arraysize(selected_gradient_points), SkShader::kClamp_TileMode));
80 SkShader::kClamp_TileMode, NULL));
81 paint.setShader(shader.get()); 80 paint.setShader(shader.get());
82 paint.setStyle(SkPaint::kFill_Style); 81 paint.setStyle(SkPaint::kFill_Style);
83 canvas->sk_canvas()->drawCircle(radius, radius, 82 canvas->sk_canvas()->drawCircle(radius, radius,
84 kSelectedIndicatorSize / 2, paint); 83 kSelectedIndicatorSize / 2, paint);
85 84
86 paint.setStrokeWidth(SkIntToScalar(0)); 85 paint.setStrokeWidth(SkIntToScalar(0));
87 paint.setShader(NULL); 86 paint.setShader(NULL);
88 paint.setStyle(SkPaint::kStroke_Style); 87 paint.setStyle(SkPaint::kStroke_Style);
89 paint.setColor(kIndicatorStroke); 88 paint.setColor(kIndicatorStroke);
90 canvas->sk_canvas()->drawCircle(radius, radius, 89 canvas->sk_canvas()->drawCircle(radius, radius,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 int image_id = selected ? IDR_MENU_RADIO_SELECTED : IDR_MENU_RADIO_EMPTY; 160 int image_id = selected ? IDR_MENU_RADIO_SELECTED : IDR_MENU_RADIO_EMPTY;
162 return ui::ResourceBundle::GetSharedInstance().GetImageNamed(image_id). 161 return ui::ResourceBundle::GetSharedInstance().GetImageNamed(image_id).
163 AsImageSkia(); 162 AsImageSkia();
164 } 163 }
165 164
166 gfx::ImageSkia GetSubmenuArrowImage(bool dark_background) { 165 gfx::ImageSkia GetSubmenuArrowImage(bool dark_background) {
167 return GetRtlSubmenuArrowImage(base::i18n::IsRTL(), dark_background); 166 return GetRtlSubmenuArrowImage(base::i18n::IsRTL(), dark_background);
168 } 167 }
169 168
170 } // namespace views 169 } // namespace views
OLDNEW
« no previous file with comments | « ui/native_theme/native_theme_base.cc ('k') | ui/views/controls/progress_bar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698