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 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
657 HDC destination_hdc, | 657 HDC destination_hdc, |
658 Part part, | 658 Part part, |
659 State state, | 659 State state, |
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 // Bitmap needs to be deleted together with DC (before or after). | |
Peter Kasting
2016/09/23 18:45:00
According to docs I found on the web, an attempt t
| |
668 base::win::ScopedBitmap bitmap; | |
667 // Create an offscreen canvas that is backed by an HDC. | 669 // Create an offscreen canvas that is backed by an HDC. |
668 base::win::ScopedCreateDC offscreen_hdc( | 670 base::win::ScopedCreateDC offscreen_hdc( |
669 skia::CreateOffscreenSurface(rect.width(), rect.height())); | 671 skia::CreateOffscreenSurface(&bitmap, rect.width(), rect.height())); |
670 sk_sp<SkSurface> offscreen_surface = | 672 sk_sp<SkSurface> offscreen_surface = |
671 skia::MapPlatformSurface(offscreen_hdc.Get()); | 673 skia::MapPlatformSurface(offscreen_hdc.Get()); |
672 DCHECK(offscreen_surface); | 674 DCHECK(offscreen_surface); |
673 SkCanvas* offscreen_canvas = offscreen_surface->getCanvas(); | 675 SkCanvas* offscreen_canvas = offscreen_surface->getCanvas(); |
674 DCHECK(offscreen_canvas); | 676 DCHECK(offscreen_canvas); |
675 | 677 |
676 // Some of the Windows theme drawing operations do not write correct alpha | 678 // 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 | 679 // 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. | 680 // especially a problem on Windows XP or when using the Classic theme. |
679 // | 681 // |
(...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2062 break; | 2064 break; |
2063 case LAST: | 2065 case LAST: |
2064 NOTREACHED(); | 2066 NOTREACHED(); |
2065 break; | 2067 break; |
2066 } | 2068 } |
2067 theme_handles_[theme_name] = handle; | 2069 theme_handles_[theme_name] = handle; |
2068 return handle; | 2070 return handle; |
2069 } | 2071 } |
2070 | 2072 |
2071 } // namespace ui | 2073 } // namespace ui |
OLD | NEW |