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" | 19 #include "skia/ext/bitmap_platform_device.h" |
20 #include "skia/ext/platform_canvas.h" | 20 #include "skia/ext/platform_canvas.h" |
21 #include "skia/ext/skia_utils_win.h" | 21 #include "skia/ext/skia_utils_win.h" |
22 #include "third_party/skia/include/core/SkCanvas.h" | 22 #include "third_party/skia/include/core/SkCanvas.h" |
23 #include "third_party/skia/include/core/SkColor.h" | 23 #include "third_party/skia/include/core/SkColor.h" |
24 #include "third_party/skia/include/core/SkColorPriv.h" | 24 #include "third_party/skia/include/core/SkColorPriv.h" |
| 25 #include "third_party/skia/include/core/SkRefCnt.h" |
25 #include "third_party/skia/include/core/SkShader.h" | 26 #include "third_party/skia/include/core/SkShader.h" |
26 #include "ui/base/material_design/material_design_controller.h" | 27 #include "ui/base/material_design/material_design_controller.h" |
27 #include "ui/display/win/dpi.h" | 28 #include "ui/display/win/dpi.h" |
28 #include "ui/gfx/color_palette.h" | 29 #include "ui/gfx/color_palette.h" |
29 #include "ui/gfx/color_utils.h" | 30 #include "ui/gfx/color_utils.h" |
30 #include "ui/gfx/gdi_util.h" | 31 #include "ui/gfx/gdi_util.h" |
31 #include "ui/gfx/geometry/rect.h" | 32 #include "ui/gfx/geometry/rect.h" |
32 #include "ui/gfx/geometry/rect_conversions.h" | 33 #include "ui/gfx/geometry/rect_conversions.h" |
33 #include "ui/gfx/skia_util.h" | 34 #include "ui/gfx/skia_util.h" |
34 #include "ui/native_theme/common_theme.h" | 35 #include "ui/native_theme/common_theme.h" |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 Part part, | 669 Part part, |
669 State state, | 670 State state, |
670 const gfx::Rect& rect, | 671 const gfx::Rect& rect, |
671 const ExtraParams& extra) const { | 672 const ExtraParams& extra) const { |
672 // TODO(asvitkine): This path is pretty inefficient - for each paint operation | 673 // TODO(asvitkine): This path is pretty inefficient - for each paint operation |
673 // it creates a new offscreen bitmap Skia canvas. This can | 674 // it creates a new offscreen bitmap Skia canvas. This can |
674 // be sped up by doing it only once per part/state and | 675 // be sped up by doing it only once per part/state and |
675 // keeping a cache of the resulting bitmaps. | 676 // keeping a cache of the resulting bitmaps. |
676 | 677 |
677 // Create an offscreen canvas that is backed by an HDC. | 678 // Create an offscreen canvas that is backed by an HDC. |
678 skia::RefPtr<skia::BitmapPlatformDevice> device = skia::AdoptRef( | 679 sk_sp<skia::BitmapPlatformDevice> device( |
679 skia::BitmapPlatformDevice::Create( | 680 skia::BitmapPlatformDevice::Create( |
680 rect.width(), rect.height(), false, NULL)); | 681 rect.width(), rect.height(), false, NULL)); |
681 DCHECK(device); | 682 DCHECK(device); |
682 SkCanvas offscreen_canvas(device.get()); | 683 SkCanvas offscreen_canvas(device.get()); |
683 DCHECK(skia::SupportsPlatformPaint(&offscreen_canvas)); | 684 DCHECK(skia::SupportsPlatformPaint(&offscreen_canvas)); |
684 | 685 |
685 // Some of the Windows theme drawing operations do not write correct alpha | 686 // Some of the Windows theme drawing operations do not write correct alpha |
686 // values for fully-opaque pixels; instead the pixels get alpha 0. This is | 687 // values for fully-opaque pixels; instead the pixels get alpha 0. This is |
687 // especially a problem on Windows XP or when using the Classic theme. | 688 // especially a problem on Windows XP or when using the Classic theme. |
688 // | 689 // |
(...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2071 break; | 2072 break; |
2072 case LAST: | 2073 case LAST: |
2073 NOTREACHED(); | 2074 NOTREACHED(); |
2074 break; | 2075 break; |
2075 } | 2076 } |
2076 theme_handles_[theme_name] = handle; | 2077 theme_handles_[theme_name] = handle; |
2077 return handle; | 2078 return handle; |
2078 } | 2079 } |
2079 | 2080 |
2080 } // namespace ui | 2081 } // namespace ui |
OLD | NEW |