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

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

Issue 1492353002: Consolidate Windows bitmap and DC code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-printing-dc-from-device
Patch Set: Created 4 years, 10 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
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 "ui/native_theme/native_theme_win.h" 5 #include "ui/native_theme/native_theme_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <uxtheme.h> 9 #include <uxtheme.h>
10 #include <vsstyle.h> 10 #include <vsstyle.h>
11 #include <vssym32.h> 11 #include <vssym32.h>
12 12
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/win/scoped_gdi_object.h" 16 #include "base/win/scoped_gdi_object.h"
17 #include "base/win/scoped_hdc.h" 17 #include "base/win/scoped_hdc.h"
18 #include "base/win/scoped_select_object.h" 18 #include "base/win/scoped_select_object.h"
19 #include "base/win/windows_version.h" 19 #include "base/win/windows_version.h"
20 #include "skia/ext/bitmap_platform_device.h"
21 #include "skia/ext/platform_canvas.h" 20 #include "skia/ext/platform_canvas.h"
22 #include "skia/ext/skia_utils_win.h" 21 #include "skia/ext/skia_utils_win.h"
23 #include "third_party/skia/include/core/SkCanvas.h" 22 #include "third_party/skia/include/core/SkCanvas.h"
24 #include "third_party/skia/include/core/SkColor.h" 23 #include "third_party/skia/include/core/SkColor.h"
25 #include "third_party/skia/include/core/SkColorPriv.h" 24 #include "third_party/skia/include/core/SkColorPriv.h"
26 #include "third_party/skia/include/core/SkShader.h" 25 #include "third_party/skia/include/core/SkShader.h"
26 #include "third_party/skia/include/core/SkSurface.h"
27 #include "ui/base/material_design/material_design_controller.h" 27 #include "ui/base/material_design/material_design_controller.h"
28 #include "ui/gfx/color_palette.h" 28 #include "ui/gfx/color_palette.h"
29 #include "ui/gfx/color_utils.h" 29 #include "ui/gfx/color_utils.h"
30 #include "ui/gfx/gdi_util.h" 30 #include "ui/gfx/gdi_util.h"
31 #include "ui/gfx/geometry/rect.h" 31 #include "ui/gfx/geometry/rect.h"
32 #include "ui/gfx/geometry/rect_conversions.h" 32 #include "ui/gfx/geometry/rect_conversions.h"
33 #include "ui/gfx/win/dpi.h" 33 #include "ui/gfx/win/dpi.h"
34 #include "ui/native_theme/common_theme.h" 34 #include "ui/native_theme/common_theme.h"
35 35
36 // This was removed from Winvers.h but is still used. 36 // This was removed from Winvers.h but is still used.
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 case kScrollbarHorizontalGripper: 285 case kScrollbarHorizontalGripper:
286 case kScrollbarVerticalGripper: 286 case kScrollbarVerticalGripper:
287 needs_paint_indirect = !GetThemeHandle(SCROLLBAR) || 287 needs_paint_indirect = !GetThemeHandle(SCROLLBAR) ||
288 base::win::GetVersion() == base::win::VERSION_XP; 288 base::win::GetVersion() == base::win::VERSION_XP;
289 break; 289 break;
290 default: 290 default:
291 break; 291 break;
292 } 292 }
293 } 293 }
294 294
295 skia::ScopedPlatformPaint paint(canvas);
296 HDC surface = paint.GetPlatformSurface();
295 if (needs_paint_indirect) 297 if (needs_paint_indirect)
296 PaintIndirect(canvas, part, state, rect, extra); 298 PaintIndirect(surface, part, state, rect, extra);
297 else 299 else
298 PaintDirect(canvas, part, state, rect, extra); 300 PaintDirect(surface, part, state, rect, extra);
299 } 301 }
300 302
301 NativeThemeWin::NativeThemeWin() 303 NativeThemeWin::NativeThemeWin()
302 : draw_theme_(NULL), 304 : draw_theme_(NULL),
303 draw_theme_ex_(NULL), 305 draw_theme_ex_(NULL),
304 get_theme_color_(NULL), 306 get_theme_color_(NULL),
305 get_theme_content_rect_(NULL), 307 get_theme_content_rect_(NULL),
306 get_theme_part_size_(NULL), 308 get_theme_part_size_(NULL),
307 open_theme_(NULL), 309 open_theme_(NULL),
308 close_theme_(NULL), 310 close_theme_(NULL),
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 UpdateSystemColors(); 356 UpdateSystemColors();
355 is_using_high_contrast_valid_ = false; 357 is_using_high_contrast_valid_ = false;
356 NotifyObservers(); 358 NotifyObservers();
357 } 359 }
358 360
359 void NativeThemeWin::UpdateSystemColors() { 361 void NativeThemeWin::UpdateSystemColors() {
360 for (int kSystemColor : kSystemColors) 362 for (int kSystemColor : kSystemColors)
361 system_colors_[kSystemColor] = color_utils::GetSysSkColor(kSystemColor); 363 system_colors_[kSystemColor] = color_utils::GetSysSkColor(kSystemColor);
362 } 364 }
363 365
364 void NativeThemeWin::PaintDirect(SkCanvas* canvas, 366 void NativeThemeWin::PaintDirect(HDC hdc,
365 Part part, 367 Part part,
366 State state, 368 State state,
367 const gfx::Rect& rect, 369 const gfx::Rect& rect,
368 const ExtraParams& extra) const { 370 const ExtraParams& extra) const {
369 skia::ScopedPlatformPaint scoped_platform_paint(canvas);
370 HDC hdc = scoped_platform_paint.GetPlatformSurface();
371
372 switch (part) { 371 switch (part) {
373 case kCheckbox: 372 case kCheckbox:
374 PaintCheckbox(hdc, part, state, rect, extra.button); 373 PaintCheckbox(hdc, part, state, rect, extra.button);
375 return; 374 return;
376 case kInnerSpinButton: 375 case kInnerSpinButton:
377 PaintSpinButton(hdc, part, state, rect, extra.inner_spin); 376 PaintSpinButton(hdc, part, state, rect, extra.inner_spin);
378 return; 377 return;
379 case kMenuList: 378 case kMenuList:
380 PaintMenuList(hdc, state, rect, extra.menu_list); 379 PaintMenuList(hdc, state, rect, extra.menu_list);
381 return; 380 return;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 PaintScrollbarArrow(hdc, part, state, rect, extra.scrollbar_arrow); 415 PaintScrollbarArrow(hdc, part, state, rect, extra.scrollbar_arrow);
417 return; 416 return;
418 case kScrollbarHorizontalThumb: 417 case kScrollbarHorizontalThumb:
419 case kScrollbarVerticalThumb: 418 case kScrollbarVerticalThumb:
420 case kScrollbarHorizontalGripper: 419 case kScrollbarHorizontalGripper:
421 case kScrollbarVerticalGripper: 420 case kScrollbarVerticalGripper:
422 PaintScrollbarThumb(hdc, part, state, rect, extra.scrollbar_thumb); 421 PaintScrollbarThumb(hdc, part, state, rect, extra.scrollbar_thumb);
423 return; 422 return;
424 case kScrollbarHorizontalTrack: 423 case kScrollbarHorizontalTrack:
425 case kScrollbarVerticalTrack: 424 case kScrollbarVerticalTrack:
426 PaintScrollbarTrack(canvas, hdc, part, state, rect, 425 PaintScrollbarTrack(hdc, part, state, rect, extra.scrollbar_track);
427 extra.scrollbar_track);
428 return; 426 return;
429 case kScrollbarCorner: 427 case kScrollbarCorner: {
430 canvas->drawColor(SK_ColorWHITE, SkXfermode::kSrc_Mode); 428 SkSurface* surface = skia::MapPlatformSurface(hdc);
429 SkCanvas* canvas = surface ? surface->getCanvas() : nullptr;
430 if (canvas)
431 canvas->drawColor(SK_ColorWHITE, SkXfermode::kSrc_Mode);
431 return; 432 return;
433 }
432 case kTabPanelBackground: 434 case kTabPanelBackground:
433 PaintTabPanelBackground(hdc, rect); 435 PaintTabPanelBackground(hdc, rect);
434 return; 436 return;
435 case kTextField: 437 case kTextField:
436 PaintTextField(hdc, part, state, rect, extra.text_field); 438 PaintTextField(hdc, part, state, rect, extra.text_field);
437 return; 439 return;
438 case kTrackbarThumb: 440 case kTrackbarThumb:
439 case kTrackbarTrack: 441 case kTrackbarTrack:
440 PaintTrackbar(canvas, hdc, part, state, rect, extra.trackbar); 442 PaintTrackbar(hdc, part, state, rect, extra.trackbar);
441 return; 443 return;
442 case kWindowResizeGripper: 444 case kWindowResizeGripper:
443 PaintWindowResizeGripper(hdc, rect); 445 PaintWindowResizeGripper(hdc, rect);
444 return; 446 return;
445 case kComboboxArrow: 447 case kComboboxArrow:
446 case kSliderTrack: 448 case kSliderTrack:
447 case kSliderThumb: 449 case kSliderThumb:
448 case kMaxPart: 450 case kMaxPart:
449 NOTREACHED(); 451 NOTREACHED();
450 } 452 }
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 case NativeTheme::kColorId_CallToActionColor: 646 case NativeTheme::kColorId_CallToActionColor:
645 return kCallToActionColorInvert; 647 return kCallToActionColorInvert;
646 default: 648 default:
647 return color_utils::InvertColor(GetAuraColor(color_id, this)); 649 return color_utils::InvertColor(GetAuraColor(color_id, this));
648 } 650 }
649 } 651 }
650 652
651 return GetAuraColor(color_id, this); 653 return GetAuraColor(color_id, this);
652 } 654 }
653 655
654 void NativeThemeWin::PaintIndirect(SkCanvas* canvas, 656 void NativeThemeWin::PaintIndirect(HDC hdc,
655 Part part, 657 Part part,
656 State state, 658 State state,
657 const gfx::Rect& rect, 659 const gfx::Rect& rect,
658 const ExtraParams& extra) const { 660 const ExtraParams& extra) const {
659 // TODO(asvitkine): This path is pretty inefficient - for each paint operation 661 // TODO(asvitkine): This path is pretty inefficient - for each paint operation
660 // it creates a new offscreen bitmap Skia canvas. This can 662 // it creates a new offscreen bitmap Skia canvas. This can
661 // be sped up by doing it only once per part/state and 663 // be sped up by doing it only once per part/state and
662 // keeping a cache of the resulting bitmaps. 664 // keeping a cache of the resulting bitmaps.
663 665
664 // Create an offscreen canvas that is backed by an HDC. 666 // Create an offscreen canvas that is backed by an HDC.
665 skia::RefPtr<skia::BitmapPlatformDevice> device = skia::AdoptRef( 667
666 skia::BitmapPlatformDevice::Create( 668 HDC offscreen_hdc = skia::CreateOffscreenSurface(rect.width(), rect.height());
Peter Kasting 2016/02/16 21:12:10 Nit: Use ScopedCreateDC here instead of a raw HDC
tomhudson 2016/06/21 22:20:23 Done.
667 rect.width(), rect.height(), false, NULL)); 669 SkSurface* offscreen_surface = skia::MapPlatformSurface(offscreen_hdc);
668 DCHECK(device); 670 DCHECK(offscreen_surface);
669 SkCanvas offscreen_canvas(device.get()); 671 SkCanvas* offscreen_canvas = offscreen_surface->getCanvas();
670 DCHECK(skia::SupportsPlatformPaint(&offscreen_canvas)); 672 DCHECK(offscreen_canvas);
671 673
672 // Some of the Windows theme drawing operations do not write correct alpha 674 // Some of the Windows theme drawing operations do not write correct alpha
673 // values for fully-opaque pixels; instead the pixels get alpha 0. This is 675 // values for fully-opaque pixels; instead the pixels get alpha 0. This is
674 // especially a problem on Windows XP or when using the Classic theme. 676 // especially a problem on Windows XP or when using the Classic theme.
675 // 677 //
676 // To work-around this, mark all pixels with a placeholder value, to detect 678 // To work-around this, mark all pixels with a placeholder value, to detect
677 // which pixels get touched by the paint operation. After paint, set any 679 // which pixels get touched by the paint operation. After paint, set any
678 // pixels that have alpha 0 to opaque and placeholders to fully-transparent. 680 // pixels that have alpha 0 to opaque and placeholders to fully-transparent.
679 const SkColor placeholder = SkColorSetARGB(1, 0, 0, 0); 681 const SkColor placeholder = SkColorSetARGB(1, 0, 0, 0);
680 offscreen_canvas.clear(placeholder); 682 offscreen_canvas->clear(placeholder);
681 683
682 // Offset destination rects to have origin (0,0). 684 // Offset destination rects to have origin (0,0).
683 gfx::Rect adjusted_rect(rect.size()); 685 gfx::Rect adjusted_rect(rect.size());
684 ExtraParams adjusted_extra(extra); 686 ExtraParams adjusted_extra(extra);
685 switch (part) { 687 switch (part) {
686 case kProgressBar: 688 case kProgressBar:
687 adjusted_extra.progress_bar.value_rect_x = 0; 689 adjusted_extra.progress_bar.value_rect_x = 0;
688 adjusted_extra.progress_bar.value_rect_y = 0; 690 adjusted_extra.progress_bar.value_rect_y = 0;
689 break; 691 break;
690 case kScrollbarHorizontalTrack: 692 case kScrollbarHorizontalTrack:
691 case kScrollbarVerticalTrack: 693 case kScrollbarVerticalTrack:
692 adjusted_extra.scrollbar_track.track_x = 0; 694 adjusted_extra.scrollbar_track.track_x = 0;
693 adjusted_extra.scrollbar_track.track_y = 0; 695 adjusted_extra.scrollbar_track.track_y = 0;
694 break; 696 break;
695 default: 697 default:
696 break; 698 break;
697 } 699 }
700
698 // Draw the theme controls using existing HDC-drawing code. 701 // Draw the theme controls using existing HDC-drawing code.
699 PaintDirect(&offscreen_canvas, part, state, adjusted_rect, adjusted_extra); 702 PaintDirect(offscreen_hdc, part, state, adjusted_rect, adjusted_extra);
700
701 // Copy the pixels to a bitmap that has ref-counted pixel storage, which is
702 // necessary to have when drawing to a SkPicture.
703 const SkBitmap& hdc_bitmap =
704 offscreen_canvas.getDevice()->accessBitmap(false);
705 SkBitmap bitmap;
706 hdc_bitmap.copyTo(&bitmap, kN32_SkColorType);
707 703
708 // Post-process the pixels to fix up the alpha values (see big comment above). 704 // Post-process the pixels to fix up the alpha values (see big comment above).
705 SkBitmap offscreen_bitmap = skia::MapPlatformBitmap(offscreen_hdc);
709 const SkPMColor placeholder_value = SkPreMultiplyColor(placeholder); 706 const SkPMColor placeholder_value = SkPreMultiplyColor(placeholder);
710 const int pixel_count = rect.width() * rect.height(); 707 const int pixel_count = rect.width() * rect.height();
711 SkPMColor* pixels = bitmap.getAddr32(0, 0); 708 SkPMColor* pixels = offscreen_bitmap.getAddr32(0, 0);
712 for (int i = 0; i < pixel_count; i++) { 709 for (int i = 0; i < pixel_count; i++) {
713 if (pixels[i] == placeholder_value) { 710 if (pixels[i] == placeholder_value) {
714 // Pixel wasn't touched - make it fully transparent. 711 // Pixel wasn't touched - make it fully transparent.
715 pixels[i] = SkPackARGB32(0, 0, 0, 0); 712 pixels[i] = SkPackARGB32(0, 0, 0, 0);
716 } else if (SkGetPackedA32(pixels[i]) == 0) { 713 } else if (SkGetPackedA32(pixels[i]) == 0) {
717 // Pixel was touched but has incorrect alpha of 0, make it fully opaque. 714 // Pixel was touched but has incorrect alpha of 0, make it fully opaque.
718 pixels[i] = SkPackARGB32(0xFF, 715 pixels[i] = SkPackARGB32(0xFF,
719 SkGetPackedR32(pixels[i]), 716 SkGetPackedR32(pixels[i]),
720 SkGetPackedG32(pixels[i]), 717 SkGetPackedG32(pixels[i]),
721 SkGetPackedB32(pixels[i])); 718 SkGetPackedB32(pixels[i]));
722 } 719 }
723 } 720 }
724 721
725 // Draw the offscreen bitmap to the destination canvas. 722 SkSurface* destination_surface = skia::MapPlatformSurface(hdc);
726 canvas->drawBitmap(bitmap, rect.x(), rect.y()); 723 DCHECK(destination_surface);
724 SkCanvas* destination_canvas = destination_surface->getCanvas();
725 DCHECK(destination_canvas);
726 destination_canvas->drawBitmap(offscreen_bitmap, rect.x(), rect.y());
727
728 DeleteDC(offscreen_hdc);
727 } 729 }
728 730
729 HRESULT NativeThemeWin::GetThemePartSize(ThemeName theme_name, 731 HRESULT NativeThemeWin::GetThemePartSize(ThemeName theme_name,
730 HDC hdc, 732 HDC hdc,
731 int part_id, 733 int part_id,
732 int state_id, 734 int state_id,
733 RECT* rect, 735 RECT* rect,
734 int ts, 736 int ts,
735 SIZE* size) const { 737 SIZE* size) const {
736 HANDLE handle = GetThemeHandle(theme_name); 738 HANDLE handle = GetThemeHandle(theme_name);
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 return PaintScaledTheme(handle, hdc, part_id, state_id, rect); 1235 return PaintScaledTheme(handle, hdc, part_id, state_id, rect);
1234 1236
1235 // Draw it manually. 1237 // Draw it manually.
1236 if ((part_id == SBP_THUMBBTNHORZ) || (part_id == SBP_THUMBBTNVERT)) 1238 if ((part_id == SBP_THUMBBTNHORZ) || (part_id == SBP_THUMBBTNVERT))
1237 DrawEdge(hdc, &rect_win, EDGE_RAISED, BF_RECT | BF_MIDDLE); 1239 DrawEdge(hdc, &rect_win, EDGE_RAISED, BF_RECT | BF_MIDDLE);
1238 // Classic mode doesn't have a gripper. 1240 // Classic mode doesn't have a gripper.
1239 return S_OK; 1241 return S_OK;
1240 } 1242 }
1241 1243
1242 HRESULT NativeThemeWin::PaintScrollbarTrack( 1244 HRESULT NativeThemeWin::PaintScrollbarTrack(
1243 SkCanvas* canvas,
1244 HDC hdc, 1245 HDC hdc,
1245 Part part, 1246 Part part,
1246 State state, 1247 State state,
1247 const gfx::Rect& rect, 1248 const gfx::Rect& rect,
1248 const ScrollbarTrackExtraParams& extra) const { 1249 const ScrollbarTrackExtraParams& extra) const {
1249 HANDLE handle = GetThemeHandle(SCROLLBAR); 1250 HANDLE handle = GetThemeHandle(SCROLLBAR);
1250 RECT rect_win = rect.ToRECT(); 1251 RECT rect_win = rect.ToRECT();
1251 1252
1252 const int part_id = extra.is_upper ? 1253 const int part_id = extra.is_upper ?
1253 ((part == kScrollbarHorizontalTrack) ? 1254 ((part == kScrollbarHorizontalTrack) ?
(...skipping 20 matching lines...) Expand all
1274 } 1275 }
1275 1276
1276 if (handle && draw_theme_) 1277 if (handle && draw_theme_)
1277 return draw_theme_(handle, hdc, part_id, state_id, &rect_win, NULL); 1278 return draw_theme_(handle, hdc, part_id, state_id, &rect_win, NULL);
1278 1279
1279 // Draw it manually. 1280 // Draw it manually.
1280 if ((system_colors_[COLOR_SCROLLBAR] != system_colors_[COLOR_3DFACE]) && 1281 if ((system_colors_[COLOR_SCROLLBAR] != system_colors_[COLOR_3DFACE]) &&
1281 (system_colors_[COLOR_SCROLLBAR] != system_colors_[COLOR_WINDOW])) { 1282 (system_colors_[COLOR_SCROLLBAR] != system_colors_[COLOR_WINDOW])) {
1282 FillRect(hdc, &rect_win, reinterpret_cast<HBRUSH>(COLOR_SCROLLBAR + 1)); 1283 FillRect(hdc, &rect_win, reinterpret_cast<HBRUSH>(COLOR_SCROLLBAR + 1));
1283 } else { 1284 } else {
1285 SkSurface* surface = skia::MapPlatformSurface(hdc);
1286 SkCanvas* canvas = surface ? surface->getCanvas() : nullptr;
1287 if (!canvas)
1288 return E_FAIL;
1284 SkPaint paint; 1289 SkPaint paint;
1285 RECT align_rect = gfx::Rect(extra.track_x, extra.track_y, extra.track_width, 1290 RECT align_rect = gfx::Rect(extra.track_x, extra.track_y, extra.track_width,
1286 extra.track_height).ToRECT(); 1291 extra.track_height).ToRECT();
1287 SetCheckerboardShader(&paint, align_rect); 1292 SetCheckerboardShader(&paint, align_rect);
1288 canvas->drawIRect(skia::RECTToSkIRect(rect_win), paint); 1293 canvas->drawIRect(skia::RECTToSkIRect(rect_win), paint);
1289 } 1294 }
1290 if (extra.classic_state & DFCS_PUSHED) 1295 if (extra.classic_state & DFCS_PUSHED)
1291 InvertRect(hdc, &rect_win); 1296 InvertRect(hdc, &rect_win);
1292 return S_OK; 1297 return S_OK;
1293 } 1298 }
(...skipping 25 matching lines...) Expand all
1319 break; 1324 break;
1320 } 1325 }
1321 1326
1322 if (handle && draw_theme_) 1327 if (handle && draw_theme_)
1323 return draw_theme_(handle, hdc, part_id, state_id, &rect_win, NULL); 1328 return draw_theme_(handle, hdc, part_id, state_id, &rect_win, NULL);
1324 DrawFrameControl(hdc, &rect_win, DFC_SCROLL, extra.classic_state); 1329 DrawFrameControl(hdc, &rect_win, DFC_SCROLL, extra.classic_state);
1325 return S_OK; 1330 return S_OK;
1326 } 1331 }
1327 1332
1328 HRESULT NativeThemeWin::PaintTrackbar( 1333 HRESULT NativeThemeWin::PaintTrackbar(
1329 SkCanvas* canvas,
1330 HDC hdc, 1334 HDC hdc,
1331 Part part, 1335 Part part,
1332 State state, 1336 State state,
1333 const gfx::Rect& rect, 1337 const gfx::Rect& rect,
1334 const TrackbarExtraParams& extra) const { 1338 const TrackbarExtraParams& extra) const {
1335 const int part_id = extra.vertical ? 1339 const int part_id = extra.vertical ?
1336 ((part == kTrackbarTrack) ? TKP_TRACKVERT : TKP_THUMBVERT) : 1340 ((part == kTrackbarTrack) ? TKP_TRACKVERT : TKP_THUMBVERT) :
1337 ((part == kTrackbarTrack) ? TKP_TRACK : TKP_THUMBBOTTOM); 1341 ((part == kTrackbarTrack) ? TKP_TRACK : TKP_THUMBBOTTOM);
1338 1342
1339 int state_id = TUS_NORMAL; 1343 int state_id = TUS_NORMAL;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 RECT right_half = bottom_section; 1397 RECT right_half = bottom_section;
1394 right_half.left += ((bottom_section.right - bottom_section.left) / 2); 1398 right_half.left += ((bottom_section.right - bottom_section.left) / 2);
1395 left_half.right = right_half.left; 1399 left_half.right = right_half.left;
1396 DrawEdge(hdc, &left_half, EDGE_RAISED, 1400 DrawEdge(hdc, &left_half, EDGE_RAISED,
1397 BF_DIAGONAL_ENDTOPLEFT | BF_SOFT | BF_MIDDLE | BF_ADJUST); 1401 BF_DIAGONAL_ENDTOPLEFT | BF_SOFT | BF_MIDDLE | BF_ADJUST);
1398 DrawEdge(hdc, &right_half, EDGE_RAISED, 1402 DrawEdge(hdc, &right_half, EDGE_RAISED,
1399 BF_DIAGONAL_ENDBOTTOMLEFT | BF_SOFT | BF_MIDDLE | BF_ADJUST); 1403 BF_DIAGONAL_ENDBOTTOMLEFT | BF_SOFT | BF_MIDDLE | BF_ADJUST);
1400 1404
1401 // If the button is pressed, draw hatching. 1405 // If the button is pressed, draw hatching.
1402 if (extra.classic_state & DFCS_PUSHED) { 1406 if (extra.classic_state & DFCS_PUSHED) {
1407 SkSurface* surface = skia::MapPlatformSurface(hdc);
1408 SkCanvas* canvas = surface ? surface->getCanvas() : nullptr;
1409 if (!canvas)
1410 return E_FAIL;
1403 SkPaint paint; 1411 SkPaint paint;
1404 SetCheckerboardShader(&paint, rect_win); 1412 SetCheckerboardShader(&paint, rect_win);
1405 1413
1406 // Fill all three pieces with the pattern. 1414 // Fill all three pieces with the pattern.
1407 canvas->drawIRect(skia::RECTToSkIRect(top_section), paint); 1415 canvas->drawIRect(skia::RECTToSkIRect(top_section), paint);
1408 1416
1409 SkScalar left_triangle_top = SkIntToScalar(left_half.top); 1417 SkScalar left_triangle_top = SkIntToScalar(left_half.top);
1410 SkScalar left_triangle_right = SkIntToScalar(left_half.right); 1418 SkScalar left_triangle_right = SkIntToScalar(left_half.right);
1411 SkPath left_triangle; 1419 SkPath left_triangle;
1412 left_triangle.moveTo(SkIntToScalar(left_half.left), left_triangle_top); 1420 left_triangle.moveTo(SkIntToScalar(left_half.left), left_triangle_top);
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
2066 break; 2074 break;
2067 case LAST: 2075 case LAST:
2068 NOTREACHED(); 2076 NOTREACHED();
2069 break; 2077 break;
2070 } 2078 }
2071 theme_handles_[theme_name] = handle; 2079 theme_handles_[theme_name] = handle;
2072 return handle; 2080 return handle;
2073 } 2081 }
2074 2082
2075 } // namespace ui 2083 } // namespace ui
OLDNEW
« skia/ext/skia_utils_win.cc ('K') | « ui/native_theme/native_theme_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698