diff options
| author | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-24 15:17:39 +0000 |
|---|---|---|
| committer | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-24 15:17:39 +0000 |
| commit | 964e09d587e7e7135353ada8b430b034a9bef0bc (patch) | |
| tree | fea4e8ad04d85e2832f41003087156bac1354e69 | |
| parent | 5a3bdf5a67b78125b0e117aad5543cab1525a053 (diff) | |
| download | chromium_src-964e09d587e7e7135353ada8b430b034a9bef0bc.zip chromium_src-964e09d587e7e7135353ada8b430b034a9bef0bc.tar.gz chromium_src-964e09d587e7e7135353ada8b430b034a9bef0bc.tar.bz2 | |
Converts ui/views/controls, ui/views/examples, ui/base/models to use gfx::ImageSkia
Converts all instances using an SkBitmap to use a gfx::ImageSkia instead
Replaces method names, variables and comments which include "bitmap" to use "image" instead
Sed script used for conversion:
1 # Modify comments.
2 /\/\// {
3 # Save line in hold buffer.
4 h
5 # Extract portion of line which represents comment
6 # and put that into pattern space.
7 s|.*//\(.*\)|\1|
8 # Perform changes.
9 s| SkBitmap| ImageSkia|g
10 s| a bitmap| an image|g
11 s| Bitmap| Image|g
12 s| bitmap| image|g
13 # Append hold buffer to pattern space,
14 G
15 # Put everything back together.
16 s|\(.*\)\n\(.*\)//.*|\2//\1|
17 }
18
19 # Modify code.
20 #
21 # Store in hold buffer [code part ]//[comment part(including //)].
22 # Thus you would get 4 consecutive slashes if the line actually does
23 # have a comment.
24 # Extract portion of line which has code and put that into pattern space.
25
26 # Line has a comment.
27 /\/\// {
28 s|\(.*\)//\(.*\)|\1////\2|
29 h
30 s|\(.*\)//.*|\1|
31 }
32 # No comment on line
33 /\/\// !{
34 s|\(.*\)|\1//|
35 h
36 s|\(.*\)//|\1|
37 }
38
39 # Perform Changes
40
41 # Delete calls.
42 /buildMipMap(false)/d
43 # Replace includes.
44 s|third_party/skia/include/core/SkBitmap\.h|ui/gfx/image/image_skia\.h|g
45 s|ToSkBitmap|ToImageSkia|g
46 s|GetBitmapNamed|GetImageSkiaNamed|g
47 # Rename variables of type SkBitmap to variables of type gfx::ImageSkia
48 # Try to avoid renaming function names and classes which have 'SkBitmap'
49 # in them.
50 s|SkBitmap\([ (*&>),]\)|gfx::ImageSkia\1|g
51 # Modify variable names.
52 s|_bitmap|_image|g
53 s|bitmap|image_skia|g
54 s|bmp|image_skia|g
55 # Rename functions and classes which have 'SkBitmap' in them to use 'ImageSkia'
instead
56 s|SkBitmap|ImageSkia|g
57 s|Bitmap|Image|g
58 # Restore things we didn't mean to change.
59 # SkImageOperations
60 s|ImageSkiaOperations|SkBitmapOperations|g
61 s|SkBitmapOperations::Create\(.*\)Image(|SkBitmapOperations::Create\1Bitmap(|g
62 s|skimage_skia_operations|skbitmap_operations|g
63 # SkPaint
64 s|setFilterImage|setFilterBitmap|g
65 s|isFilterImage|isFilterBitmap|g
66 # gfx::Canvas
67 s|ExtractImage|ExtractBitmap|g
68 # We will want to rename this function after everything else has changed.
69 s|DrawImageInt|DrawBitmapInt|g
70
71 # Append hold buffer to pattern space.
72 # Pattern space will look like: [code part]\n[code part]//[comment part (includi
ng //).
73 G
74 # Put everything back together.
75 s|\(.*\)\n\(.*\)//\(.*\)|\1\3|
I modified the following files manually afterwards:
1 ash/wm/workspace/frame_maximize_button.cc
2 ash/wm/workspace/frame_maximize_button.h
3 chrome/browser/chromeos/login/helper.cc
4 chrome/browser/chromeos/status/network_menu.cc
5 chrome/browser/cookies_tree_model.cc
6 chrome/browser/cookies_tree_model.h
7 chrome/browser/ui/gtk/gtk_tree.cc
8 chrome/browser/ui/gtk/menu_gtk.cc
9 chrome/browser/ui/search_engines/template_url_table_model.cc
10 chrome/browser/ui/search_engines/template_url_table_model.h
11 chrome/browser/ui/toolbar/back_forward_menu_model.cc
12 chrome/browser/ui/toolbar/back_forward_menu_model.h
13 chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc
14 chrome/browser/ui/toolbar/wrench_menu_model.cc
15 chrome/browser/ui/toolbar/wrench_menu_model.h
16 chrome/browser/ui/views/hung_renderer_view.cc
17 chrome/browser/ui/views/infobars/infobar_button_border.cc
18 chrome/browser/ui/views/infobars/infobar_view.cc
19 chrome/browser/ui/views/task_manager_view.cc
20 chrome/browser/ui/views/web_intent_picker_views.cc
21 chrome/browser/ui/views/wrench_menu.cc
22 chrome/browser/ui/webui/chromeos/login/network_dropdown.cc
23 ui/views/controls/button/image_button.cc
24 ui/views/controls/button/image_button_unittest.cc
25 ui/views/controls/image_view.cc
26 ui/views/controls/image_view.h
27 ui/views/controls/scrollbar/bitmap_scroll_bar.cc
28 ui/views/controls/scrollbar/bitmap_scroll_bar.h
29 ui/views/controls/scrollbar/scroll_bar.h
30 ui/views/controls/table/table_view_win.cc
31 ui/views/controls/tree/tree_view_views.h
32 ui/views/controls/tree/tree_view_win.cc
33 ui/views/examples/table_example.cc
34 ui/views/view_unittest.cc
Whitespace changes and changes in includes in:
1 ui/base/models/menu_model.h
2 ui/base/models/table_model.h
3 ui/base/models/tree_model.h
4 ui/views/controls/glow_hover_controller.h
5 ui/views/controls/menu/menu.h
6 ui/views/controls/menu/menu_config_views.cc
7 ui/views/controls/menu/native_menu_win.cc
8 ui/views/controls/message_box_view.h
9 ui/views/controls/table/table_view_views.cc
10 ui/views/controls/throbber.h
11 ui/views/examples/table_example.h
TBR=sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10437006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138800 0039d316-1c4b-4281-b951-d872f2087c98
76 files changed, 409 insertions, 362 deletions
diff --git a/ash/wm/workspace/frame_maximize_button.cc b/ash/wm/workspace/frame_maximize_button.cc index 7ea1874..0d83ec3 100644 --- a/ash/wm/workspace/frame_maximize_button.cc +++ b/ash/wm/workspace/frame_maximize_button.cc @@ -175,7 +175,7 @@ void FrameMaximizeButton::OnMouseCaptureLost() { ImageButton::OnMouseCaptureLost(); } -SkBitmap FrameMaximizeButton::GetImageToPaint() { +gfx::ImageSkia FrameMaximizeButton::GetImageToPaint() { if (is_snap_enabled_) { int id = 0; if (frame_->GetWidget()->IsMaximized()) { diff --git a/ash/wm/workspace/frame_maximize_button.h b/ash/wm/workspace/frame_maximize_button.h index 99e12f4..c95e515 100644 --- a/ash/wm/workspace/frame_maximize_button.h +++ b/ash/wm/workspace/frame_maximize_button.h @@ -38,7 +38,7 @@ class ASH_EXPORT FrameMaximizeButton : public views::ImageButton { protected: // ImageButton overrides: - virtual SkBitmap GetImageToPaint() OVERRIDE; + virtual gfx::ImageSkia GetImageToPaint() OVERRIDE; private: class EscapeEventFilter; diff --git a/chrome/browser/chromeos/login/helper.cc b/chrome/browser/chromeos/login/helper.cc index 439ccbb..7fd1bf39 100644 --- a/chrome/browser/chromeos/login/helper.cc +++ b/chrome/browser/chromeos/login/helper.cc @@ -41,7 +41,7 @@ views::SmoothedThrobber* CreateDefaultSmoothedThrobber() { views::SmoothedThrobber* throbber = new views::SmoothedThrobber(kThrobberFrameMs); throbber->SetFrames( - ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_SPINNER)); + ResourceBundle::GetSharedInstance().GetImageSkiaNamed(IDR_SPINNER)); throbber->set_start_delay_ms(kThrobberStartDelayMs); return throbber; } @@ -49,7 +49,7 @@ views::SmoothedThrobber* CreateDefaultSmoothedThrobber() { views::Throbber* CreateDefaultThrobber() { views::Throbber* throbber = new views::Throbber(kThrobberFrameMs, false); throbber->SetFrames( - ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_SPINNER)); + ResourceBundle::GetSharedInstance().GetImageSkiaNamed(IDR_SPINNER)); return throbber; } diff --git a/chrome/browser/chromeos/status/network_menu.cc b/chrome/browser/chromeos/status/network_menu.cc index af8b182..1b5ce7b 100644 --- a/chrome/browser/chromeos/status/network_menu.cc +++ b/chrome/browser/chromeos/status/network_menu.cc @@ -174,7 +174,7 @@ class NetworkMenuModel : public ui::MenuModel { ui::Accelerator* accelerator) const OVERRIDE; virtual bool IsItemCheckedAt(int index) const OVERRIDE; virtual int GetGroupIdAt(int index) const OVERRIDE; - virtual bool GetIconAt(int index, SkBitmap* icon) OVERRIDE; + virtual bool GetIconAt(int index, gfx::ImageSkia* icon) OVERRIDE; virtual ui::ButtonMenuItemModel* GetButtonMenuItemAt( int index) const OVERRIDE; virtual bool IsEnabledAt(int index) const OVERRIDE; @@ -469,7 +469,7 @@ int NetworkMenuModel::GetGroupIdAt(int index) const { return 0; } -bool NetworkMenuModel::GetIconAt(int index, SkBitmap* icon) { +bool NetworkMenuModel::GetIconAt(int index, gfx::ImageSkia* icon) { if (!menu_items_[index].icon.empty()) { *icon = menu_items_[index].icon; return true; diff --git a/chrome/browser/cookies_tree_model.cc b/chrome/browser/cookies_tree_model.cc index f01aeb1..8d66ec8 100644 --- a/chrome/browser/cookies_tree_model.cc +++ b/chrome/browser/cookies_tree_model.cc @@ -22,9 +22,9 @@ #include "net/base/registry_controlled_domain.h" #include "net/cookies/cookie_monster.h" #include "net/url_request/url_request_context.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/gfx/image/image_skia.h" static const char kFileOriginNodeName[] = "file://"; @@ -709,12 +709,12 @@ CookiesTreeModel::~CookiesTreeModel() {} // TreeModel methods: // Returns the set of icons for the nodes in the tree. You only need override // this if you don't want to use the default folder icons. -void CookiesTreeModel::GetIcons(std::vector<SkBitmap>* icons) { - icons->push_back(*ResourceBundle::GetSharedInstance().GetBitmapNamed( +void CookiesTreeModel::GetIcons(std::vector<gfx::ImageSkia>* icons) { + icons->push_back(*ResourceBundle::GetSharedInstance().GetImageSkiaNamed( IDR_OMNIBOX_HTTP)); - icons->push_back(*ResourceBundle::GetSharedInstance().GetBitmapNamed( + icons->push_back(*ResourceBundle::GetSharedInstance().GetImageSkiaNamed( IDR_COOKIE_ICON)); - icons->push_back(*ResourceBundle::GetSharedInstance().GetBitmapNamed( + icons->push_back(*ResourceBundle::GetSharedInstance().GetImageSkiaNamed( IDR_COOKIE_STORAGE_ICON)); } diff --git a/chrome/browser/cookies_tree_model.h b/chrome/browser/cookies_tree_model.h index aec5a5f..e99fa7f 100644 --- a/chrome/browser/cookies_tree_model.h +++ b/chrome/browser/cookies_tree_model.h @@ -644,7 +644,7 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { // ui::TreeModel methods: // Returns the set of icons for the nodes in the tree. You only need override // this if you don't want to use the default folder icons. - virtual void GetIcons(std::vector<SkBitmap>* icons) OVERRIDE; + virtual void GetIcons(std::vector<gfx::ImageSkia>* icons) OVERRIDE; // Returns the index of the icon to use for |node|. Return -1 to use the // default icon. The index is relative to the list of icons returned from diff --git a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm index ae379ef..879d901 100644 --- a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm +++ b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm @@ -42,6 +42,7 @@ #include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image.h" +#include "ui/gfx/image/image_skia.h" namespace { // Colors for the infobar. @@ -407,12 +408,12 @@ void CollectedCookiesMac::OnSheetDidEnd(NSWindow* sheet) { true)); // Convert the model's icons from Skia to Cocoa. - std::vector<SkBitmap> skiaIcons; + std::vector<gfx::ImageSkia> skiaIcons; allowedTreeModel_->GetIcons(&skiaIcons); icons_.reset([[NSMutableArray alloc] init]); - for (std::vector<SkBitmap>::iterator it = skiaIcons.begin(); + for (std::vector<gfx::ImageSkia>::iterator it = skiaIcons.begin(); it != skiaIcons.end(); ++it) { - [icons_ addObject:gfx::SkBitmapToNSImage(*it)]; + [icons_ addObject:gfx::SkBitmapToNSImage(*it->bitmap())]; } // Default icon will be the last item in the array. diff --git a/chrome/browser/ui/cocoa/menu_controller.mm b/chrome/browser/ui/cocoa/menu_controller.mm index 2cb6a60..8de231b 100644 --- a/chrome/browser/ui/cocoa/menu_controller.mm +++ b/chrome/browser/ui/cocoa/menu_controller.mm @@ -12,6 +12,7 @@ #include "ui/base/accelerators/accelerator_cocoa.h" #include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/models/simple_menu_model.h" +#include "ui/gfx/image/image_skia.h" @interface MenuController (Private) - (void)addSeparatorToMenu:(NSMenu*)menu @@ -106,9 +107,9 @@ keyEquivalent:@""]); // If the menu item has an icon, set it. - SkBitmap skiaIcon; + gfx::ImageSkia skiaIcon; if (model->GetIconAt(modelIndex, &skiaIcon) && !skiaIcon.isNull()) { - NSImage* icon = gfx::SkBitmapToNSImage(skiaIcon); + NSImage* icon = gfx::SkBitmapToNSImage(*skiaIcon.bitmap()); if (icon) { [item setImage:icon]; } @@ -165,10 +166,10 @@ NSString* label = l10n_util::FixUpWindowsStyleLabel(model->GetLabelAt(modelIndex)); [(id)item setTitle:label]; - SkBitmap skiaIcon; + gfx::ImageSkia skiaIcon; NSImage* icon = nil; if (model->GetIconAt(modelIndex, &skiaIcon) && !skiaIcon.isNull()) - icon = gfx::SkBitmapToNSImage(skiaIcon); + icon = gfx::SkBitmapToNSImage(*skiaIcon.bitmap()); [(id)item setImage:icon]; } return model->IsEnabledAt(modelIndex); diff --git a/chrome/browser/ui/cocoa/menu_controller_unittest.mm b/chrome/browser/ui/cocoa/menu_controller_unittest.mm index d838531..6d9a792 100644 --- a/chrome/browser/ui/cocoa/menu_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/menu_controller_unittest.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -14,6 +14,7 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/models/simple_menu_model.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/gfx/image/image_skia.h" class MenuControllerTest : public CocoaTest { }; @@ -75,7 +76,7 @@ class DynamicDelegate : public Delegate { DynamicDelegate() : icon_(NULL) {} virtual bool IsItemForCommandIdDynamic(int command_id) const { return true; } virtual string16 GetLabelForCommandId(int command_id) const { return label_; } - virtual bool GetIconForCommandId(int command_id, SkBitmap* icon) const { + virtual bool GetIconForCommandId(int command_id, gfx::ImageSkia* icon) const { if (icon_) { *icon = *icon_; return true; diff --git a/chrome/browser/ui/cocoa/toolbar/back_forward_menu_controller.mm b/chrome/browser/ui/cocoa/toolbar/back_forward_menu_controller.mm index 97a6e52..396d9ab 100644 --- a/chrome/browser/ui/cocoa/toolbar/back_forward_menu_controller.mm +++ b/chrome/browser/ui/cocoa/toolbar/back_forward_menu_controller.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -12,6 +12,7 @@ #include "chrome/browser/ui/toolbar/back_forward_menu_model.h" #include "skia/ext/skia_utils_mac.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "ui/gfx/image/image_skia.h" using base::SysUTF16ToNSString; using gfx::SkBitmapToNSImage; @@ -71,10 +72,10 @@ using gfx::SkBitmapToNSImage; keyEquivalent:@""]; [menuItem autorelease]; - SkBitmap icon; + gfx::ImageSkia icon; // Icon (if it has one). if (model_->GetIconAt(menuID, &icon)) - [menuItem setImage:SkBitmapToNSImage(icon)]; + [menuItem setImage:SkBitmapToNSImage(*icon.bitmap())]; // This will make it call our |-executeMenuItem:| method. We store the // |menuID| (or |menu_id|) in the tag. diff --git a/chrome/browser/ui/gtk/gtk_tree.cc b/chrome/browser/ui/gtk/gtk_tree.cc index 6c9d6dc..5f1fa24 100644 --- a/chrome/browser/ui/gtk/gtk_tree.cc +++ b/chrome/browser/ui/gtk/gtk_tree.cc @@ -11,6 +11,7 @@ #include "ui/base/models/table_model.h" #include "ui/gfx/gtk_util.h" #include "ui/gfx/image/image.h" +#include "ui/gfx/image/image_skia.h" namespace gtk_tree { @@ -351,10 +352,10 @@ TreeAdapter::TreeAdapter(Delegate* delegate, ui::TreeModel* tree_model) G_TYPE_POINTER); tree_model->AddObserver(this); - std::vector<SkBitmap> icons; + std::vector<gfx::ImageSkia> icons; tree_model->GetIcons(&icons); for (size_t i = 0; i < icons.size(); ++i) { - pixbufs_.push_back(gfx::GdkPixbufFromSkBitmap(icons[i])); + pixbufs_.push_back(gfx::GdkPixbufFromSkBitmap(*icons[i].bitmap())); } } diff --git a/chrome/browser/ui/gtk/menu_gtk.cc b/chrome/browser/ui/gtk/menu_gtk.cc index b58abe8..4d9ad42 100644 --- a/chrome/browser/ui/gtk/menu_gtk.cc +++ b/chrome/browser/ui/gtk/menu_gtk.cc @@ -445,7 +445,7 @@ void MenuGtk::BuildSubmenuFromModel(ui::MenuModel* model, GtkWidget* menu) { std::map<int, GtkWidget*> radio_groups; GtkWidget* menu_item = NULL; for (int i = 0; i < model->GetItemCount(); ++i) { - SkBitmap icon; + gfx::ImageSkia icon; std::string label = ui::ConvertAcceleratorsFromWindowsStyle( UTF16ToUTF8(model->GetLabelAt(i))); bool connect_to_activate = true; @@ -876,7 +876,7 @@ void MenuGtk::SetMenuItemInfo(GtkWidget* widget, gpointer userdata) { gtk_menu_item_set_label(GTK_MENU_ITEM(widget), label.c_str()); if (GTK_IS_IMAGE_MENU_ITEM(widget)) { - SkBitmap icon; + gfx::ImageSkia icon; if (model->GetIconAt(id, &icon)) { GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(icon); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), diff --git a/chrome/browser/ui/search_engines/template_url_table_model.cc b/chrome/browser/ui/search_engines/template_url_table_model.cc index 8ba1e88..662c910c 100644 --- a/chrome/browser/ui/search_engines/template_url_table_model.cc +++ b/chrome/browser/ui/search_engines/template_url_table_model.cc @@ -20,6 +20,7 @@ #include "ui/base/models/table_model_observer.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/codec/png_codec.h" +#include "ui/gfx/image/image_skia.h" // Group IDs used by TemplateURLTableModel. static const int kMainGroupID = 0; @@ -49,7 +50,7 @@ class ModelEntry { return template_url_; } - SkBitmap GetIcon() { + gfx::ImageSkia GetIcon() { if (load_state_ == NOT_LOADED) LoadFavicon(); if (!favicon_.isNull()) @@ -193,7 +194,7 @@ string16 TemplateURLTableModel::GetText(int row, int col_id) { return base::i18n::GetDisplayStringInLTRDirectionality(url->keyword()); } -SkBitmap TemplateURLTableModel::GetIcon(int row) { +gfx::ImageSkia TemplateURLTableModel::GetIcon(int row) { DCHECK(row >= 0 && row < RowCount()); return entries_[row]->GetIcon(); } diff --git a/chrome/browser/ui/search_engines/template_url_table_model.h b/chrome/browser/ui/search_engines/template_url_table_model.h index 3ee549b..78dcb43 100644 --- a/chrome/browser/ui/search_engines/template_url_table_model.h +++ b/chrome/browser/ui/search_engines/template_url_table_model.h @@ -19,6 +19,10 @@ class SkBitmap; class TemplateURL; class TemplateURLService; +namespace gfx { +class ImageSkia; +} + // TemplateURLTableModel is the TableModel implementation used by // KeywordEditorView to show the keywords in a TableView. // @@ -45,7 +49,7 @@ class TemplateURLTableModel : public ui::TableModel, // ui::TableModel overrides. virtual int RowCount() OVERRIDE; virtual string16 GetText(int row, int column) OVERRIDE; - virtual SkBitmap GetIcon(int row) OVERRIDE; + virtual gfx::ImageSkia GetIcon(int row) OVERRIDE; virtual void SetObserver(ui::TableModelObserver* observer) OVERRIDE; virtual bool HasGroups() OVERRIDE; virtual Groups GetGroups() OVERRIDE; diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model.cc b/chrome/browser/ui/toolbar/back_forward_menu_model.cc index de085cf..c719308 100644 --- a/chrome/browser/ui/toolbar/back_forward_menu_model.cc +++ b/chrome/browser/ui/toolbar/back_forward_menu_model.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -131,12 +131,12 @@ int BackForwardMenuModel::GetGroupIdAt(int index) const { return false; } -bool BackForwardMenuModel::GetIconAt(int index, SkBitmap* icon) { +bool BackForwardMenuModel::GetIconAt(int index, gfx::ImageSkia* icon) { if (!ItemHasIcon(index)) return false; if (index == GetItemCount() - 1) { - *icon = *ResourceBundle::GetSharedInstance().GetBitmapNamed( + *icon = *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( IDR_HISTORY_FAVICON); } else { NavigationEntry* entry = GetNavigationEntry(index); diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model.h b/chrome/browser/ui/toolbar/back_forward_menu_model.h index 0c8cf54..03c13f5 100644 --- a/chrome/browser/ui/toolbar/back_forward_menu_model.h +++ b/chrome/browser/ui/toolbar/back_forward_menu_model.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,13 +17,16 @@ #include "webkit/glue/window_open_disposition.h" class Browser; -class SkBitmap; namespace content { class NavigationEntry; class WebContents; } +namespace gfx { +class ImageSkia; +} + /////////////////////////////////////////////////////////////////////////////// // // BackForwardMenuModel @@ -58,7 +61,7 @@ class BackForwardMenuModel : public ui::MenuModel { ui::Accelerator* accelerator) const OVERRIDE; virtual bool IsItemCheckedAt(int index) const OVERRIDE; virtual int GetGroupIdAt(int index) const OVERRIDE; - virtual bool GetIconAt(int index, SkBitmap* icon) OVERRIDE; + virtual bool GetIconAt(int index, gfx::ImageSkia* icon) OVERRIDE; virtual ui::ButtonMenuItemModel* GetButtonMenuItemAt( int index) const OVERRIDE; virtual bool IsEnabledAt(int index) const OVERRIDE; diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc b/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc index cb8e775..6eb5b68 100644 --- a/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc +++ b/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc @@ -509,9 +509,9 @@ TEST_F(BackFwdMenuModelTest, FaviconLoadTest) { back_model.set_test_web_contents(controller().GetWebContents()); back_model.SetMenuModelDelegate(&favicon_delegate); - SkBitmap new_icon(CreateBitmap(SK_ColorRED)); + SkBitmap new_icon_bitmap(CreateBitmap(SK_ColorRED)); std::vector<unsigned char> icon_data; - gfx::PNGCodec::EncodeBGRASkBitmap(new_icon, false, &icon_data); + gfx::PNGCodec::EncodeBGRASkBitmap(new_icon_bitmap, false, &icon_data); GURL url1 = GURL("http://www.a.com/1"); GURL url2 = GURL("http://www.a.com/2"); @@ -529,7 +529,7 @@ TEST_F(BackFwdMenuModelTest, FaviconLoadTest) { // Will return the current icon (default) but start an anync call // to retrieve the favicon from the favicon service. - SkBitmap default_icon; + gfx::ImageSkia default_icon; back_model.GetIconAt(0, &default_icon); // Make the favicon service run GetFavIconForURL, @@ -540,22 +540,27 @@ TEST_F(BackFwdMenuModelTest, FaviconLoadTest) { EXPECT_TRUE(favicon_delegate.was_called()); // Verify the bitmaps match. - SkBitmap valid_icon; + gfx::ImageSkia valid_icon; // This time we will get the new favicon returned. back_model.GetIconAt(0, &valid_icon); - SkAutoLockPixels a(new_icon); - SkAutoLockPixels b(valid_icon); - SkAutoLockPixels c(default_icon); + + SkBitmap default_icon_bitmap = *default_icon.bitmap(); + SkBitmap valid_icon_bitmap = *valid_icon.bitmap(); + + SkAutoLockPixels a(new_icon_bitmap); + SkAutoLockPixels b(valid_icon_bitmap); + SkAutoLockPixels c(default_icon_bitmap); // Verify we did not get the default favicon. - EXPECT_NE(0, memcmp(default_icon.getPixels(), valid_icon.getPixels(), - default_icon.getSize())); + EXPECT_NE(0, memcmp(default_icon_bitmap.getPixels(), + valid_icon_bitmap.getPixels(), + default_icon_bitmap.getSize())); // Verify we did get the expected favicon. - EXPECT_EQ(0, memcmp(new_icon.getPixels(), valid_icon.getPixels(), - new_icon.getSize())); + EXPECT_EQ(0, memcmp(new_icon_bitmap.getPixels(), + valid_icon_bitmap.getPixels(), + new_icon_bitmap.getSize())); // Make sure the browser deconstructor doesn't have problems. browser.CloseAllTabs(); // This is required to prevent the message loop from hanging. profile()->DestroyHistoryService(); } - diff --git a/chrome/browser/ui/toolbar/wrench_menu_model.cc b/chrome/browser/ui/toolbar/wrench_menu_model.cc index 6dd6b56..11ac89d 100644 --- a/chrome/browser/ui/toolbar/wrench_menu_model.cc +++ b/chrome/browser/ui/toolbar/wrench_menu_model.cc @@ -281,14 +281,14 @@ string16 WrenchMenuModel::GetLabelForCommandId(int command_id) const { } bool WrenchMenuModel::GetIconForCommandId(int command_id, - SkBitmap* icon) const { + gfx::ImageSkia* icon) const { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); switch (command_id) { case IDC_UPGRADE_DIALOG: { if (UpgradeDetector::GetInstance()->notify_upgrade()) { - *icon = *rb.GetNativeImageNamed( + *icon = *rb.GetImageNamed( UpgradeDetector::GetInstance()->GetIconResourceID( - UpgradeDetector::UPGRADE_ICON_TYPE_MENU_ICON)).ToSkBitmap(); + UpgradeDetector::UPGRADE_ICON_TYPE_MENU_ICON)).ToImageSkia(); return true; } return false; @@ -301,7 +301,7 @@ bool WrenchMenuModel::GetIconForCommandId(int command_id, if (error && error->HasCustomizedSyncMenuItem()) { int icon_id = error->MenuItemIconResourceID(); if (icon_id) { - *icon = *rb.GetNativeImageNamed(icon_id).ToSkBitmap(); + *icon = *rb.GetImageNamed(icon_id).ToImageSkia(); return true; } } diff --git a/chrome/browser/ui/toolbar/wrench_menu_model.h b/chrome/browser/ui/toolbar/wrench_menu_model.h index 445223a..ccde76a 100644 --- a/chrome/browser/ui/toolbar/wrench_menu_model.h +++ b/chrome/browser/ui/toolbar/wrench_menu_model.h @@ -88,7 +88,7 @@ class WrenchMenuModel : public ui::SimpleMenuModel, virtual bool IsItemForCommandIdDynamic(int command_id) const OVERRIDE; virtual string16 GetLabelForCommandId(int command_id) const OVERRIDE; virtual bool GetIconForCommandId(int command_id, - SkBitmap* icon) const OVERRIDE; + gfx::ImageSkia* icon) const OVERRIDE; virtual void ExecuteCommand(int command_id) OVERRIDE; virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; diff --git a/chrome/browser/ui/views/hung_renderer_view.cc b/chrome/browser/ui/views/hung_renderer_view.cc index bcd3e91..3e8428c 100644 --- a/chrome/browser/ui/views/hung_renderer_view.cc +++ b/chrome/browser/ui/views/hung_renderer_view.cc @@ -84,7 +84,7 @@ class HungPagesTableModel : public views::GroupTableModel { // Overridden from views::GroupTableModel: virtual int RowCount(); virtual string16 GetText(int row, int column_id); - virtual SkBitmap GetIcon(int row); + virtual gfx::ImageSkia GetIcon(int row); virtual void SetObserver(ui::TableModelObserver* observer); virtual void GetGroupRangeForItem(int item, views::GroupRange* range); @@ -188,7 +188,7 @@ string16 HungPagesTableModel::GetText(int row, int column_id) { return title; } -SkBitmap HungPagesTableModel::GetIcon(int row) { +gfx::ImageSkia HungPagesTableModel::GetIcon(int row) { DCHECK(row >= 0 && row < RowCount()); return tab_observers_[row]->favicon_tab_helper()->GetFavicon(); } diff --git a/chrome/browser/ui/views/infobars/infobar_button_border.cc b/chrome/browser/ui/views/infobars/infobar_button_border.cc index d7998b1..45fc88f 100644 --- a/chrome/browser/ui/views/infobars/infobar_button_border.cc +++ b/chrome/browser/ui/views/infobars/infobar_button_border.cc @@ -14,41 +14,41 @@ InfoBarButtonBorder::InfoBarButtonBorder() { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); BorderImageSet normal_set = { - rb.GetImageNamed(IDR_INFOBARBUTTON_TOP_LEFT_N).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_TOP_N).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_TOP_RIGHT_N).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_LEFT_N).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_CENTER_N).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_RIGHT_N).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_BOTTOM_LEFT_N).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_BOTTOM_N).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_BOTTOM_RIGHT_N).ToSkBitmap(), + rb.GetImageNamed(IDR_INFOBARBUTTON_TOP_LEFT_N).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_TOP_N).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_TOP_RIGHT_N).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_LEFT_N).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_CENTER_N).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_RIGHT_N).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_BOTTOM_LEFT_N).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_BOTTOM_N).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_BOTTOM_RIGHT_N).ToImageSkia(), }; set_normal_set(normal_set); BorderImageSet hot_set = { - rb.GetImageNamed(IDR_INFOBARBUTTON_TOP_LEFT_H).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_TOP_H).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_TOP_RIGHT_H).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_LEFT_H).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_CENTER_H).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_RIGHT_H).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_BOTTOM_LEFT_H).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_BOTTOM_H).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_BOTTOM_RIGHT_H).ToSkBitmap(), + rb.GetImageNamed(IDR_INFOBARBUTTON_TOP_LEFT_H).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_TOP_H).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_TOP_RIGHT_H).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_LEFT_H).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_CENTER_H).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_RIGHT_H).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_BOTTOM_LEFT_H).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_BOTTOM_H).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_BOTTOM_RIGHT_H).ToImageSkia(), }; set_hot_set(hot_set); BorderImageSet pushed_set = { - rb.GetImageNamed(IDR_INFOBARBUTTON_TOP_LEFT_P).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_TOP_P).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_TOP_RIGHT_P).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_LEFT_P).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_CENTER_P).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_RIGHT_P).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_BOTTOM_LEFT_P).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_BOTTOM_P).ToSkBitmap(), - rb.GetImageNamed(IDR_INFOBARBUTTON_BOTTOM_RIGHT_P).ToSkBitmap(), + rb.GetImageNamed(IDR_INFOBARBUTTON_TOP_LEFT_P).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_TOP_P).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_TOP_RIGHT_P).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_LEFT_P).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_CENTER_P).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_RIGHT_P).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_BOTTOM_LEFT_P).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_BOTTOM_P).ToImageSkia(), + rb.GetImageNamed(IDR_INFOBARBUTTON_BOTTOM_RIGHT_P).ToImageSkia(), }; set_pushed_set(pushed_set); } diff --git a/chrome/browser/ui/views/infobars/infobar_view.cc b/chrome/browser/ui/views/infobars/infobar_view.cc index 9b7b9fe..0563e1f 100644 --- a/chrome/browser/ui/views/infobars/infobar_view.cc +++ b/chrome/browser/ui/views/infobars/infobar_view.cc @@ -104,7 +104,7 @@ views::MenuButton* InfoBarView::CreateMenuButton( menu_button->set_animate_on_state_change(false); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); menu_button->set_menu_marker( - rb.GetImageNamed(IDR_INFOBARBUTTON_MENU_DROPARROW).ToSkBitmap()); + rb.GetImageNamed(IDR_INFOBARBUTTON_MENU_DROPARROW).ToImageSkia()); menu_button->SetEnabledColor(SK_ColorBLACK); menu_button->SetHighlightColor(SK_ColorBLACK); menu_button->SetHoverColor(SK_ColorBLACK); diff --git a/chrome/browser/ui/views/menu_model_adapter_test.cc b/chrome/browser/ui/views/menu_model_adapter_test.cc index 0ec3eb9..74371a8 100644 --- a/chrome/browser/ui/views/menu_model_adapter_test.cc +++ b/chrome/browser/ui/views/menu_model_adapter_test.cc @@ -143,7 +143,7 @@ class CommonMenuModel : public ui::MenuModel { return 0; } - virtual bool GetIconAt(int index, SkBitmap* icon) OVERRIDE { + virtual bool GetIconAt(int index, gfx::ImageSkia* icon) OVERRIDE { return false; } diff --git a/chrome/browser/ui/views/task_manager_view.cc b/chrome/browser/ui/views/task_manager_view.cc index bd56df4..b110211 100644 --- a/chrome/browser/ui/views/task_manager_view.cc +++ b/chrome/browser/ui/views/task_manager_view.cc @@ -67,7 +67,7 @@ class TaskManagerTableModel : public views::GroupTableModel, // GroupTableModel. int RowCount() OVERRIDE; string16 GetText(int row, int column) OVERRIDE; - SkBitmap GetIcon(int row) OVERRIDE; + gfx::ImageSkia GetIcon(int row) OVERRIDE; void GetGroupRangeForItem(int item, views::GroupRange* range) OVERRIDE; void SetObserver(ui::TableModelObserver* observer) OVERRIDE; virtual int CompareValues(int row1, int row2, int column_id) OVERRIDE; @@ -163,7 +163,7 @@ string16 TaskManagerTableModel::GetText(int row, int col_id) { } } -SkBitmap TaskManagerTableModel::GetIcon(int row) { +gfx::ImageSkia TaskManagerTableModel::GetIcon(int row) { return model_->GetResourceIcon(row); } diff --git a/chrome/browser/ui/views/web_intent_picker_views.cc b/chrome/browser/ui/views/web_intent_picker_views.cc index 2a5e35b..5de1d08 100644 --- a/chrome/browser/ui/views/web_intent_picker_views.cc +++ b/chrome/browser/ui/views/web_intent_picker_views.cc @@ -144,20 +144,20 @@ class ThrobberNativeTextButton : public views::NativeTextButton { void StopThrobber(); // Set the throbber bitmap to use. IDR_THROBBER is used by default. - void SetFrames(const SkBitmap* frames); + void SetFrames(const gfx::ImageSkia* frames); protected: - virtual const SkBitmap& GetImageToPaint() const OVERRIDE; + virtual const gfx::ImageSkia& GetImageToPaint() const OVERRIDE; private: // The timer callback to schedule painting this view. void Run(); - // Bitmap that contains the throbber frames. - const SkBitmap* frames_; + // Image that contains the throbber frames. + const gfx::ImageSkia* frames_; // The currently displayed frame, given to GetImageToPaint. - mutable SkBitmap this_frame_; + mutable gfx::ImageSkia this_frame_; // How long one frame is displayed. base::TimeDelta frame_time_; @@ -184,7 +184,7 @@ ThrobberNativeTextButton::ThrobberNativeTextButton( frame_count_(0), running_(false) { SetFrames(ui::ResourceBundle::GetSharedInstance().GetImageNamed( - IDR_THROBBER).ToSkBitmap()); + IDR_THROBBER).ToImageSkia()); } ThrobberNativeTextButton::~ThrobberNativeTextButton() { @@ -210,7 +210,7 @@ void ThrobberNativeTextButton::StopThrobber() { running_ = false; } -void ThrobberNativeTextButton::SetFrames(const SkBitmap* frames) { +void ThrobberNativeTextButton::SetFrames(const gfx::ImageSkia* frames) { frames_ = frames; DCHECK(frames_->width() > 0 && frames_->height() > 0); DCHECK(frames_->width() % frames_->height() == 0); @@ -218,7 +218,7 @@ void ThrobberNativeTextButton::SetFrames(const SkBitmap* frames) { PreferredSizeChanged(); } -const SkBitmap& ThrobberNativeTextButton::GetImageToPaint() const { +const gfx::ImageSkia& ThrobberNativeTextButton::GetImageToPaint() const { if (!running_) return NativeTextButton::GetImageToPaint(); diff --git a/chrome/browser/ui/views/wrench_menu.cc b/chrome/browser/ui/views/wrench_menu.cc index b624a33..88d9a1f 100644 --- a/chrome/browser/ui/views/wrench_menu.cc +++ b/chrome/browser/ui/views/wrench_menu.cc @@ -929,7 +929,7 @@ MenuItemView* WrenchMenu::AppendMenuItem(MenuItemView* parent, menu_item->SetVisible(model->IsVisibleAt(index)); if (menu_type == MenuModel::TYPE_COMMAND && model->HasIcons()) { - SkBitmap icon; + gfx::ImageSkia icon; if (model->GetIconAt(index, &icon)) menu_item->SetIcon(icon); } diff --git a/chrome/browser/ui/webui/chromeos/login/network_dropdown.cc b/chrome/browser/ui/webui/chromeos/login/network_dropdown.cc index cfb2a1b..cad8a9b 100644 --- a/chrome/browser/ui/webui/chromeos/login/network_dropdown.cc +++ b/chrome/browser/ui/webui/chromeos/login/network_dropdown.cc @@ -74,7 +74,7 @@ base::ListValue* NetworkMenuWebUI::ConvertMenuModel(ui::MenuModel* model) { base::DictionaryValue* item = new base::DictionaryValue(); item->SetInteger("id", id); item->SetString("label", model->GetLabelAt(i)); - SkBitmap icon; + gfx::ImageSkia icon; if (model->GetIconAt(i, &icon)) item->SetString("icon", web_ui_util::GetImageDataUrl(icon)); if (id >= 0) { diff --git a/ui/base/models/menu_model.h b/ui/base/models/menu_model.h index 7ca33bd..f7acb16 100644 --- a/ui/base/models/menu_model.h +++ b/ui/base/models/menu_model.h @@ -9,12 +9,13 @@ #include "base/string16.h" #include "ui/base/models/menu_model_delegate.h" #include "ui/base/ui_export.h" +#include "ui/gfx/image/image_skia.h" #include "ui/gfx/native_widget_types.h" -class SkBitmap; namespace gfx { class Font; +class ImageSkia; } namespace ui { @@ -87,7 +88,7 @@ class UI_EXPORT MenuModel { // Gets the icon for the item at the specified index, returning true if there // is an icon, false otherwise. - virtual bool GetIconAt(int index, SkBitmap* icon) = 0; + virtual bool GetIconAt(int index, gfx::ImageSkia* icon) = 0; // Returns the model for a menu item with a line of buttons at |index|. virtual ButtonMenuItemModel* GetButtonMenuItemAt(int index) const = 0; diff --git a/ui/base/models/simple_menu_model.cc b/ui/base/models/simple_menu_model.cc index be84356..3a38b0d 100644 --- a/ui/base/models/simple_menu_model.cc +++ b/ui/base/models/simple_menu_model.cc @@ -6,8 +6,8 @@ #include "base/bind.h" #include "base/message_loop.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/gfx/image/image_skia.h" namespace ui { @@ -16,7 +16,7 @@ const int kSeparatorId = -1; struct SimpleMenuModel::Item { int command_id; string16 label; - SkBitmap icon; + gfx::ImageSkia icon; ItemType type; int group_id; MenuModel* submenu; @@ -40,7 +40,7 @@ string16 SimpleMenuModel::Delegate::GetLabelForCommandId(int command_id) const { } bool SimpleMenuModel::Delegate::GetIconForCommandId( - int command_id, SkBitmap* bitmap) const { + int command_id, gfx::ImageSkia* image_skia) const { return false; } @@ -71,7 +71,8 @@ SimpleMenuModel::~SimpleMenuModel() { } void SimpleMenuModel::AddItem(int command_id, const string16& label) { - Item item = { command_id, label, SkBitmap(), TYPE_COMMAND, -1, NULL, NULL }; + Item item = { command_id, label, gfx::ImageSkia(), TYPE_COMMAND, -1, NULL, + NULL }; AppendItem(item); } @@ -80,13 +81,14 @@ void SimpleMenuModel::AddItemWithStringId(int command_id, int string_id) { } void SimpleMenuModel::AddSeparator() { - Item item = { kSeparatorId, string16(), SkBitmap(), TYPE_SEPARATOR, -1, + Item item = { kSeparatorId, string16(), gfx::ImageSkia(), TYPE_SEPARATOR, -1, NULL, NULL }; AppendItem(item); } void SimpleMenuModel::AddCheckItem(int command_id, const string16& label) { - Item item = { command_id, label, SkBitmap(), TYPE_CHECK, -1, NULL, NULL }; + Item item = { command_id, label, gfx::ImageSkia(), TYPE_CHECK, -1, NULL, + NULL }; AppendItem(item); } @@ -96,7 +98,7 @@ void SimpleMenuModel::AddCheckItemWithStringId(int command_id, int string_id) { void SimpleMenuModel::AddRadioItem(int command_id, const string16& label, int group_id) { - Item item = { command_id, label, SkBitmap(), TYPE_RADIO, group_id, NULL, + Item item = { command_id, label, gfx::ImageSkia(), TYPE_RADIO, group_id, NULL, NULL }; AppendItem(item); } @@ -108,14 +110,15 @@ void SimpleMenuModel::AddRadioItemWithStringId(int command_id, int string_id, void SimpleMenuModel::AddButtonItem(int command_id, ButtonMenuItemModel* model) { - Item item = { command_id, string16(), SkBitmap(), TYPE_BUTTON_ITEM, -1, NULL, - model }; + Item item = { command_id, string16(), gfx::ImageSkia(), TYPE_BUTTON_ITEM, -1, + NULL, model }; AppendItem(item); } void SimpleMenuModel::AddSubMenu(int command_id, const string16& label, MenuModel* model) { - Item item = { command_id, label, SkBitmap(), TYPE_SUBMENU, -1, model, NULL }; + Item item = { command_id, label, gfx::ImageSkia(), TYPE_SUBMENU, -1, model, + NULL }; AppendItem(item); } @@ -126,7 +129,8 @@ void SimpleMenuModel::AddSubMenuWithStringId(int command_id, void SimpleMenuModel::InsertItemAt( int index, int command_id, const string16& label) { - Item item = { command_id, label, SkBitmap(), TYPE_COMMAND, -1, NULL, NULL }; + Item item = { command_id, label, gfx::ImageSkia(), TYPE_COMMAND, -1, NULL, + NULL }; InsertItemAtIndex(item, index); } @@ -136,14 +140,15 @@ void SimpleMenuModel::InsertItemWithStringIdAt( } void SimpleMenuModel::InsertSeparatorAt(int index) { - Item item = { kSeparatorId, string16(), SkBitmap(), TYPE_SEPARATOR, -1, + Item item = { kSeparatorId, string16(), gfx::ImageSkia(), TYPE_SEPARATOR, -1, NULL, NULL }; InsertItemAtIndex(item, index); } void SimpleMenuModel::InsertCheckItemAt( int index, int command_id, const string16& label) { - Item item = { command_id, label, SkBitmap(), TYPE_CHECK, -1, NULL, NULL }; + Item item = { command_id, label, gfx::ImageSkia(), TYPE_CHECK, -1, NULL, + NULL }; InsertItemAtIndex(item, index); } @@ -155,7 +160,7 @@ void SimpleMenuModel::InsertCheckItemWithStringIdAt( void SimpleMenuModel::InsertRadioItemAt( int index, int command_id, const string16& label, int group_id) { - Item item = { command_id, label, SkBitmap(), TYPE_RADIO, group_id, NULL, + Item item = { command_id, label, gfx::ImageSkia(), TYPE_RADIO, group_id, NULL, NULL }; InsertItemAtIndex(item, index); } @@ -168,7 +173,8 @@ void SimpleMenuModel::InsertRadioItemWithStringIdAt( void SimpleMenuModel::InsertSubMenuAt( int index, int command_id, const string16& label, MenuModel* model) { - Item item = { command_id, label, SkBitmap(), TYPE_SUBMENU, -1, model, NULL }; + Item item = { command_id, label, gfx::ImageSkia(), TYPE_SUBMENU, -1, model, + NULL }; InsertItemAtIndex(item, index); } @@ -178,7 +184,7 @@ void SimpleMenuModel::InsertSubMenuWithStringIdAt( model); } -void SimpleMenuModel::SetIcon(int index, const SkBitmap& icon) { +void SimpleMenuModel::SetIcon(int index, const gfx::ImageSkia& icon) { items_[index].icon = icon; } @@ -253,7 +259,7 @@ int SimpleMenuModel::GetGroupIdAt(int index) const { return items_.at(FlipIndex(index)).group_id; } -bool SimpleMenuModel::GetIconAt(int index, SkBitmap* icon) { +bool SimpleMenuModel::GetIconAt(int index, gfx::ImageSkia* icon) { if (IsItemDynamicAt(index)) return delegate_->GetIconForCommandId(GetCommandIdAt(index), icon); diff --git a/ui/base/models/simple_menu_model.h b/ui/base/models/simple_menu_model.h index c8da021..217a0cf 100644 --- a/ui/base/models/simple_menu_model.h +++ b/ui/base/models/simple_menu_model.h @@ -12,6 +12,10 @@ #include "base/string16.h" #include "ui/base/models/menu_model.h" +namespace gfx { +class ImageSkia; +} + namespace ui { class ButtonMenuItemModel; @@ -40,7 +44,8 @@ class UI_EXPORT SimpleMenuModel : public MenuModel { virtual string16 GetLabelForCommandId(int command_id) const; // Gets the icon for the item with the specified id, returning true if there // is an icon, false otherwise. - virtual bool GetIconForCommandId(int command_id, SkBitmap* icon) const; + virtual bool GetIconForCommandId(int command_id, + gfx::ImageSkia* icon) const; // Notifies the delegate that the item with the specified command id was // visually highlighted within the menu. @@ -98,7 +103,7 @@ class UI_EXPORT SimpleMenuModel : public MenuModel { int index, int command_id, int string_id, MenuModel* model); // Sets the icon for the item at |index|. - void SetIcon(int index, const SkBitmap& icon); + void SetIcon(int index, const gfx::ImageSkia& icon); // Clears all items. Note that it does not free MenuModel of submenu. void Clear(); @@ -118,7 +123,7 @@ class UI_EXPORT SimpleMenuModel : public MenuModel { ui::Accelerator* accelerator) const OVERRIDE; virtual bool IsItemCheckedAt(int index) const OVERRIDE; virtual int GetGroupIdAt(int index) const OVERRIDE; - virtual bool GetIconAt(int index, SkBitmap* icon) OVERRIDE; + virtual bool GetIconAt(int index, gfx::ImageSkia* icon) OVERRIDE; virtual ui::ButtonMenuItemModel* GetButtonMenuItemAt( int index) const OVERRIDE; virtual bool IsEnabledAt(int index) const OVERRIDE; diff --git a/ui/base/models/table_model.cc b/ui/base/models/table_model.cc index 921ca89..c73466f 100644 --- a/ui/base/models/table_model.cc +++ b/ui/base/models/table_model.cc @@ -1,11 +1,11 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ui/base/models/table_model.h" #include "base/logging.h" -#include "third_party/skia/include/core/SkBitmap.h" +#include "ui/gfx/image/image_skia.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util_collator.h" @@ -74,8 +74,8 @@ TableColumn::TableColumn(int id, Alignment alignment, int width, float percent) // Used for sorting. static icu::Collator* collator = NULL; -SkBitmap TableModel::GetIcon(int row) { - return SkBitmap(); +gfx::ImageSkia TableModel::GetIcon(int row) { + return gfx::ImageSkia(); } string16 TableModel::GetTooltip(int row) { diff --git a/ui/base/models/table_model.h b/ui/base/models/table_model.h index a6dbbb3..0565cd8 100644 --- a/ui/base/models/table_model.h +++ b/ui/base/models/table_model.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -12,7 +12,9 @@ #include "ui/base/ui_export.h" #include "unicode/coll.h" -class SkBitmap; +namespace gfx { +class ImageSkia; +} namespace ui { @@ -39,9 +41,9 @@ class UI_EXPORT TableModel { // Returns the small icon (16x16) that should be displayed in the first // column before the text. This is only used when the TableView was created - // with the ICON_AND_TEXT table type. Returns an isNull() bitmap if there is - // no bitmap. - virtual SkBitmap GetIcon(int row); + // with the ICON_AND_TEXT table type. Returns an isNull() image if there is + // no image. + virtual gfx::ImageSkia GetIcon(int row); // Returns the tooltip, if any, to show for a particular row. If there are // multiple columns in the row, this will only be shown when hovering over diff --git a/ui/base/models/tree_model.h b/ui/base/models/tree_model.h index 5dfa8f9..11ea193 100644 --- a/ui/base/models/tree_model.h +++ b/ui/base/models/tree_model.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -11,7 +11,9 @@ #include "base/string16.h" #include "ui/base/ui_export.h" -class SkBitmap; +namespace gfx { +class ImageSkia; +} namespace ui { @@ -84,7 +86,7 @@ class UI_EXPORT TreeModel { // Returns the set of icons for the nodes in the tree. You only need override // this if you don't want to use the default folder icons. - virtual void GetIcons(std::vector<SkBitmap>* icons) {} + virtual void GetIcons(std::vector<gfx::ImageSkia>* icons) {} // Returns the index of the icon to use for |node|. Return -1 to use the // default icon. The index is relative to the list of icons returned from diff --git a/ui/views/controls/button/image_button.cc b/ui/views/controls/button/image_button.cc index 35e4960..729e848 100644 --- a/ui/views/controls/button/image_button.cc +++ b/ui/views/controls/button/image_button.cc @@ -23,7 +23,7 @@ ImageButton::ImageButton(ButtonListener* listener) v_alignment_(ALIGN_TOP), preferred_size_(kDefaultWidth, kDefaultHeight) { // By default, we request that the gfx::Canvas passed to our View::OnPaint() - // implementation is flipped horizontally so that the button's bitmaps are + // implementation is flipped horizontally so that the button's images are // mirrored when the UI directionality is right-to-left. EnableCanvasFlippingForRTLUI(true); } @@ -40,7 +40,7 @@ void ImageButton::SetBackground(SkColor color, const gfx::ImageSkia* image, const gfx::ImageSkia* mask) { if (!image || !mask) { - background_image_.reset(); + background_image_ = gfx::ImageSkia(); return; } @@ -48,9 +48,9 @@ void ImageButton::SetBackground(SkColor color, SkBitmapOperations::CreateButtonBackground(color, *image, *mask); } -void ImageButton::SetOverlayImage(const SkBitmap* image) { +void ImageButton::SetOverlayImage(const gfx::ImageSkia* image) { if (!image) { - overlay_image_.reset(); + overlay_image_ = gfx::ImageSkia(); return; } overlay_image_ = *image; @@ -76,7 +76,7 @@ void ImageButton::OnPaint(gfx::Canvas* canvas) { // Call the base class first to paint any background/borders. View::OnPaint(canvas); - SkBitmap img = GetImageToPaint(); + gfx::ImageSkia img = GetImageToPaint(); if (!img.isNull()) { int x = 0, y = 0; @@ -105,8 +105,8 @@ void ImageButton::OnPaint(gfx::Canvas* canvas) { //////////////////////////////////////////////////////////////////////////////// // ImageButton, protected: -SkBitmap ImageButton::GetImageToPaint() { - SkBitmap img; +gfx::ImageSkia ImageButton::GetImageToPaint() { + gfx::ImageSkia img; if (!images_[BS_HOT].isNull() && hover_animation_->is_animating()) { img = SkBitmapOperations::CreateBlendedBitmap(images_[BS_NORMAL], @@ -134,7 +134,7 @@ void ToggleImageButton::SetToggled(bool toggled) { return; for (int i = 0; i < BS_COUNT; ++i) { - SkBitmap temp = images_[i]; + gfx::ImageSkia temp = images_[i]; images_[i] = alternate_images_[i]; alternate_images_[i] = temp; } diff --git a/ui/views/controls/button/image_button.h b/ui/views/controls/button/image_button.h index 3a54e20..b267e3c 100644 --- a/ui/views/controls/button/image_button.h +++ b/ui/views/controls/button/image_button.h @@ -7,7 +7,6 @@ #pragma once #include "base/gtest_prod_util.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/image/image_skia.h" #include "ui/views/controls/button/custom_button.h" @@ -46,7 +45,7 @@ class VIEWS_EXPORT ImageButton : public CustomButton { // Set an |image| to draw on top of the normal / hot / pushed image. // Pass NULL for no image. - void SetOverlayImage(const SkBitmap* image); + void SetOverlayImage(const gfx::ImageSkia* image); // Sets how the image is laid out within the button's bounds. void SetImageAlignment(HorizontalAlignment h_align, @@ -65,16 +64,16 @@ class VIEWS_EXPORT ImageButton : public CustomButton { protected: // Returns the image to paint. This is invoked from paint and returns a value // from images. - virtual SkBitmap GetImageToPaint(); + virtual gfx::ImageSkia GetImageToPaint(); // The images used to render the different states of this button. - SkBitmap images_[BS_COUNT]; + gfx::ImageSkia images_[BS_COUNT]; // The background image. - SkBitmap background_image_; + gfx::ImageSkia background_image_; // Image to draw on top of normal / hot / pushed image. Usually empty. - SkBitmap overlay_image_; + gfx::ImageSkia overlay_image_; private: FRIEND_TEST_ALL_PREFIXES(ImageButtonTest, Basics); @@ -122,7 +121,7 @@ class VIEWS_EXPORT ToggleImageButton : public ImageButton { // The parent class's images_ member is used for the current images, // and this array is used to hold the alternative images. // We swap between the two when toggling. - SkBitmap alternate_images_[BS_COUNT]; + gfx::ImageSkia alternate_images_[BS_COUNT]; // True if the button is currently toggled. bool toggled_; diff --git a/ui/views/controls/button/image_button_unittest.cc b/ui/views/controls/button/image_button_unittest.cc index f9b17c8..4e6c5b2 100644 --- a/ui/views/controls/button/image_button_unittest.cc +++ b/ui/views/controls/button/image_button_unittest.cc @@ -8,11 +8,11 @@ namespace { -SkBitmap CreateTestBitmap(int width, int height) { +gfx::ImageSkia CreateTestImage(int width, int height) { SkBitmap bitmap; bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); bitmap.allocPixels(); - return bitmap; + return gfx::ImageSkia(bitmap); } } // namespace @@ -35,8 +35,8 @@ TEST_F(ImageButtonTest, Basics) { EXPECT_EQ("5x15", button.GetPreferredSize().ToString()); // Set a normal image. - gfx::ImageSkia normal_bitmap = CreateTestBitmap(10, 20); - button.SetImage(CustomButton::BS_NORMAL, &normal_bitmap); + gfx::ImageSkia normal_image = CreateTestImage(10, 20); + button.SetImage(CustomButton::BS_NORMAL, &normal_image); // Image uses normal image for painting. EXPECT_FALSE(button.GetImageToPaint().empty()); @@ -47,8 +47,8 @@ TEST_F(ImageButtonTest, Basics) { EXPECT_EQ("10x20", button.GetPreferredSize().ToString()); // Set a pushed image. - gfx::ImageSkia pushed_bitmap = CreateTestBitmap(11, 21); - button.SetImage(CustomButton::BS_PUSHED, &pushed_bitmap); + gfx::ImageSkia pushed_image = CreateTestImage(11, 21); + button.SetImage(CustomButton::BS_PUSHED, &pushed_image); // By convention, preferred size doesn't change, even though pushed image // is bigger. @@ -59,9 +59,9 @@ TEST_F(ImageButtonTest, Basics) { EXPECT_EQ(10, button.GetImageToPaint().width()); EXPECT_EQ(20, button.GetImageToPaint().height()); - // Set an overlay bitmap. - SkBitmap overlay_bitmap = CreateTestBitmap(12, 22); - button.SetOverlayImage(&overlay_bitmap); + // Set an overlay image. + gfx::ImageSkia overlay_image = CreateTestImage(12, 22); + button.SetOverlayImage(&overlay_image); EXPECT_EQ(12, button.overlay_image_.width()); EXPECT_EQ(22, button.overlay_image_.height()); @@ -74,7 +74,7 @@ TEST_F(ImageButtonTest, Basics) { EXPECT_EQ(10, button.GetImageToPaint().width()); EXPECT_EQ(20, button.GetImageToPaint().height()); - // Reset the overlay bitmap. + // Reset the overlay image. button.SetOverlayImage(NULL); EXPECT_TRUE(button.overlay_image_.empty()); } diff --git a/ui/views/controls/button/menu_button.cc b/ui/views/controls/button/menu_button.cc index 0959bcf..a9aeb5b 100644 --- a/ui/views/controls/button/menu_button.cc +++ b/ui/views/controls/button/menu_button.cc @@ -56,7 +56,7 @@ MenuButton::MenuButton(ButtonListener* listener, listener_(menu_button_listener), show_menu_marker_(show_menu_marker), menu_marker_(ui::ResourceBundle::GetSharedInstance().GetImageNamed( - IDR_MENU_DROPARROW).ToSkBitmap()), + IDR_MENU_DROPARROW).ToImageSkia()), destroyed_flag_(NULL) { set_alignment(TextButton::ALIGN_LEFT); } diff --git a/ui/views/controls/button/menu_button.h b/ui/views/controls/button/menu_button.h index d37044b..58f14f3 100644 --- a/ui/views/controls/button/menu_button.h +++ b/ui/views/controls/button/menu_button.h @@ -38,7 +38,7 @@ class VIEWS_EXPORT MenuButton : public TextButton { bool show_menu_marker); virtual ~MenuButton(); - void set_menu_marker(const SkBitmap* menu_marker) { + void set_menu_marker(const gfx::ImageSkia* menu_marker) { menu_marker_ = menu_marker; } @@ -91,7 +91,7 @@ class VIEWS_EXPORT MenuButton : public TextButton { // The down arrow used to differentiate the menu button from normal // text buttons. - const SkBitmap* menu_marker_; + const gfx::ImageSkia* menu_marker_; // If non-null the destuctor sets this to true. This is set while the menu is // showing and used to detect if the menu was deleted while running. diff --git a/ui/views/controls/button/text_button.cc b/ui/views/controls/button/text_button.cc index c44b65e..764fac2 100644 --- a/ui/views/controls/button/text_button.cc +++ b/ui/views/controls/button/text_button.cc @@ -90,28 +90,28 @@ TextButtonBorder::TextButtonBorder() set_normal_set(normal_set); BorderImageSet hot_set = { - rb.GetImageNamed(IDR_TEXTBUTTON_TOP_LEFT_H).ToSkBitmap(), - rb.GetImageNamed(IDR_TEXTBUTTON_TOP_H).ToSkBitmap(), - rb.GetImageNamed(IDR_TEXTBUTTON_TOP_RIGHT_H).ToSkBitmap(), - rb.GetImageNamed(IDR_TEXTBUTTON_LEFT_H).ToSkBitmap(), - rb.GetImageNamed(IDR_TEXTBUTTON_CENTER_H).ToSkBitmap(), - rb.GetImageNamed(IDR_TEXTBUTTON_RIGHT_H).ToSkBitmap(), - rb.GetImageNamed(IDR_TEXTBUTTON_BOTTOM_LEFT_H).ToSkBitmap(), - rb.GetImageNamed(IDR_TEXTBUTTON_BOTTOM_H).ToSkBitmap(), - rb.GetImageNamed(IDR_TEXTBUTTON_BOTTOM_RIGHT_H).ToSkBitmap(), + rb.GetImageNamed(IDR_TEXTBUTTON_TOP_LEFT_H).ToImageSkia(), + rb.GetImageNamed(IDR_TEXTBUTTON_TOP_H).ToImageSkia(), + rb.GetImageNamed(IDR_TEXTBUTTON_TOP_RIGHT_H).ToImageSkia(), + rb.GetImageNamed(IDR_TEXTBUTTON_LEFT_H).ToImageSkia(), + rb.GetImageNamed(IDR_TEXTBUTTON_CENTER_H).ToImageSkia(), + rb.GetImageNamed(IDR_TEXTBUTTON_RIGHT_H).ToImageSkia(), + rb.GetImageNamed(IDR_TEXTBUTTON_BOTTOM_LEFT_H).ToImageSkia(), + rb.GetImageNamed(IDR_TEXTBUTTON_BOTTOM_H).ToImageSkia(), + rb.GetImageNamed(IDR_TEXTBUTTON_BOTTOM_RIGHT_H).ToImageSkia(), }; set_hot_set(hot_set); BorderImageSet pushed_set = { - rb.GetImageNamed(IDR_TEXTBUTTON_TOP_LEFT_P).ToSkBitmap(), - rb.GetImageNamed(IDR_TEXTBUTTON_TOP_P).ToSkBitmap(), - rb.GetImageNamed(IDR_TEXTBUTTON_TOP_RIGHT_P).ToSkBitmap(), - rb.GetImageNamed(IDR_TEXTBUTTON_LEFT_P).ToSkBitmap(), - rb.GetImageNamed(IDR_TEXTBUTTON_CENTER_P).ToSkBitmap(), - rb.GetImageNamed(IDR_TEXTBUTTON_RIGHT_P).ToSkBitmap(), - rb.GetImageNamed(IDR_TEXTBUTTON_BOTTOM_LEFT_P).ToSkBitmap(), - rb.GetImageNamed(IDR_TEXTBUTTON_BOTTOM_P).ToSkBitmap(), - rb.GetImageNamed(IDR_TEXTBUTTON_BOTTOM_RIGHT_P).ToSkBitmap(), + rb.GetImageNamed(IDR_TEXTBUTTON_TOP_LEFT_P).ToImageSkia(), + rb.GetImageNamed(IDR_TEXTBUTTON_TOP_P).ToImageSkia(), + rb.GetImageNamed(IDR_TEXTBUTTON_TOP_RIGHT_P).ToImageSkia(), + rb.GetImageNamed(IDR_TEXTBUTTON_LEFT_P).ToImageSkia(), + rb.GetImageNamed(IDR_TEXTBUTTON_CENTER_P).ToImageSkia(), + rb.GetImageNamed(IDR_TEXTBUTTON_RIGHT_P).ToImageSkia(), + rb.GetImageNamed(IDR_TEXTBUTTON_BOTTOM_LEFT_P).ToImageSkia(), + rb.GetImageNamed(IDR_TEXTBUTTON_BOTTOM_P).ToImageSkia(), + rb.GetImageNamed(IDR_TEXTBUTTON_BOTTOM_RIGHT_P).ToImageSkia(), }; set_pushed_set(pushed_set); } @@ -514,7 +514,7 @@ void TextButtonBase::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { // canvas, we can not mirror the button by simply flipping the canvas as // doing this will mirror the text itself. Flipping the canvas will also // make the icons look wrong because icons are almost always represented as - // direction-insensitive bitmaps and such bitmaps should never be flipped + // direction-insensitive images and such images should never be flipped // horizontally. // // Due to the above, we must perform the flipping manually for RTL UIs. @@ -668,18 +668,18 @@ TextButton::TextButton(ButtonListener* listener, const string16& text) TextButton::~TextButton() { } -void TextButton::SetIcon(const SkBitmap& icon) { +void TextButton::SetIcon(const gfx::ImageSkia& icon) { icon_ = icon; SchedulePaint(); } -void TextButton::SetHoverIcon(const SkBitmap& icon) { +void TextButton::SetHoverIcon(const gfx::ImageSkia& icon) { icon_hover_ = icon; has_hover_icon_ = true; SchedulePaint(); } -void TextButton::SetPushedIcon(const SkBitmap& icon) { +void TextButton::SetPushedIcon(const gfx::ImageSkia& icon) { icon_pushed_ = icon; has_pushed_icon_ = true; SchedulePaint(); @@ -717,7 +717,7 @@ gfx::Size TextButton::GetPreferredSize() { void TextButton::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { TextButtonBase::PaintButton(canvas, mode); - const SkBitmap& icon = GetImageToPaint(); + const gfx::ImageSkia& icon = GetImageToPaint(); if (icon.width() > 0) { gfx::Rect text_bounds = GetTextBounds(); @@ -768,7 +768,7 @@ void TextButton::GetExtraParams(ui::NativeTheme::ExtraParams* params) const { gfx::Rect TextButton::GetTextBounds() const { int extra_width = 0; - const SkBitmap& icon = GetImageToPaint(); + const gfx::ImageSkia& icon = GetImageToPaint(); if (icon.width() > 0) extra_width = icon.width() + (text_.empty() ? 0 : icon_text_spacing_); @@ -786,7 +786,7 @@ gfx::Rect TextButton::GetTextBounds() const { return bounds; } -const SkBitmap& TextButton::GetImageToPaint() const { +const gfx::ImageSkia& TextButton::GetImageToPaint() const { if (show_multiple_icon_states_) { if (has_hover_icon_ && (state() == BS_HOT)) return icon_hover_; diff --git a/ui/views/controls/button/text_button.h b/ui/views/controls/button/text_button.h index 2dd1cb8..4d75eae 100644 --- a/ui/views/controls/button/text_button.h +++ b/ui/views/controls/button/text_button.h @@ -10,7 +10,7 @@ #include "base/compiler_specific.h" #include "base/string16.h" -#include "third_party/skia/include/core/SkBitmap.h" +#include "ui/gfx/image/image_skia.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/gfx/font.h" #include "ui/views/border.h" @@ -44,15 +44,15 @@ class VIEWS_EXPORT TextButtonBorder : public Border { protected: struct BorderImageSet { - const SkBitmap* top_left; - const SkBitmap* top; - const SkBitmap* top_right; - const SkBitmap* left; - const SkBitmap* center; - const SkBitmap* right; - const SkBitmap* bottom_left; - const SkBitmap* bottom; - const SkBitmap* bottom_right; + const gfx::ImageSkia* top_left; + const gfx::ImageSkia* top; + const gfx::ImageSkia* top_right; + const gfx::ImageSkia* left; + const gfx::ImageSkia* center; + const gfx::ImageSkia* right; + const gfx::ImageSkia* bottom_left; + const gfx::ImageSkia* bottom; + const gfx::ImageSkia* bottom_right; }; void Paint(const View& view, @@ -320,9 +320,9 @@ class VIEWS_EXPORT TextButton : public TextButtonBase { } // Sets the icon. - virtual void SetIcon(const SkBitmap& icon); - virtual void SetHoverIcon(const SkBitmap& icon); - virtual void SetPushedIcon(const SkBitmap& icon); + virtual void SetIcon(const gfx::ImageSkia& icon); + virtual void SetHoverIcon(const gfx::ImageSkia& icon); + virtual void SetPushedIcon(const gfx::ImageSkia& icon); bool HasIcon() const { return !icon_.empty(); } @@ -348,9 +348,9 @@ class VIEWS_EXPORT TextButton : public TextButtonBase { virtual void PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) OVERRIDE; protected: - SkBitmap icon() const { return icon_; } + gfx::ImageSkia icon() const { return icon_; } - virtual const SkBitmap& GetImageToPaint() const; + virtual const gfx::ImageSkia& GetImageToPaint() const; // Overridden from NativeThemeDelegate: virtual ui::NativeTheme::Part GetThemePart() const OVERRIDE; @@ -365,14 +365,14 @@ class VIEWS_EXPORT TextButton : public TextButtonBase { IconPlacement icon_placement_; // An icon displayed with the text. - SkBitmap icon_; + gfx::ImageSkia icon_; // An optional different version of the icon for hover state. - SkBitmap icon_hover_; + gfx::ImageSkia icon_hover_; bool has_hover_icon_; // An optional different version of the icon for pushed state. - SkBitmap icon_pushed_; + gfx::ImageSkia icon_pushed_; bool has_pushed_icon_; // Space between icon and text. diff --git a/ui/views/controls/combobox/native_combobox_views.cc b/ui/views/controls/combobox/native_combobox_views.cc index 1a538c8..4bd17a3 100644 --- a/ui/views/controls/combobox/native_combobox_views.cc +++ b/ui/views/controls/combobox/native_combobox_views.cc @@ -57,7 +57,7 @@ NativeComboboxViews::NativeComboboxViews(Combobox* combobox) : combobox_(combobox), text_border_(new FocusableBorder()), disclosure_arrow_(ui::ResourceBundle::GetSharedInstance().GetImageNamed( - IDR_DISCLOSURE_ARROW).ToSkBitmap()), + IDR_DISCLOSURE_ARROW).ToImageSkia()), dropdown_open_(false), selected_index_(-1), content_width_(0), diff --git a/ui/views/controls/combobox/native_combobox_views.h b/ui/views/controls/combobox/native_combobox_views.h index 502fb9e..145599e 100644 --- a/ui/views/controls/combobox/native_combobox_views.h +++ b/ui/views/controls/combobox/native_combobox_views.h @@ -79,7 +79,7 @@ class NativeComboboxViews : public views::View, FocusableBorder* text_border_; // The disclosure arrow next to the currently selected item from the list. - const SkBitmap* disclosure_arrow_; + const gfx::ImageSkia* disclosure_arrow_; // Responsible for showing the context menu. scoped_ptr<MenuRunner> dropdown_list_menu_runner_; diff --git a/ui/views/controls/glow_hover_controller.cc b/ui/views/controls/glow_hover_controller.cc index c998f34..f3b356b 100644 --- a/ui/views/controls/glow_hover_controller.cc +++ b/ui/views/controls/glow_hover_controller.cc @@ -4,9 +4,9 @@ #include "ui/views/controls/glow_hover_controller.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/effects/SkGradientShader.h" #include "ui/gfx/canvas.h" +#include "ui/gfx/image/image_skia.h" #include "ui/gfx/skbitmap_operations.h" #include "ui/views/view.h" @@ -64,7 +64,7 @@ bool GlowHoverController::ShouldDraw() const { } void GlowHoverController::Draw(gfx::Canvas* canvas, - const SkBitmap& mask_image) const { + const gfx::ImageSkia& mask_image) const { if (!ShouldDraw()) return; @@ -96,7 +96,7 @@ void GlowHoverController::Draw(gfx::Canvas* canvas, location_.y() - radius, radius * 2, radius * 2), paint); } - SkBitmap result = SkBitmapOperations::CreateMaskedBitmap( + gfx::ImageSkia result = SkBitmapOperations::CreateMaskedBitmap( hover_canvas.ExtractBitmap(), mask_image); canvas->DrawBitmapInt(result, (view_->width() - mask_image.width()) / 2, (view_->height() - mask_image.height()) / 2); diff --git a/ui/views/controls/glow_hover_controller.h b/ui/views/controls/glow_hover_controller.h index 69aeecf..ea71252 100644 --- a/ui/views/controls/glow_hover_controller.h +++ b/ui/views/controls/glow_hover_controller.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -12,11 +12,10 @@ namespace gfx { class Canvas; +class ImageSkia; class Point; } -class SkBitmap; - namespace views { class View; @@ -59,7 +58,7 @@ class VIEWS_EXPORT GlowHoverController : public ui::AnimationDelegate { // If the hover is currently visible it is drawn to the supplied canvas. // |mask_image| is used to determine what parts of the canvas to draw on. - void Draw(gfx::Canvas* canvas, const SkBitmap& mask_image) const; + void Draw(gfx::Canvas* canvas, const gfx::ImageSkia& mask_image) const; // ui::AnimationDelegate overrides: virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; diff --git a/ui/views/controls/image_view.cc b/ui/views/controls/image_view.cc index e09603d..bf8043d 100644 --- a/ui/views/controls/image_view.cc +++ b/ui/views/controls/image_view.cc @@ -22,9 +22,9 @@ ImageView::ImageView() ImageView::~ImageView() { } -void ImageView::SetImage(const SkBitmap& bm) { +void ImageView::SetImage(const gfx::ImageSkia& img) { gfx::Size pref_size(GetPreferredSize()); - image_ = bm; + image_ = img; if (pref_size != GetPreferredSize()) PreferredSizeChanged(); SchedulePaint(); @@ -34,12 +34,12 @@ void ImageView::SetImage(const gfx::ImageSkia* image_skia) { if (image_skia) { SetImage(*image_skia); } else { - SkBitmap t; + gfx::ImageSkia t; SetImage(t); } } -const SkBitmap& ImageView::GetImage() { +const gfx::ImageSkia& ImageView::GetImage() { return image_; } @@ -119,7 +119,6 @@ void ImageView::OnPaint(gfx::Canvas* canvas) { if (image_bounds.size() != gfx::Size(image_.width(), image_.height())) { // Resize case - image_.buildMipMap(false); SkPaint paint; paint.setFilterBitmap(true); canvas->DrawBitmapInt(image_, 0, 0, image_.width(), image_.height(), diff --git a/ui/views/controls/image_view.h b/ui/views/controls/image_view.h index 7c90fd8..5aa1553 100644 --- a/ui/views/controls/image_view.h +++ b/ui/views/controls/image_view.h @@ -6,7 +6,6 @@ #define UI_VIEWS_CONTROLS_IMAGE_VIEW_H_ #pragma once -#include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/image/image_skia.h" #include "ui/views/view.h" @@ -20,7 +19,7 @@ namespace views { // // ImageView class. // -// An ImageView can display an image from an SkBitmap. If a size is provided, +// An ImageView can display an image from an ImageSkia. If a size is provided, // the ImageView will resize the provided image to fit if it is too big or will // center the image if smaller. Otherwise, the preferred size matches the // provided image size. @@ -37,17 +36,17 @@ class VIEWS_EXPORT ImageView : public View { ImageView(); virtual ~ImageView(); - // Set the bitmap that should be displayed. - void SetImage(const SkBitmap& bm); + // Set the image that should be displayed. + void SetImage(const gfx::ImageSkia& img); // Set the image that should be displayed from a pointer. Reset the image // if the pointer is NULL. The pointer contents is copied in the receiver's - // bitmap. + // image. void SetImage(const gfx::ImageSkia* image_skia); - // Returns the bitmap currently displayed or NULL of none is currently set. - // The returned bitmap is still owned by the ImageView. - const SkBitmap& GetImage(); + // Returns the image currently displayed or NULL of none is currently set. + // The returned image is still owned by the ImageView. + const gfx::ImageSkia& GetImage(); // Set the desired image size for the receiving ImageView. void SetImageSize(const gfx::Size& image_size); @@ -93,8 +92,8 @@ class VIEWS_EXPORT ImageView : public View { // The actual image size. gfx::Size image_size_; - // The underlying bitmap. - SkBitmap image_; + // The underlying image. + gfx::ImageSkia image_; // Horizontal alignment. Alignment horiz_alignment_; diff --git a/ui/views/controls/menu/menu.cc b/ui/views/controls/menu/menu.cc index 2607cde..9b9a099 100644 --- a/ui/views/controls/menu/menu.cc +++ b/ui/views/controls/menu/menu.cc @@ -1,11 +1,11 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ui/views/controls/menu/menu.h" #include "base/i18n/rtl.h" -#include "third_party/skia/include/core/SkBitmap.h" +#include "ui/gfx/image/image_skia.h" namespace views { @@ -13,8 +13,8 @@ bool Menu::Delegate::IsRightToLeftUILayout() const { return base::i18n::IsRTL(); } -const SkBitmap& Menu::Delegate::GetEmptyIcon() const { - static const SkBitmap* empty_icon = new SkBitmap(); +const gfx::ImageSkia& Menu::Delegate::GetEmptyIcon() const { + static const gfx::ImageSkia* empty_icon = new gfx::ImageSkia(); return *empty_icon; } @@ -44,7 +44,7 @@ void Menu::AddMenuItem(int index, if (type == SEPARATOR) AddSeparator(index); else - AddMenuItemInternal(index, item_id, label, SkBitmap(), type); + AddMenuItemInternal(index, item_id, label, gfx::ImageSkia(), type); } Menu* Menu::AppendSubMenu(int item_id, const string16& label) { @@ -52,12 +52,12 @@ Menu* Menu::AppendSubMenu(int item_id, const string16& label) { } Menu* Menu::AddSubMenu(int index, int item_id, const string16& label) { - return AddSubMenuWithIcon(index, item_id, label, SkBitmap()); + return AddSubMenuWithIcon(index, item_id, label, gfx::ImageSkia()); } Menu* Menu::AppendSubMenuWithIcon(int item_id, const string16& label, - const SkBitmap& icon) { + const gfx::ImageSkia& icon) { return AddSubMenuWithIcon(-1, item_id, label, icon); } @@ -85,14 +85,14 @@ void Menu::AppendSeparator() { void Menu::AppendMenuItemWithIcon(int item_id, const string16& label, - const SkBitmap& icon) { + const gfx::ImageSkia& icon) { AddMenuItemWithIcon(-1, item_id, label, icon); } void Menu::AddMenuItemWithIcon(int index, int item_id, const string16& label, - const SkBitmap& icon) { + const gfx::ImageSkia& icon) { AddMenuItemInternal(index, item_id, label, icon, Menu::NORMAL); } diff --git a/ui/views/controls/menu/menu.h b/ui/views/controls/menu/menu.h index 2ee90f9..2ec9d36 100644 --- a/ui/views/controls/menu/menu.h +++ b/ui/views/controls/menu/menu.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -13,9 +13,8 @@ #include "ui/gfx/native_widget_types.h" #include "ui/views/views_export.h" -class SkBitmap; - namespace gfx { +class ImageSkia; class Point; } @@ -63,7 +62,7 @@ class VIEWS_EXPORT Menu { } // The icon shown for the menu item. - virtual const SkBitmap& GetIcon(int id) const { + virtual const gfx::ImageSkia& GetIcon(int id) const { return GetEmptyIcon(); } @@ -124,7 +123,7 @@ class VIEWS_EXPORT Menu { protected: // Returns an empty icon. - const SkBitmap& GetEmptyIcon() const; + const gfx::ImageSkia& GetEmptyIcon() const; }; // How this popup should align itself relative to the point it is run at. @@ -194,11 +193,11 @@ class VIEWS_EXPORT Menu { // to draw the menu, instead of relying on Windows. Menu* AppendSubMenuWithIcon(int item_id, const string16& label, - const SkBitmap& icon); + const gfx::ImageSkia& icon); virtual Menu* AddSubMenuWithIcon(int index, int item_id, const string16& label, - const SkBitmap& icon) = 0; + const gfx::ImageSkia& icon) = 0; // This is a convenience for standard text label menu items where the label // is provided with this call. @@ -219,11 +218,11 @@ class VIEWS_EXPORT Menu { // the menu, instead of relying on Windows. void AppendMenuItemWithIcon(int item_id, const string16& label, - const SkBitmap& icon); + const gfx::ImageSkia& icon); virtual void AddMenuItemWithIcon(int index, int item_id, const string16& label, - const SkBitmap& icon); + const gfx::ImageSkia& icon); // Enables or disables the item with the specified id. virtual void EnableMenuItemByID(int item_id, bool enabled) = 0; @@ -235,7 +234,7 @@ class VIEWS_EXPORT Menu { // Sets an icon for an item with a given item_id. Calling this function // also forces the Menu class to draw the menu, instead of relying on Windows. // Returns false if the item with |item_id| is not found. - virtual bool SetIcon(const SkBitmap& icon, int item_id) = 0; + virtual bool SetIcon(const gfx::ImageSkia& icon, int item_id) = 0; // Shows the menu, blocks until the user dismisses the menu or selects an // item, and executes the command for the selected item (if any). @@ -259,7 +258,7 @@ class VIEWS_EXPORT Menu { virtual void AddMenuItemInternal(int index, int item_id, const string16& label, - const SkBitmap& icon, + const gfx::ImageSkia& icon, MenuItemType type) = 0; private: diff --git a/ui/views/controls/menu/menu_config_views.cc b/ui/views/controls/menu/menu_config_views.cc index bfb0464..c690ebd 100644 --- a/ui/views/controls/menu/menu_config_views.cc +++ b/ui/views/controls/menu/menu_config_views.cc @@ -5,10 +5,10 @@ #include "ui/views/controls/menu/menu_config.h" #include "grit/ui_resources.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/layout.h" #include "ui/gfx/image/image.h" +#include "ui/gfx/image/image_skia.h" #include "ui/base/native_theme/native_theme_aura.h" namespace views { @@ -25,8 +25,8 @@ MenuConfig* MenuConfig::Create() { config->item_left_margin = 8; config->arrow_to_edge_padding = 20; config->icon_to_label_padding = 4; - config->arrow_width = rb.GetImageNamed(IDR_MENU_ARROW).ToSkBitmap()->width(); - const SkBitmap* check = rb.GetImageNamed(IDR_MENU_CHECK).ToSkBitmap(); + config->arrow_width = rb.GetImageNamed(IDR_MENU_ARROW).ToImageSkia()->width(); + const gfx::ImageSkia* check = rb.GetImageNamed(IDR_MENU_CHECK).ToImageSkia(); // Add 4 to force some padding between check and label. config->check_width = check->width() + 4; config->check_height = check->height(); diff --git a/ui/views/controls/menu/menu_image_util.cc b/ui/views/controls/menu/menu_image_util.cc index bd58755..d5a8be2 100644 --- a/ui/views/controls/menu/menu_image_util.cc +++ b/ui/views/controls/menu/menu_image_util.cc @@ -10,6 +10,7 @@ #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas.h" #include "ui/gfx/image/image.h" +#include "ui/gfx/image/image_skia.h" #include "ui/gfx/point.h" #include "ui/gfx/size.h" @@ -29,7 +30,7 @@ const SkColor kRadioButtonIndicatorGradient0 = SkColorSetRGB(0, 0, 0); const SkColor kRadioButtonIndicatorGradient1 = SkColorSetRGB(0x83, 0x83, 0x83); const SkColor kIndicatorStroke = SkColorSetRGB(0, 0, 0); -SkBitmap* CreateRadioButtonImage(bool selected) { +gfx::ImageSkia* CreateRadioButtonImage(bool selected) { // + 2 (1px on each side) to cover rounding error. gfx::Canvas canvas(gfx::Size(kIndicatorSize + 2, kIndicatorSize + 2), false); canvas.Translate(gfx::Point(1, 1)); @@ -78,18 +79,18 @@ SkBitmap* CreateRadioButtonImage(bool selected) { canvas.sk_canvas()->drawCircle(radius, radius, kSelectedIndicatorSize / 2, paint); } - return new SkBitmap(canvas.ExtractBitmap()); + return new gfx::ImageSkia(canvas.ExtractBitmap()); } -SkBitmap* GetRtlSubmenuArrowImage() { - static SkBitmap* kRtlArrow = NULL; +gfx::ImageSkia* GetRtlSubmenuArrowImage() { + static gfx::ImageSkia* kRtlArrow = NULL; if (!kRtlArrow) { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - const SkBitmap* r = rb.GetImageNamed(IDR_MENU_ARROW).ToSkBitmap(); + const gfx::ImageSkia* r = rb.GetImageNamed(IDR_MENU_ARROW).ToImageSkia(); gfx::Canvas canvas(gfx::Size(r->width(), r->height()), false); canvas.Scale(-1, 1); canvas.DrawBitmapInt(*r, - r->width(), 0); - kRtlArrow = new SkBitmap(canvas.ExtractBitmap()); + kRtlArrow = new gfx::ImageSkia(canvas.ExtractBitmap()); } return kRtlArrow; } @@ -98,17 +99,17 @@ SkBitmap* GetRtlSubmenuArrowImage() { namespace views { -const SkBitmap* GetRadioButtonImage(bool selected) { - static const SkBitmap* kRadioOn = CreateRadioButtonImage(true); - static const SkBitmap* kRadioOff = CreateRadioButtonImage(false); +const gfx::ImageSkia* GetRadioButtonImage(bool selected) { + static const gfx::ImageSkia* kRadioOn = CreateRadioButtonImage(true); + static const gfx::ImageSkia* kRadioOff = CreateRadioButtonImage(false); return selected ? kRadioOn : kRadioOff; } -const SkBitmap* GetSubmenuArrowImage() { +const gfx::ImageSkia* GetSubmenuArrowImage() { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); return base::i18n::IsRTL() ? GetRtlSubmenuArrowImage() - : rb.GetImageNamed(IDR_MENU_ARROW).ToSkBitmap(); + : rb.GetImageNamed(IDR_MENU_ARROW).ToImageSkia(); } } // namespace views diff --git a/ui/views/controls/menu/menu_image_util.h b/ui/views/controls/menu/menu_image_util.h index 7d98035..5e1062c 100644 --- a/ui/views/controls/menu/menu_image_util.h +++ b/ui/views/controls/menu/menu_image_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,7 +6,9 @@ #define UI_VIEWS_CONTROLS_MENU_MENU_IMAGE_UTIL_H_ #pragma once -#include "third_party/skia/include/core/SkBitmap.h" +namespace gfx { +class ImageSkia; +} namespace views { @@ -14,10 +16,10 @@ namespace views { // It returns the "selected" image when |selected| is // true, or the "unselected" image if false. // The returned image is global object and should not be freed. -const SkBitmap* GetRadioButtonImage(bool selected); +const gfx::ImageSkia* GetRadioButtonImage(bool selected); // Returns the image for submenu arrow for current RTL setting. -const SkBitmap* GetSubmenuArrowImage(); +const gfx::ImageSkia* GetSubmenuArrowImage(); } // namespace views diff --git a/ui/views/controls/menu/menu_item_view.cc b/ui/views/controls/menu/menu_item_view.cc index fff309b..b5f8111 100644 --- a/ui/views/controls/menu/menu_item_view.cc +++ b/ui/views/controls/menu/menu_item_view.cc @@ -203,7 +203,7 @@ void MenuItemView::Cancel() { MenuItemView* MenuItemView::AddMenuItemAt(int index, int item_id, const string16& label, - const SkBitmap& icon, + const gfx::ImageSkia& icon, Type type) { DCHECK_NE(type, EMPTY); DCHECK_LE(0, index); @@ -244,17 +244,17 @@ void MenuItemView::RemoveMenuItemAt(int index) { MenuItemView* MenuItemView::AppendMenuItem(int item_id, const string16& label, Type type) { - return AppendMenuItemImpl(item_id, label, SkBitmap(), type); + return AppendMenuItemImpl(item_id, label, gfx::ImageSkia(), type); } MenuItemView* MenuItemView::AppendSubMenu(int item_id, const string16& label) { - return AppendMenuItemImpl(item_id, label, SkBitmap(), SUBMENU); + return AppendMenuItemImpl(item_id, label, gfx::ImageSkia(), SUBMENU); } MenuItemView* MenuItemView::AppendSubMenuWithIcon(int item_id, const string16& label, - const SkBitmap& icon) { + const gfx::ImageSkia& icon) { return AppendMenuItemImpl(item_id, label, icon, SUBMENU); } @@ -268,19 +268,19 @@ MenuItemView* MenuItemView::AppendDelegateMenuItem(int item_id) { } void MenuItemView::AppendSeparator() { - AppendMenuItemImpl(0, string16(), SkBitmap(), SEPARATOR); + AppendMenuItemImpl(0, string16(), gfx::ImageSkia(), SEPARATOR); } MenuItemView* MenuItemView::AppendMenuItemWithIcon(int item_id, const string16& label, - const SkBitmap& icon) { + const gfx::ImageSkia& icon) { return AppendMenuItemImpl(item_id, label, icon, NORMAL); } MenuItemView* MenuItemView::AppendMenuItemFromModel(ui::MenuModel* model, int index, int id) { - SkBitmap icon; + gfx::ImageSkia icon; string16 label; MenuItemView::Type type; ui::MenuModel::ItemType menu_type = model->GetTypeAt(index); @@ -317,7 +317,7 @@ MenuItemView* MenuItemView::AppendMenuItemFromModel(ui::MenuModel* model, MenuItemView* MenuItemView::AppendMenuItemImpl(int item_id, const string16& label, - const SkBitmap& icon, + const gfx::ImageSkia& icon, Type type) { const int index = submenu_ ? submenu_->child_count() : 0; return AddMenuItemAt(index, item_id, label, icon, type); @@ -353,13 +353,13 @@ void MenuItemView::SetTooltip(const string16& tooltip, int item_id) { item->tooltip_ = tooltip; } -void MenuItemView::SetIcon(const SkBitmap& icon, int item_id) { +void MenuItemView::SetIcon(const gfx::ImageSkia& icon, int item_id) { MenuItemView* item = GetMenuItemByID(item_id); DCHECK(item); item->SetIcon(icon); } -void MenuItemView::SetIcon(const SkBitmap& icon) { +void MenuItemView::SetIcon(const gfx::ImageSkia& icon) { icon_ = icon; SchedulePaint(); } diff --git a/ui/views/controls/menu/menu_item_view.h b/ui/views/controls/menu/menu_item_view.h index 928ea84..6f4b89a 100644 --- a/ui/views/controls/menu/menu_item_view.h +++ b/ui/views/controls/menu/menu_item_view.h @@ -13,7 +13,7 @@ #include "base/logging.h" #include "base/string16.h" #include "build/build_config.h" -#include "third_party/skia/include/core/SkBitmap.h" +#include "ui/gfx/image/image_skia.h" #include "ui/views/view.h" #if defined(OS_WIN) @@ -134,7 +134,7 @@ class VIEWS_EXPORT MenuItemView : public View { MenuItemView* AddMenuItemAt(int index, int item_id, const string16& label, - const SkBitmap& icon, + const gfx::ImageSkia& icon, Type type); // Remove an item from the menu at a specified index. @@ -163,7 +163,7 @@ class VIEWS_EXPORT MenuItemView : public View { // The returned pointer is owned by this menu. MenuItemView* AppendSubMenuWithIcon(int item_id, const string16& label, - const SkBitmap& icon); + const gfx::ImageSkia& icon); // This is a convenience for standard text label menu items where the label // is provided with this call. @@ -182,7 +182,7 @@ class VIEWS_EXPORT MenuItemView : public View { // the menu, instead of relying on Windows. MenuItemView* AppendMenuItemWithIcon(int item_id, const string16& label, - const SkBitmap& icon); + const gfx::ImageSkia& icon); // Creates a menu item for the specified entry in the model and appends it as // a child. |index| should be offset by GetFirstItemIndex() before calling @@ -194,7 +194,7 @@ class VIEWS_EXPORT MenuItemView : public View { // All the AppendXXX methods funnel into this. MenuItemView* AppendMenuItemImpl(int item_id, const string16& label, - const SkBitmap& icon, + const gfx::ImageSkia& icon, Type type); // Returns the view that contains child menu items. If the submenu has @@ -234,13 +234,13 @@ class VIEWS_EXPORT MenuItemView : public View { void SetTooltip(const string16& tooltip, int item_id); // Sets the icon for the descendant identified by item_id. - void SetIcon(const SkBitmap& icon, int item_id); + void SetIcon(const gfx::ImageSkia& icon, int item_id); // Sets the icon of this menu item. - void SetIcon(const SkBitmap& icon); + void SetIcon(const gfx::ImageSkia& icon); // Returns the icon. - const SkBitmap& GetIcon() const { return icon_; } + const gfx::ImageSkia& GetIcon() const { return icon_; } // Sets the command id of this menu item. void SetCommand(int command) { command_ = command; } @@ -436,7 +436,7 @@ class VIEWS_EXPORT MenuItemView : public View { string16 title_; // Icon. - SkBitmap icon_; + gfx::ImageSkia icon_; // Does the title have a mnemonic? Only useful on the root menu item. bool has_mnemonics_; diff --git a/ui/views/controls/menu/menu_item_view_views.cc b/ui/views/controls/menu/menu_item_view_views.cc index 00beeb9..e859546 100644 --- a/ui/views/controls/menu/menu_item_view_views.cc +++ b/ui/views/controls/menu/menu_item_view_views.cc @@ -45,13 +45,14 @@ void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { // Render the check. if (type_ == CHECKBOX && GetDelegate()->IsItemChecked(GetCommand())) { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - const SkBitmap* check = rb.GetImageNamed(IDR_MENU_CHECK).ToSkBitmap(); + const gfx::ImageSkia* check = rb.GetImageNamed( + IDR_MENU_CHECK).ToImageSkia(); // Don't use config.check_width here as it's padded to force more padding. gfx::Rect check_bounds(icon_x, icon_y, check->width(), icon_height); AdjustBoundsForRTLUI(&check_bounds); canvas->DrawBitmapInt(*check, check_bounds.x(), check_bounds.y()); } else if (type_ == RADIO) { - const SkBitmap* image = + const gfx::ImageSkia* image = GetRadioButtonImage(GetDelegate()->IsItemChecked(GetCommand())); gfx::Rect radio_bounds(icon_x, top_margin + diff --git a/ui/views/controls/menu/menu_model_adapter_unittest.cc b/ui/views/controls/menu/menu_model_adapter_unittest.cc index ba6d406..8f86335 100644 --- a/ui/views/controls/menu/menu_model_adapter_unittest.cc +++ b/ui/views/controls/menu/menu_model_adapter_unittest.cc @@ -79,7 +79,7 @@ class MenuModelBase : public ui::MenuModel { return 0; } - virtual bool GetIconAt(int index, SkBitmap* icon) OVERRIDE { + virtual bool GetIconAt(int index, gfx::ImageSkia* icon) OVERRIDE { return false; } diff --git a/ui/views/controls/menu/menu_win.cc b/ui/views/controls/menu/menu_win.cc index 564fd5c..736a7ed 100644 --- a/ui/views/controls/menu/menu_win.cc +++ b/ui/views/controls/menu/menu_win.cc @@ -40,7 +40,7 @@ static MenuHostWindow* active_host_window = NULL; // The data of menu items needed to display. struct MenuWin::ItemData { string16 label; - SkBitmap icon; + gfx::ImageSkia icon; bool submenu; }; @@ -263,7 +263,7 @@ MenuWin::~MenuWin() { void MenuWin::AddMenuItemWithIcon(int index, int item_id, const string16& label, - const SkBitmap& icon) { + const gfx::ImageSkia& icon) { owner_draw_ = true; Menu::AddMenuItemWithIcon(index, item_id, label, icon); } @@ -271,7 +271,7 @@ void MenuWin::AddMenuItemWithIcon(int index, Menu* MenuWin::AddSubMenuWithIcon(int index, int item_id, const string16& label, - const SkBitmap& icon) { + const gfx::ImageSkia& icon) { MenuWin* submenu = new MenuWin(this); submenus_.push_back(submenu); AddMenuItemInternal(index, item_id, label, icon, submenu->menu_, NORMAL); @@ -305,7 +305,7 @@ void MenuWin::SetMenuLabel(int item_id, const string16& label) { SetMenuItemInfo(menu_, item_id, false, &mii); } -bool MenuWin::SetIcon(const SkBitmap& icon, int item_id) { +bool MenuWin::SetIcon(const gfx::ImageSkia& icon, int item_id) { if (!owner_draw_) owner_draw_ = true; @@ -386,7 +386,7 @@ int MenuWin::ItemCount() { void MenuWin::AddMenuItemInternal(int index, int item_id, const string16& label, - const SkBitmap& icon, + const gfx::ImageSkia& icon, MenuItemType type) { AddMenuItemInternal(index, item_id, label, icon, NULL, type); } @@ -394,7 +394,7 @@ void MenuWin::AddMenuItemInternal(int index, void MenuWin::AddMenuItemInternal(int index, int item_id, const string16& label, - const SkBitmap& icon, + const gfx::ImageSkia& icon, HMENU submenu, MenuItemType type) { DCHECK(type != SEPARATOR) << "Call AddSeparator instead!"; diff --git a/ui/views/controls/menu/menu_win.h b/ui/views/controls/menu/menu_win.h index 3b20f27..dd12a64 100644 --- a/ui/views/controls/menu/menu_win.h +++ b/ui/views/controls/menu/menu_win.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -50,16 +50,16 @@ class MenuWin : public Menu { virtual void AddMenuItemWithIcon(int index, int item_id, const string16& label, - const SkBitmap& icon) OVERRIDE; + const gfx::ImageSkia& icon) OVERRIDE; virtual Menu* AddSubMenuWithIcon(int index, int item_id, const string16& label, - const SkBitmap& icon) OVERRIDE; + const gfx::ImageSkia& icon) OVERRIDE; virtual void AddSeparator(int index) OVERRIDE; virtual void EnableMenuItemByID(int item_id, bool enabled) OVERRIDE; virtual void EnableMenuItemAt(int index, bool enabled) OVERRIDE; virtual void SetMenuLabel(int item_id, const string16& label) OVERRIDE; - virtual bool SetIcon(const SkBitmap& icon, int item_id) OVERRIDE; + virtual bool SetIcon(const gfx::ImageSkia& icon, int item_id) OVERRIDE; virtual void RunMenuAt(int x, int y) OVERRIDE; virtual void Cancel() OVERRIDE; virtual int ItemCount() OVERRIDE; @@ -75,7 +75,7 @@ class MenuWin : public Menu { virtual void AddMenuItemInternal(int index, int item_id, const string16& label, - const SkBitmap& icon, + const gfx::ImageSkia& icon, MenuItemType type) OVERRIDE; private: @@ -87,7 +87,7 @@ class MenuWin : public Menu { void AddMenuItemInternal(int index, int item_id, const string16& label, - const SkBitmap& icon, + const gfx::ImageSkia& icon, HMENU submenu, MenuItemType type); diff --git a/ui/views/controls/menu/native_menu_win.cc b/ui/views/controls/menu/native_menu_win.cc index 2b4af01..94461f33 100644 --- a/ui/views/controls/menu/native_menu_win.cc +++ b/ui/views/controls/menu/native_menu_win.cc @@ -12,7 +12,7 @@ #include "base/stl_util.h" #include "base/string_util.h" #include "base/win/wrapped_window_proc.h" -#include "third_party/skia/include/core/SkBitmap.h" +#include "ui/gfx/image/image_skia.h" #include "ui/base/accelerators/accelerator.h" #include "ui/base/keycodes/keyboard_codes.h" #include "ui/base/l10n/l10n_util.h" @@ -252,7 +252,7 @@ class NativeMenuWin::MenuHostWindow { // Draw the icon after the label, otherwise it would be covered // by the label. - SkBitmap icon; + gfx::ImageSkia icon; if (data->native_menu_win->model_->GetIconAt(data->model_index, &icon)) { // We currently don't support items with both icons and checkboxes. DCHECK(type != ui::MenuModel::TYPE_CHECK); diff --git a/ui/views/controls/message_box_view.cc b/ui/views/controls/message_box_view.cc index a0a2bf6..23151f1 100644 --- a/ui/views/controls/message_box_view.cc +++ b/ui/views/controls/message_box_view.cc @@ -91,7 +91,7 @@ bool MessageBoxView::IsCheckBoxSelected() { return checkbox_ ? checkbox_->checked() : false; } -void MessageBoxView::SetIcon(const SkBitmap& icon) { +void MessageBoxView::SetIcon(const gfx::ImageSkia& icon) { if (!icon_) icon_ = new ImageView(); icon_->SetImage(icon); diff --git a/ui/views/controls/message_box_view.h b/ui/views/controls/message_box_view.h index 7fa2f07..c492155 100644 --- a/ui/views/controls/message_box_view.h +++ b/ui/views/controls/message_box_view.h @@ -11,6 +11,10 @@ #include "base/string16.h" #include "ui/views/view.h" +namespace gfx { +class ImageSkia; +} + namespace views { class Checkbox; @@ -62,7 +66,7 @@ class VIEWS_EXPORT MessageBoxView : public View { // Adds |icon| to the upper left of the message box or replaces the current // icon. To start out, the message box has no icon. - void SetIcon(const SkBitmap& icon); + void SetIcon(const gfx::ImageSkia& icon); // Adds a checkbox with the specified label to the message box if this is the // first call. Otherwise, it changes the label of the current checkbox. To diff --git a/ui/views/controls/scrollbar/bitmap_scroll_bar.cc b/ui/views/controls/scrollbar/bitmap_scroll_bar.cc index aa614ea..6caaac0 100644 --- a/ui/views/controls/scrollbar/bitmap_scroll_bar.cc +++ b/ui/views/controls/scrollbar/bitmap_scroll_bar.cc @@ -13,10 +13,10 @@ #include "base/utf_string_conversions.h" #include "build/build_config.h" #include "grit/ui_strings.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/keycodes/keyboard_codes.h" #include "ui/base/l10n/l10n_util.h" #include "ui/gfx/canvas.h" +#include "ui/gfx/image/image_skia.h" #include "ui/views/controls/menu/menu.h" #include "ui/views/controls/scroll_view.h" #include "ui/views/controls/scrollbar/base_scroll_bar_thumb.h" @@ -109,50 +109,50 @@ class BitmapScrollBarThumb : public BaseScrollBarThumb { // View overrides: virtual gfx::Size GetPreferredSize() OVERRIDE { - return gfx::Size(background_bitmap()->width(), - start_cap_bitmap()->height() + - end_cap_bitmap()->height() + - grippy_bitmap()->height()); + return gfx::Size(background_image()->width(), + start_cap_image()->height() + + end_cap_image()->height() + + grippy_image()->height()); } protected: // View overrides: virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { - canvas->DrawBitmapInt(*start_cap_bitmap(), 0, 0); - int top_cap_height = start_cap_bitmap()->height(); - int bottom_cap_height = end_cap_bitmap()->height(); + canvas->DrawBitmapInt(*start_cap_image(), 0, 0); + int top_cap_height = start_cap_image()->height(); + int bottom_cap_height = end_cap_image()->height(); int thumb_body_height = height() - top_cap_height - bottom_cap_height; - canvas->TileImageInt(*background_bitmap(), 0, top_cap_height, - background_bitmap()->width(), thumb_body_height); - canvas->DrawBitmapInt(*end_cap_bitmap(), 0, + canvas->TileImageInt(*background_image(), 0, top_cap_height, + background_image()->width(), thumb_body_height); + canvas->DrawBitmapInt(*end_cap_image(), 0, height() - bottom_cap_height); // Paint the grippy over the track. - int grippy_x = (width() - grippy_bitmap()->width()) / 2; - int grippy_y = (thumb_body_height - grippy_bitmap()->height()) / 2; - canvas->DrawBitmapInt(*grippy_bitmap(), grippy_x, grippy_y); + int grippy_x = (width() - grippy_image()->width()) / 2; + int grippy_y = (thumb_body_height - grippy_image()->height()) / 2; + canvas->DrawBitmapInt(*grippy_image(), grippy_x, grippy_y); } private: // Returns the image rendered at the start of the thumb. - gfx::ImageSkia* start_cap_bitmap() const { + gfx::ImageSkia* start_cap_image() const { return scroll_bar_->images_[BitmapScrollBar::THUMB_START_CAP][GetState()]; } // Returns the image rendered at the end of the thumb. - gfx::ImageSkia* end_cap_bitmap() const { + gfx::ImageSkia* end_cap_image() const { return scroll_bar_->images_[BitmapScrollBar::THUMB_END_CAP][GetState()]; } // Returns the image that is tiled in the background of the thumb between // the start and the end caps. - gfx::ImageSkia* background_bitmap() const { + gfx::ImageSkia* background_image() const { return scroll_bar_->images_[BitmapScrollBar::THUMB_MIDDLE][GetState()]; } // Returns the image that is rendered in the middle of the thumb - // transparently over the background bitmap. - gfx::ImageSkia* grippy_bitmap() const { + // transparently over the background image. + gfx::ImageSkia* grippy_image() const { return scroll_bar_->images_[BitmapScrollBar::THUMB_GRIPPY] [CustomButton::BS_NORMAL]; } @@ -265,7 +265,7 @@ void BitmapScrollBar::Layout() { // Preserve the height/width of the thumb (depending on orientation) as set // by the last call to |Update|, but coerce the width/height to be the - // appropriate value for the bitmaps provided. + // appropriate value for the images provided. if (IsHorizontal()) { thumb->SetBounds(thumb->x(), thumb->y(), thumb->width(), thumb_prefsize.height()); diff --git a/ui/views/controls/scrollbar/bitmap_scroll_bar.h b/ui/views/controls/scrollbar/bitmap_scroll_bar.h index 3c6a1b4..10fd6d1 100644 --- a/ui/views/controls/scrollbar/bitmap_scroll_bar.h +++ b/ui/views/controls/scrollbar/bitmap_scroll_bar.h @@ -18,8 +18,8 @@ class BitmapScrollBarThumb; // // BitmapScrollBar // -// A ScrollBar subclass that implements a scroll bar rendered using bitmaps -// that the user provides. There are bitmaps for the up and down buttons, as +// A ScrollBar subclass that implements a scroll bar rendered using images +// that the user provides. There are images for the up and down buttons, as // well as for the thumb and track. This is intended for creating UIs that // have customized, non-native appearances, like floating HUDs etc. // @@ -30,7 +30,7 @@ class VIEWS_EXPORT BitmapScrollBar : public BaseScrollBar, BitmapScrollBar(bool horizontal, bool show_scroll_buttons); virtual ~BitmapScrollBar() { } - // A list of parts that the user may supply bitmaps for. + // A list of parts that the user may supply images for. enum ScrollBarPart { // The button used to represent scrolling up/left by 1 line. PREV_BUTTON = 0, diff --git a/ui/views/controls/scrollbar/scroll_bar.h b/ui/views/controls/scrollbar/scroll_bar.h index 52bbb17..b34f4ed 100644 --- a/ui/views/controls/scrollbar/scroll_bar.h +++ b/ui/views/controls/scrollbar/scroll_bar.h @@ -91,7 +91,7 @@ class VIEWS_EXPORT ScrollBar : public View { protected: // Create new scrollbar, either horizontal or vertical. These are protected // since you need to be creating either a NativeScrollBar or a - // BitmapScrollBar. + // ImageScrollBar. explicit ScrollBar(bool is_horiz); private: diff --git a/ui/views/controls/table/table_view_views.cc b/ui/views/controls/table/table_view_views.cc index 365f81ba..bc27412 100644 --- a/ui/views/controls/table/table_view_views.cc +++ b/ui/views/controls/table/table_view_views.cc @@ -5,10 +5,10 @@ #include "ui/views/controls/table/table_view_views.h" #include "base/i18n/rtl.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/models/table_model.h" -#include "ui/gfx/canvas.h" #include "ui/base/native_theme/native_theme.h" +#include "ui/gfx/canvas.h" +#include "ui/gfx/image/image_skia.h" #include "ui/gfx/skia_util.h" #include "ui/views/border.h" #include "ui/views/controls/scroll_view.h" @@ -249,7 +249,7 @@ void TableView::OnPaint(gfx::Canvas* canvas) { } int text_x = kTextHorizontalPadding; if (table_type_ == ICON_AND_TEXT) { - SkBitmap image = model_->GetIcon(i); + gfx::ImageSkia image = model_->GetIcon(i); if (!image.isNull()) { int image_x = GetMirroredXWithWidthInView(text_x, image.width()); canvas->DrawBitmapInt( diff --git a/ui/views/controls/table/table_view_win.cc b/ui/views/controls/table/table_view_win.cc index 3a1be57..42a266a 100644 --- a/ui/views/controls/table/table_view_win.cc +++ b/ui/views/controls/table/table_view_win.cc @@ -13,7 +13,7 @@ #include "base/string_util.h" #include "base/win/scoped_gdi_object.h" #include "skia/ext/skia_utils_win.h" -#include "third_party/skia/include/core/SkBitmap.h" +#include "ui/gfx/image/image_skia.h" #include "third_party/skia/include/core/SkColorFilter.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util_win.h" @@ -24,6 +24,7 @@ #include "ui/gfx/favicon_size.h" #include "ui/gfx/font.h" #include "ui/gfx/icon_util.h" +#include "ui/gfx/image/image_skia.h" #include "ui/views/controls/native/native_view_host.h" #include "ui/views/controls/table/table_view_observer.h" @@ -1225,7 +1226,7 @@ LRESULT TableView::OnCustomDraw(NMLVCUSTOMDRAW* draw_info) { LRESULT r = CDRF_DODEFAULT; // First let's take care of painting the right icon. if (table_type_ == ICON_AND_TEXT) { - SkBitmap image = model_->GetIcon(model_index); + gfx::ImageSkia image = model_->GetIcon(model_index); if (!image.isNull()) { // Get the rect that holds the icon. RECT icon_rect, client_rect; diff --git a/ui/views/controls/textfield/native_textfield_views_unittest.cc b/ui/views/controls/textfield/native_textfield_views_unittest.cc index 2d557cc..2849617 100644 --- a/ui/views/controls/textfield/native_textfield_views_unittest.cc +++ b/ui/views/controls/textfield/native_textfield_views_unittest.cc @@ -866,7 +866,7 @@ TEST_F(NativeTextfieldViewsTest, DragAndDrop_AcceptDrop) { bad_data.SetFilename(FilePath(FILE_PATH_LITERAL("x"))); #if defined(OS_WIN) #if defined(USE_AURA) - ui::OSExchangeData::CustomFormat fmt = ui::Clipboard::GetBitmapFormatType(); + ui::OSExchangeData::CustomFormat fmt = ui::Clipboard::GetImageFormatType(); #else ui::OSExchangeData::CustomFormat fmt = CF_BITMAP; #endif diff --git a/ui/views/controls/throbber.cc b/ui/views/controls/throbber.cc index 8fe55ff..d9feb14 100644 --- a/ui/views/controls/throbber.cc +++ b/ui/views/controls/throbber.cc @@ -6,7 +6,7 @@ #include "base/time.h" #include "grit/ui_resources.h" -#include "third_party/skia/include/core/SkBitmap.h" +#include "ui/gfx/image/image_skia.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas.h" #include "ui/gfx/image/image.h" @@ -23,7 +23,7 @@ Throbber::Throbber(int frame_time_ms, frames_(NULL), frame_time_(TimeDelta::FromMilliseconds(frame_time_ms)) { SetFrames(ui::ResourceBundle::GetSharedInstance().GetImageNamed( - IDR_THROBBER).ToSkBitmap()); + IDR_THROBBER).ToImageSkia()); } Throbber::~Throbber() { @@ -54,7 +54,7 @@ void Throbber::Stop() { SchedulePaint(); // Important if we're not painting while stopped } -void Throbber::SetFrames(const SkBitmap* frames) { +void Throbber::SetFrames(const gfx::ImageSkia* frames) { frames_ = frames; DCHECK(frames_->width() > 0 && frames_->height() > 0); DCHECK(frames_->width() % frames_->height() == 0); @@ -140,7 +140,7 @@ CheckmarkThrobber::CheckmarkThrobber() : Throbber(kFrameTimeMs, false), checked_(false), checkmark_(ui::ResourceBundle::GetSharedInstance().GetImageNamed( - IDR_CHECKMARK).ToSkBitmap()) { + IDR_CHECKMARK).ToImageSkia()) { } void CheckmarkThrobber::SetChecked(bool checked) { diff --git a/ui/views/controls/throbber.h b/ui/views/controls/throbber.h index aeb1d9b..7fa6ea8 100644 --- a/ui/views/controls/throbber.h +++ b/ui/views/controls/throbber.h @@ -12,7 +12,9 @@ #include "base/timer.h" #include "ui/views/view.h" -class SkBitmap; +namespace gfx { +class ImageSkia; +} namespace views { @@ -25,7 +27,7 @@ class VIEWS_EXPORT Throbber : public View { // If |paint_while_stopped| is false, this view will be invisible when not // running. Throbber(int frame_time_ms, bool paint_while_stopped); - Throbber(int frame_time_ms, bool paint_while_stopped, SkBitmap* frames); + Throbber(int frame_time_ms, bool paint_while_stopped, gfx::ImageSkia* frames); virtual ~Throbber(); // Start and stop the throbber animation @@ -33,7 +35,7 @@ class VIEWS_EXPORT Throbber : public View { virtual void Stop(); // Set custom throbber frames. Otherwise IDR_THROBBER is loaded. - void SetFrames(const SkBitmap* frames); + void SetFrames(const gfx::ImageSkia* frames); // Overridden from View: virtual gfx::Size GetPreferredSize() OVERRIDE; @@ -49,7 +51,7 @@ class VIEWS_EXPORT Throbber : public View { bool paint_while_stopped_; int frame_count_; // How many frames we have. base::Time start_time_; // Time when Start was called. - const SkBitmap* frames_; // Frames bitmaps. + const gfx::ImageSkia* frames_; // Frames images. base::TimeDelta frame_time_; // How long one frame is displayed. base::RepeatingTimer<Throbber> timer_; // Used to schedule Run calls. @@ -63,7 +65,7 @@ class VIEWS_EXPORT Throbber : public View { class VIEWS_EXPORT SmoothedThrobber : public Throbber { public: explicit SmoothedThrobber(int frame_delay_ms); - SmoothedThrobber(int frame_delay_ms, SkBitmap* frames); + SmoothedThrobber(int frame_delay_ms, gfx::ImageSkia* frames); virtual ~SmoothedThrobber(); virtual void Start() OVERRIDE; @@ -116,7 +118,7 @@ class VIEWS_EXPORT CheckmarkThrobber : public Throbber { bool checked_; // The checkmark image. - const SkBitmap* checkmark_; + const gfx::ImageSkia* checkmark_; DISALLOW_COPY_AND_ASSIGN(CheckmarkThrobber); }; diff --git a/ui/views/controls/tree/tree_view_views.cc b/ui/views/controls/tree/tree_view_views.cc index 524b763..20634e9 100644 --- a/ui/views/controls/tree/tree_view_views.cc +++ b/ui/views/controls/tree/tree_view_views.cc @@ -60,10 +60,10 @@ TreeView::TreeView() set_background(Background::CreateSolidBackground(SK_ColorWHITE)); closed_icon_ = *ui::ResourceBundle::GetSharedInstance().GetImageNamed( (base::i18n::IsRTL() ? IDR_FOLDER_CLOSED_RTL - : IDR_FOLDER_CLOSED)).ToSkBitmap(); + : IDR_FOLDER_CLOSED)).ToImageSkia(); open_icon_ = *ui::ResourceBundle::GetSharedInstance().GetImageNamed( (base::i18n::IsRTL() ? IDR_FOLDER_OPEN_RTL - : IDR_FOLDER_OPEN)).ToSkBitmap(); + : IDR_FOLDER_OPEN)).ToImageSkia(); text_offset_ = closed_icon_.width() + kImagePadding + kImagePadding + kArrowRegionSize; } @@ -639,7 +639,7 @@ void TreeView::PaintRow(gfx::Canvas* canvas, PaintExpandControl(canvas, bounds, node->is_expanded()); // Paint the icon. - SkBitmap icon; + gfx::ImageSkia icon; int icon_index = model_->GetIconIndex(node->model_node()); if (icon_index != -1) icon = icons_[icon_index]; diff --git a/ui/views/controls/tree/tree_view_views.h b/ui/views/controls/tree/tree_view_views.h index f2ec5ce..4eb6368 100644 --- a/ui/views/controls/tree/tree_view_views.h +++ b/ui/views/controls/tree/tree_view_views.h @@ -10,9 +10,9 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/models/tree_node_model.h" #include "ui/gfx/font.h" +#include "ui/gfx/image/image_skia.h" #include "ui/views/controls/textfield/textfield_controller.h" #include "ui/views/focus/focus_manager.h" #include "ui/views/view.h" @@ -311,11 +311,11 @@ class VIEWS_EXPORT TreeView : public View, ui::TreeModel* model_; // Default icons for closed/open. - SkBitmap closed_icon_; - SkBitmap open_icon_; + gfx::ImageSkia closed_icon_; + gfx::ImageSkia open_icon_; // Icons from the model. - std::vector<SkBitmap> icons_; + std::vector<gfx::ImageSkia> icons_; // The root node. InternalNode root_; diff --git a/ui/views/controls/tree/tree_view_win.cc b/ui/views/controls/tree/tree_view_win.cc index a878432..3f982fc 100644 --- a/ui/views/controls/tree/tree_view_win.cc +++ b/ui/views/controls/tree/tree_view_win.cc @@ -657,16 +657,16 @@ TreeView::NodeDetails* TreeView::GetNodeDetailsByTreeItem(HTREEITEM tree_item) { } HIMAGELIST TreeView::CreateImageList() { - std::vector<SkBitmap> model_images; + std::vector<gfx::ImageSkia> model_images; model_->GetIcons(&model_images); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); bool rtl = base::i18n::IsRTL(); // Creates the default image list used for trees. - const SkBitmap* closed_icon = rb.GetImageNamed( - (rtl ? IDR_FOLDER_CLOSED_RTL : IDR_FOLDER_CLOSED)).ToSkBitmap(); - const SkBitmap* opened_icon = rb.GetImageNamed( - (rtl ? IDR_FOLDER_OPEN_RTL : IDR_FOLDER_OPEN)).ToSkBitmap(); + const gfx::ImageSkia* closed_icon = rb.GetImageNamed( + (rtl ? IDR_FOLDER_CLOSED_RTL : IDR_FOLDER_CLOSED)).ToImageSkia(); + const gfx::ImageSkia* opened_icon = rb.GetImageNamed( + (rtl ? IDR_FOLDER_OPEN_RTL : IDR_FOLDER_OPEN)).ToImageSkia(); int width = closed_icon->width(); int height = closed_icon->height(); DCHECK(opened_icon->width() == width && opened_icon->height() == height); diff --git a/ui/views/examples/button_example.cc b/ui/views/examples/button_example.cc index 21dfc20..dca7c8f 100644 --- a/ui/views/examples/button_example.cc +++ b/ui/views/examples/button_example.cc @@ -29,7 +29,7 @@ ButtonExample::ButtonExample() icon_(NULL), count_(0) { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - icon_ = rb.GetImageNamed(IDR_CLOSE_SA_H).ToSkBitmap(); + icon_ = rb.GetImageNamed(IDR_CLOSE_SA_H).ToImageSkia(); } ButtonExample::~ButtonExample() { @@ -50,7 +50,8 @@ void ButtonExample::CreateExampleView(View* container) { rb.GetImageNamed(IDR_CLOSE_H).ToImageSkia()); image_button_->SetImage(ImageButton::BS_PUSHED, rb.GetImageNamed(IDR_CLOSE_P).ToImageSkia()); - image_button_->SetOverlayImage(rb.GetImageNamed(IDR_MENU_CHECK).ToSkBitmap()); + image_button_->SetOverlayImage(rb.GetImageNamed( + IDR_MENU_CHECK).ToImageSkia()); container->AddChildView(image_button_); } @@ -80,7 +81,7 @@ void ButtonExample::ButtonPressed(Button* sender, const Event& event) { } } else if (event.IsAltDown()) { if (text_button_->HasIcon()) - text_button_->SetIcon(SkBitmap()); + text_button_->SetIcon(gfx::ImageSkia()); else text_button_->SetIcon(*icon_); } else { diff --git a/ui/views/examples/button_example.h b/ui/views/examples/button_example.h index da0970c..55f4685 100644 --- a/ui/views/examples/button_example.h +++ b/ui/views/examples/button_example.h @@ -38,7 +38,7 @@ class ButtonExample : public ExampleBase, public ButtonListener { // Values used to modify the look and feel of the button. TextButton::TextAlignment alignment_; bool use_native_theme_border_; - const SkBitmap* icon_; + const gfx::ImageSkia* icon_; // The number of times the buttons are pressed. int count_; diff --git a/ui/views/examples/table_example.cc b/ui/views/examples/table_example.cc index f0595c8..51ab1d3 100644 --- a/ui/views/examples/table_example.cc +++ b/ui/views/examples/table_example.cc @@ -8,7 +8,9 @@ #include "base/string_util.h" #include "base/utf_string_conversions.h" +#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkCanvas.h" +#include "ui/gfx/image/image_skia.h" #include "ui/views/controls/button/checkbox.h" #include "ui/views/layout/grid_layout.h" @@ -111,7 +113,7 @@ string16 TableExample::GetText(int row, int column_id) { return ASCIIToUTF16(cells[row % 5][column_id]); } -SkBitmap TableExample::GetIcon(int row) { +gfx::ImageSkia TableExample::GetIcon(int row) { return row % 2 ? icon1_ : icon2_; } diff --git a/ui/views/examples/table_example.h b/ui/views/examples/table_example.h index 45a98ad..33f1cde 100644 --- a/ui/views/examples/table_example.h +++ b/ui/views/examples/table_example.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,6 +17,10 @@ #include "ui/views/controls/table/table_view_observer.h" #include "ui/views/examples/example_base.h" +namespace gfx { +class ImageSkia; +} + namespace views { class Checkbox; class Event; @@ -38,7 +42,7 @@ class TableExample : public ExampleBase, // ui::TableModel: virtual int RowCount() OVERRIDE; virtual string16 GetText(int row, int column_id) OVERRIDE; - virtual SkBitmap GetIcon(int row) OVERRIDE; + virtual gfx::ImageSkia GetIcon(int row) OVERRIDE; virtual void SetObserver(ui::TableModelObserver* observer) OVERRIDE; // TableViewObserver: diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc index 2e32f63..f78e06f 100644 --- a/ui/views/view_unittest.cc +++ b/ui/views/view_unittest.cc @@ -1367,7 +1367,7 @@ class MockMenuModel : public ui::MenuModel { ui::Accelerator* accelerator)); MOCK_CONST_METHOD1(IsItemCheckedAt, bool(int index)); MOCK_CONST_METHOD1(GetGroupIdAt, int(int index)); - MOCK_METHOD2(GetIconAt, bool(int index, SkBitmap* icon)); + MOCK_METHOD2(GetIconAt, bool(int index, gfx::ImageSkia* icon)); MOCK_CONST_METHOD1(GetButtonMenuItemAt, ui::ButtonMenuItemModel*(int index)); MOCK_CONST_METHOD1(IsEnabledAt, bool(int index)); MOCK_CONST_METHOD1(IsVisibleAt, bool(int index)); |
