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

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

Issue 8122013: Allow CanvasSkia to bind to an existing SkCanvas. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: 1 more fix Created 9 years, 2 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 DestroyIcon(h_opened_icon); 692 DestroyIcon(h_opened_icon);
693 for (size_t i = 0; i < model_images.size(); ++i) { 693 for (size_t i = 0; i < model_images.size(); ++i) {
694 HICON model_icon; 694 HICON model_icon;
695 695
696 // Need to resize the provided icons to be the same size as 696 // Need to resize the provided icons to be the same size as
697 // IDR_FOLDER_CLOSED if they aren't already. 697 // IDR_FOLDER_CLOSED if they aren't already.
698 if (model_images[i].width() != width || 698 if (model_images[i].width() != width ||
699 model_images[i].height() != height) { 699 model_images[i].height() != height) {
700 gfx::CanvasSkia canvas(width, height, false); 700 gfx::CanvasSkia canvas(width, height, false);
701 // Make the background completely transparent. 701 // Make the background completely transparent.
702 canvas.drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode); 702 canvas.sk_canvas()->drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode);
703 703
704 // Draw our icons into this canvas. 704 // Draw our icons into this canvas.
705 int height_offset = (height - model_images[i].height()) / 2; 705 int height_offset = (height - model_images[i].height()) / 2;
706 int width_offset = (width - model_images[i].width()) / 2; 706 int width_offset = (width - model_images[i].width()) / 2;
707 canvas.DrawBitmapInt(model_images[i], width_offset, height_offset); 707 canvas.DrawBitmapInt(model_images[i], width_offset, height_offset);
708 model_icon = IconUtil::CreateHICONFromSkBitmap(canvas.ExtractBitmap()); 708 model_icon = IconUtil::CreateHICONFromSkBitmap(canvas.ExtractBitmap());
709 } else { 709 } else {
710 model_icon = IconUtil::CreateHICONFromSkBitmap(model_images[i]); 710 model_icon = IconUtil::CreateHICONFromSkBitmap(model_images[i]);
711 } 711 }
712 ImageList_AddIcon(image_list, model_icon); 712 ImageList_AddIcon(image_list, model_icon);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 // flickering during resize. 745 // flickering during resize.
746 switch (message) { 746 switch (message) {
747 case WM_ERASEBKGND: 747 case WM_ERASEBKGND:
748 return 1; 748 return 1;
749 749
750 case WM_PAINT: { 750 case WM_PAINT: {
751 gfx::CanvasSkiaPaint canvas(window); 751 gfx::CanvasSkiaPaint canvas(window);
752 if (canvas.isEmpty()) 752 if (canvas.isEmpty())
753 return 0; 753 return 0;
754 754
755 HDC dc = skia::BeginPlatformPaint(&canvas); 755 HDC dc = skia::BeginPlatformPaint(canvas.sk_canvas());
756 if (base::i18n::IsRTL()) { 756 if (base::i18n::IsRTL()) {
757 // gfx::CanvasSkia ends up configuring the DC with a mode of 757 // gfx::CanvasSkia ends up configuring the DC with a mode of
758 // GM_ADVANCED. For some reason a graphics mode of ADVANCED triggers 758 // GM_ADVANCED. For some reason a graphics mode of ADVANCED triggers
759 // all the text to be mirrored when RTL. Set the mode back to COMPATIBLE 759 // all the text to be mirrored when RTL. Set the mode back to COMPATIBLE
760 // and explicitly set the layout. Additionally SetWorldTransform and 760 // and explicitly set the layout. Additionally SetWorldTransform and
761 // COMPATIBLE don't play nicely together. We need to use 761 // COMPATIBLE don't play nicely together. We need to use
762 // SetViewportOrgEx when using a mode of COMPATIBLE. 762 // SetViewportOrgEx when using a mode of COMPATIBLE.
763 // 763 //
764 // Reset the transform to the identify transform. Even though 764 // Reset the transform to the identify transform. Even though
765 // SetWorldTransform and COMPATIBLE don't play nicely, bits of the 765 // SetWorldTransform and COMPATIBLE don't play nicely, bits of the
(...skipping 13 matching lines...) Expand all
779 // copying the upper-left corner to the redraw region. 779 // copying the upper-left corner to the redraw region.
780 SetViewportOrgEx(dc, -canvas.paintStruct().rcPaint.left, 780 SetViewportOrgEx(dc, -canvas.paintStruct().rcPaint.left,
781 -canvas.paintStruct().rcPaint.top, NULL); 781 -canvas.paintStruct().rcPaint.top, NULL);
782 } 782 }
783 SendMessage(window, WM_PRINTCLIENT, reinterpret_cast<WPARAM>(dc), 0); 783 SendMessage(window, WM_PRINTCLIENT, reinterpret_cast<WPARAM>(dc), 0);
784 if (base::i18n::IsRTL()) { 784 if (base::i18n::IsRTL()) {
785 // Reset the origin of the dc back to 0. This way when we copy the bits 785 // Reset the origin of the dc back to 0. This way when we copy the bits
786 // over we copy the right bits. 786 // over we copy the right bits.
787 SetViewportOrgEx(dc, 0, 0, NULL); 787 SetViewportOrgEx(dc, 0, 0, NULL);
788 } 788 }
789 skia::EndPlatformPaint(&canvas); 789 skia::EndPlatformPaint(canvas.sk_canvas());
790 return 0; 790 return 0;
791 } 791 }
792 792
793 case WM_RBUTTONDOWN: 793 case WM_RBUTTONDOWN:
794 if (tree->select_on_right_mouse_down_) { 794 if (tree->select_on_right_mouse_down_) {
795 TVHITTESTINFO hit_info; 795 TVHITTESTINFO hit_info;
796 hit_info.pt = gfx::Point(l_param).ToPOINT(); 796 hit_info.pt = gfx::Point(l_param).ToPOINT();
797 HTREEITEM hit_item = TreeView_HitTest(window, &hit_info); 797 HTREEITEM hit_item = TreeView_HitTest(window, &hit_info);
798 if (hit_item && (hit_info.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT | 798 if (hit_item && (hit_info.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT |
799 TVHT_ONITEMINDENT)) != 0) 799 TVHT_ONITEMINDENT)) != 0)
800 TreeView_SelectItem(tree->tree_view_, hit_item); 800 TreeView_SelectItem(tree->tree_view_, hit_item);
801 } 801 }
802 // Fall through and let the default handler process as well. 802 // Fall through and let the default handler process as well.
803 break; 803 break;
804 } 804 }
805 WNDPROC handler = tree->original_handler_; 805 WNDPROC handler = tree->original_handler_;
806 DCHECK(handler); 806 DCHECK(handler);
807 return CallWindowProc(handler, window, message, w_param, l_param); 807 return CallWindowProc(handler, window, message, w_param, l_param);
808 } 808 }
809 809
810 } // namespace views 810 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698