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

Side by Side Diff: chrome/browser/ui/views/detachable_toolbar_view.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 "chrome/browser/ui/views/detachable_toolbar_view.h" 5 #include "chrome/browser/ui/views/detachable_toolbar_view.h"
6 6
7 #include "chrome/browser/themes/theme_service.h" 7 #include "chrome/browser/themes/theme_service.h"
8 #include "grit/theme_resources.h" 8 #include "grit/theme_resources.h"
9 #include "grit/theme_resources_standard.h" 9 #include "grit/theme_resources_standard.h"
10 #include "third_party/skia/include/core/SkBitmap.h" 10 #include "third_party/skia/include/core/SkBitmap.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } 63 }
64 64
65 // static 65 // static
66 void DetachableToolbarView::PaintContentAreaBackground( 66 void DetachableToolbarView::PaintContentAreaBackground(
67 gfx::Canvas* canvas, ui::ThemeProvider* theme_provider, 67 gfx::Canvas* canvas, ui::ThemeProvider* theme_provider,
68 const SkRect& rect, double roundness) { 68 const SkRect& rect, double roundness) {
69 SkPaint paint; 69 SkPaint paint;
70 paint.setAntiAlias(true); 70 paint.setAntiAlias(true);
71 paint.setColor(theme_provider->GetColor(ThemeService::COLOR_TOOLBAR)); 71 paint.setColor(theme_provider->GetColor(ThemeService::COLOR_TOOLBAR));
72 72
73 canvas->AsCanvasSkia()->drawRoundRect( 73 canvas->GetSkCanvas()->drawRoundRect(
74 rect, SkDoubleToScalar(roundness), SkDoubleToScalar(roundness), paint); 74 rect, SkDoubleToScalar(roundness), SkDoubleToScalar(roundness), paint);
75 } 75 }
76 76
77 // static 77 // static
78 void DetachableToolbarView::PaintContentAreaBorder( 78 void DetachableToolbarView::PaintContentAreaBorder(
79 gfx::Canvas* canvas, ui::ThemeProvider* theme_provider, 79 gfx::Canvas* canvas, ui::ThemeProvider* theme_provider,
80 const SkRect& rect, double roundness) { 80 const SkRect& rect, double roundness) {
81 SkPaint border_paint; 81 SkPaint border_paint;
82 border_paint.setColor( 82 border_paint.setColor(
83 theme_provider->GetColor(ThemeService::COLOR_NTP_HEADER)); 83 theme_provider->GetColor(ThemeService::COLOR_NTP_HEADER));
84 border_paint.setStyle(SkPaint::kStroke_Style); 84 border_paint.setStyle(SkPaint::kStroke_Style);
85 border_paint.setAlpha(96); 85 border_paint.setAlpha(96);
86 border_paint.setAntiAlias(true); 86 border_paint.setAntiAlias(true);
87 87
88 canvas->AsCanvasSkia()->drawRoundRect( 88 canvas->GetSkCanvas()->drawRoundRect(
89 rect, SkDoubleToScalar(roundness), SkDoubleToScalar(roundness), 89 rect, SkDoubleToScalar(roundness), SkDoubleToScalar(roundness),
90 border_paint); 90 border_paint);
91 } 91 }
92 92
93 // static 93 // static
94 void DetachableToolbarView::PaintVerticalDivider( 94 void DetachableToolbarView::PaintVerticalDivider(
95 gfx::Canvas* canvas, int x, int height, int vertical_padding, 95 gfx::Canvas* canvas, int x, int height, int vertical_padding,
96 const SkColor& top_color, 96 const SkColor& top_color,
97 const SkColor& middle_color, 97 const SkColor& middle_color,
98 const SkColor& bottom_color) { 98 const SkColor& bottom_color) {
99 // Draw the upper half of the divider. 99 // Draw the upper half of the divider.
100 SkPaint paint; 100 SkPaint paint;
101 SkSafeUnref(paint.setShader(gfx::CreateGradientShader(vertical_padding + 1, 101 SkSafeUnref(paint.setShader(gfx::CreateGradientShader(vertical_padding + 1,
102 height / 2, 102 height / 2,
103 top_color, 103 top_color,
104 middle_color))); 104 middle_color)));
105 SkRect rc = { SkIntToScalar(x), 105 SkRect rc = { SkIntToScalar(x),
106 SkIntToScalar(vertical_padding + 1), 106 SkIntToScalar(vertical_padding + 1),
107 SkIntToScalar(x + 1), 107 SkIntToScalar(x + 1),
108 SkIntToScalar(height / 2) }; 108 SkIntToScalar(height / 2) };
109 canvas->AsCanvasSkia()->drawRect(rc, paint); 109 canvas->GetSkCanvas()->drawRect(rc, paint);
110 110
111 // Draw the lower half of the divider. 111 // Draw the lower half of the divider.
112 SkPaint paint_down; 112 SkPaint paint_down;
113 SkSafeUnref(paint_down.setShader(gfx::CreateGradientShader( 113 SkSafeUnref(paint_down.setShader(gfx::CreateGradientShader(
114 height / 2, height - vertical_padding, middle_color, bottom_color))); 114 height / 2, height - vertical_padding, middle_color, bottom_color)));
115 SkRect rc_down = { SkIntToScalar(x), 115 SkRect rc_down = { SkIntToScalar(x),
116 SkIntToScalar(height / 2), 116 SkIntToScalar(height / 2),
117 SkIntToScalar(x + 1), 117 SkIntToScalar(x + 1),
118 SkIntToScalar(height - vertical_padding) }; 118 SkIntToScalar(height - vertical_padding) };
119 canvas->AsCanvasSkia()->drawRect(rc_down, paint_down); 119 canvas->GetSkCanvas()->drawRect(rc_down, paint_down);
120 } 120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698