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

Side by Side Diff: chrome/browser/views/extensions/extension_shelf.cc

Issue 2811032: Revert 50784 - Canvas refactoring part 3.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 5 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) 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 "chrome/browser/views/extensions/extension_shelf.h" 5 #include "chrome/browser/views/extensions/extension_shelf.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/resource_bundle.h" 9 #include "app/resource_bundle.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/stl_util-inl.h" 12 #include "base/stl_util-inl.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "chrome/browser/browser.h" 14 #include "chrome/browser/browser.h"
15 #include "chrome/browser/browser_theme_provider.h" 15 #include "chrome/browser/browser_theme_provider.h"
16 #include "chrome/browser/extensions/extension_host.h" 16 #include "chrome/browser/extensions/extension_host.h"
17 #include "chrome/browser/extensions/extension_process_manager.h" 17 #include "chrome/browser/extensions/extension_process_manager.h"
18 #include "chrome/browser/extensions/extensions_service.h" 18 #include "chrome/browser/extensions/extensions_service.h"
19 #include "chrome/browser/profile.h" 19 #include "chrome/browser/profile.h"
20 #include "chrome/browser/tab_contents/tab_contents.h" 20 #include "chrome/browser/tab_contents/tab_contents.h"
21 #include "chrome/browser/views/extensions/extension_view.h" 21 #include "chrome/browser/views/extensions/extension_view.h"
22 #include "chrome/browser/view_ids.h" 22 #include "chrome/browser/view_ids.h"
23 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
24 #include "chrome/common/extensions/extension.h" 24 #include "chrome/common/extensions/extension.h"
25 #include "chrome/common/notification_service.h" 25 #include "chrome/common/notification_service.h"
26 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
27 #include "gfx/canvas_skia.h"
28 #include "views/controls/label.h" 27 #include "views/controls/label.h"
29 #include "views/screen.h" 28 #include "views/screen.h"
30 #include "views/widget/root_view.h" 29 #include "views/widget/root_view.h"
31 30
32 namespace { 31 namespace {
33 32
34 // This is the slight padding that is there around the edge of the browser. This 33 // This is the slight padding that is there around the edge of the browser. This
35 // has been determined empirically. 34 // has been determined empirically.
36 // TODO(sidchat): Compute this value from the root view of the extension shelf. 35 // TODO(sidchat): Compute this value from the root view of the extension shelf.
37 static const int kExtensionShelfPaddingOnLeft = 4; 36 static const int kExtensionShelfPaddingOnLeft = 4;
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 SkIntToScalar(0), 935 SkIntToScalar(0),
937 SkIntToScalar(width()), 936 SkIntToScalar(width()),
938 SkIntToScalar(height()) 937 SkIntToScalar(height())
939 }; 938 };
940 939
941 // Tell all extension views about the new background. 940 // Tell all extension views about the new background.
942 int count = model_->count(); 941 int count = model_->count();
943 for (int i = 0; i < count; ++i) { 942 for (int i = 0; i < count; ++i) {
944 ExtensionView* view = ToolstripAtIndex(i)->view(); 943 ExtensionView* view = ToolstripAtIndex(i)->view();
945 944
946 const SkBitmap& background = 945 const SkBitmap& background = canvas->getDevice()->accessBitmap(false);
947 canvas->AsCanvasSkia()->getDevice()->accessBitmap(false);
948 946
949 SkRect mapped_subset = background_rect; 947 SkRect mapped_subset = background_rect;
950 gfx::Rect view_bounds = view->bounds(); 948 gfx::Rect view_bounds = view->bounds();
951 mapped_subset.offset(SkIntToScalar(view_bounds.x()), 949 mapped_subset.offset(SkIntToScalar(view_bounds.x()),
952 SkIntToScalar(view_bounds.y())); 950 SkIntToScalar(view_bounds.y()));
953 bool result = 951 bool result = canvas->getTotalMatrix().mapRect(&mapped_subset);
954 canvas->AsCanvasSkia()->getTotalMatrix().mapRect(&mapped_subset);
955 DCHECK(result); 952 DCHECK(result);
956 953
957 SkIRect isubset; 954 SkIRect isubset;
958 mapped_subset.round(&isubset); 955 mapped_subset.round(&isubset);
959 SkBitmap subset_bitmap; 956 SkBitmap subset_bitmap;
960 // This will create another bitmap that just references pixels in the 957 // This will create another bitmap that just references pixels in the
961 // actual bitmap. 958 // actual bitmap.
962 result = background.extractSubset(&subset_bitmap, isubset); 959 result = background.extractSubset(&subset_bitmap, isubset);
963 if (!result) 960 if (!result)
964 return; 961 return;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 } 1095 }
1099 1096
1100 void ExtensionShelf::OnFullscreenToggled(bool fullscreen) { 1097 void ExtensionShelf::OnFullscreenToggled(bool fullscreen) {
1101 if (fullscreen == fullscreen_) 1098 if (fullscreen == fullscreen_)
1102 return; 1099 return;
1103 fullscreen_ = fullscreen; 1100 fullscreen_ = fullscreen;
1104 if (!IsAlwaysShown()) 1101 if (!IsAlwaysShown())
1105 return; 1102 return;
1106 size_animation_->Reset(fullscreen ? 0 : 1); 1103 size_animation_->Reset(fullscreen ? 0 : 1);
1107 } 1104 }
OLDNEW
« no previous file with comments | « chrome/browser/views/extensions/browser_action_overflow_menu_controller.cc ('k') | chrome/browser/views/frame/browser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698