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> |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
660 const gfx::Rect& rect, | 660 const gfx::Rect& rect, |
661 const ExtraParams& extra) const { | 661 const ExtraParams& extra) const { |
662 // TODO(asvitkine): This path is pretty inefficient - for each paint operation | 662 // TODO(asvitkine): This path is pretty inefficient - for each paint operation |
663 // it creates a new offscreen bitmap Skia canvas. This can | 663 // it creates a new offscreen bitmap Skia canvas. This can |
664 // be sped up by doing it only once per part/state and | 664 // be sped up by doing it only once per part/state and |
665 // keeping a cache of the resulting bitmaps. | 665 // keeping a cache of the resulting bitmaps. |
666 | 666 |
667 // Create an offscreen canvas that is backed by an HDC. | 667 // Create an offscreen canvas that is backed by an HDC. |
668 base::win::ScopedCreateDC offscreen_hdc( | 668 base::win::ScopedCreateDC offscreen_hdc( |
669 skia::CreateOffscreenSurface(rect.width(), rect.height())); | 669 skia::CreateOffscreenSurface(rect.width(), rect.height())); |
670 if (!offscreen_hdc.IsValid()) | |
671 return; | |
Peter Kasting
2016/09/21 20:50:44
Nit: It's probably worth a comment or two on these
tomhudson
2016/09/21 21:19:20
Done, although we don't know as much as we'd like
| |
672 | |
670 sk_sp<SkSurface> offscreen_surface = | 673 sk_sp<SkSurface> offscreen_surface = |
671 skia::MapPlatformSurface(offscreen_hdc.Get()); | 674 skia::MapPlatformSurface(offscreen_hdc.Get()); |
672 DCHECK(offscreen_surface); | 675 if (!offscreen_surface) |
676 return; | |
677 | |
673 SkCanvas* offscreen_canvas = offscreen_surface->getCanvas(); | 678 SkCanvas* offscreen_canvas = offscreen_surface->getCanvas(); |
674 DCHECK(offscreen_canvas); | 679 DCHECK(offscreen_canvas); |
675 | 680 |
676 // Some of the Windows theme drawing operations do not write correct alpha | 681 // Some of the Windows theme drawing operations do not write correct alpha |
677 // values for fully-opaque pixels; instead the pixels get alpha 0. This is | 682 // values for fully-opaque pixels; instead the pixels get alpha 0. This is |
678 // especially a problem on Windows XP or when using the Classic theme. | 683 // especially a problem on Windows XP or when using the Classic theme. |
679 // | 684 // |
680 // To work-around this, mark all pixels with a placeholder value, to detect | 685 // To work-around this, mark all pixels with a placeholder value, to detect |
681 // which pixels get touched by the paint operation. After paint, set any | 686 // which pixels get touched by the paint operation. After paint, set any |
682 // pixels that have alpha 0 to opaque and placeholders to fully-transparent. | 687 // pixels that have alpha 0 to opaque and placeholders to fully-transparent. |
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2062 break; | 2067 break; |
2063 case LAST: | 2068 case LAST: |
2064 NOTREACHED(); | 2069 NOTREACHED(); |
2065 break; | 2070 break; |
2066 } | 2071 } |
2067 theme_handles_[theme_name] = handle; | 2072 theme_handles_[theme_name] = handle; |
2068 return handle; | 2073 return handle; |
2069 } | 2074 } |
2070 | 2075 |
2071 } // namespace ui | 2076 } // namespace ui |
OLD | NEW |