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 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 case kScrollbarVerticalTrack: | 713 case kScrollbarVerticalTrack: |
714 adjusted_extra.scrollbar_track.track_x = 0; | 714 adjusted_extra.scrollbar_track.track_x = 0; |
715 adjusted_extra.scrollbar_track.track_y = 0; | 715 adjusted_extra.scrollbar_track.track_y = 0; |
716 break; | 716 break; |
717 default: | 717 default: |
718 break; | 718 break; |
719 } | 719 } |
720 // Draw the theme controls using existing HDC-drawing code. | 720 // Draw the theme controls using existing HDC-drawing code. |
721 PaintDirect(&offscreen_canvas, part, state, adjusted_rect, adjusted_extra); | 721 PaintDirect(&offscreen_canvas, part, state, adjusted_rect, adjusted_extra); |
722 | 722 |
723 // Copy the pixels to a bitmap that has ref-counted pixel storage, which is | 723 SkBitmap bitmap = skia::ReadPixels(&offscreen_canvas); |
724 // necessary to have when drawing to a SkPicture. | |
725 const SkBitmap& hdc_bitmap = | |
726 offscreen_canvas.getDevice()->accessBitmap(false); | |
727 SkBitmap bitmap; | |
728 hdc_bitmap.copyTo(&bitmap, kN32_SkColorType); | |
729 | 724 |
730 // Post-process the pixels to fix up the alpha values (see big comment above). | 725 // Post-process the pixels to fix up the alpha values (see big comment above). |
731 const SkPMColor placeholder_value = SkPreMultiplyColor(placeholder); | 726 const SkPMColor placeholder_value = SkPreMultiplyColor(placeholder); |
732 const int pixel_count = rect.width() * rect.height(); | 727 const int pixel_count = rect.width() * rect.height(); |
733 SkPMColor* pixels = bitmap.getAddr32(0, 0); | 728 SkPMColor* pixels = bitmap.getAddr32(0, 0); |
734 for (int i = 0; i < pixel_count; i++) { | 729 for (int i = 0; i < pixel_count; i++) { |
735 if (pixels[i] == placeholder_value) { | 730 if (pixels[i] == placeholder_value) { |
736 // Pixel wasn't touched - make it fully transparent. | 731 // Pixel wasn't touched - make it fully transparent. |
737 pixels[i] = SkPackARGB32(0, 0, 0, 0); | 732 pixels[i] = SkPackARGB32(0, 0, 0, 0); |
738 } else if (SkGetPackedA32(pixels[i]) == 0) { | 733 } else if (SkGetPackedA32(pixels[i]) == 0) { |
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2088 break; | 2083 break; |
2089 case LAST: | 2084 case LAST: |
2090 NOTREACHED(); | 2085 NOTREACHED(); |
2091 break; | 2086 break; |
2092 } | 2087 } |
2093 theme_handles_[theme_name] = handle; | 2088 theme_handles_[theme_name] = handle; |
2094 return handle; | 2089 return handle; |
2095 } | 2090 } |
2096 | 2091 |
2097 } // namespace ui | 2092 } // namespace ui |
OLD | NEW |