Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: views/controls/tree/tree_view.cc

Issue 2862025: Canvas refactoring part 2.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/controls/table/table_view.cc ('k') | views/drag_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "views/controls/tree/tree_view.h" 5 #include "views/controls/tree/tree_view.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/l10n_util_win.h" 10 #include "app/l10n_util_win.h"
11 #include "app/resource_bundle.h" 11 #include "app/resource_bundle.h"
12 #include "base/i18n/rtl.h" 12 #include "base/i18n/rtl.h"
13 #include "base/keyboard_codes.h" 13 #include "base/keyboard_codes.h"
14 #include "base/stl_util-inl.h" 14 #include "base/stl_util-inl.h"
15 #include "base/win_util.h" 15 #include "base/win_util.h"
16 #include "gfx/canvas.h" 16 #include "gfx/canvas_skia.h"
17 #include "gfx/canvas_paint.h" 17 #include "gfx/canvas_skia_paint.h"
18 #include "gfx/favicon_size.h" 18 #include "gfx/favicon_size.h"
19 #include "gfx/icon_util.h" 19 #include "gfx/icon_util.h"
20 #include "gfx/point.h" 20 #include "gfx/point.h"
21 #include "grit/app_resources.h" 21 #include "grit/app_resources.h"
22 #include "views/focus/focus_manager.h" 22 #include "views/focus/focus_manager.h"
23 #include "views/widget/widget.h" 23 #include "views/widget/widget.h"
24 24
25 namespace views { 25 namespace views {
26 26
27 TreeView::TreeView() 27 TreeView::TreeView()
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 ImageList_AddIcon(image_list, h_opened_icon); 681 ImageList_AddIcon(image_list, h_opened_icon);
682 DestroyIcon(h_closed_icon); 682 DestroyIcon(h_closed_icon);
683 DestroyIcon(h_opened_icon); 683 DestroyIcon(h_opened_icon);
684 for (size_t i = 0; i < model_images.size(); ++i) { 684 for (size_t i = 0; i < model_images.size(); ++i) {
685 HICON model_icon; 685 HICON model_icon;
686 686
687 // Need to resize the provided icons to be the same size as 687 // Need to resize the provided icons to be the same size as
688 // IDR_FOLDER_CLOSED if they aren't already. 688 // IDR_FOLDER_CLOSED if they aren't already.
689 if (model_images[i].width() != width || 689 if (model_images[i].width() != width ||
690 model_images[i].height() != height) { 690 model_images[i].height() != height) {
691 gfx::Canvas canvas(width, height, false); 691 gfx::CanvasSkia canvas(width, height, false);
692 // Make the background completely transparent. 692 // Make the background completely transparent.
693 canvas.drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode); 693 canvas.drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode);
694 694
695 // Draw our icons into this canvas. 695 // Draw our icons into this canvas.
696 int height_offset = (height - model_images[i].height()) / 2; 696 int height_offset = (height - model_images[i].height()) / 2;
697 int width_offset = (width - model_images[i].width()) / 2; 697 int width_offset = (width - model_images[i].width()) / 2;
698 canvas.DrawBitmapInt(model_images[i], width_offset, height_offset); 698 canvas.DrawBitmapInt(model_images[i], width_offset, height_offset);
699 model_icon = IconUtil::CreateHICONFromSkBitmap(canvas.ExtractBitmap()); 699 model_icon = IconUtil::CreateHICONFromSkBitmap(canvas.ExtractBitmap());
700 } else { 700 } else {
701 model_icon = IconUtil::CreateHICONFromSkBitmap(model_images[i]); 701 model_icon = IconUtil::CreateHICONFromSkBitmap(model_images[i]);
(...skipping 30 matching lines...) Expand all
732 732
733 // We handle the messages WM_ERASEBKGND and WM_PAINT such that we paint into 733 // We handle the messages WM_ERASEBKGND and WM_PAINT such that we paint into
734 // a DIB first and then perform a BitBlt from the DIB into the underlying 734 // a DIB first and then perform a BitBlt from the DIB into the underlying
735 // window's DC. This double buffering code prevents the tree view from 735 // window's DC. This double buffering code prevents the tree view from
736 // flickering during resize. 736 // flickering during resize.
737 switch (message) { 737 switch (message) {
738 case WM_ERASEBKGND: 738 case WM_ERASEBKGND:
739 return 1; 739 return 1;
740 740
741 case WM_PAINT: { 741 case WM_PAINT: {
742 gfx::CanvasPaint canvas(window); 742 gfx::CanvasSkiaPaint canvas(window);
743 if (canvas.isEmpty()) 743 if (canvas.isEmpty())
744 return 0; 744 return 0;
745 745
746 HDC dc = canvas.beginPlatformPaint(); 746 HDC dc = canvas.beginPlatformPaint();
747 if (base::i18n::IsRTL()) { 747 if (base::i18n::IsRTL()) {
748 // gfx::Canvas ends up configuring the DC with a mode of GM_ADVANCED. 748 // gfx::CanvasSkia ends up configuring the DC with a mode of GM_ADVANCED .
749 // For some reason a graphics mode of ADVANCED triggers all the text 749 // For some reason a graphics mode of ADVANCED triggers all the text
750 // to be mirrored when RTL. Set the mode back to COMPATIBLE and 750 // to be mirrored when RTL. Set the mode back to COMPATIBLE and
751 // explicitly set the layout. Additionally SetWorldTransform and 751 // explicitly set the layout. Additionally SetWorldTransform and
752 // COMPATIBLE don't play nicely together. We need to use 752 // COMPATIBLE don't play nicely together. We need to use
753 // SetViewportOrgEx when using a mode of COMPATIBLE. 753 // SetViewportOrgEx when using a mode of COMPATIBLE.
754 // 754 //
755 // Reset the transform to the identify transform. Even though 755 // Reset the transform to the identify transform. Even though
756 // SetWorldTransform and COMPATIBLE don't play nicely, bits of the 756 // SetWorldTransform and COMPATIBLE don't play nicely, bits of the
757 // transform still carry over when we set the mode. 757 // transform still carry over when we set the mode.
758 XFORM xform = {0}; 758 XFORM xform = {0};
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 } 792 }
793 // Fall through and let the default handler process as well. 793 // Fall through and let the default handler process as well.
794 break; 794 break;
795 } 795 }
796 WNDPROC handler = tree->original_handler_; 796 WNDPROC handler = tree->original_handler_;
797 DCHECK(handler); 797 DCHECK(handler);
798 return CallWindowProc(handler, window, message, w_param, l_param); 798 return CallWindowProc(handler, window, message, w_param, l_param);
799 } 799 }
800 800
801 } // namespace views 801 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/table/table_view.cc ('k') | views/drag_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698