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

Side by Side Diff: ui/gfx/native_theme_win.cc

Issue 6783023: Eliminate skia::PlatformCanvas - Step 1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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 "ui/gfx/native_theme_win.h" 5 #include "ui/gfx/native_theme_win.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/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/scoped_handle.h" 13 #include "base/memory/scoped_handle.h"
14 #include "base/win/scoped_gdi_object.h" 14 #include "base/win/scoped_gdi_object.h"
15 #include "base/win/scoped_hdc.h" 15 #include "base/win/scoped_hdc.h"
16 #include "base/win/windows_version.h" 16 #include "base/win/windows_version.h"
17 #include "skia/ext/platform_canvas.h"
18 #include "skia/ext/skia_utils_win.h" 17 #include "skia/ext/skia_utils_win.h"
18 #include "third_party/skia/include/core/SkCanvas.h"
19 #include "third_party/skia/include/core/SkShader.h" 19 #include "third_party/skia/include/core/SkShader.h"
20 #include "ui/gfx/gdi_util.h" 20 #include "ui/gfx/gdi_util.h"
21 #include "ui/gfx/rect.h" 21 #include "ui/gfx/rect.h"
22 22
23 namespace { 23 namespace {
24 24
25 void SetCheckerboardShader(SkPaint* paint, const RECT& align_rect) { 25 void SetCheckerboardShader(SkPaint* paint, const RECT& align_rect) {
26 // Create a 2x2 checkerboard pattern using the 3D face and highlight colors. 26 // Create a 2x2 checkerboard pattern using the 3D face and highlight colors.
27 SkColor face = skia::COLORREFToSkColor(GetSysColor(COLOR_3DFACE)); 27 SkColor face = skia::COLORREFToSkColor(GetSysColor(COLOR_3DFACE));
28 SkColor highlight = skia::COLORREFToSkColor(GetSysColor(COLOR_3DHILIGHT)); 28 SkColor highlight = skia::COLORREFToSkColor(GetSysColor(COLOR_3DHILIGHT));
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 return S_OK; 326 return S_OK;
327 } 327 }
328 328
329 HRESULT NativeThemeWin::PaintScrollbarTrack( 329 HRESULT NativeThemeWin::PaintScrollbarTrack(
330 HDC hdc, 330 HDC hdc,
331 int part_id, 331 int part_id,
332 int state_id, 332 int state_id,
333 int classic_state, 333 int classic_state,
334 RECT* target_rect, 334 RECT* target_rect,
335 RECT* align_rect, 335 RECT* align_rect,
336 skia::PlatformCanvas* canvas) const { 336 SkCanvas* canvas) const {
337 HANDLE handle = GetThemeHandle(SCROLLBAR); 337 HANDLE handle = GetThemeHandle(SCROLLBAR);
338 if (handle && draw_theme_) 338 if (handle && draw_theme_)
339 return draw_theme_(handle, hdc, part_id, state_id, target_rect, NULL); 339 return draw_theme_(handle, hdc, part_id, state_id, target_rect, NULL);
340 340
341 // Draw it manually. 341 // Draw it manually.
342 const DWORD colorScrollbar = GetSysColor(COLOR_SCROLLBAR); 342 const DWORD colorScrollbar = GetSysColor(COLOR_SCROLLBAR);
343 const DWORD color3DFace = GetSysColor(COLOR_3DFACE); 343 const DWORD color3DFace = GetSysColor(COLOR_3DFACE);
344 if ((colorScrollbar != color3DFace) && 344 if ((colorScrollbar != color3DFace) &&
345 (colorScrollbar != GetSysColor(COLOR_WINDOW))) { 345 (colorScrollbar != GetSysColor(COLOR_WINDOW))) {
346 FillRect(hdc, target_rect, reinterpret_cast<HBRUSH>(COLOR_SCROLLBAR + 1)); 346 FillRect(hdc, target_rect, reinterpret_cast<HBRUSH>(COLOR_SCROLLBAR + 1));
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 // Classic just renders a flat color background. 409 // Classic just renders a flat color background.
410 FillRect(hdc, rect, reinterpret_cast<HBRUSH>(COLOR_3DFACE + 1)); 410 FillRect(hdc, rect, reinterpret_cast<HBRUSH>(COLOR_3DFACE + 1));
411 return S_OK; 411 return S_OK;
412 } 412 }
413 413
414 HRESULT NativeThemeWin::PaintTrackbar(HDC hdc, 414 HRESULT NativeThemeWin::PaintTrackbar(HDC hdc,
415 int part_id, 415 int part_id,
416 int state_id, 416 int state_id,
417 int classic_state, 417 int classic_state,
418 RECT* rect, 418 RECT* rect,
419 skia::PlatformCanvas* canvas) const { 419 SkCanvas* canvas) const {
420 // Make the channel be 4 px thick in the center of the supplied rect. (4 px 420 // Make the channel be 4 px thick in the center of the supplied rect. (4 px
421 // matches what XP does in various menus; GetThemePartSize() doesn't seem to 421 // matches what XP does in various menus; GetThemePartSize() doesn't seem to
422 // return good values here.) 422 // return good values here.)
423 RECT channel_rect = *rect; 423 RECT channel_rect = *rect;
424 const int channel_thickness = 4; 424 const int channel_thickness = 4;
425 if (part_id == TKP_TRACK) { 425 if (part_id == TKP_TRACK) {
426 channel_rect.top += 426 channel_rect.top +=
427 ((channel_rect.bottom - channel_rect.top - channel_thickness) / 2); 427 ((channel_rect.bottom - channel_rect.top - channel_thickness) / 2);
428 channel_rect.bottom = channel_rect.top + channel_thickness; 428 channel_rect.bottom = channel_rect.top + channel_thickness;
429 } else if (part_id == TKP_TRACKVERT) { 429 } else if (part_id == TKP_TRACKVERT) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 gfx::Rect result(*rect); 518 gfx::Rect result(*rect);
519 result.Inset(size, size); 519 result.Inset(size, size);
520 return result.ToRECT(); 520 return result.ToRECT();
521 } 521 }
522 522
523 HRESULT NativeThemeWin::PaintProgressBar(HDC hdc, 523 HRESULT NativeThemeWin::PaintProgressBar(HDC hdc,
524 RECT* bar_rect, 524 RECT* bar_rect,
525 RECT* value_rect, 525 RECT* value_rect,
526 bool determinate, 526 bool determinate,
527 double animated_seconds, 527 double animated_seconds,
528 skia::PlatformCanvas* canvas) const { 528 SkCanvas* canvas) const {
529 // There is no documentation about the animation speed, frame-rate, nor 529 // There is no documentation about the animation speed, frame-rate, nor
530 // size of moving overlay of the indeterminate progress bar. 530 // size of moving overlay of the indeterminate progress bar.
531 // So we just observed real-world programs and guessed following parameters. 531 // So we just observed real-world programs and guessed following parameters.
532 const int kDeteminateOverlayPixelsPerSecond = 300; 532 const int kDeteminateOverlayPixelsPerSecond = 300;
533 const int kDeteminateOverlayWidth = 120; 533 const int kDeteminateOverlayWidth = 120;
534 const int kIndeterminateOverlayPixelsPerSecond = 175; 534 const int kIndeterminateOverlayPixelsPerSecond = 175;
535 const int kVistaIndeterminateOverlayWidth = 120; 535 const int kVistaIndeterminateOverlayWidth = 120;
536 const int kXPIndeterminateOverlayWidth = 55; 536 const int kXPIndeterminateOverlayWidth = 55;
537 // The thickness of the bar frame inside |value_rect| 537 // The thickness of the bar frame inside |value_rect|
538 const int kXPBarPadding = 3; 538 const int kXPBarPadding = 3;
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 handle = open_theme_(NULL, L"Spin"); 865 handle = open_theme_(NULL, L"Spin");
866 break; 866 break;
867 default: 867 default:
868 NOTREACHED(); 868 NOTREACHED();
869 } 869 }
870 theme_handles_[theme_name] = handle; 870 theme_handles_[theme_name] = handle;
871 return handle; 871 return handle;
872 } 872 }
873 873
874 } // namespace gfx 874 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698