diff options
author | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-20 21:54:52 +0000 |
---|---|---|
committer | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-20 21:54:52 +0000 |
commit | d24adc83e7de8b042739c96f37588dee5ba091b3 (patch) | |
tree | e82cf26051eb22ce33a61a3f2816c39e6135675f /ash | |
parent | fc28c977a4969a3ff4c4e8dee98fe67ce111ed86 (diff) | |
download | chromium_src-d24adc83e7de8b042739c96f37588dee5ba091b3.zip chromium_src-d24adc83e7de8b042739c96f37588dee5ba091b3.tar.gz chromium_src-d24adc83e7de8b042739c96f37588dee5ba091b3.tar.bz2 |
Revert 224473 "Remove dependency on ui::ScaleFactor from ui/gfx"
> Remove dependency on ui::ScaleFactor from ui/gfx
>
> As part of the work to removed dependencies on ui/base from ui/gfx I have
> changed the public api to Canvas, ImageSkia, ImageSkiaRep and ImagePNGRep
> to take float scale values instead of ui::ScaleFactor.
>
> The notion of supported scale factors has been broken into 2 parts.
> ui::SetSupportedScaleFactors remains and calls the
> new ImageSkia::SetSupportedScales().
>
> The initialization of the supported scale factors has been moved from layout.h
> into ResourceBundle, and is done explicitly in tests that don't use
> ResourceBundle.
>
> BUG=103304
> R=ben@chromium.org, oshima@chromium.org, sky@chromium.org
>
> Review URL: https://codereview.chromium.org/24175004
TBR=davemoore@chromium.org
Review URL: https://codereview.chromium.org/24262008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@224499 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/desktop_background/wallpaper_resizer_unittest.cc | 6 | ||||
-rw-r--r-- | ash/display/mirror_window_controller.cc | 5 | ||||
-rw-r--r-- | ash/drag_drop/drag_drop_controller_unittest.cc | 2 | ||||
-rw-r--r-- | ash/drag_drop/drag_image_view.cc | 8 | ||||
-rw-r--r-- | ash/launcher/launcher_delegate.h | 4 | ||||
-rw-r--r-- | ash/launcher/launcher_item_delegate_manager.cc | 2 | ||||
-rw-r--r-- | ash/shell/app_list.cc | 3 | ||||
-rw-r--r-- | ash/shell/window_watcher.cc | 3 | ||||
-rw-r--r-- | ash/system/chromeos/network/network_icon.cc | 14 | ||||
-rw-r--r-- | ash/wm/frame_painter.cc | 2 |
10 files changed, 28 insertions, 21 deletions
diff --git a/ash/desktop_background/wallpaper_resizer_unittest.cc b/ash/desktop_background/wallpaper_resizer_unittest.cc index 8447307..5761b67 100644 --- a/ash/desktop_background/wallpaper_resizer_unittest.cc +++ b/ash/desktop_background/wallpaper_resizer_unittest.cc @@ -104,14 +104,16 @@ TEST_F(WallpaperResizerTest, BasicResize) { for (int i = 0; i < length; i++) { WallpaperLayout layout = layouts[i]; - gfx::ImageSkia small_image(gfx::ImageSkiaRep(gfx::Size(10, 20), 1.0f)); + gfx::ImageSkia small_image(gfx::ImageSkiaRep(gfx::Size(10, 20), + ui::SCALE_FACTOR_100P)); gfx::ImageSkia resized_small = Resize(small_image, gfx::Size(800, 600), layout); EXPECT_EQ(10, resized_small.width()); EXPECT_EQ(20, resized_small.height()); - gfx::ImageSkia large_image(gfx::ImageSkiaRep(gfx::Size(1000, 1000), 1.0f)); + gfx::ImageSkia large_image(gfx::ImageSkiaRep(gfx::Size(1000, 1000), + ui::SCALE_FACTOR_100P)); gfx::ImageSkia resized_large = Resize(large_image, gfx::Size(800, 600), layout); EXPECT_EQ(800, resized_large.width()); diff --git a/ash/display/mirror_window_controller.cc b/ash/display/mirror_window_controller.cc index d7cd6f0..2de135a 100644 --- a/ash/display/mirror_window_controller.cc +++ b/ash/display/mirror_window_controller.cc @@ -127,8 +127,10 @@ class CursorWindowDelegate : public aura::WindowDelegate { // take 2x's image and paint as if it's 1x image. void SetCursorImage(const gfx::ImageSkia& image, const gfx::Display& display) { + device_scale_factor_ = + ui::GetScaleFactorFromScale(display.device_scale_factor()); const gfx::ImageSkiaRep& image_rep = - image.GetRepresentation(display.device_scale_factor()); + image.GetRepresentation(device_scale_factor_); size_ = image_rep.pixel_size(); cursor_image_ = gfx::ImageSkia::CreateFrom1xBitmap(image_rep.sk_bitmap()); } @@ -137,6 +139,7 @@ class CursorWindowDelegate : public aura::WindowDelegate { private: gfx::ImageSkia cursor_image_; + ui::ScaleFactor device_scale_factor_; gfx::Size size_; DISALLOW_COPY_AND_ASSIGN(CursorWindowDelegate); diff --git a/ash/drag_drop/drag_drop_controller_unittest.cc b/ash/drag_drop/drag_drop_controller_unittest.cc index 0cd770e..ba46192 100644 --- a/ash/drag_drop/drag_drop_controller_unittest.cc +++ b/ash/drag_drop/drag_drop_controller_unittest.cc @@ -77,7 +77,7 @@ class DragTestView : public views::View { virtual void WriteDragData(const gfx::Point& p, OSExchangeData* data) OVERRIDE { data->SetString(UTF8ToUTF16("I am being dragged")); - gfx::ImageSkiaRep image_rep(gfx::Size(10, 20), 1.0f); + gfx::ImageSkiaRep image_rep(gfx::Size(10, 20), ui::SCALE_FACTOR_100P); gfx::ImageSkia image_skia(image_rep); drag_utils::SetDragImageOnDataObject( diff --git a/ash/drag_drop/drag_image_view.cc b/ash/drag_drop/drag_image_view.cc index 84eef1e..5d0f2be 100644 --- a/ash/drag_drop/drag_image_view.cc +++ b/ash/drag_drop/drag_image_view.cc @@ -90,17 +90,21 @@ void DragImageView::OnPaint(gfx::Canvas* canvas) { device_scale = ui::GetDeviceScaleFactor( widget_->GetNativeView()->layer()); } + ui::ScaleFactor device_scale_factor = + ui::GetScaleFactorFromScale(device_scale); + // The drag image already has device scale factor applied. But // |widget_size_| is in DIP units. gfx::Size scaled_widget_size = gfx::ToRoundedSize( gfx::ScaleSize(widget_size_, device_scale)); - gfx::ImageSkiaRep image_rep = GetImage().GetRepresentation(device_scale); + gfx::ImageSkiaRep image_rep = GetImage().GetRepresentation( + device_scale_factor); if (image_rep.is_null()) return; SkBitmap scaled = skia::ImageOperations::Resize( image_rep.sk_bitmap(), skia::ImageOperations::RESIZE_LANCZOS3, scaled_widget_size.width(), scaled_widget_size.height()); - gfx::ImageSkia image_skia(gfx::ImageSkiaRep(scaled, device_scale)); + gfx::ImageSkia image_skia(gfx::ImageSkiaRep(scaled, device_scale_factor)); canvas->DrawImageInt(image_skia, 0, 0); } } diff --git a/ash/launcher/launcher_delegate.h b/ash/launcher/launcher_delegate.h index 41d0c29..06e0445 100644 --- a/ash/launcher/launcher_delegate.h +++ b/ash/launcher/launcher_delegate.h @@ -8,10 +8,6 @@ #include "ash/ash_export.h" #include "ash/launcher/launcher_types.h" -namespace aura { -class Window; -} - namespace ash { class Launcher; diff --git a/ash/launcher/launcher_item_delegate_manager.cc b/ash/launcher/launcher_item_delegate_manager.cc index 1708fe6..65fb0f0 100644 --- a/ash/launcher/launcher_item_delegate_manager.cc +++ b/ash/launcher/launcher_item_delegate_manager.cc @@ -4,8 +4,6 @@ #include "ash/launcher/launcher_item_delegate_manager.h" -#include "base/logging.h" - namespace ash { LauncherItemDelegateManager::LauncherItemDelegateManager() { diff --git a/ash/shell/app_list.cc b/ash/shell/app_list.cc index 25306b3..f0dae34 100644 --- a/ash/shell/app_list.cc +++ b/ash/shell/app_list.cc @@ -204,7 +204,8 @@ class ExampleAppListViewDelegate : public app_list::AppListViewDelegate { const base::string16 icon_text = ASCIIToUTF16("ash"); const gfx::Size icon_size(32, 32); - gfx::Canvas canvas(icon_size, 1.0f, false /* is_opaque */); + gfx::Canvas canvas(icon_size, ui::SCALE_FACTOR_100P, + false /* is_opaque */); canvas.DrawStringInt(icon_text, gfx::Font(), SK_ColorBLACK, diff --git a/ash/shell/window_watcher.cc b/ash/shell/window_watcher.cc index f076483..4dfcea4 100644 --- a/ash/shell/window_watcher.cc +++ b/ash/shell/window_watcher.cc @@ -118,7 +118,8 @@ void WindowWatcher::OnWindowAdded(aura::Window* new_window) { image_count == 1 ? 255 : 0, image_count == 2 ? 255 : 0); image_count = (image_count + 1) % 3; - item.image = gfx::ImageSkia(gfx::ImageSkiaRep(icon_bitmap, 1.0f)); + item.image = gfx::ImageSkia(gfx::ImageSkiaRep(icon_bitmap, + ui::SCALE_FACTOR_100P)); model->Add(item); } diff --git a/ash/system/chromeos/network/network_icon.cc b/ash/system/chromeos/network/network_icon.cc index 7e64bbe..7cb009a 100644 --- a/ash/system/chromeos/network/network_icon.cc +++ b/ash/system/chromeos/network/network_icon.cc @@ -196,12 +196,13 @@ class EmptyImageSource: public gfx::ImageSkiaSource { : size_(size) { } - virtual gfx::ImageSkiaRep GetImageForScale(float scale) OVERRIDE { - gfx::Size pixel_size = gfx::ToFlooredSize(gfx::ScaleSize(size_, scale)); + virtual gfx::ImageSkiaRep GetImageForScale( + ui::ScaleFactor scale_factor) OVERRIDE { + gfx::Size pixel_size = gfx::ToFlooredSize( + gfx::ScaleSize(size_, ui::GetScaleFactorScale(scale_factor))); SkBitmap empty_bitmap = GetEmptyBitmap(pixel_size); - return gfx::ImageSkiaRep(empty_bitmap, scale); + return gfx::ImageSkiaRep(empty_bitmap, scale_factor); } - private: const gfx::Size size_; @@ -219,8 +220,9 @@ class NetworkIconImageSource : public gfx::ImageSkiaSource { // TODO(pkotwicz): Figure out what to do when a new image resolution becomes // available. - virtual gfx::ImageSkiaRep GetImageForScale(float scale) OVERRIDE { - gfx::ImageSkiaRep icon_rep = icon_.GetRepresentation(scale); + virtual gfx::ImageSkiaRep GetImageForScale( + ui::ScaleFactor scale_factor) OVERRIDE { + gfx::ImageSkiaRep icon_rep = icon_.GetRepresentation(scale_factor); if (icon_rep.is_null()) return gfx::ImageSkiaRep(); gfx::Canvas canvas(icon_rep, false); diff --git a/ash/wm/frame_painter.cc b/ash/wm/frame_painter.cc index 0e53e33..b27fc7b 100644 --- a/ash/wm/frame_painter.cc +++ b/ash/wm/frame_painter.cc @@ -136,7 +136,7 @@ void PaintFrameImagesInRoundRect(gfx::Canvas* canvas, top_left_corner_radius, top_right_corner_radius, 0); } } else { - gfx::Canvas temporary_canvas(bounds.size(), canvas->image_scale(), false); + gfx::Canvas temporary_canvas(bounds.size(), canvas->scale_factor(), false); temporary_canvas.TileImageInt(*frame_image, image_inset_x, 0, 0, 0, |