| 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 "chrome/common/gfx/chrome_canvas.h" | 11 #include "chrome/common/gfx/chrome_canvas.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "skia/ext/bitmap_platform_device_win.h" | 13 #include "skia/ext/bitmap_platform_device_win.h" |
| 14 #include "SkGradientShader.h" | 14 #include "SkGradientShader.h" |
| 15 | 15 |
| 16 void GetRebarGradientColors(int width, int x1, int x2, SkColor* c1, SkColor* c2)
{ | 16 void GetRebarGradientColors(int width, int x1, int x2, |
| 17 DCHECK(c1 && c2) << "ThemeHelpers::GetRebarGradientColors - c1 or c2 is NULL!"
; | 17 SkColor* c1, SkColor* c2) { |
| 18 DCHECK(c1 && c2) << |
| 19 "ThemeHelpers::GetRebarGradientColors - c1 or c2 is NULL!"; |
| 18 | 20 |
| 19 // 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 |
| 20 // DrawThemeBackground, then extract the pixel values from and return | 22 // DrawThemeBackground, then extract the pixel values from and return |
| 21 // 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 |
| 22 // rendering in other directions. | 24 // rendering in other directions. |
| 23 | 25 |
| 24 ChromeCanvas canvas(width, 1, true); | 26 ChromeCanvas canvas(width, 1, true); |
| 25 | 27 |
| 26 // Render the Rebar gradient into the DIB | 28 // Render the Rebar gradient into the DIB |
| 27 CTheme theme; | 29 CTheme theme; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 56 gradient_shader->unref(); | 58 gradient_shader->unref(); |
| 57 paint.setStyle(SkPaint::kFill_Style); | 59 paint.setStyle(SkPaint::kFill_Style); |
| 58 canvas.drawRectCoords(SkIntToScalar(0), SkIntToScalar(0), | 60 canvas.drawRectCoords(SkIntToScalar(0), SkIntToScalar(0), |
| 59 SkIntToScalar(width), SkIntToScalar(1), paint); | 61 SkIntToScalar(width), SkIntToScalar(1), paint); |
| 60 } | 62 } |
| 61 | 63 |
| 62 // Extract the color values from the selected pixels | 64 // Extract the color values from the selected pixels |
| 63 // The | in the following operations forces the alpha to 0xFF. This is | 65 // The | in the following operations forces the alpha to 0xFF. This is |
| 64 // needed as windows sets the alpha to 0 when it renders. | 66 // needed as windows sets the alpha to 0 when it renders. |
| 65 skia::BitmapPlatformDeviceWin& device = | 67 skia::BitmapPlatformDeviceWin& device = |
| 66 static_cast<skia::BitmapPlatformDeviceWin&>(canvas.getTopPlatformDevice())
; | 68 static_cast<skia::BitmapPlatformDeviceWin&>( |
| 69 canvas.getTopPlatformDevice()); |
| 67 *c1 = 0xFF000000 | device.getColorAt(x1, 0); | 70 *c1 = 0xFF000000 | device.getColorAt(x1, 0); |
| 68 *c2 = 0xFF000000 | device.getColorAt(x2, 0); | 71 *c2 = 0xFF000000 | device.getColorAt(x2, 0); |
| 69 } | 72 } |
| 70 | 73 |
| 71 void GetDarkLineColor(SkColor* dark_color) { | 74 void GetDarkLineColor(SkColor* dark_color) { |
| 72 DCHECK(dark_color) << "ThemeHelpers::DarkColor - dark_color is NULL!"; | 75 DCHECK(dark_color) << "ThemeHelpers::DarkColor - dark_color is NULL!"; |
| 73 | 76 |
| 74 CTheme theme; | 77 CTheme theme; |
| 75 if (theme.IsThemingSupported()) | 78 if (theme.IsThemingSupported()) |
| 76 theme.OpenThemeData(NULL, L"REBAR"); | 79 theme.OpenThemeData(NULL, L"REBAR"); |
| 77 | 80 |
| 78 // Note: the alpha values were chosen scientifically according to what looked | 81 // Note: the alpha values were chosen scientifically according to what looked |
| 79 // best to me at the time! --beng | 82 // best to me at the time! --beng |
| 80 if (!theme.IsThemeNull()) { | 83 if (!theme.IsThemeNull()) { |
| 81 *dark_color = SkColorSetARGB(60, 0, 0, 0); | 84 *dark_color = SkColorSetARGB(60, 0, 0, 0); |
| 82 } else { | 85 } else { |
| 83 COLORREF shadow_ref = ::GetSysColor(COLOR_3DSHADOW); | 86 COLORREF shadow_ref = ::GetSysColor(COLOR_3DSHADOW); |
| 84 *dark_color = SkColorSetARGB(175, | 87 *dark_color = SkColorSetARGB(175, |
| 85 GetRValue(shadow_ref), | 88 GetRValue(shadow_ref), |
| 86 GetGValue(shadow_ref), | 89 GetGValue(shadow_ref), |
| 87 GetBValue(shadow_ref)); | 90 GetBValue(shadow_ref)); |
| 88 } | 91 } |
| 89 } | 92 } |
| 90 | 93 |
| 91 | 94 |
| OLD | NEW |