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

Side by Side Diff: base/gfx/native_theme.cc

Issue 12842: Move convolver, image_operations, and skia_utils from base/gfx to skia/ext.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 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
« no previous file with comments | « base/gfx/img_resize_perftest.cc ('k') | base/gfx/skia_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/gfx/native_theme.h" 5 #include "base/gfx/native_theme.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <uxtheme.h> 8 #include <uxtheme.h>
9 #include <vsstyle.h> 9 #include <vsstyle.h>
10 #include <vssym32.h> 10 #include <vssym32.h>
11 11
12 #include "base/gfx/gdi_util.h" 12 #include "base/gfx/gdi_util.h"
13 #include "base/gfx/skia_utils.h"
14 #include "base/gfx/rect.h" 13 #include "base/gfx/rect.h"
15 #include "base/logging.h" 14 #include "base/logging.h"
16 #include "base/scoped_handle.h" 15 #include "base/scoped_handle.h"
17 #include "skia/ext/platform_canvas.h" 16 #include "skia/ext/platform_canvas.h"
17 #include "skia/ext/skia_utils_win.h"
18 #include "skia/include/SkShader.h" 18 #include "skia/include/SkShader.h"
19 19
20 namespace gfx { 20 namespace gfx {
21 21
22 /* static */ 22 /* static */
23 const NativeTheme* NativeTheme::instance() { 23 const NativeTheme* NativeTheme::instance() {
24 // The global NativeTheme instance. 24 // The global NativeTheme instance.
25 static const NativeTheme s_native_theme; 25 static const NativeTheme s_native_theme;
26 return &s_native_theme; 26 return &s_native_theme;
27 } 27 }
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 206
207 // Draw it manually. 207 // Draw it manually.
208 const DWORD colorScrollbar = GetSysColor(COLOR_SCROLLBAR); 208 const DWORD colorScrollbar = GetSysColor(COLOR_SCROLLBAR);
209 const DWORD color3DFace = GetSysColor(COLOR_3DFACE); 209 const DWORD color3DFace = GetSysColor(COLOR_3DFACE);
210 if ((colorScrollbar != color3DFace) && 210 if ((colorScrollbar != color3DFace) &&
211 (colorScrollbar != GetSysColor(COLOR_WINDOW))) { 211 (colorScrollbar != GetSysColor(COLOR_WINDOW))) {
212 FillRect(hdc, target_rect, reinterpret_cast<HBRUSH>(COLOR_SCROLLBAR + 1)); 212 FillRect(hdc, target_rect, reinterpret_cast<HBRUSH>(COLOR_SCROLLBAR + 1));
213 } else { 213 } else {
214 // Create a 2x2 checkerboard pattern using the 3D face and highlight 214 // Create a 2x2 checkerboard pattern using the 3D face and highlight
215 // colors. 215 // colors.
216 SkColor face = COLORREFToSkColor(color3DFace); 216 SkColor face = skia::COLORREFToSkColor(color3DFace);
217 SkColor highlight = COLORREFToSkColor(GetSysColor(COLOR_3DHILIGHT)); 217 SkColor highlight = skia::COLORREFToSkColor(GetSysColor(COLOR_3DHILIGHT));
218 SkColor buffer[] = { face, highlight, highlight, face }; 218 SkColor buffer[] = { face, highlight, highlight, face };
219 SkBitmap bitmap; 219 SkBitmap bitmap;
220 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 2, 2); 220 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 2, 2);
221 bitmap.setPixels(buffer); 221 bitmap.setPixels(buffer);
222 SkShader* shader = SkShader::CreateBitmapShader(bitmap, 222 SkShader* shader = SkShader::CreateBitmapShader(bitmap,
223 SkShader::kRepeat_TileMode, 223 SkShader::kRepeat_TileMode,
224 SkShader::kRepeat_TileMode); 224 SkShader::kRepeat_TileMode);
225 225
226 // Draw that pattern into the target rect, setting the origin to the top 226 // Draw that pattern into the target rect, setting the origin to the top
227 // left corner of the scrollbar track (so the checked rect below the thumb 227 // left corner of the scrollbar track (so the checked rect below the thumb
228 // aligns properly with the portion above the thumb). 228 // aligns properly with the portion above the thumb).
229 SkMatrix matrix; 229 SkMatrix matrix;
230 matrix.setTranslate(SkIntToScalar(align_rect->left), 230 matrix.setTranslate(SkIntToScalar(align_rect->left),
231 SkIntToScalar(align_rect->top)); 231 SkIntToScalar(align_rect->top));
232 shader->setLocalMatrix(matrix); 232 shader->setLocalMatrix(matrix);
233 SkPaint paint; 233 SkPaint paint;
234 paint.setShader(shader)->unref(); 234 paint.setShader(shader)->unref();
235 canvas->drawIRect(RECTToSkIRect(*target_rect), paint); 235 canvas->drawIRect(skia::RECTToSkIRect(*target_rect), paint);
236 } 236 }
237 if (classic_state & DFCS_PUSHED) 237 if (classic_state & DFCS_PUSHED)
238 InvertRect(hdc, target_rect); 238 InvertRect(hdc, target_rect);
239 return S_OK; 239 return S_OK;
240 } 240 }
241 241
242 HRESULT NativeTheme::PaintScrollbarThumb(HDC hdc, 242 HRESULT NativeTheme::PaintScrollbarThumb(HDC hdc,
243 int part_id, 243 int part_id,
244 int state_id, 244 int state_id,
245 int classic_state, 245 int classic_state,
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 HRESULT NativeTheme::GetThemeColor(ThemeName theme, 459 HRESULT NativeTheme::GetThemeColor(ThemeName theme,
460 int part_id, 460 int part_id,
461 int state_id, 461 int state_id,
462 int prop_id, 462 int prop_id,
463 SkColor* color) const { 463 SkColor* color) const {
464 HANDLE handle = GetThemeHandle(theme); 464 HANDLE handle = GetThemeHandle(theme);
465 if (handle && get_theme_color_) { 465 if (handle && get_theme_color_) {
466 COLORREF color_ref; 466 COLORREF color_ref;
467 if (get_theme_color_(handle, part_id, state_id, prop_id, &color_ref) == 467 if (get_theme_color_(handle, part_id, state_id, prop_id, &color_ref) ==
468 S_OK) { 468 S_OK) {
469 *color = gfx::COLORREFToSkColor(color_ref); 469 *color = skia::COLORREFToSkColor(color_ref);
470 return S_OK; 470 return S_OK;
471 } 471 }
472 } 472 }
473 return E_NOTIMPL; 473 return E_NOTIMPL;
474 } 474 }
475 475
476 SkColor NativeTheme::GetThemeColorWithDefault(ThemeName theme, 476 SkColor NativeTheme::GetThemeColorWithDefault(ThemeName theme,
477 int part_id, 477 int part_id,
478 int state_id, 478 int state_id,
479 int prop_id, 479 int prop_id,
480 int default_sys_color) const { 480 int default_sys_color) const {
481 SkColor color; 481 SkColor color;
482 if (GetThemeColor(theme, part_id, state_id, prop_id, &color) != S_OK) 482 if (GetThemeColor(theme, part_id, state_id, prop_id, &color) != S_OK)
483 color = gfx::COLORREFToSkColor(GetSysColor(default_sys_color)); 483 color = skia::COLORREFToSkColor(GetSysColor(default_sys_color));
484 return color; 484 return color;
485 } 485 }
486 486
487 HRESULT NativeTheme::GetThemeInt(ThemeName theme, 487 HRESULT NativeTheme::GetThemeInt(ThemeName theme,
488 int part_id, 488 int part_id,
489 int state_id, 489 int state_id,
490 int prop_id, 490 int prop_id,
491 int *value) const { 491 int *value) const {
492 HANDLE handle = GetThemeHandle(theme); 492 HANDLE handle = GetThemeHandle(theme);
493 if (handle && get_theme_int_) 493 if (handle && get_theme_int_)
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 break; 603 break;
604 default: 604 default:
605 NOTREACHED(); 605 NOTREACHED();
606 } 606 }
607 theme_handles_[theme_name] = handle; 607 theme_handles_[theme_name] = handle;
608 return handle; 608 return handle;
609 } 609 }
610 610
611 } // namespace gfx 611 } // namespace gfx
612 612
OLDNEW
« no previous file with comments | « base/gfx/img_resize_perftest.cc ('k') | base/gfx/skia_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698