OLD | NEW |
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 "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 "skia/ext/refptr.h" |
9 #include "third_party/skia/include/core/SkShader.h" | 10 #include "third_party/skia/include/core/SkShader.h" |
10 #include "ui/base/resource/resource_bundle.h" | 11 #include "ui/base/resource/resource_bundle.h" |
11 #include "ui/gfx/canvas.h" | 12 #include "ui/gfx/canvas.h" |
12 #include "ui/gfx/image/image_skia.h" | 13 #include "ui/gfx/image/image_skia.h" |
13 #include "ui/gfx/skia_util.h" | 14 #include "ui/gfx/skia_util.h" |
14 #include "ui/views/window/non_client_view.h" | 15 #include "ui/views/window/non_client_view.h" |
15 | 16 |
16 // How round the 'new tab' style bookmarks bar is. | 17 // How round the 'new tab' style bookmarks bar is. |
17 static const int kNewtabBarRoundness = 5; | 18 static const int kNewtabBarRoundness = 5; |
18 | 19 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 } | 113 } |
113 | 114 |
114 // static | 115 // static |
115 void DetachableToolbarView::PaintVerticalDivider(gfx::Canvas* canvas, | 116 void DetachableToolbarView::PaintVerticalDivider(gfx::Canvas* canvas, |
116 int x, | 117 int x, |
117 int height, | 118 int height, |
118 int vertical_padding, | 119 int vertical_padding, |
119 SkColor top_color, | 120 SkColor top_color, |
120 SkColor middle_color, | 121 SkColor middle_color, |
121 SkColor bottom_color) { | 122 SkColor bottom_color) { |
| 123 skia::RefPtr<SkShader> gradient; |
| 124 |
122 // Draw the upper half of the divider. | 125 // Draw the upper half of the divider. |
123 SkPaint paint; | 126 SkPaint paint; |
124 SkSafeUnref(paint.setShader(gfx::CreateGradientShader(vertical_padding + 1, | 127 gradient = gfx::CreateGradientShader(vertical_padding + 1, height / 2, |
125 height / 2, | 128 top_color, middle_color); |
126 top_color, | 129 paint.setShader(gradient.get()); |
127 middle_color))); | |
128 SkRect rc = { SkIntToScalar(x), | 130 SkRect rc = { SkIntToScalar(x), |
129 SkIntToScalar(vertical_padding + 1), | 131 SkIntToScalar(vertical_padding + 1), |
130 SkIntToScalar(x + 1), | 132 SkIntToScalar(x + 1), |
131 SkIntToScalar(height / 2) }; | 133 SkIntToScalar(height / 2) }; |
132 canvas->sk_canvas()->drawRect(rc, paint); | 134 canvas->sk_canvas()->drawRect(rc, paint); |
133 | 135 |
134 // Draw the lower half of the divider. | 136 // Draw the lower half of the divider. |
135 SkPaint paint_down; | 137 SkPaint paint_down; |
136 SkSafeUnref(paint_down.setShader(gfx::CreateGradientShader( | 138 gradient = gfx::CreateGradientShader(height / 2, height - vertical_padding, |
137 height / 2, height - vertical_padding, middle_color, bottom_color))); | 139 middle_color, bottom_color); |
| 140 paint_down.setShader(gradient.get()); |
138 SkRect rc_down = { SkIntToScalar(x), | 141 SkRect rc_down = { SkIntToScalar(x), |
139 SkIntToScalar(height / 2), | 142 SkIntToScalar(height / 2), |
140 SkIntToScalar(x + 1), | 143 SkIntToScalar(x + 1), |
141 SkIntToScalar(height - vertical_padding) }; | 144 SkIntToScalar(height - vertical_padding) }; |
142 canvas->sk_canvas()->drawRect(rc_down, paint_down); | 145 canvas->sk_canvas()->drawRect(rc_down, paint_down); |
143 } | 146 } |
OLD | NEW |