| 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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 PaintMenuSeparator(canvas, *extra.menu_separator.paint_rect); | 269 PaintMenuSeparator(canvas, *extra.menu_separator.paint_rect); |
| 270 return; | 270 return; |
| 271 case kMenuPopupBackground: | 271 case kMenuPopupBackground: |
| 272 PaintMenuBackground(canvas, rect); | 272 PaintMenuBackground(canvas, rect); |
| 273 return; | 273 return; |
| 274 case kMenuItemBackground: | 274 case kMenuItemBackground: |
| 275 CommonThemePaintMenuItemBackground(this, canvas, state, rect, | 275 CommonThemePaintMenuItemBackground(this, canvas, state, rect, |
| 276 extra.menu_item); | 276 extra.menu_item); |
| 277 return; | 277 return; |
| 278 default: | 278 default: |
| 279 break; | 279 PaintIndirect(canvas, part, state, rect, extra); |
| 280 return; |
| 280 } | 281 } |
| 281 | |
| 282 HDC surface = skia::GetNativeDrawingContext(canvas); | |
| 283 | |
| 284 // When drawing the task manager or the bookmark editor, we draw into an | |
| 285 // offscreen buffer, where we can use OS-specific drawing routines for | |
| 286 // UI features like scrollbars. However, we need to set up that buffer, | |
| 287 // and then read it back when it's done and blit it onto the screen. | |
| 288 | |
| 289 if (surface) | |
| 290 PaintDirect(canvas, surface, part, state, rect, extra); | |
| 291 else | |
| 292 PaintIndirect(canvas, part, state, rect, extra); | |
| 293 } | 282 } |
| 294 | 283 |
| 295 NativeThemeWin::NativeThemeWin() | 284 NativeThemeWin::NativeThemeWin() |
| 296 : draw_theme_(NULL), | 285 : draw_theme_(NULL), |
| 297 draw_theme_ex_(NULL), | 286 draw_theme_ex_(NULL), |
| 298 get_theme_color_(NULL), | 287 get_theme_color_(NULL), |
| 299 get_theme_content_rect_(NULL), | 288 get_theme_content_rect_(NULL), |
| 300 get_theme_part_size_(NULL), | 289 get_theme_part_size_(NULL), |
| 301 open_theme_(NULL), | 290 open_theme_(NULL), |
| 302 close_theme_(NULL), | 291 close_theme_(NULL), |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 | 659 |
| 671 return GetAuraColor(color_id, this); | 660 return GetAuraColor(color_id, this); |
| 672 } | 661 } |
| 673 | 662 |
| 674 void NativeThemeWin::PaintIndirect(SkCanvas* destination_canvas, | 663 void NativeThemeWin::PaintIndirect(SkCanvas* destination_canvas, |
| 675 Part part, | 664 Part part, |
| 676 State state, | 665 State state, |
| 677 const gfx::Rect& rect, | 666 const gfx::Rect& rect, |
| 678 const ExtraParams& extra) const { | 667 const ExtraParams& extra) const { |
| 679 // TODO(asvitkine): This path is pretty inefficient - for each paint operation | 668 // TODO(asvitkine): This path is pretty inefficient - for each paint operation |
| 680 // it creates a new offscreen bitmap Skia canvas. This can | 669 // it creates a new offscreen bitmap Skia canvas. This can be sped up by doing |
| 681 // be sped up by doing it only once per part/state and | 670 // it only once per part/state and keeping a cache of the resulting bitmaps. |
| 682 // keeping a cache of the resulting bitmaps. | 671 // |
| 672 // TODO(enne): This could also potentially be sped up for software raster |
| 673 // by moving these draw ops into PaintRecord itself and then moving the |
| 674 // PaintDirect code to be part of the raster for PaintRecord. |
| 683 | 675 |
| 684 // If this process doesn't have access to GDI, we'd need to use shared memory | 676 // If this process doesn't have access to GDI, we'd need to use shared memory |
| 685 // segment instead but that is not supported right now. | 677 // segment instead but that is not supported right now. |
| 686 if (!base::win::IsUser32AndGdi32Available()) | 678 if (!base::win::IsUser32AndGdi32Available()) |
| 687 return; | 679 return; |
| 688 | 680 |
| 689 ScopedCreateDCWithBitmap offscreen_hdc(CreateCompatibleDC(nullptr)); | 681 ScopedCreateDCWithBitmap offscreen_hdc(CreateCompatibleDC(nullptr)); |
| 690 if (!offscreen_hdc.IsValid()) | 682 if (!offscreen_hdc.IsValid()) |
| 691 return; | 683 return; |
| 692 | 684 |
| (...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2101 break; | 2093 break; |
| 2102 case LAST: | 2094 case LAST: |
| 2103 NOTREACHED(); | 2095 NOTREACHED(); |
| 2104 break; | 2096 break; |
| 2105 } | 2097 } |
| 2106 theme_handles_[theme_name] = handle; | 2098 theme_handles_[theme_name] = handle; |
| 2107 return handle; | 2099 return handle; |
| 2108 } | 2100 } |
| 2109 | 2101 |
| 2110 } // namespace ui | 2102 } // namespace ui |
| OLD | NEW |