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

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

Issue 11418217: Add skia::RefPtr class to wrap ref counted classes from Skia. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Drop TNoRef Created 8 years 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) 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
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 SkColor grad_colors[2]; 42 SkColor grad_colors[2];
43 COLORREF hl_ref = ::GetSysColor(COLOR_3DHILIGHT); 43 COLORREF hl_ref = ::GetSysColor(COLOR_3DHILIGHT);
44 grad_colors[0] = SkColorSetRGB(GetRValue(hl_ref), GetGValue(hl_ref), 44 grad_colors[0] = SkColorSetRGB(GetRValue(hl_ref), GetGValue(hl_ref),
45 GetBValue(hl_ref)); 45 GetBValue(hl_ref));
46 COLORREF face_ref = ::GetSysColor(COLOR_3DFACE); 46 COLORREF face_ref = ::GetSysColor(COLOR_3DFACE);
47 grad_colors[1] = SkColorSetRGB(GetRValue(face_ref), GetGValue(face_ref), 47 grad_colors[1] = SkColorSetRGB(GetRValue(face_ref), GetGValue(face_ref),
48 GetBValue(face_ref)); 48 GetBValue(face_ref));
49 SkPoint grad_points[2]; 49 SkPoint grad_points[2];
50 grad_points[0].set(SkIntToScalar(0), SkIntToScalar(0)); 50 grad_points[0].set(SkIntToScalar(0), SkIntToScalar(0));
51 grad_points[1].set(SkIntToScalar(width), SkIntToScalar(0)); 51 grad_points[1].set(SkIntToScalar(width), SkIntToScalar(0));
52 SkShader* gradient_shader = SkGradientShader::CreateLinear( 52 skia::RefPtr<SkShader> gradient_shader = SkGradientShader::CreateLinear(
53 grad_points, grad_colors, NULL, 2, SkShader::kRepeat_TileMode); 53 grad_points, grad_colors, NULL, 2, SkShader::kRepeat_TileMode);
54 SkPaint paint; 54 SkPaint paint;
55 paint.setShader(gradient_shader); 55 paint.setShader(gradient_shader.get());
56 // Shader created with a ref count of 1, release as the paint now owns 56 // Shader created with a ref count of 1, release as the paint now owns
57 // the gradient. 57 // the gradient.
58 gradient_shader->unref();
59 paint.setStyle(SkPaint::kFill_Style); 58 paint.setStyle(SkPaint::kFill_Style);
60 canvas.sk_canvas()->drawRectCoords( 59 canvas.sk_canvas()->drawRectCoords(
61 SkIntToScalar(0), SkIntToScalar(0), 60 SkIntToScalar(0), SkIntToScalar(0),
62 SkIntToScalar(width), SkIntToScalar(1), paint); 61 SkIntToScalar(width), SkIntToScalar(1), paint);
63 } 62 }
64 63
65 // Extract the color values from the selected pixels 64 // Extract the color values from the selected pixels
66 // 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
67 // needed as windows sets the alpha to 0 when it renders. 66 // needed as windows sets the alpha to 0 when it renders.
68 SkDevice* device = skia::GetTopDevice(*canvas.sk_canvas()); 67 SkDevice* device = skia::GetTopDevice(*canvas.sk_canvas());
(...skipping 16 matching lines...) Expand all
85 if (!theme.IsThemeNull()) { 84 if (!theme.IsThemeNull()) {
86 *dark_color = SkColorSetARGB(60, 0, 0, 0); 85 *dark_color = SkColorSetARGB(60, 0, 0, 0);
87 } else { 86 } else {
88 COLORREF shadow_ref = ::GetSysColor(COLOR_3DSHADOW); 87 COLORREF shadow_ref = ::GetSysColor(COLOR_3DSHADOW);
89 *dark_color = SkColorSetARGB(175, 88 *dark_color = SkColorSetARGB(175,
90 GetRValue(shadow_ref), 89 GetRValue(shadow_ref),
91 GetGValue(shadow_ref), 90 GetGValue(shadow_ref),
92 GetBValue(shadow_ref)); 91 GetBValue(shadow_ref));
93 } 92 }
94 } 93 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698