OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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; |
| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 case NativeTheme::kColorId_CallToActionColor: | 667 case NativeTheme::kColorId_CallToActionColor: |
666 return kCallToActionColorInvert; | 668 return kCallToActionColorInvert; |
667 default: | 669 default: |
668 return color_utils::InvertColor(GetAuraColor(color_id, this)); | 670 return color_utils::InvertColor(GetAuraColor(color_id, this)); |
669 } | 671 } |
670 } | 672 } |
671 | 673 |
672 return GetAuraColor(color_id, this); | 674 return GetAuraColor(color_id, this); |
673 } | 675 } |
674 | 676 |
675 void NativeThemeWin::PaintIndirect(SkCanvas* canvas, | 677 void NativeThemeWin::PaintIndirect(HDC hdc, |
676 Part part, | 678 Part part, |
677 State state, | 679 State state, |
678 const gfx::Rect& rect, | 680 const gfx::Rect& rect, |
679 const ExtraParams& extra) const { | 681 const ExtraParams& extra) const { |
680 // TODO(asvitkine): This path is pretty inefficient - for each paint operation | 682 // TODO(asvitkine): This path is pretty inefficient - for each paint operation |
681 // it creates a new offscreen bitmap Skia canvas. This can | 683 // it creates a new offscreen bitmap Skia canvas. This can |
682 // be sped up by doing it only once per part/state and | 684 // be sped up by doing it only once per part/state and |
683 // keeping a cache of the resulting bitmaps. | 685 // keeping a cache of the resulting bitmaps. |
684 | 686 |
685 // Create an offscreen canvas that is backed by an HDC. | 687 // Create an offscreen canvas that is backed by an HDC. |
686 sk_sp<skia::BitmapPlatformDevice> device( | 688 base::win::ScopedCreateDC offscreen_hdc |
687 skia::BitmapPlatformDevice::Create( | 689 (skia::CreateOffscreenSurface(rect.width(), rect.height())); |
688 rect.width(), rect.height(), false, NULL)); | 690 sk_sp<SkSurface> offscreen_surface |
689 DCHECK(device); | 691 (skia::MapPlatformSurface(offscreen_hdc.Get())); |
690 SkCanvas offscreen_canvas(device.get()); | 692 DCHECK(offscreen_surface); |
691 DCHECK(skia::SupportsPlatformPaint(&offscreen_canvas)); | 693 SkCanvas* offscreen_canvas = offscreen_surface->getCanvas(); |
| 694 DCHECK(offscreen_canvas); |
692 | 695 |
693 // Some of the Windows theme drawing operations do not write correct alpha | 696 // Some of the Windows theme drawing operations do not write correct alpha |
694 // values for fully-opaque pixels; instead the pixels get alpha 0. This is | 697 // values for fully-opaque pixels; instead the pixels get alpha 0. This is |
695 // especially a problem on Windows XP or when using the Classic theme. | 698 // especially a problem on Windows XP or when using the Classic theme. |
696 // | 699 // |
697 // To work-around this, mark all pixels with a placeholder value, to detect | 700 // To work-around this, mark all pixels with a placeholder value, to detect |
698 // which pixels get touched by the paint operation. After paint, set any | 701 // which pixels get touched by the paint operation. After paint, set any |
699 // pixels that have alpha 0 to opaque and placeholders to fully-transparent. | 702 // pixels that have alpha 0 to opaque and placeholders to fully-transparent. |
700 const SkColor placeholder = SkColorSetARGB(1, 0, 0, 0); | 703 const SkColor placeholder = SkColorSetARGB(1, 0, 0, 0); |
701 offscreen_canvas.clear(placeholder); | 704 offscreen_canvas->clear(placeholder); |
702 | 705 |
703 // Offset destination rects to have origin (0,0). | 706 // Offset destination rects to have origin (0,0). |
704 gfx::Rect adjusted_rect(rect.size()); | 707 gfx::Rect adjusted_rect(rect.size()); |
705 ExtraParams adjusted_extra(extra); | 708 ExtraParams adjusted_extra(extra); |
706 switch (part) { | 709 switch (part) { |
707 case kProgressBar: | 710 case kProgressBar: |
708 adjusted_extra.progress_bar.value_rect_x = 0; | 711 adjusted_extra.progress_bar.value_rect_x = 0; |
709 adjusted_extra.progress_bar.value_rect_y = 0; | 712 adjusted_extra.progress_bar.value_rect_y = 0; |
710 break; | 713 break; |
711 case kScrollbarHorizontalTrack: | 714 case kScrollbarHorizontalTrack: |
712 case kScrollbarVerticalTrack: | 715 case kScrollbarVerticalTrack: |
713 adjusted_extra.scrollbar_track.track_x = 0; | 716 adjusted_extra.scrollbar_track.track_x = 0; |
714 adjusted_extra.scrollbar_track.track_y = 0; | 717 adjusted_extra.scrollbar_track.track_y = 0; |
715 break; | 718 break; |
716 default: | 719 default: |
717 break; | 720 break; |
718 } | 721 } |
| 722 |
| 723 SkBitmap bitmap = skia::ReadPixels(offscreen_canvas); |
719 // Draw the theme controls using existing HDC-drawing code. | 724 // Draw the theme controls using existing HDC-drawing code. |
720 PaintDirect(&offscreen_canvas, part, state, adjusted_rect, adjusted_extra); | 725 PaintDirect(offscreen_hdc.Get(), part, state, adjusted_rect, adjusted_extra); |
721 | |
722 SkBitmap bitmap = skia::ReadPixels(&offscreen_canvas); | |
723 | 726 |
724 // Post-process the pixels to fix up the alpha values (see big comment above). | 727 // Post-process the pixels to fix up the alpha values (see big comment above). |
| 728 SkBitmap offscreen_bitmap = skia::MapPlatformBitmap(offscreen_hdc.Get()); |
725 const SkPMColor placeholder_value = SkPreMultiplyColor(placeholder); | 729 const SkPMColor placeholder_value = SkPreMultiplyColor(placeholder); |
726 const int pixel_count = rect.width() * rect.height(); | 730 const int pixel_count = rect.width() * rect.height(); |
727 SkPMColor* pixels = bitmap.getAddr32(0, 0); | 731 SkPMColor* pixels = offscreen_bitmap.getAddr32(0, 0); |
728 for (int i = 0; i < pixel_count; i++) { | 732 for (int i = 0; i < pixel_count; i++) { |
729 if (pixels[i] == placeholder_value) { | 733 if (pixels[i] == placeholder_value) { |
730 // Pixel wasn't touched - make it fully transparent. | 734 // Pixel wasn't touched - make it fully transparent. |
731 pixels[i] = SkPackARGB32(0, 0, 0, 0); | 735 pixels[i] = SkPackARGB32(0, 0, 0, 0); |
732 } else if (SkGetPackedA32(pixels[i]) == 0) { | 736 } else if (SkGetPackedA32(pixels[i]) == 0) { |
733 // Pixel was touched but has incorrect alpha of 0, make it fully opaque. | 737 // Pixel was touched but has incorrect alpha of 0, make it fully opaque. |
734 pixels[i] = SkPackARGB32(0xFF, | 738 pixels[i] = SkPackARGB32(0xFF, |
735 SkGetPackedR32(pixels[i]), | 739 SkGetPackedR32(pixels[i]), |
736 SkGetPackedG32(pixels[i]), | 740 SkGetPackedG32(pixels[i]), |
737 SkGetPackedB32(pixels[i])); | 741 SkGetPackedB32(pixels[i])); |
738 } | 742 } |
739 } | 743 } |
740 | 744 |
741 // Draw the offscreen bitmap to the destination canvas. | 745 sk_sp<SkSurface> destination_surface(skia::MapPlatformSurface(hdc)); |
742 canvas->drawBitmap(bitmap, rect.x(), rect.y()); | 746 DCHECK(destination_surface); |
| 747 SkCanvas* destination_canvas = destination_surface->getCanvas(); |
| 748 DCHECK(destination_canvas); |
| 749 destination_canvas->drawBitmap(offscreen_bitmap, rect.x(), rect.y()); |
743 } | 750 } |
744 | 751 |
745 HRESULT NativeThemeWin::GetThemePartSize(ThemeName theme_name, | 752 HRESULT NativeThemeWin::GetThemePartSize(ThemeName theme_name, |
746 HDC hdc, | 753 HDC hdc, |
747 int part_id, | 754 int part_id, |
748 int state_id, | 755 int state_id, |
749 RECT* rect, | 756 RECT* rect, |
750 int ts, | 757 int ts, |
751 SIZE* size) const { | 758 SIZE* size) const { |
752 HANDLE handle = GetThemeHandle(theme_name); | 759 HANDLE handle = GetThemeHandle(theme_name); |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1249 return PaintScaledTheme(handle, hdc, part_id, state_id, rect); | 1256 return PaintScaledTheme(handle, hdc, part_id, state_id, rect); |
1250 | 1257 |
1251 // Draw it manually. | 1258 // Draw it manually. |
1252 if ((part_id == SBP_THUMBBTNHORZ) || (part_id == SBP_THUMBBTNVERT)) | 1259 if ((part_id == SBP_THUMBBTNHORZ) || (part_id == SBP_THUMBBTNVERT)) |
1253 DrawEdge(hdc, &rect_win, EDGE_RAISED, BF_RECT | BF_MIDDLE); | 1260 DrawEdge(hdc, &rect_win, EDGE_RAISED, BF_RECT | BF_MIDDLE); |
1254 // Classic mode doesn't have a gripper. | 1261 // Classic mode doesn't have a gripper. |
1255 return S_OK; | 1262 return S_OK; |
1256 } | 1263 } |
1257 | 1264 |
1258 HRESULT NativeThemeWin::PaintScrollbarTrack( | 1265 HRESULT NativeThemeWin::PaintScrollbarTrack( |
1259 SkCanvas* canvas, | |
1260 HDC hdc, | 1266 HDC hdc, |
1261 Part part, | 1267 Part part, |
1262 State state, | 1268 State state, |
1263 const gfx::Rect& rect, | 1269 const gfx::Rect& rect, |
1264 const ScrollbarTrackExtraParams& extra) const { | 1270 const ScrollbarTrackExtraParams& extra) const { |
1265 HANDLE handle = GetThemeHandle(SCROLLBAR); | 1271 HANDLE handle = GetThemeHandle(SCROLLBAR); |
1266 RECT rect_win = rect.ToRECT(); | 1272 RECT rect_win = rect.ToRECT(); |
1267 | 1273 |
1268 const int part_id = extra.is_upper ? | 1274 const int part_id = extra.is_upper ? |
1269 ((part == kScrollbarHorizontalTrack) ? | 1275 ((part == kScrollbarHorizontalTrack) ? |
(...skipping 20 matching lines...) Expand all Loading... |
1290 } | 1296 } |
1291 | 1297 |
1292 if (handle && draw_theme_) | 1298 if (handle && draw_theme_) |
1293 return draw_theme_(handle, hdc, part_id, state_id, &rect_win, NULL); | 1299 return draw_theme_(handle, hdc, part_id, state_id, &rect_win, NULL); |
1294 | 1300 |
1295 // Draw it manually. | 1301 // Draw it manually. |
1296 if ((system_colors_[COLOR_SCROLLBAR] != system_colors_[COLOR_3DFACE]) && | 1302 if ((system_colors_[COLOR_SCROLLBAR] != system_colors_[COLOR_3DFACE]) && |
1297 (system_colors_[COLOR_SCROLLBAR] != system_colors_[COLOR_WINDOW])) { | 1303 (system_colors_[COLOR_SCROLLBAR] != system_colors_[COLOR_WINDOW])) { |
1298 FillRect(hdc, &rect_win, reinterpret_cast<HBRUSH>(COLOR_SCROLLBAR + 1)); | 1304 FillRect(hdc, &rect_win, reinterpret_cast<HBRUSH>(COLOR_SCROLLBAR + 1)); |
1299 } else { | 1305 } else { |
| 1306 sk_sp<SkSurface> surface(skia::MapPlatformSurface(hdc)); |
| 1307 SkCanvas* canvas = surface ? surface->getCanvas() : nullptr; |
| 1308 if (!canvas) |
| 1309 return E_FAIL; |
1300 SkPaint paint; | 1310 SkPaint paint; |
1301 RECT align_rect = gfx::Rect(extra.track_x, extra.track_y, extra.track_width, | 1311 RECT align_rect = gfx::Rect(extra.track_x, extra.track_y, extra.track_width, |
1302 extra.track_height).ToRECT(); | 1312 extra.track_height).ToRECT(); |
1303 SetCheckerboardShader(&paint, align_rect); | 1313 SetCheckerboardShader(&paint, align_rect); |
1304 canvas->drawIRect(skia::RECTToSkIRect(rect_win), paint); | 1314 canvas->drawIRect(skia::RECTToSkIRect(rect_win), paint); |
1305 } | 1315 } |
1306 if (extra.classic_state & DFCS_PUSHED) | 1316 if (extra.classic_state & DFCS_PUSHED) |
1307 InvertRect(hdc, &rect_win); | 1317 InvertRect(hdc, &rect_win); |
1308 return S_OK; | 1318 return S_OK; |
1309 } | 1319 } |
(...skipping 25 matching lines...) Expand all Loading... |
1335 break; | 1345 break; |
1336 } | 1346 } |
1337 | 1347 |
1338 if (handle && draw_theme_) | 1348 if (handle && draw_theme_) |
1339 return draw_theme_(handle, hdc, part_id, state_id, &rect_win, NULL); | 1349 return draw_theme_(handle, hdc, part_id, state_id, &rect_win, NULL); |
1340 DrawFrameControl(hdc, &rect_win, DFC_SCROLL, extra.classic_state); | 1350 DrawFrameControl(hdc, &rect_win, DFC_SCROLL, extra.classic_state); |
1341 return S_OK; | 1351 return S_OK; |
1342 } | 1352 } |
1343 | 1353 |
1344 HRESULT NativeThemeWin::PaintTrackbar( | 1354 HRESULT NativeThemeWin::PaintTrackbar( |
1345 SkCanvas* canvas, | |
1346 HDC hdc, | 1355 HDC hdc, |
1347 Part part, | 1356 Part part, |
1348 State state, | 1357 State state, |
1349 const gfx::Rect& rect, | 1358 const gfx::Rect& rect, |
1350 const TrackbarExtraParams& extra) const { | 1359 const TrackbarExtraParams& extra) const { |
1351 const int part_id = extra.vertical ? | 1360 const int part_id = extra.vertical ? |
1352 ((part == kTrackbarTrack) ? TKP_TRACKVERT : TKP_THUMBVERT) : | 1361 ((part == kTrackbarTrack) ? TKP_TRACKVERT : TKP_THUMBVERT) : |
1353 ((part == kTrackbarTrack) ? TKP_TRACK : TKP_THUMBBOTTOM); | 1362 ((part == kTrackbarTrack) ? TKP_TRACK : TKP_THUMBBOTTOM); |
1354 | 1363 |
1355 int state_id = TUS_NORMAL; | 1364 int state_id = TUS_NORMAL; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1409 RECT right_half = bottom_section; | 1418 RECT right_half = bottom_section; |
1410 right_half.left += ((bottom_section.right - bottom_section.left) / 2); | 1419 right_half.left += ((bottom_section.right - bottom_section.left) / 2); |
1411 left_half.right = right_half.left; | 1420 left_half.right = right_half.left; |
1412 DrawEdge(hdc, &left_half, EDGE_RAISED, | 1421 DrawEdge(hdc, &left_half, EDGE_RAISED, |
1413 BF_DIAGONAL_ENDTOPLEFT | BF_SOFT | BF_MIDDLE | BF_ADJUST); | 1422 BF_DIAGONAL_ENDTOPLEFT | BF_SOFT | BF_MIDDLE | BF_ADJUST); |
1414 DrawEdge(hdc, &right_half, EDGE_RAISED, | 1423 DrawEdge(hdc, &right_half, EDGE_RAISED, |
1415 BF_DIAGONAL_ENDBOTTOMLEFT | BF_SOFT | BF_MIDDLE | BF_ADJUST); | 1424 BF_DIAGONAL_ENDBOTTOMLEFT | BF_SOFT | BF_MIDDLE | BF_ADJUST); |
1416 | 1425 |
1417 // If the button is pressed, draw hatching. | 1426 // If the button is pressed, draw hatching. |
1418 if (extra.classic_state & DFCS_PUSHED) { | 1427 if (extra.classic_state & DFCS_PUSHED) { |
| 1428 sk_sp<SkSurface> surface(skia::MapPlatformSurface(hdc)); |
| 1429 SkCanvas* canvas = surface ? surface->getCanvas() : nullptr; |
| 1430 if (!canvas) |
| 1431 return E_FAIL; |
1419 SkPaint paint; | 1432 SkPaint paint; |
1420 SetCheckerboardShader(&paint, rect_win); | 1433 SetCheckerboardShader(&paint, rect_win); |
1421 | 1434 |
1422 // Fill all three pieces with the pattern. | 1435 // Fill all three pieces with the pattern. |
1423 canvas->drawIRect(skia::RECTToSkIRect(top_section), paint); | 1436 canvas->drawIRect(skia::RECTToSkIRect(top_section), paint); |
1424 | 1437 |
1425 SkScalar left_triangle_top = SkIntToScalar(left_half.top); | 1438 SkScalar left_triangle_top = SkIntToScalar(left_half.top); |
1426 SkScalar left_triangle_right = SkIntToScalar(left_half.right); | 1439 SkScalar left_triangle_right = SkIntToScalar(left_half.right); |
1427 SkPath left_triangle; | 1440 SkPath left_triangle; |
1428 left_triangle.moveTo(SkIntToScalar(left_half.left), left_triangle_top); | 1441 left_triangle.moveTo(SkIntToScalar(left_half.left), left_triangle_top); |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2079 break; | 2092 break; |
2080 case LAST: | 2093 case LAST: |
2081 NOTREACHED(); | 2094 NOTREACHED(); |
2082 break; | 2095 break; |
2083 } | 2096 } |
2084 theme_handles_[theme_name] = handle; | 2097 theme_handles_[theme_name] = handle; |
2085 return handle; | 2098 return handle; |
2086 } | 2099 } |
2087 | 2100 |
2088 } // namespace ui | 2101 } // namespace ui |
OLD | NEW |