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

Side by Side Diff: chrome/browser/ui/views/theme_helpers.cc

Issue 7019013: Removal of dependencies on PlatformDevice classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Remove unnecessary headers. Created 9 years, 7 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/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 "skia/ext/bitmap_platform_device_win.h"
13 #include "third_party/skia/include/effects/SkGradientShader.h" 12 #include "third_party/skia/include/effects/SkGradientShader.h"
14 #include "ui/gfx/canvas_skia.h" 13 #include "ui/gfx/canvas_skia.h"
15 14
16 void GetRebarGradientColors(int width, int x1, int x2, 15 void GetRebarGradientColors(int width, int x1, int x2,
17 SkColor* c1, SkColor* c2) { 16 SkColor* c1, SkColor* c2) {
18 DCHECK(c1 && c2) << 17 DCHECK(c1 && c2) <<
19 "ThemeHelpers::GetRebarGradientColors - c1 or c2 is NULL!"; 18 "ThemeHelpers::GetRebarGradientColors - c1 or c2 is NULL!";
20 19
21 // To get the colors we need, we draw a horizontal gradient using 20 // To get the colors we need, we draw a horizontal gradient using
22 // DrawThemeBackground, then extract the pixel values from and return 21 // DrawThemeBackground, then extract the pixel values from and return
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // the gradient. 56 // the gradient.
58 gradient_shader->unref(); 57 gradient_shader->unref();
59 paint.setStyle(SkPaint::kFill_Style); 58 paint.setStyle(SkPaint::kFill_Style);
60 canvas.drawRectCoords(SkIntToScalar(0), SkIntToScalar(0), 59 canvas.drawRectCoords(SkIntToScalar(0), SkIntToScalar(0),
61 SkIntToScalar(width), SkIntToScalar(1), paint); 60 SkIntToScalar(width), SkIntToScalar(1), paint);
62 } 61 }
63 62
64 // Extract the color values from the selected pixels 63 // Extract the color values from the selected pixels
65 // The | in the following operations forces the alpha to 0xFF. This is 64 // The | in the following operations forces the alpha to 0xFF. This is
66 // needed as windows sets the alpha to 0 when it renders. 65 // needed as windows sets the alpha to 0 when it renders.
67 skia::BitmapPlatformDevice& device = 66 SkDevice& device = canvas.getTopDevice();
68 static_cast<skia::BitmapPlatformDevice&>( 67
69 canvas.getTopPlatformDevice()); 68 *c1 = 0xFF000000 | skia::platform_util::GetColorAt(&device, x1, 0);
70 *c1 = 0xFF000000 | device.getColorAt(x1, 0); 69 *c2 = 0xFF000000 | skia::platform_util::GetColorAt(&device, x2, 0);
71 *c2 = 0xFF000000 | device.getColorAt(x2, 0);
72 } 70 }
73 71
74 void GetDarkLineColor(SkColor* dark_color) { 72 void GetDarkLineColor(SkColor* dark_color) {
75 DCHECK(dark_color) << "ThemeHelpers::DarkColor - dark_color is NULL!"; 73 DCHECK(dark_color) << "ThemeHelpers::DarkColor - dark_color is NULL!";
76 74
77 CTheme theme; 75 CTheme theme;
78 if (theme.IsThemingSupported()) 76 if (theme.IsThemingSupported())
79 theme.OpenThemeData(NULL, L"REBAR"); 77 theme.OpenThemeData(NULL, L"REBAR");
80 78
81 // Note: the alpha values were chosen scientifically according to what looked 79 // Note: the alpha values were chosen scientifically according to what looked
82 // best to me at the time! --beng 80 // best to me at the time! --beng
83 if (!theme.IsThemeNull()) { 81 if (!theme.IsThemeNull()) {
84 *dark_color = SkColorSetARGB(60, 0, 0, 0); 82 *dark_color = SkColorSetARGB(60, 0, 0, 0);
85 } else { 83 } else {
86 COLORREF shadow_ref = ::GetSysColor(COLOR_3DSHADOW); 84 COLORREF shadow_ref = ::GetSysColor(COLOR_3DSHADOW);
87 *dark_color = SkColorSetARGB(175, 85 *dark_color = SkColorSetARGB(175,
88 GetRValue(shadow_ref), 86 GetRValue(shadow_ref),
89 GetGValue(shadow_ref), 87 GetGValue(shadow_ref),
90 GetBValue(shadow_ref)); 88 GetBValue(shadow_ref));
91 } 89 }
92 } 90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698