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

Side by Side Diff: views/controls/menu/menu_image_util_linux.cc

Issue 8122013: Allow CanvasSkia to bind to an existing SkCanvas. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: 1 more fix Created 9 years, 2 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/menu/menu_image_util_linux.h" 5 #include "views/controls/menu/menu_image_util_linux.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "grit/ui_resources.h" 8 #include "grit/ui_resources.h"
9 #include "third_party/skia/include/effects/SkGradientShader.h" 9 #include "third_party/skia/include/effects/SkGradientShader.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
(...skipping 29 matching lines...) Expand all
40 SkColor gradient_colors[3] = { kGradient0, kGradient1, kGradient2 }; 40 SkColor gradient_colors[3] = { kGradient0, kGradient1, kGradient2 };
41 SkShader* shader = SkGradientShader::CreateLinear( 41 SkShader* shader = SkGradientShader::CreateLinear(
42 gradient_points, gradient_colors, NULL, arraysize(gradient_points), 42 gradient_points, gradient_colors, NULL, arraysize(gradient_points),
43 SkShader::kClamp_TileMode, NULL); 43 SkShader::kClamp_TileMode, NULL);
44 SkPaint paint; 44 SkPaint paint;
45 paint.setStyle(SkPaint::kFill_Style); 45 paint.setStyle(SkPaint::kFill_Style);
46 paint.setAntiAlias(true); 46 paint.setAntiAlias(true);
47 paint.setShader(shader); 47 paint.setShader(shader);
48 shader->unref(); 48 shader->unref();
49 int radius = kIndicatorSize / 2; 49 int radius = kIndicatorSize / 2;
50 canvas.drawCircle(radius, radius, radius, paint); 50 canvas.sk_canvas()->drawCircle(radius, radius, radius, paint);
51 51
52 paint.setStrokeWidth(SkIntToScalar(0)); 52 paint.setStrokeWidth(SkIntToScalar(0));
53 paint.setShader(NULL); 53 paint.setShader(NULL);
54 paint.setStyle(SkPaint::kStroke_Style); 54 paint.setStyle(SkPaint::kStroke_Style);
55 paint.setColor(kBaseStroke); 55 paint.setColor(kBaseStroke);
56 canvas.drawCircle(radius, radius, radius, paint); 56 canvas.sk_canvas()->drawCircle(radius, radius, radius, paint);
57 57
58 if (selected) { 58 if (selected) {
59 SkPoint selected_gradient_points[2]; 59 SkPoint selected_gradient_points[2];
60 selected_gradient_points[0].set(SkIntToScalar(0), SkIntToScalar(0)); 60 selected_gradient_points[0].set(SkIntToScalar(0), SkIntToScalar(0));
61 selected_gradient_points[1].set( 61 selected_gradient_points[1].set(
62 SkIntToScalar(0), 62 SkIntToScalar(0),
63 SkIntToScalar(kSelectedIndicatorSize)); 63 SkIntToScalar(kSelectedIndicatorSize));
64 SkColor selected_gradient_colors[2] = { kRadioButtonIndicatorGradient0, 64 SkColor selected_gradient_colors[2] = { kRadioButtonIndicatorGradient0,
65 kRadioButtonIndicatorGradient1 }; 65 kRadioButtonIndicatorGradient1 };
66 shader = SkGradientShader::CreateLinear( 66 shader = SkGradientShader::CreateLinear(
67 selected_gradient_points, selected_gradient_colors, NULL, 67 selected_gradient_points, selected_gradient_colors, NULL,
68 arraysize(selected_gradient_points), SkShader::kClamp_TileMode, NULL); 68 arraysize(selected_gradient_points), SkShader::kClamp_TileMode, NULL);
69 paint.setShader(shader); 69 paint.setShader(shader);
70 shader->unref(); 70 shader->unref();
71 paint.setStyle(SkPaint::kFill_Style); 71 paint.setStyle(SkPaint::kFill_Style);
72 canvas.drawCircle(radius, radius, 72 canvas.sk_canvas()->drawCircle(radius, radius,
73 kSelectedIndicatorSize / 2, paint); 73 kSelectedIndicatorSize / 2, paint);
74 74
75 paint.setStrokeWidth(SkIntToScalar(0)); 75 paint.setStrokeWidth(SkIntToScalar(0));
76 paint.setShader(NULL); 76 paint.setShader(NULL);
77 paint.setStyle(SkPaint::kStroke_Style); 77 paint.setStyle(SkPaint::kStroke_Style);
78 paint.setColor(kIndicatorStroke); 78 paint.setColor(kIndicatorStroke);
79 canvas.drawCircle(radius, radius, 79 canvas.sk_canvas()->drawCircle(radius, radius,
80 kSelectedIndicatorSize / 2, paint); 80 kSelectedIndicatorSize / 2, paint);
81 } 81 }
82 return new SkBitmap(canvas.ExtractBitmap()); 82 return new SkBitmap(canvas.ExtractBitmap());
83 } 83 }
84 84
85 SkBitmap* GetRtlSubmenuArrowImage() { 85 SkBitmap* GetRtlSubmenuArrowImage() {
86 static SkBitmap* kRtlArrow = NULL; 86 static SkBitmap* kRtlArrow = NULL;
87 if (!kRtlArrow) { 87 if (!kRtlArrow) {
88 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 88 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
89 SkBitmap* r = rb.GetBitmapNamed(IDR_MENU_ARROW); 89 SkBitmap* r = rb.GetBitmapNamed(IDR_MENU_ARROW);
90 gfx::CanvasSkia canvas(r->width(), r->height(), false); 90 gfx::CanvasSkia canvas(r->width(), r->height(), false);
(...skipping 15 matching lines...) Expand all
106 return selected ? kRadioOn : kRadioOff; 106 return selected ? kRadioOn : kRadioOff;
107 } 107 }
108 108
109 const SkBitmap* GetSubmenuArrowImage() { 109 const SkBitmap* GetSubmenuArrowImage() {
110 return base::i18n::IsRTL() ? 110 return base::i18n::IsRTL() ?
111 GetRtlSubmenuArrowImage() : 111 GetRtlSubmenuArrowImage() :
112 ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_MENU_ARROW); 112 ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_MENU_ARROW);
113 } 113 }
114 114
115 } // namespace views; 115 } // namespace views;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698