diff options
author | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-14 20:22:01 +0000 |
---|---|---|
committer | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-14 20:22:01 +0000 |
commit | 6c158192e64a230aa18f2ba4dd647d5b1a5a8b1d (patch) | |
tree | 34957fa50c8682e7e2bec16321ff34a2c6aa16aa /ui | |
parent | fe7d500a0d9a42d358f5f1ca24d4770d9bb3b6cd (diff) | |
download | chromium_src-6c158192e64a230aa18f2ba4dd647d5b1a5a8b1d.zip chromium_src-6c158192e64a230aa18f2ba4dd647d5b1a5a8b1d.tar.gz chromium_src-6c158192e64a230aa18f2ba4dd647d5b1a5a8b1d.tar.bz2 |
Change SetImage, SetBackground, and SetToggledImage to take in a gfx::ImageSkia
The files were changed using the following sed script
1 :top
2 /SetImage/ {
3 s|ToSkBitmap|ToImageSkia|g
4 s|GetBitmapNamed|GetImageSkiaNamed|g
5 n
6 N
7 s|ToSkBitmap|ToImageSkia|g
8 s|GetBitmapNamed|GetImageSkiaNamed|g
9 b top
10 }
11 /SetBackground/ {
12 s|ToSkBitmap|ToImageSkia|g
13 s|GetBitmapNamed|GetImageSkiaNamed|g
14 n
15 N
16 s|ToSkBitmap|ToImageSkia|g
17 s|GetBitmapNamed|GetImageSkiaNamed|g
18 b top
19 }
20 /SetToggledImage/ {
21 s|ToSkBitmap|ToImageSkia|g
22 s|GetBitmapNamed|GetImageSkiaNamed|g
23 n
24 N
25 s|ToSkBitmap|ToImageSkia|g
26 s|GetBitmapNamed|GetImageSkiaNamed|g
27 b top
28 }
The following files were modified by hand afterwards:
1 ash/launcher/launcher_button.cc
2 ash/system/audio/tray_volume.cc
3 ash/system/drive/tray_drive.cc
4 ash/system/tray/system_tray_delegate.h
5 ash/system/tray/tray_item_more.cc
6 ash/system/tray/tray_item_more.h
7 chrome/browser/chromeos/login/take_photo_view.cc
8 chrome/browser/chromeos/login/take_photo_view.h
9 chrome/browser/chromeos/options/network_config_view.cc
10 chrome/browser/chromeos/options/network_config_view.h
11 chrome/browser/ui/panels/panel_browser_frame_view.cc
12 chrome/browser/ui/views/autocomplete/autocomplete_result_view.cc
13 chrome/browser/ui/views/autocomplete/autocomplete_result_view.h
14 chrome/browser/ui/views/avatar_menu_bubble_view.cc
15 chrome/browser/ui/views/chrome_to_mobile_bubble_view.cc
16 chrome/browser/ui/views/confirm_bubble_view.cc
17 chrome/browser/ui/views/download/download_shelf_view.cc
18 chrome/browser/ui/views/download/download_started_animation_views.cc
19 chrome/browser/ui/views/dropdown_bar_view.cc
20 chrome/browser/ui/views/dropdown_bar_view.h
21 chrome/browser/ui/views/find_bar_view.cc
22 chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
23 chrome/browser/ui/views/hung_renderer_view.cc
24 chrome/browser/ui/views/location_bar/page_action_image_view.cc
25 chrome/browser/ui/views/tabs/tab_strip.cc
26 chrome/browser/ui/views/tabs/tab_strip.h
27 ui/views/controls/button/image_button.h
28 ui/views/controls/button/image_button_unittest.cc
29 ui/views/controls/scrollbar/bitmap_scroll_bar.cc
30 ui/views/controls/scrollbar/bitmap_scroll_bar.h
Whitespace changes were made in the following files manually
1 ash/launcher/launcher_view.cc
2 chrome/browser/chromeos/login/simple_web_view_dialog.cc
3 chrome/browser/ui/views/location_bar/chrome_to_mobile_view.cc
4 chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc
5 chrome/browser/ui/views/toolbar_view.cc
Bug=124566
Test=Compiles, try bots pass
Review URL: https://chromiumcodereview.appspot.com/10382144
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136964 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/views/controls/button/image_button.cc | 21 | ||||
-rw-r--r-- | ui/views/controls/button/image_button.h | 12 | ||||
-rw-r--r-- | ui/views/controls/button/image_button_unittest.cc | 4 | ||||
-rw-r--r-- | ui/views/controls/image_view.cc | 6 | ||||
-rw-r--r-- | ui/views/controls/image_view.h | 7 | ||||
-rw-r--r-- | ui/views/controls/scrollbar/bitmap_scroll_bar.cc | 24 | ||||
-rw-r--r-- | ui/views/controls/scrollbar/bitmap_scroll_bar.h | 8 | ||||
-rw-r--r-- | ui/views/examples/button_example.cc | 6 | ||||
-rw-r--r-- | ui/views/window/custom_frame_view.cc | 12 |
9 files changed, 52 insertions, 48 deletions
diff --git a/ui/views/controls/button/image_button.cc b/ui/views/controls/button/image_button.cc index 85c705d..35e4960 100644 --- a/ui/views/controls/button/image_button.cc +++ b/ui/views/controls/button/image_button.cc @@ -31,14 +31,14 @@ ImageButton::ImageButton(ButtonListener* listener) ImageButton::~ImageButton() { } -void ImageButton::SetImage(ButtonState state, const SkBitmap* image) { - images_[state] = image ? *image : SkBitmap(); +void ImageButton::SetImage(ButtonState state, const gfx::ImageSkia* image) { + images_[state] = image ? *image : gfx::ImageSkia(); PreferredSizeChanged(); } void ImageButton::SetBackground(SkColor color, - const SkBitmap* image, - const SkBitmap* mask) { + const gfx::ImageSkia* image, + const gfx::ImageSkia* mask) { if (!image || !mask) { background_image_.reset(); return; @@ -143,13 +143,13 @@ void ToggleImageButton::SetToggled(bool toggled) { } void ToggleImageButton::SetToggledImage(ButtonState state, - const SkBitmap* image) { + const gfx::ImageSkia* image) { if (toggled_) { - images_[state] = image ? *image : SkBitmap(); + images_[state] = image ? *image : gfx::ImageSkia(); if (state_ == state) SchedulePaint(); } else { - alternate_images_[state] = image ? *image : SkBitmap(); + alternate_images_[state] = image ? *image : gfx::ImageSkia(); } } @@ -160,11 +160,12 @@ void ToggleImageButton::SetToggledTooltipText(const string16& tooltip) { //////////////////////////////////////////////////////////////////////////////// // ToggleImageButton, ImageButton overrides: -void ToggleImageButton::SetImage(ButtonState state, const SkBitmap* image) { +void ToggleImageButton::SetImage(ButtonState state, + const gfx::ImageSkia* image) { if (toggled_) { - alternate_images_[state] = image ? *image : SkBitmap(); + alternate_images_[state] = image ? *image : gfx::ImageSkia(); } else { - images_[state] = image ? *image : SkBitmap(); + images_[state] = image ? *image : gfx::ImageSkia(); if (state_ == state) SchedulePaint(); } diff --git a/ui/views/controls/button/image_button.h b/ui/views/controls/button/image_button.h index ed0c80e..3a54e20 100644 --- a/ui/views/controls/button/image_button.h +++ b/ui/views/controls/button/image_button.h @@ -8,6 +8,7 @@ #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" namespace views { @@ -36,12 +37,12 @@ class VIEWS_EXPORT ImageButton : public CustomButton { virtual ~ImageButton(); // Set the image the button should use for the provided state. - virtual void SetImage(ButtonState state, const SkBitmap* image); + virtual void SetImage(ButtonState state, const gfx::ImageSkia* image); // Set the background details. void SetBackground(SkColor color, - const SkBitmap* image, - const SkBitmap* mask); + const gfx::ImageSkia* image, + const gfx::ImageSkia* mask); // Set an |image| to draw on top of the normal / hot / pushed image. // Pass NULL for no image. @@ -104,13 +105,14 @@ class VIEWS_EXPORT ToggleImageButton : public ImageButton { // Like ImageButton::SetImage(), but to set the graphics used for the // "has been toggled" state. Must be called for each button state // before the button is toggled. - void SetToggledImage(ButtonState state, const SkBitmap* image); + void SetToggledImage(ButtonState state, const gfx::ImageSkia* image); // Set the tooltip text displayed when the button is toggled. void SetToggledTooltipText(const string16& tooltip); // Overridden from ImageButton: - virtual void SetImage(ButtonState state, const SkBitmap* image) OVERRIDE; + virtual void SetImage(ButtonState state, + const gfx::ImageSkia* image) OVERRIDE; // Overridden from View: virtual bool GetTooltipText(const gfx::Point& p, diff --git a/ui/views/controls/button/image_button_unittest.cc b/ui/views/controls/button/image_button_unittest.cc index 9d9a9b1..f9b17c8 100644 --- a/ui/views/controls/button/image_button_unittest.cc +++ b/ui/views/controls/button/image_button_unittest.cc @@ -35,7 +35,7 @@ TEST_F(ImageButtonTest, Basics) { EXPECT_EQ("5x15", button.GetPreferredSize().ToString()); // Set a normal image. - SkBitmap normal_bitmap = CreateTestBitmap(10, 20); + gfx::ImageSkia normal_bitmap = CreateTestBitmap(10, 20); button.SetImage(CustomButton::BS_NORMAL, &normal_bitmap); // Image uses normal image for painting. @@ -47,7 +47,7 @@ TEST_F(ImageButtonTest, Basics) { EXPECT_EQ("10x20", button.GetPreferredSize().ToString()); // Set a pushed image. - SkBitmap pushed_bitmap = CreateTestBitmap(11, 21); + gfx::ImageSkia pushed_bitmap = CreateTestBitmap(11, 21); button.SetImage(CustomButton::BS_PUSHED, &pushed_bitmap); // By convention, preferred size doesn't change, even though pushed image diff --git a/ui/views/controls/image_view.cc b/ui/views/controls/image_view.cc index 64ccf5b..e09603d 100644 --- a/ui/views/controls/image_view.cc +++ b/ui/views/controls/image_view.cc @@ -30,9 +30,9 @@ void ImageView::SetImage(const SkBitmap& bm) { SchedulePaint(); } -void ImageView::SetImage(const SkBitmap* bm) { - if (bm) { - SetImage(*bm); +void ImageView::SetImage(const gfx::ImageSkia* image_skia) { + if (image_skia) { + SetImage(*image_skia); } else { SkBitmap t; SetImage(t); diff --git a/ui/views/controls/image_view.h b/ui/views/controls/image_view.h index 8827d4e..7c90fd8 100644 --- a/ui/views/controls/image_view.h +++ b/ui/views/controls/image_view.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. @@ -7,6 +7,7 @@ #pragma once #include "third_party/skia/include/core/SkBitmap.h" +#include "ui/gfx/image/image_skia.h" #include "ui/views/view.h" namespace gfx { @@ -39,10 +40,10 @@ class VIEWS_EXPORT ImageView : public View { // Set the bitmap that should be displayed. void SetImage(const SkBitmap& bm); - // Set the bitmap that should be displayed from a pointer. Reset the image + // 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. - void SetImage(const SkBitmap* bm); + 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. diff --git a/ui/views/controls/scrollbar/bitmap_scroll_bar.cc b/ui/views/controls/scrollbar/bitmap_scroll_bar.cc index ee2ea4a..aa614ea 100644 --- a/ui/views/controls/scrollbar/bitmap_scroll_bar.cc +++ b/ui/views/controls/scrollbar/bitmap_scroll_bar.cc @@ -134,25 +134,25 @@ class BitmapScrollBarThumb : public BaseScrollBarThumb { } private: - // Returns the bitmap rendered at the start of the thumb. - SkBitmap* start_cap_bitmap() const { + // Returns the image rendered at the start of the thumb. + gfx::ImageSkia* start_cap_bitmap() const { return scroll_bar_->images_[BitmapScrollBar::THUMB_START_CAP][GetState()]; } - // Returns the bitmap rendered at the end of the thumb. - SkBitmap* end_cap_bitmap() const { + // Returns the image rendered at the end of the thumb. + gfx::ImageSkia* end_cap_bitmap() const { return scroll_bar_->images_[BitmapScrollBar::THUMB_END_CAP][GetState()]; } - // Returns the bitmap that is tiled in the background of the thumb between + // Returns the image that is tiled in the background of the thumb between // the start and the end caps. - SkBitmap* background_bitmap() const { + gfx::ImageSkia* background_bitmap() const { return scroll_bar_->images_[BitmapScrollBar::THUMB_MIDDLE][GetState()]; } - // Returns the bitmap that is rendered in the middle of the thumb + // Returns the image that is rendered in the middle of the thumb // transparently over the background bitmap. - SkBitmap* grippy_bitmap() const { + gfx::ImageSkia* grippy_bitmap() const { return scroll_bar_->images_[BitmapScrollBar::THUMB_GRIPPY] [CustomButton::BS_NORMAL]; } @@ -188,22 +188,22 @@ BitmapScrollBar::BitmapScrollBar(bool horizontal, bool show_scroll_buttons) void BitmapScrollBar::SetImage(ScrollBarPart part, CustomButton::ButtonState state, - SkBitmap* bitmap) { + gfx::ImageSkia* image_skia) { DCHECK(part < PART_COUNT); DCHECK(state < CustomButton::BS_COUNT); switch (part) { case PREV_BUTTON: - prev_button_->SetImage(state, bitmap); + prev_button_->SetImage(state, image_skia); break; case NEXT_BUTTON: - next_button_->SetImage(state, bitmap); + next_button_->SetImage(state, image_skia); break; case THUMB_START_CAP: case THUMB_MIDDLE: case THUMB_END_CAP: case THUMB_GRIPPY: case THUMB_TRACK: - images_[part][state] = bitmap; + images_[part][state] = image_skia; break; } } diff --git a/ui/views/controls/scrollbar/bitmap_scroll_bar.h b/ui/views/controls/scrollbar/bitmap_scroll_bar.h index 3f9ccab..3c6a1b4 100644 --- a/ui/views/controls/scrollbar/bitmap_scroll_bar.h +++ b/ui/views/controls/scrollbar/bitmap_scroll_bar.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. @@ -51,10 +51,10 @@ class VIEWS_EXPORT BitmapScrollBar : public BaseScrollBar, PART_COUNT }; - // Sets the bitmap to be rendered for the specified part and state. + // Sets the image to be rendered for the specified part and state. void SetImage(ScrollBarPart part, CustomButton::ButtonState state, - SkBitmap* bitmap); + gfx::ImageSkia* image_skia); gfx::Rect GetTrackBounds() const; @@ -79,7 +79,7 @@ class VIEWS_EXPORT BitmapScrollBar : public BaseScrollBar, // The thumb needs to be able to access the part images. friend BitmapScrollBarThumb; - SkBitmap* images_[PART_COUNT][CustomButton::BS_COUNT]; + gfx::ImageSkia* images_[PART_COUNT][CustomButton::BS_COUNT]; // True if the scroll buttons at each end of the scroll bar should be shown. bool show_scroll_buttons_; diff --git a/ui/views/examples/button_example.cc b/ui/views/examples/button_example.cc index a86ee66..21dfc20 100644 --- a/ui/views/examples/button_example.cc +++ b/ui/views/examples/button_example.cc @@ -45,11 +45,11 @@ void ButtonExample::CreateExampleView(View* container) { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); image_button_ = new ImageButton(this); image_button_->SetImage(ImageButton::BS_NORMAL, - rb.GetImageNamed(IDR_CLOSE).ToSkBitmap()); + rb.GetImageNamed(IDR_CLOSE).ToImageSkia()); image_button_->SetImage(ImageButton::BS_HOT, - rb.GetImageNamed(IDR_CLOSE_H).ToSkBitmap()); + rb.GetImageNamed(IDR_CLOSE_H).ToImageSkia()); image_button_->SetImage(ImageButton::BS_PUSHED, - rb.GetImageNamed(IDR_CLOSE_P).ToSkBitmap()); + rb.GetImageNamed(IDR_CLOSE_P).ToImageSkia()); image_button_->SetOverlayImage(rb.GetImageNamed(IDR_MENU_CHECK).ToSkBitmap()); container->AddChildView(image_button_); } diff --git a/ui/views/window/custom_frame_view.cc b/ui/views/window/custom_frame_view.cc index 33974a3..f4dd9dd 100644 --- a/ui/views/window/custom_frame_view.cc +++ b/ui/views/window/custom_frame_view.cc @@ -490,11 +490,11 @@ void CustomFrameView::LayoutWindowControls() { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); close_button_->SetImage(CustomButton::BS_NORMAL, - rb.GetImageNamed(normal_part).ToSkBitmap()); + rb.GetImageNamed(normal_part).ToImageSkia()); close_button_->SetImage(CustomButton::BS_HOT, - rb.GetImageNamed(hot_part).ToSkBitmap()); + rb.GetImageNamed(hot_part).ToImageSkia()); close_button_->SetImage(CustomButton::BS_PUSHED, - rb.GetImageNamed(pushed_part).ToSkBitmap()); + rb.GetImageNamed(pushed_part).ToImageSkia()); } void CustomFrameView::LayoutTitleBar() { @@ -538,11 +538,11 @@ ImageButton* CustomFrameView::InitWindowCaptionButton( ImageButton* button = new ImageButton(this); button->SetAccessibleName(l10n_util::GetStringUTF16(accessibility_string_id)); button->SetImage(CustomButton::BS_NORMAL, - rb.GetImageNamed(normal_image_id).ToSkBitmap()); + rb.GetImageNamed(normal_image_id).ToImageSkia()); button->SetImage(CustomButton::BS_HOT, - rb.GetImageNamed(hot_image_id).ToSkBitmap()); + rb.GetImageNamed(hot_image_id).ToImageSkia()); button->SetImage(CustomButton::BS_PUSHED, - rb.GetImageNamed(pushed_image_id).ToSkBitmap()); + rb.GetImageNamed(pushed_image_id).ToImageSkia()); AddChildView(button); return button; } |