OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/theme_helpers.h" | 5 #include "chrome/browser/views/theme_helpers.h" |
6 | 6 |
7 #include <atlbase.h> | 7 #include <atlbase.h> |
8 #include <atlapp.h> | 8 #include <atlapp.h> |
9 #include <atltheme.h> | 9 #include <atltheme.h> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "gfx/canvas.h" | 12 #include "gfx/canvas_skia.h" |
13 #include "skia/ext/bitmap_platform_device_win.h" | 13 #include "skia/ext/bitmap_platform_device_win.h" |
14 #include "third_party/skia/include/effects/SkGradientShader.h" | 14 #include "third_party/skia/include/effects/SkGradientShader.h" |
15 | 15 |
16 void GetRebarGradientColors(int width, int x1, int x2, | 16 void GetRebarGradientColors(int width, int x1, int x2, |
17 SkColor* c1, SkColor* c2) { | 17 SkColor* c1, SkColor* c2) { |
18 DCHECK(c1 && c2) << | 18 DCHECK(c1 && c2) << |
19 "ThemeHelpers::GetRebarGradientColors - c1 or c2 is NULL!"; | 19 "ThemeHelpers::GetRebarGradientColors - c1 or c2 is NULL!"; |
20 | 20 |
21 // To get the colors we need, we draw a horizontal gradient using | 21 // To get the colors we need, we draw a horizontal gradient using |
22 // DrawThemeBackground, then extract the pixel values from and return | 22 // DrawThemeBackground, then extract the pixel values from and return |
23 // those so calling code can use them to create gradient brushes for use in | 23 // those so calling code can use them to create gradient brushes for use in |
24 // rendering in other directions. | 24 // rendering in other directions. |
25 | 25 |
26 gfx::Canvas canvas(width, 1, true); | 26 gfx::CanvasSkia canvas(width, 1, true); |
27 | 27 |
28 // Render the Rebar gradient into the DIB | 28 // Render the Rebar gradient into the DIB |
29 CTheme theme; | 29 CTheme theme; |
30 if (theme.IsThemingSupported()) | 30 if (theme.IsThemingSupported()) |
31 theme.OpenThemeData(NULL, L"REBAR"); | 31 theme.OpenThemeData(NULL, L"REBAR"); |
32 // On Windows XP+, if using a Theme, we can ask the theme to render the | 32 // On Windows XP+, if using a Theme, we can ask the theme to render the |
33 // gradient for us. | 33 // gradient for us. |
34 if (!theme.IsThemeNull()) { | 34 if (!theme.IsThemeNull()) { |
35 HDC dc = canvas.beginPlatformPaint(); | 35 HDC dc = canvas.beginPlatformPaint(); |
36 RECT rect = { 0, 0, width, 1 }; | 36 RECT rect = { 0, 0, width, 1 }; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 if (!theme.IsThemeNull()) { | 83 if (!theme.IsThemeNull()) { |
84 *dark_color = SkColorSetARGB(60, 0, 0, 0); | 84 *dark_color = SkColorSetARGB(60, 0, 0, 0); |
85 } else { | 85 } else { |
86 COLORREF shadow_ref = ::GetSysColor(COLOR_3DSHADOW); | 86 COLORREF shadow_ref = ::GetSysColor(COLOR_3DSHADOW); |
87 *dark_color = SkColorSetARGB(175, | 87 *dark_color = SkColorSetARGB(175, |
88 GetRValue(shadow_ref), | 88 GetRValue(shadow_ref), |
89 GetGValue(shadow_ref), | 89 GetGValue(shadow_ref), |
90 GetBValue(shadow_ref)); | 90 GetBValue(shadow_ref)); |
91 } | 91 } |
92 } | 92 } |
OLD | NEW |