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 <uxtheme.h> | 8 #include <uxtheme.h> |
9 #include <vsstyle.h> | 9 #include <vsstyle.h> |
10 #include <vssym32.h> | 10 #include <vssym32.h> |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // Create a 2x2 checkerboard pattern using the 3D face and highlight colors. | 75 // Create a 2x2 checkerboard pattern using the 3D face and highlight colors. |
76 const SkColor face = color_utils::GetSysSkColor(COLOR_3DFACE); | 76 const SkColor face = color_utils::GetSysSkColor(COLOR_3DFACE); |
77 const SkColor highlight = color_utils::GetSysSkColor(COLOR_3DHILIGHT); | 77 const SkColor highlight = color_utils::GetSysSkColor(COLOR_3DHILIGHT); |
78 SkColor buffer[] = { face, highlight, highlight, face }; | 78 SkColor buffer[] = { face, highlight, highlight, face }; |
79 // Confusing bit: we first create a temporary bitmap with our desired pattern, | 79 // Confusing bit: we first create a temporary bitmap with our desired pattern, |
80 // then copy it to another bitmap. The temporary bitmap doesn't take | 80 // then copy it to another bitmap. The temporary bitmap doesn't take |
81 // ownership of the pixel data, and so will point to garbage when this | 81 // ownership of the pixel data, and so will point to garbage when this |
82 // function returns. The copy will copy the pixel data into a place owned by | 82 // function returns. The copy will copy the pixel data into a place owned by |
83 // the bitmap, which is in turn owned by the shader, etc., so it will live | 83 // the bitmap, which is in turn owned by the shader, etc., so it will live |
84 // until we're done using it. | 84 // until we're done using it. |
| 85 SkImageInfo info = SkImageInfo::MakeN32Premul(2, 2); |
85 SkBitmap temp_bitmap; | 86 SkBitmap temp_bitmap; |
86 temp_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 2, 2); | 87 temp_bitmap.installPixels(info, buffer, info.minRowBytes()); |
87 temp_bitmap.setPixels(buffer); | |
88 SkBitmap bitmap; | 88 SkBitmap bitmap; |
89 temp_bitmap.copyTo(&bitmap); | 89 temp_bitmap.copyTo(&bitmap); |
90 | 90 |
91 // Align the pattern with the upper corner of |align_rect|. | 91 // Align the pattern with the upper corner of |align_rect|. |
92 SkMatrix local_matrix; | 92 SkMatrix local_matrix; |
93 local_matrix.setTranslate(SkIntToScalar(align_rect.left), | 93 local_matrix.setTranslate(SkIntToScalar(align_rect.left), |
94 SkIntToScalar(align_rect.top)); | 94 SkIntToScalar(align_rect.top)); |
95 skia::RefPtr<SkShader> shader = | 95 skia::RefPtr<SkShader> shader = |
96 skia::AdoptRef(SkShader::CreateBitmapShader(bitmap, | 96 skia::AdoptRef(SkShader::CreateBitmapShader(bitmap, |
97 SkShader::kRepeat_TileMode, | 97 SkShader::kRepeat_TileMode, |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 part, | 699 part, |
700 state, | 700 state, |
701 adjusted_rect, | 701 adjusted_rect, |
702 adjusted_extra); | 702 adjusted_extra); |
703 | 703 |
704 // Copy the pixels to a bitmap that has ref-counted pixel storage, which is | 704 // Copy the pixels to a bitmap that has ref-counted pixel storage, which is |
705 // necessary to have when drawing to a SkPicture. | 705 // necessary to have when drawing to a SkPicture. |
706 const SkBitmap& hdc_bitmap = | 706 const SkBitmap& hdc_bitmap = |
707 offscreen_canvas.getDevice()->accessBitmap(false); | 707 offscreen_canvas.getDevice()->accessBitmap(false); |
708 SkBitmap bitmap; | 708 SkBitmap bitmap; |
709 hdc_bitmap.copyTo(&bitmap, kPMColor_SkColorType); | 709 hdc_bitmap.copyTo(&bitmap, kN32_SkColorType); |
710 | 710 |
711 // Post-process the pixels to fix up the alpha values (see big comment above). | 711 // Post-process the pixels to fix up the alpha values (see big comment above). |
712 const SkPMColor placeholder_value = SkPreMultiplyColor(placeholder); | 712 const SkPMColor placeholder_value = SkPreMultiplyColor(placeholder); |
713 const int pixel_count = rect.width() * rect.height(); | 713 const int pixel_count = rect.width() * rect.height(); |
714 SkPMColor* pixels = bitmap.getAddr32(0, 0); | 714 SkPMColor* pixels = bitmap.getAddr32(0, 0); |
715 for (int i = 0; i < pixel_count; i++) { | 715 for (int i = 0; i < pixel_count; i++) { |
716 if (pixels[i] == placeholder_value) { | 716 if (pixels[i] == placeholder_value) { |
717 // Pixel wasn't touched - make it fully transparent. | 717 // Pixel wasn't touched - make it fully transparent. |
718 pixels[i] = SkPackARGB32(0, 0, 0, 0); | 718 pixels[i] = SkPackARGB32(0, 0, 0, 0); |
719 } else if (SkGetPackedA32(pixels[i]) == 0) { | 719 } else if (SkGetPackedA32(pixels[i]) == 0) { |
(...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2146 handle = open_theme_(NULL, L"Spin"); | 2146 handle = open_theme_(NULL, L"Spin"); |
2147 break; | 2147 break; |
2148 default: | 2148 default: |
2149 NOTREACHED(); | 2149 NOTREACHED(); |
2150 } | 2150 } |
2151 theme_handles_[theme_name] = handle; | 2151 theme_handles_[theme_name] = handle; |
2152 return handle; | 2152 return handle; |
2153 } | 2153 } |
2154 | 2154 |
2155 } // namespace ui | 2155 } // namespace ui |
OLD | NEW |