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

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: remove !_WIN64 restriction on error reporting Created 4 years, 6 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/win/scoped_gdi_object.h" 15 #include "base/win/scoped_gdi_object.h"
16 #include "base/win/scoped_hdc.h" 16 #include "base/win/scoped_hdc.h"
17 #include "base/win/scoped_select_object.h" 17 #include "base/win/scoped_select_object.h"
18 #include "base/win/windows_version.h" 18 #include "base/win/windows_version.h"
19 #include "skia/ext/bitmap_platform_device.h"
20 #include "skia/ext/platform_canvas.h" 19 #include "skia/ext/platform_canvas.h"
21 #include "skia/ext/skia_utils_win.h" 20 #include "skia/ext/skia_utils_win.h"
22 #include "third_party/skia/include/core/SkCanvas.h" 21 #include "third_party/skia/include/core/SkCanvas.h"
23 #include "third_party/skia/include/core/SkColor.h" 22 #include "third_party/skia/include/core/SkColor.h"
24 #include "third_party/skia/include/core/SkColorPriv.h" 23 #include "third_party/skia/include/core/SkColorPriv.h"
25 #include "third_party/skia/include/core/SkRefCnt.h" 24 #include "third_party/skia/include/core/SkRefCnt.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/display/win/dpi.h" 28 #include "ui/display/win/dpi.h"
29 #include "ui/gfx/color_palette.h" 29 #include "ui/gfx/color_palette.h"
30 #include "ui/gfx/color_utils.h" 30 #include "ui/gfx/color_utils.h"
31 #include "ui/gfx/gdi_util.h" 31 #include "ui/gfx/gdi_util.h"
32 #include "ui/gfx/geometry/rect.h" 32 #include "ui/gfx/geometry/rect.h"
33 #include "ui/gfx/geometry/rect_conversions.h" 33 #include "ui/gfx/geometry/rect_conversions.h"
34 #include "ui/gfx/skia_util.h" 34 #include "ui/gfx/skia_util.h"
35 #include "ui/native_theme/common_theme.h" 35 #include "ui/native_theme/common_theme.h"
36 36
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 case kScrollbarHorizontalGripper: 277 case kScrollbarHorizontalGripper:
278 case kScrollbarVerticalGripper: 278 case kScrollbarVerticalGripper:
279 needs_paint_indirect = !GetThemeHandle(SCROLLBAR) || 279 needs_paint_indirect = !GetThemeHandle(SCROLLBAR) ||
280 base::win::GetVersion() == base::win::VERSION_XP; 280 base::win::GetVersion() == base::win::VERSION_XP;
281 break; 281 break;
282 default: 282 default:
283 break; 283 break;
284 } 284 }
285 } 285 }
286 286
287 skia::ScopedPlatformPaint paint(canvas);
288 HDC surface = paint.GetPlatformSurface();
287 if (needs_paint_indirect) 289 if (needs_paint_indirect)
288 PaintIndirect(canvas, part, state, rect, extra); 290 PaintIndirect(surface, part, state, rect, extra);
289 else 291 else
290 PaintDirect(canvas, part, state, rect, extra); 292 PaintDirect(surface, part, state, rect, extra);
291 } 293 }
292 294
293 NativeThemeWin::NativeThemeWin() 295 NativeThemeWin::NativeThemeWin()
294 : draw_theme_(NULL), 296 : draw_theme_(NULL),
295 draw_theme_ex_(NULL), 297 draw_theme_ex_(NULL),
296 get_theme_color_(NULL), 298 get_theme_color_(NULL),
297 get_theme_content_rect_(NULL), 299 get_theme_content_rect_(NULL),
298 get_theme_part_size_(NULL), 300 get_theme_part_size_(NULL),
299 open_theme_(NULL), 301 open_theme_(NULL),
300 close_theme_(NULL), 302 close_theme_(NULL),
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 canvas->drawLine(position_x, rect.y(), position_x, rect.bottom(), paint); 371 canvas->drawLine(position_x, rect.y(), position_x, rect.bottom(), paint);
370 } 372 }
371 373
372 void NativeThemeWin::PaintMenuBackground(SkCanvas* canvas, 374 void NativeThemeWin::PaintMenuBackground(SkCanvas* canvas,
373 const gfx::Rect& rect) const { 375 const gfx::Rect& rect) const {
374 SkPaint paint; 376 SkPaint paint;
375 paint.setColor(GetSystemColor(NativeTheme::kColorId_MenuBackgroundColor)); 377 paint.setColor(GetSystemColor(NativeTheme::kColorId_MenuBackgroundColor));
376 canvas->drawRect(gfx::RectToSkRect(rect), paint); 378 canvas->drawRect(gfx::RectToSkRect(rect), paint);
377 } 379 }
378 380
379 void NativeThemeWin::PaintDirect(SkCanvas* canvas, 381 void NativeThemeWin::PaintDirect(HDC hdc,
380 Part part, 382 Part part,
381 State state, 383 State state,
382 const gfx::Rect& rect, 384 const gfx::Rect& rect,
383 const ExtraParams& extra) const { 385 const ExtraParams& extra) const {
384 skia::ScopedPlatformPaint scoped_platform_paint(canvas);
385 HDC hdc = scoped_platform_paint.GetPlatformSurface();
386
387 switch (part) { 386 switch (part) {
388 case kCheckbox: 387 case kCheckbox:
389 PaintCheckbox(hdc, part, state, rect, extra.button); 388 PaintCheckbox(hdc, part, state, rect, extra.button);
390 return; 389 return;
391 case kInnerSpinButton: 390 case kInnerSpinButton:
392 PaintSpinButton(hdc, part, state, rect, extra.inner_spin); 391 PaintSpinButton(hdc, part, state, rect, extra.inner_spin);
393 return; 392 return;
394 case kMenuList: 393 case kMenuList:
395 PaintMenuList(hdc, state, rect, extra.menu_list); 394 PaintMenuList(hdc, state, rect, extra.menu_list);
396 return; 395 return;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 PaintScrollbarArrow(hdc, part, state, rect, extra.scrollbar_arrow); 430 PaintScrollbarArrow(hdc, part, state, rect, extra.scrollbar_arrow);
432 return; 431 return;
433 case kScrollbarHorizontalThumb: 432 case kScrollbarHorizontalThumb:
434 case kScrollbarVerticalThumb: 433 case kScrollbarVerticalThumb:
435 case kScrollbarHorizontalGripper: 434 case kScrollbarHorizontalGripper:
436 case kScrollbarVerticalGripper: 435 case kScrollbarVerticalGripper:
437 PaintScrollbarThumb(hdc, part, state, rect, extra.scrollbar_thumb); 436 PaintScrollbarThumb(hdc, part, state, rect, extra.scrollbar_thumb);
438 return; 437 return;
439 case kScrollbarHorizontalTrack: 438 case kScrollbarHorizontalTrack:
440 case kScrollbarVerticalTrack: 439 case kScrollbarVerticalTrack:
441 PaintScrollbarTrack(canvas, hdc, part, state, rect, 440 PaintScrollbarTrack(hdc, part, state, rect, extra.scrollbar_track);
442 extra.scrollbar_track);
443 return; 441 return;
444 case kScrollbarCorner: 442 case kScrollbarCorner: {
445 canvas->drawColor(SK_ColorWHITE, SkXfermode::kSrc_Mode); 443 sk_sp<SkSurface> surface(skia::MapPlatformSurface(hdc));
444 SkCanvas* canvas = surface ? surface->getCanvas() : nullptr;
tomhudson 2016/06/22 21:29:58 This really *ought* to succeed, given that skia::S
Peter Kasting 2016/06/22 23:43:51 If we're sure that has to work, I'd rather do that
445 if (canvas)
446 canvas->drawColor(SK_ColorWHITE, SkXfermode::kSrc_Mode);
446 return; 447 return;
448 }
447 case kTabPanelBackground: 449 case kTabPanelBackground:
448 PaintTabPanelBackground(hdc, rect); 450 PaintTabPanelBackground(hdc, rect);
449 return; 451 return;
450 case kTextField: 452 case kTextField:
451 PaintTextField(hdc, part, state, rect, extra.text_field); 453 PaintTextField(hdc, part, state, rect, extra.text_field);
452 return; 454 return;
453 case kTrackbarThumb: 455 case kTrackbarThumb:
454 case kTrackbarTrack: 456 case kTrackbarTrack:
455 PaintTrackbar(canvas, hdc, part, state, rect, extra.trackbar); 457 PaintTrackbar(hdc, part, state, rect, extra.trackbar);
456 return; 458 return;
457 case kWindowResizeGripper: 459 case kWindowResizeGripper:
458 PaintWindowResizeGripper(hdc, rect); 460 PaintWindowResizeGripper(hdc, rect);
459 return; 461 return;
460 case kSliderTrack: 462 case kSliderTrack:
461 case kSliderThumb: 463 case kSliderThumb:
462 case kMaxPart: 464 case kMaxPart:
463 NOTREACHED(); 465 NOTREACHED();
464 } 466 }
465 } 467 }
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 case NativeTheme::kColorId_CallToActionColor: 660 case NativeTheme::kColorId_CallToActionColor:
659 return kCallToActionColorInvert; 661 return kCallToActionColorInvert;
660 default: 662 default:
661 return color_utils::InvertColor(GetAuraColor(color_id, this)); 663 return color_utils::InvertColor(GetAuraColor(color_id, this));
662 } 664 }
663 } 665 }
664 666
665 return GetAuraColor(color_id, this); 667 return GetAuraColor(color_id, this);
666 } 668 }
667 669
668 void NativeThemeWin::PaintIndirect(SkCanvas* canvas, 670 void NativeThemeWin::PaintIndirect(HDC hdc,
669 Part part, 671 Part part,
670 State state, 672 State state,
671 const gfx::Rect& rect, 673 const gfx::Rect& rect,
672 const ExtraParams& extra) const { 674 const ExtraParams& extra) const {
673 // TODO(asvitkine): This path is pretty inefficient - for each paint operation 675 // TODO(asvitkine): This path is pretty inefficient - for each paint operation
674 // it creates a new offscreen bitmap Skia canvas. This can 676 // it creates a new offscreen bitmap Skia canvas. This can
675 // be sped up by doing it only once per part/state and 677 // be sped up by doing it only once per part/state and
676 // keeping a cache of the resulting bitmaps. 678 // keeping a cache of the resulting bitmaps.
677 679
678 // Create an offscreen canvas that is backed by an HDC. 680 // Create an offscreen canvas that is backed by an HDC.
679 sk_sp<skia::BitmapPlatformDevice> device( 681 base::win::ScopedCreateDC offscreen_hdc
680 skia::BitmapPlatformDevice::Create( 682 (skia::CreateOffscreenSurface(rect.width(), rect.height()));
681 rect.width(), rect.height(), false, NULL)); 683 sk_sp<SkSurface> offscreen_surface
682 DCHECK(device); 684 (skia::MapPlatformSurface(offscreen_hdc.Get()));
683 SkCanvas offscreen_canvas(device.get()); 685 DCHECK(offscreen_surface);
684 DCHECK(skia::SupportsPlatformPaint(&offscreen_canvas)); 686 SkCanvas* offscreen_canvas = offscreen_surface->getCanvas();
687 DCHECK(offscreen_canvas);
Peter Kasting 2016/06/22 02:23:34 It's really unclear to me how we know when to null
tomhudson 2016/06/22 21:29:58 We don't have any control over the canvas passed i
685 688
686 // Some of the Windows theme drawing operations do not write correct alpha 689 // Some of the Windows theme drawing operations do not write correct alpha
687 // values for fully-opaque pixels; instead the pixels get alpha 0. This is 690 // values for fully-opaque pixels; instead the pixels get alpha 0. This is
688 // especially a problem on Windows XP or when using the Classic theme. 691 // especially a problem on Windows XP or when using the Classic theme.
689 // 692 //
690 // To work-around this, mark all pixels with a placeholder value, to detect 693 // To work-around this, mark all pixels with a placeholder value, to detect
691 // which pixels get touched by the paint operation. After paint, set any 694 // which pixels get touched by the paint operation. After paint, set any
692 // pixels that have alpha 0 to opaque and placeholders to fully-transparent. 695 // pixels that have alpha 0 to opaque and placeholders to fully-transparent.
693 const SkColor placeholder = SkColorSetARGB(1, 0, 0, 0); 696 const SkColor placeholder = SkColorSetARGB(1, 0, 0, 0);
694 offscreen_canvas.clear(placeholder); 697 offscreen_canvas->clear(placeholder);
695 698
696 // Offset destination rects to have origin (0,0). 699 // Offset destination rects to have origin (0,0).
697 gfx::Rect adjusted_rect(rect.size()); 700 gfx::Rect adjusted_rect(rect.size());
698 ExtraParams adjusted_extra(extra); 701 ExtraParams adjusted_extra(extra);
699 switch (part) { 702 switch (part) {
700 case kProgressBar: 703 case kProgressBar:
701 adjusted_extra.progress_bar.value_rect_x = 0; 704 adjusted_extra.progress_bar.value_rect_x = 0;
702 adjusted_extra.progress_bar.value_rect_y = 0; 705 adjusted_extra.progress_bar.value_rect_y = 0;
703 break; 706 break;
704 case kScrollbarHorizontalTrack: 707 case kScrollbarHorizontalTrack:
705 case kScrollbarVerticalTrack: 708 case kScrollbarVerticalTrack:
706 adjusted_extra.scrollbar_track.track_x = 0; 709 adjusted_extra.scrollbar_track.track_x = 0;
707 adjusted_extra.scrollbar_track.track_y = 0; 710 adjusted_extra.scrollbar_track.track_y = 0;
708 break; 711 break;
709 default: 712 default:
710 break; 713 break;
711 } 714 }
715
716 SkBitmap bitmap = skia::ReadPixels(offscreen_canvas);
712 // Draw the theme controls using existing HDC-drawing code. 717 // Draw the theme controls using existing HDC-drawing code.
713 PaintDirect(&offscreen_canvas, part, state, adjusted_rect, adjusted_extra); 718 PaintDirect(offscreen_hdc.Get(), part, state, adjusted_rect, adjusted_extra);
714
715 SkBitmap bitmap = skia::ReadPixels(&offscreen_canvas);
716 719
717 // Post-process the pixels to fix up the alpha values (see big comment above). 720 // Post-process the pixels to fix up the alpha values (see big comment above).
721 SkBitmap offscreen_bitmap = skia::MapPlatformBitmap(offscreen_hdc.Get());
718 const SkPMColor placeholder_value = SkPreMultiplyColor(placeholder); 722 const SkPMColor placeholder_value = SkPreMultiplyColor(placeholder);
719 const int pixel_count = rect.width() * rect.height(); 723 const int pixel_count = rect.width() * rect.height();
720 SkPMColor* pixels = bitmap.getAddr32(0, 0); 724 SkPMColor* pixels = offscreen_bitmap.getAddr32(0, 0);
721 for (int i = 0; i < pixel_count; i++) { 725 for (int i = 0; i < pixel_count; i++) {
722 if (pixels[i] == placeholder_value) { 726 if (pixels[i] == placeholder_value) {
723 // Pixel wasn't touched - make it fully transparent. 727 // Pixel wasn't touched - make it fully transparent.
724 pixels[i] = SkPackARGB32(0, 0, 0, 0); 728 pixels[i] = SkPackARGB32(0, 0, 0, 0);
725 } else if (SkGetPackedA32(pixels[i]) == 0) { 729 } else if (SkGetPackedA32(pixels[i]) == 0) {
726 // Pixel was touched but has incorrect alpha of 0, make it fully opaque. 730 // Pixel was touched but has incorrect alpha of 0, make it fully opaque.
727 pixels[i] = SkPackARGB32(0xFF, 731 pixels[i] = SkPackARGB32(0xFF,
728 SkGetPackedR32(pixels[i]), 732 SkGetPackedR32(pixels[i]),
729 SkGetPackedG32(pixels[i]), 733 SkGetPackedG32(pixels[i]),
730 SkGetPackedB32(pixels[i])); 734 SkGetPackedB32(pixels[i]));
731 } 735 }
732 } 736 }
733 737
734 // Draw the offscreen bitmap to the destination canvas. 738 sk_sp<SkSurface> destination_surface(skia::MapPlatformSurface(hdc));
735 canvas->drawBitmap(bitmap, rect.x(), rect.y()); 739 DCHECK(destination_surface);
740 SkCanvas* destination_canvas = destination_surface->getCanvas();
741 DCHECK(destination_canvas);
742 destination_canvas->drawBitmap(offscreen_bitmap, rect.x(), rect.y());
736 } 743 }
737 744
738 HRESULT NativeThemeWin::GetThemePartSize(ThemeName theme_name, 745 HRESULT NativeThemeWin::GetThemePartSize(ThemeName theme_name,
739 HDC hdc, 746 HDC hdc,
740 int part_id, 747 int part_id,
741 int state_id, 748 int state_id,
742 RECT* rect, 749 RECT* rect,
743 int ts, 750 int ts,
744 SIZE* size) const { 751 SIZE* size) const {
745 HANDLE handle = GetThemeHandle(theme_name); 752 HANDLE handle = GetThemeHandle(theme_name);
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 return PaintScaledTheme(handle, hdc, part_id, state_id, rect); 1249 return PaintScaledTheme(handle, hdc, part_id, state_id, rect);
1243 1250
1244 // Draw it manually. 1251 // Draw it manually.
1245 if ((part_id == SBP_THUMBBTNHORZ) || (part_id == SBP_THUMBBTNVERT)) 1252 if ((part_id == SBP_THUMBBTNHORZ) || (part_id == SBP_THUMBBTNVERT))
1246 DrawEdge(hdc, &rect_win, EDGE_RAISED, BF_RECT | BF_MIDDLE); 1253 DrawEdge(hdc, &rect_win, EDGE_RAISED, BF_RECT | BF_MIDDLE);
1247 // Classic mode doesn't have a gripper. 1254 // Classic mode doesn't have a gripper.
1248 return S_OK; 1255 return S_OK;
1249 } 1256 }
1250 1257
1251 HRESULT NativeThemeWin::PaintScrollbarTrack( 1258 HRESULT NativeThemeWin::PaintScrollbarTrack(
1252 SkCanvas* canvas,
1253 HDC hdc, 1259 HDC hdc,
1254 Part part, 1260 Part part,
1255 State state, 1261 State state,
1256 const gfx::Rect& rect, 1262 const gfx::Rect& rect,
1257 const ScrollbarTrackExtraParams& extra) const { 1263 const ScrollbarTrackExtraParams& extra) const {
1258 HANDLE handle = GetThemeHandle(SCROLLBAR); 1264 HANDLE handle = GetThemeHandle(SCROLLBAR);
1259 RECT rect_win = rect.ToRECT(); 1265 RECT rect_win = rect.ToRECT();
1260 1266
1261 const int part_id = extra.is_upper ? 1267 const int part_id = extra.is_upper ?
1262 ((part == kScrollbarHorizontalTrack) ? 1268 ((part == kScrollbarHorizontalTrack) ?
(...skipping 20 matching lines...) Expand all
1283 } 1289 }
1284 1290
1285 if (handle && draw_theme_) 1291 if (handle && draw_theme_)
1286 return draw_theme_(handle, hdc, part_id, state_id, &rect_win, NULL); 1292 return draw_theme_(handle, hdc, part_id, state_id, &rect_win, NULL);
1287 1293
1288 // Draw it manually. 1294 // Draw it manually.
1289 if ((system_colors_[COLOR_SCROLLBAR] != system_colors_[COLOR_3DFACE]) && 1295 if ((system_colors_[COLOR_SCROLLBAR] != system_colors_[COLOR_3DFACE]) &&
1290 (system_colors_[COLOR_SCROLLBAR] != system_colors_[COLOR_WINDOW])) { 1296 (system_colors_[COLOR_SCROLLBAR] != system_colors_[COLOR_WINDOW])) {
1291 FillRect(hdc, &rect_win, reinterpret_cast<HBRUSH>(COLOR_SCROLLBAR + 1)); 1297 FillRect(hdc, &rect_win, reinterpret_cast<HBRUSH>(COLOR_SCROLLBAR + 1));
1292 } else { 1298 } else {
1299 sk_sp<SkSurface> surface(skia::MapPlatformSurface(hdc));
1300 SkCanvas* canvas = surface ? surface->getCanvas() : nullptr;
1301 if (!canvas)
1302 return E_FAIL;
1293 SkPaint paint; 1303 SkPaint paint;
1294 RECT align_rect = gfx::Rect(extra.track_x, extra.track_y, extra.track_width, 1304 RECT align_rect = gfx::Rect(extra.track_x, extra.track_y, extra.track_width,
1295 extra.track_height).ToRECT(); 1305 extra.track_height).ToRECT();
1296 SetCheckerboardShader(&paint, align_rect); 1306 SetCheckerboardShader(&paint, align_rect);
1297 canvas->drawIRect(skia::RECTToSkIRect(rect_win), paint); 1307 canvas->drawIRect(skia::RECTToSkIRect(rect_win), paint);
1298 } 1308 }
1299 if (extra.classic_state & DFCS_PUSHED) 1309 if (extra.classic_state & DFCS_PUSHED)
1300 InvertRect(hdc, &rect_win); 1310 InvertRect(hdc, &rect_win);
1301 return S_OK; 1311 return S_OK;
1302 } 1312 }
(...skipping 25 matching lines...) Expand all
1328 break; 1338 break;
1329 } 1339 }
1330 1340
1331 if (handle && draw_theme_) 1341 if (handle && draw_theme_)
1332 return draw_theme_(handle, hdc, part_id, state_id, &rect_win, NULL); 1342 return draw_theme_(handle, hdc, part_id, state_id, &rect_win, NULL);
1333 DrawFrameControl(hdc, &rect_win, DFC_SCROLL, extra.classic_state); 1343 DrawFrameControl(hdc, &rect_win, DFC_SCROLL, extra.classic_state);
1334 return S_OK; 1344 return S_OK;
1335 } 1345 }
1336 1346
1337 HRESULT NativeThemeWin::PaintTrackbar( 1347 HRESULT NativeThemeWin::PaintTrackbar(
1338 SkCanvas* canvas,
1339 HDC hdc, 1348 HDC hdc,
1340 Part part, 1349 Part part,
1341 State state, 1350 State state,
1342 const gfx::Rect& rect, 1351 const gfx::Rect& rect,
1343 const TrackbarExtraParams& extra) const { 1352 const TrackbarExtraParams& extra) const {
1344 const int part_id = extra.vertical ? 1353 const int part_id = extra.vertical ?
1345 ((part == kTrackbarTrack) ? TKP_TRACKVERT : TKP_THUMBVERT) : 1354 ((part == kTrackbarTrack) ? TKP_TRACKVERT : TKP_THUMBVERT) :
1346 ((part == kTrackbarTrack) ? TKP_TRACK : TKP_THUMBBOTTOM); 1355 ((part == kTrackbarTrack) ? TKP_TRACK : TKP_THUMBBOTTOM);
1347 1356
1348 int state_id = TUS_NORMAL; 1357 int state_id = TUS_NORMAL;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 RECT right_half = bottom_section; 1411 RECT right_half = bottom_section;
1403 right_half.left += ((bottom_section.right - bottom_section.left) / 2); 1412 right_half.left += ((bottom_section.right - bottom_section.left) / 2);
1404 left_half.right = right_half.left; 1413 left_half.right = right_half.left;
1405 DrawEdge(hdc, &left_half, EDGE_RAISED, 1414 DrawEdge(hdc, &left_half, EDGE_RAISED,
1406 BF_DIAGONAL_ENDTOPLEFT | BF_SOFT | BF_MIDDLE | BF_ADJUST); 1415 BF_DIAGONAL_ENDTOPLEFT | BF_SOFT | BF_MIDDLE | BF_ADJUST);
1407 DrawEdge(hdc, &right_half, EDGE_RAISED, 1416 DrawEdge(hdc, &right_half, EDGE_RAISED,
1408 BF_DIAGONAL_ENDBOTTOMLEFT | BF_SOFT | BF_MIDDLE | BF_ADJUST); 1417 BF_DIAGONAL_ENDBOTTOMLEFT | BF_SOFT | BF_MIDDLE | BF_ADJUST);
1409 1418
1410 // If the button is pressed, draw hatching. 1419 // If the button is pressed, draw hatching.
1411 if (extra.classic_state & DFCS_PUSHED) { 1420 if (extra.classic_state & DFCS_PUSHED) {
1421 sk_sp<SkSurface> surface(skia::MapPlatformSurface(hdc));
1422 SkCanvas* canvas = surface ? surface->getCanvas() : nullptr;
1423 if (!canvas)
1424 return E_FAIL;
1412 SkPaint paint; 1425 SkPaint paint;
1413 SetCheckerboardShader(&paint, rect_win); 1426 SetCheckerboardShader(&paint, rect_win);
1414 1427
1415 // Fill all three pieces with the pattern. 1428 // Fill all three pieces with the pattern.
1416 canvas->drawIRect(skia::RECTToSkIRect(top_section), paint); 1429 canvas->drawIRect(skia::RECTToSkIRect(top_section), paint);
1417 1430
1418 SkScalar left_triangle_top = SkIntToScalar(left_half.top); 1431 SkScalar left_triangle_top = SkIntToScalar(left_half.top);
1419 SkScalar left_triangle_right = SkIntToScalar(left_half.right); 1432 SkScalar left_triangle_right = SkIntToScalar(left_half.right);
1420 SkPath left_triangle; 1433 SkPath left_triangle;
1421 left_triangle.moveTo(SkIntToScalar(left_half.left), left_triangle_top); 1434 left_triangle.moveTo(SkIntToScalar(left_half.left), left_triangle_top);
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
2072 break; 2085 break;
2073 case LAST: 2086 case LAST:
2074 NOTREACHED(); 2087 NOTREACHED();
2075 break; 2088 break;
2076 } 2089 }
2077 theme_handles_[theme_name] = handle; 2090 theme_handles_[theme_name] = handle;
2078 return handle; 2091 return handle;
2079 } 2092 }
2080 2093
2081 } // namespace ui 2094 } // 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