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/theme_helpers.h" | 5 #include "chrome/browser/ui/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 "third_party/skia/include/effects/SkGradientShader.h" | 12 #include "third_party/skia/include/effects/SkGradientShader.h" |
13 #include "ui/gfx/canvas.h" | 13 #include "ui/gfx/canvas.h" |
14 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.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(gfx::Size(width, 1), true); | 26 gfx::Canvas canvas(gfx::Size(width, 1), ui::SCALE_FACTOR_100P, 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 skia::ScopedPlatformPaint scoped_platform_paint(canvas.sk_canvas()); | 35 skia::ScopedPlatformPaint scoped_platform_paint(canvas.sk_canvas()); |
36 HDC dc = scoped_platform_paint.GetPlatformSurface(); | 36 HDC dc = scoped_platform_paint.GetPlatformSurface(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 if (!theme.IsThemeNull()) { | 85 if (!theme.IsThemeNull()) { |
86 *dark_color = SkColorSetARGB(60, 0, 0, 0); | 86 *dark_color = SkColorSetARGB(60, 0, 0, 0); |
87 } else { | 87 } else { |
88 COLORREF shadow_ref = ::GetSysColor(COLOR_3DSHADOW); | 88 COLORREF shadow_ref = ::GetSysColor(COLOR_3DSHADOW); |
89 *dark_color = SkColorSetARGB(175, | 89 *dark_color = SkColorSetARGB(175, |
90 GetRValue(shadow_ref), | 90 GetRValue(shadow_ref), |
91 GetGValue(shadow_ref), | 91 GetGValue(shadow_ref), |
92 GetBValue(shadow_ref)); | 92 GetBValue(shadow_ref)); |
93 } | 93 } |
94 } | 94 } |
OLD | NEW |