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

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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 return S_OK; 533 return S_OK;
534 } 534 }
535 535
536 HRESULT NativeThemeWin::PaintScrollbarTrack( 536 HRESULT NativeThemeWin::PaintScrollbarTrack(
537 HDC hdc, 537 HDC hdc,
538 int part_id, 538 int part_id,
539 int state_id, 539 int state_id,
540 int classic_state, 540 int classic_state,
541 RECT* target_rect, 541 RECT* target_rect,
542 RECT* align_rect, 542 RECT* align_rect,
543 skia::PlatformCanvas* canvas) const { 543 SkCanvas* canvas) const {
544 HANDLE handle = GetThemeHandle(SCROLLBAR); 544 HANDLE handle = GetThemeHandle(SCROLLBAR);
545 if (handle && draw_theme_) 545 if (handle && draw_theme_)
546 return draw_theme_(handle, hdc, part_id, state_id, target_rect, NULL); 546 return draw_theme_(handle, hdc, part_id, state_id, target_rect, NULL);
547 547
548 // Draw it manually. 548 // Draw it manually.
549 const DWORD colorScrollbar = GetSysColor(COLOR_SCROLLBAR); 549 const DWORD colorScrollbar = GetSysColor(COLOR_SCROLLBAR);
550 const DWORD color3DFace = GetSysColor(COLOR_3DFACE); 550 const DWORD color3DFace = GetSysColor(COLOR_3DFACE);
551 if ((colorScrollbar != color3DFace) && 551 if ((colorScrollbar != color3DFace) &&
552 (colorScrollbar != GetSysColor(COLOR_WINDOW))) { 552 (colorScrollbar != GetSysColor(COLOR_WINDOW))) {
553 FillRect(hdc, target_rect, reinterpret_cast<HBRUSH>(COLOR_SCROLLBAR + 1)); 553 FillRect(hdc, target_rect, reinterpret_cast<HBRUSH>(COLOR_SCROLLBAR + 1));
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 // Classic just renders a flat color background. 616 // Classic just renders a flat color background.
617 FillRect(hdc, rect, reinterpret_cast<HBRUSH>(COLOR_3DFACE + 1)); 617 FillRect(hdc, rect, reinterpret_cast<HBRUSH>(COLOR_3DFACE + 1));
618 return S_OK; 618 return S_OK;
619 } 619 }
620 620
621 HRESULT NativeThemeWin::PaintTrackbar(HDC hdc, 621 HRESULT NativeThemeWin::PaintTrackbar(HDC hdc,
622 int part_id, 622 int part_id,
623 int state_id, 623 int state_id,
624 int classic_state, 624 int classic_state,
625 RECT* rect, 625 RECT* rect,
626 skia::PlatformCanvas* canvas) const { 626 SkCanvas* canvas) const {
627 // Make the channel be 4 px thick in the center of the supplied rect. (4 px 627 // Make the channel be 4 px thick in the center of the supplied rect. (4 px
628 // matches what XP does in various menus; GetThemePartSize() doesn't seem to 628 // matches what XP does in various menus; GetThemePartSize() doesn't seem to
629 // return good values here.) 629 // return good values here.)
630 RECT channel_rect = *rect; 630 RECT channel_rect = *rect;
631 const int channel_thickness = 4; 631 const int channel_thickness = 4;
632 if (part_id == TKP_TRACK) { 632 if (part_id == TKP_TRACK) {
633 channel_rect.top += 633 channel_rect.top +=
634 ((channel_rect.bottom - channel_rect.top - channel_thickness) / 2); 634 ((channel_rect.bottom - channel_rect.top - channel_thickness) / 2);
635 channel_rect.bottom = channel_rect.top + channel_thickness; 635 channel_rect.bottom = channel_rect.top + channel_thickness;
636 } else if (part_id == TKP_TRACKVERT) { 636 } else if (part_id == TKP_TRACKVERT) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 gfx::Rect result(*rect); 725 gfx::Rect result(*rect);
726 result.Inset(size, size); 726 result.Inset(size, size);
727 return result.ToRECT(); 727 return result.ToRECT();
728 } 728 }
729 729
730 HRESULT NativeThemeWin::PaintProgressBar(HDC hdc, 730 HRESULT NativeThemeWin::PaintProgressBar(HDC hdc,
731 RECT* bar_rect, 731 RECT* bar_rect,
732 RECT* value_rect, 732 RECT* value_rect,
733 bool determinate, 733 bool determinate,
734 double animated_seconds, 734 double animated_seconds,
735 skia::PlatformCanvas* canvas) const { 735 SkCanvas* canvas) const {
736 // There is no documentation about the animation speed, frame-rate, nor 736 // There is no documentation about the animation speed, frame-rate, nor
737 // size of moving overlay of the indeterminate progress bar. 737 // size of moving overlay of the indeterminate progress bar.
738 // So we just observed real-world programs and guessed following parameters. 738 // So we just observed real-world programs and guessed following parameters.
739 const int kDeteminateOverlayPixelsPerSecond = 300; 739 const int kDeteminateOverlayPixelsPerSecond = 300;
740 const int kDeteminateOverlayWidth = 120; 740 const int kDeteminateOverlayWidth = 120;
741 const int kIndeterminateOverlayPixelsPerSecond = 175; 741 const int kIndeterminateOverlayPixelsPerSecond = 175;
742 const int kVistaIndeterminateOverlayWidth = 120; 742 const int kVistaIndeterminateOverlayWidth = 120;
743 const int kXPIndeterminateOverlayWidth = 55; 743 const int kXPIndeterminateOverlayWidth = 55;
744 // The thickness of the bar frame inside |value_rect| 744 // The thickness of the bar frame inside |value_rect|
745 const int kXPBarPadding = 3; 745 const int kXPBarPadding = 3;
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 default: 1149 default:
1150 // While transitioning NativeThemeWin to the single Paint() entry point, 1150 // While transitioning NativeThemeWin to the single Paint() entry point,
1151 // unsupported parts will DCHECK here. 1151 // unsupported parts will DCHECK here.
1152 DCHECK(false); 1152 DCHECK(false);
1153 break; 1153 break;
1154 } 1154 }
1155 return part_id; 1155 return part_id;
1156 } 1156 }
1157 1157
1158 } // namespace gfx 1158 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698