diff options
author | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-11 01:30:23 +0000 |
---|---|---|
committer | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-11 01:30:23 +0000 |
commit | 353c5f9f197f27c17dcbb39cb1be798d35196e6d (patch) | |
tree | f2b2d1e1ea1b9907d4b7490e85bebdeeaa283ba0 /ui | |
parent | f4e5a1273c901d0d74edf6ece0afd06bf703d443 (diff) | |
download | chromium_src-353c5f9f197f27c17dcbb39cb1be798d35196e6d.zip chromium_src-353c5f9f197f27c17dcbb39cb1be798d35196e6d.tar.gz chromium_src-353c5f9f197f27c17dcbb39cb1be798d35196e6d.tar.bz2 |
Get rid of implicit conversion to and from ImageSkiaRep
Bug=None
Test=Compiles
R=ben,oshima
TBR=sadrul
Review URL: https://chromiumcodereview.appspot.com/10696130
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146022 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/gfx/image/image_skia.cc | 16 | ||||
-rw-r--r-- | ui/gfx/image/image_skia.h | 7 | ||||
-rw-r--r-- | ui/gfx/image/image_skia_rep.cc | 15 | ||||
-rw-r--r-- | ui/gfx/image/image_skia_rep.h | 10 | ||||
-rw-r--r-- | ui/views/controls/menu/menu_win.cc | 4 | ||||
-rw-r--r-- | ui/views/controls/menu/native_menu_win.cc | 3 |
6 files changed, 7 insertions, 48 deletions
diff --git a/ui/gfx/image/image_skia.cc b/ui/gfx/image/image_skia.cc index 3d8acf1..9472cda 100644 --- a/ui/gfx/image/image_skia.cc +++ b/ui/gfx/image/image_skia.cc @@ -141,7 +141,7 @@ ImageSkia::ImageSkia(ImageSkiaSource* source, const gfx::Size& size) } ImageSkia::ImageSkia(const SkBitmap& bitmap) { - Init(ImageSkiaRep(bitmap)); + Init(ImageSkiaRep(bitmap, ui::SCALE_FACTOR_100P)); } ImageSkia::ImageSkia(const ImageSkiaRep& image_rep) { @@ -157,12 +157,7 @@ ImageSkia& ImageSkia::operator=(const ImageSkia& other) { } ImageSkia& ImageSkia::operator=(const SkBitmap& other) { - Init(ImageSkiaRep(other)); - return *this; -} - -ImageSkia& ImageSkia::operator=(const ImageSkiaRep& other) { - Init(other); + Init(ImageSkiaRep(other, ui::SCALE_FACTOR_100P)); return *this; } @@ -173,13 +168,6 @@ ImageSkia::operator SkBitmap&() const { return const_cast<SkBitmap&>(storage_->image_reps()[0].sk_bitmap()); } -ImageSkia::operator ImageSkiaRep&() const { - if (isNull()) - return NullImageRep(); - - return storage_->image_reps()[0]; -} - ImageSkia::~ImageSkia() { } diff --git a/ui/gfx/image/image_skia.h b/ui/gfx/image/image_skia.h index d872a15..9bcd1b4 100644 --- a/ui/gfx/image/image_skia.h +++ b/ui/gfx/image/image_skia.h @@ -61,17 +61,10 @@ class UI_EXPORT ImageSkia { // done. ImageSkia& operator=(const SkBitmap& other); - // Converts from gfx::ImageSkiaRep. - // Adds ref to passed in image rep. - // TODO(pkotwicz): This is temporary till conversion to gfx::ImageSkia is - // done. - ImageSkia& operator=(const gfx::ImageSkiaRep& other); - // Converts to gfx::ImageSkiaRep and SkBitmap. // TODO(pkotwicz): This is temporary till conversion to gfx::ImageSkia is // done. operator SkBitmap&() const; - operator gfx::ImageSkiaRep&() const; ~ImageSkia(); diff --git a/ui/gfx/image/image_skia_rep.cc b/ui/gfx/image/image_skia_rep.cc index be0331a..c4c0d9c 100644 --- a/ui/gfx/image/image_skia_rep.cc +++ b/ui/gfx/image/image_skia_rep.cc @@ -25,27 +25,12 @@ ImageSkiaRep::ImageSkiaRep(const gfx::Size& size, bitmap_.allocPixels(); } -ImageSkiaRep::ImageSkiaRep(const SkBitmap& src) - : bitmap_(src), - scale_factor_(ui::SCALE_FACTOR_NONE) { -} - ImageSkiaRep::ImageSkiaRep(const SkBitmap& src, ui::ScaleFactor scale_factor) : bitmap_(src), scale_factor_(scale_factor) { } -ImageSkiaRep& ImageSkiaRep::operator=(const SkBitmap& other) { - bitmap_ = other; - scale_factor_ = ui::SCALE_FACTOR_NONE; - return *this; -} - -ImageSkiaRep::operator SkBitmap&() const { - return const_cast<SkBitmap&>(bitmap_); -} - int ImageSkiaRep::GetWidth() const { return static_cast<int>(bitmap_.width() / ui::GetScaleFactorScale(scale_factor_)); diff --git a/ui/gfx/image/image_skia_rep.h b/ui/gfx/image/image_skia_rep.h index 84904b7..c7a689c 100644 --- a/ui/gfx/image/image_skia_rep.h +++ b/ui/gfx/image/image_skia_rep.h @@ -24,20 +24,10 @@ class UI_EXPORT ImageSkiaRep { // This allocates pixels in the bitmap. ImageSkiaRep(const gfx::Size& size, ui::ScaleFactor scale_factor); - // Creates a bitmap with a default scale factor of 1x. - // Adds ref to |src|. - // TODO(pkotwicz): This is temporary and should be removed ASAP. - ImageSkiaRep(const SkBitmap& src); - // Creates a bitmap with given scale factor. // Adds ref to |src|. ImageSkiaRep(const SkBitmap& src, ui::ScaleFactor scale_factor); - // Converts to and from SkBitmap. - // TODO(pkotwicz): This is temporary and should be removed ASAP. - ImageSkiaRep& operator=(const SkBitmap& other); - operator SkBitmap&() const; - // Returns true if the backing bitmap is null. bool is_null() const { return bitmap_.isNull(); } diff --git a/ui/views/controls/menu/menu_win.cc b/ui/views/controls/menu/menu_win.cc index 736a7ed..b473d5c 100644 --- a/ui/views/controls/menu/menu_win.cc +++ b/ui/views/controls/menu/menu_win.cc @@ -183,8 +183,10 @@ class MenuHostWindow : public ui::WindowImpl { // Draw the icon after the label, otherwise it would be covered // by the label. + gfx::ImageSkiaRep icon_image_rep = + data->icon.GetRepresentation(ui::SCALE_FACTOR_100P); if (data->icon.width() != 0 && data->icon.height() != 0) { - gfx::Canvas canvas(data->icon, false); + gfx::Canvas canvas(icon_image_rep, false); skia::DrawToNativeContext( canvas.sk_canvas(), hDC, lpdis->rcItem.left + kItemLeftMargin, lpdis->rcItem.top + (lpdis->rcItem.bottom - lpdis->rcItem.top - diff --git a/ui/views/controls/menu/native_menu_win.cc b/ui/views/controls/menu/native_menu_win.cc index c11406e..c04a2bd 100644 --- a/ui/views/controls/menu/native_menu_win.cc +++ b/ui/views/controls/menu/native_menu_win.cc @@ -256,7 +256,8 @@ class NativeMenuWin::MenuHostWindow { 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); - gfx::Canvas canvas(icon, false); + gfx::Canvas canvas(icon.GetRepresentation(ui::SCALE_FACTOR_100P), + false); skia::DrawToNativeContext( canvas.sk_canvas(), dc, draw_item_struct->rcItem.left + kItemLeftMargin, |