summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-10 09:34:28 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-10 09:34:28 +0000
commit01a15a710b6ffb772bdf8e3827e9f1395d29d814 (patch)
treee0bf4c1332ac22b7cc939be4b08f2bdafa732a9c
parentbcf7636d116fe67fd79d9acca753b1b18f380654 (diff)
downloadchromium_src-01a15a710b6ffb772bdf8e3827e9f1395d29d814.zip
chromium_src-01a15a710b6ffb772bdf8e3827e9f1395d29d814.tar.gz
chromium_src-01a15a710b6ffb772bdf8e3827e9f1395d29d814.tar.bz2
ui: Make gfx::Size::Scale() mutate the class. Add gfx::ScaleSize() similar to Rect/Point.
Covered by existing unit tests. R=sky BUG=160158 Review URL: https://chromiumcodereview.appspot.com/11377068 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167077 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/display/multi_display_manager.cc7
-rw-r--r--cc/contents_scaling_layer.cc2
-rw-r--r--cc/layer_tree_host_impl.cc15
-rw-r--r--cc/layer_tree_host_impl_unittest.cc2
-rw-r--r--cc/layer_tree_host_unittest.cc7
-rw-r--r--cc/page_scale_animation.cc2
-rw-r--r--chrome/browser/chromeos/status/network_menu_icon.cc2
-rw-r--r--chrome/browser/extensions/extension_icon_image.cc4
-rw-r--r--chrome/browser/thumbnails/render_widget_snapshot_taker.cc2
-rw-r--r--chrome/browser/thumbnails/thumbnail_tab_helper.cc10
-rw-r--r--content/browser/renderer_host/backing_store_aura.cc11
-rw-r--r--content/browser/renderer_host/backing_store_mac.mm10
-rw-r--r--content/browser/renderer_host/compositing_iosurface_mac.mm4
-rw-r--r--content/browser/renderer_host/dip_util.cc5
-rw-r--r--content/browser/renderer_host/render_widget_host_impl.cc2
-rw-r--r--content/browser/renderer_host/render_widget_host_view_mac.mm3
-rw-r--r--content/renderer/browser_plugin/browser_plugin_backing_store.cc2
-rw-r--r--content/renderer/disambiguation_popup_helper.cc2
-rw-r--r--content/renderer/disambiguation_popup_helper_unittest.cc6
-rw-r--r--content/renderer/render_view_impl.cc2
-rw-r--r--content/renderer/render_widget.cc4
-rw-r--r--content/renderer/render_widget_fullscreen_pepper.cc6
-rw-r--r--ui/compositor/dip_util.cc5
-rw-r--r--ui/compositor/layer.cc3
-rw-r--r--ui/gfx/canvas.cc6
-rw-r--r--ui/gfx/display.cc4
-rw-r--r--ui/gfx/image/image_skia_operations.cc2
-rw-r--r--ui/gfx/rect_f.h4
-rw-r--r--ui/gfx/size.h8
-rw-r--r--ui/gfx/size_f.cc6
-rw-r--r--ui/gfx/size_f.h14
-rw-r--r--webkit/glue/webcursor_aurax11.cc2
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.cc3
33 files changed, 90 insertions, 77 deletions
diff --git a/ash/display/multi_display_manager.cc b/ash/display/multi_display_manager.cc
index 3f1e93d..46f1abc 100644
--- a/ash/display/multi_display_manager.cc
+++ b/ash/display/multi_display_manager.cc
@@ -449,9 +449,10 @@ void MultiDisplayManager::ScaleDisplayImpl() {
iter != displays_.end(); ++iter) {
gfx::Display display = *iter;
float factor = display.device_scale_factor() == 1.0f ? 2.0f : 1.0f;
- display.SetScaleAndBounds(
- factor, gfx::Rect(display.bounds_in_pixel().origin(),
- gfx::ToFlooredSize(display.size().Scale(factor))));
+ gfx::Point display_origin = display.bounds_in_pixel().origin();
+ gfx::Size display_size = gfx::ToFlooredSize(
+ gfx::ScaleSize(display.size(), factor));
+ display.SetScaleAndBounds(factor, gfx::Rect(display_origin, display_size));
new_displays.push_back(display);
}
OnNativeDisplaysChanged(new_displays);
diff --git a/cc/contents_scaling_layer.cc b/cc/contents_scaling_layer.cc
index c0fb126..b758bd3 100644
--- a/cc/contents_scaling_layer.cc
+++ b/cc/contents_scaling_layer.cc
@@ -15,7 +15,7 @@ ContentsScalingLayer::~ContentsScalingLayer() {
}
gfx::Size ContentsScalingLayer::contentBounds() const {
- return gfx::ToCeiledSize(bounds().Scale(contentsScaleX(), contentsScaleY()));
+ return gfx::ToCeiledSize(gfx::ScaleSize(bounds(), contentsScaleX(), contentsScaleY()));
}
float ContentsScalingLayer::contentsScaleX() const {
diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc
index 5bd3cac..b39dec9 100644
--- a/cc/layer_tree_host_impl.cc
+++ b/cc/layer_tree_host_impl.cc
@@ -297,10 +297,9 @@ void LayerTreeHostImpl::startPageScaleAnimation(gfx::Vector2d targetPosition, bo
gfx::SizeF scaledContentSize = contentSize();
if (!Settings::pageScalePinchZoomEnabled()) {
scrollTotal.Scale(1 / m_pinchZoomViewport.pageScaleFactor());
- scaledContentSize = scaledContentSize.Scale(1 / m_pinchZoomViewport.pageScaleFactor());
+ scaledContentSize.Scale(1 / m_pinchZoomViewport.pageScaleFactor());
}
- gfx::SizeF viewportSize = m_deviceViewportSize;
- viewportSize = viewportSize.Scale(1 / m_deviceScaleFactor);
+ gfx::SizeF viewportSize = gfx::ScaleSize(m_deviceViewportSize, 1 / m_deviceScaleFactor);
double startTimeSeconds = (startTime - base::TimeTicks()).InSecondsF();
m_pageScaleAnimation = PageScaleAnimation::create(scrollTotal, m_pinchZoomViewport.totalPageScaleFactor(), viewportSize, scaledContentSize, startTimeSeconds);
@@ -983,10 +982,8 @@ void LayerTreeHostImpl::updateMaxScrollOffset()
gfx::SizeF viewBounds = m_deviceViewportSize;
if (LayerImpl* clipLayer = m_rootScrollLayerImpl->parent()) {
// Compensate for non-overlay scrollbars.
- if (clipLayer->masksToBounds()) {
- viewBounds = clipLayer->bounds();
- viewBounds = viewBounds.Scale(m_deviceScaleFactor);
- }
+ if (clipLayer->masksToBounds())
+ viewBounds = gfx::ScaleSize(clipLayer->bounds(), m_deviceScaleFactor);
}
gfx::Size contentBounds = contentSize();
@@ -998,7 +995,7 @@ void LayerTreeHostImpl::updateMaxScrollOffset()
contentBounds.set_width(contentBounds.width() / pageScaleFactor);
contentBounds.set_height(contentBounds.height() / pageScaleFactor);
} else {
- viewBounds = viewBounds.Scale(1 / m_pinchZoomViewport.pageScaleDelta());
+ viewBounds.Scale(1 / m_pinchZoomViewport.pageScaleDelta());
}
gfx::Vector2dF maxScroll = BottomRight(gfx::Rect(contentBounds)) - BottomRight(gfx::RectF(viewBounds));
@@ -1288,7 +1285,7 @@ void LayerTreeHostImpl::computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo)
scrollBegin.Scale(m_pinchZoomViewport.pageScaleDelta());
float scaleBegin = m_pinchZoomViewport.totalPageScaleFactor();
float pageScaleDeltaToSend = m_pinchZoomViewport.minPageScaleFactor() / m_pinchZoomViewport.pageScaleFactor();
- gfx::SizeF scaledContentsSize = contentSize().Scale(pageScaleDeltaToSend);
+ gfx::SizeF scaledContentsSize = gfx::ScaleSize(contentSize(), pageScaleDeltaToSend);
gfx::Vector2d anchorOffset = m_previousPinchAnchor.OffsetFromOrigin();
gfx::Vector2dF scrollEnd = scrollBegin + anchorOffset;
diff --git a/cc/layer_tree_host_impl_unittest.cc b/cc/layer_tree_host_impl_unittest.cc
index 3e25195..78691d9 100644
--- a/cc/layer_tree_host_impl_unittest.cc
+++ b/cc/layer_tree_host_impl_unittest.cc
@@ -485,7 +485,7 @@ TEST_P(LayerTreeHostImplTest, maxScrollOffsetChangedByDeviceScaleFactor)
float deviceScaleFactor = 2;
gfx::Size layoutViewport(25, 25);
- gfx::Size deviceViewport(gfx::ToFlooredSize(layoutViewport.Scale(deviceScaleFactor)));
+ gfx::Size deviceViewport(gfx::ToFlooredSize(gfx::ScaleSize(layoutViewport, deviceScaleFactor)));
m_hostImpl->setViewportSize(layoutViewport, deviceViewport);
m_hostImpl->setDeviceScaleFactor(deviceScaleFactor);
EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), gfx::Vector2d(25, 25));
diff --git a/cc/layer_tree_host_unittest.cc b/cc/layer_tree_host_unittest.cc
index 633b8ff..4fa8fc7 100644
--- a/cc/layer_tree_host_unittest.cc
+++ b/cc/layer_tree_host_unittest.cc
@@ -1337,8 +1337,7 @@ public:
EXPECT_RECT_EQ(gfx::Rect(0, 0, 60, 60), root->renderSurface()->contentRect());
// The content bounds of the child should be scaled.
- gfx::Size childBoundsScaled = child->bounds();
- childBoundsScaled = gfx::ToRoundedSize(childBoundsScaled.Scale(1.5));
+ gfx::Size childBoundsScaled = gfx::ToCeiledSize(gfx::ScaleSize(child->bounds(), 1.5));
EXPECT_EQ(childBoundsScaled, child->contentBounds());
WebTransformationMatrix scaleTransform;
@@ -2185,7 +2184,7 @@ public:
virtual void beginTest() OVERRIDE
{
gfx::Size viewportSize(10, 10);
- gfx::Size deviceViewportSize = gfx::ToCeiledSize(viewportSize.Scale(m_deviceScaleFactor));
+ gfx::Size deviceViewportSize = gfx::ToCeiledSize(gfx::ScaleSize(viewportSize, m_deviceScaleFactor));
m_layerTreeHost->setViewportSize(viewportSize, deviceViewportSize);
m_layerTreeHost->setDeviceScaleFactor(m_deviceScaleFactor);
@@ -2345,7 +2344,7 @@ public:
virtual void beginTest() OVERRIDE
{
gfx::Size viewportSize(10, 10);
- gfx::Size deviceViewportSize = gfx::ToCeiledSize(viewportSize.Scale(m_deviceScaleFactor));
+ gfx::Size deviceViewportSize = gfx::ToCeiledSize(gfx::ScaleSize(viewportSize, m_deviceScaleFactor));
m_layerTreeHost->setViewportSize(viewportSize, deviceViewportSize);
m_layerTreeHost->setDeviceScaleFactor(m_deviceScaleFactor);
diff --git a/cc/page_scale_animation.cc b/cc/page_scale_animation.cc
index 5d9e882..e5b1fec 100644
--- a/cc/page_scale_animation.cc
+++ b/cc/page_scale_animation.cc
@@ -99,7 +99,7 @@ void PageScaleAnimation::zoomWithAnchor(const gfx::Vector2dF& anchor, float targ
gfx::SizeF PageScaleAnimation::viewportSizeAtScale(float pageScaleFactor) const
{
- return gfx::SizeF(m_viewportSize.width() / pageScaleFactor, m_viewportSize.height() / pageScaleFactor);
+ return gfx::ScaleSize(m_viewportSize, 1 / pageScaleFactor);
}
void PageScaleAnimation::inferTargetScrollOffsetFromStartAnchor()
diff --git a/chrome/browser/chromeos/status/network_menu_icon.cc b/chrome/browser/chromeos/status/network_menu_icon.cc
index d852ac6..11f2a26 100644
--- a/chrome/browser/chromeos/status/network_menu_icon.cc
+++ b/chrome/browser/chromeos/status/network_menu_icon.cc
@@ -184,7 +184,7 @@ class EmptyImageSource: public gfx::ImageSkiaSource {
virtual gfx::ImageSkiaRep GetImageForScale(
ui::ScaleFactor scale_factor) OVERRIDE {
gfx::Size pixel_size = gfx::ToFlooredSize(
- size_.Scale(ui::GetScaleFactorScale(scale_factor)));
+ gfx::ScaleSize(size_, ui::GetScaleFactorScale(scale_factor)));
SkBitmap empty_bitmap = GetEmptyBitmap(pixel_size);
return gfx::ImageSkiaRep(empty_bitmap, scale_factor);
}
diff --git a/chrome/browser/extensions/extension_icon_image.cc b/chrome/browser/extensions/extension_icon_image.cc
index f748f2f..ee252e7 100644
--- a/chrome/browser/extensions/extension_icon_image.cc
+++ b/chrome/browser/extensions/extension_icon_image.cc
@@ -193,8 +193,8 @@ gfx::ImageSkiaRep IconImage::LoadImageForScaleFactor(
info_list.push_back(ImageLoadingTracker::ImageRepresentation(
resource,
ImageLoadingTracker::ImageRepresentation::ALWAYS_RESIZE,
- gfx::ToFlooredSize(
- gfx::Size(resource_size_in_dip_, resource_size_in_dip_).Scale(scale)),
+ gfx::ToFlooredSize(gfx::ScaleSize(
+ gfx::Size(resource_size_in_dip_, resource_size_in_dip_), scale)),
scale_factor));
tracker_.LoadImages(extension_, info_list, ImageLoadingTracker::DONT_CACHE);
diff --git a/chrome/browser/thumbnails/render_widget_snapshot_taker.cc b/chrome/browser/thumbnails/render_widget_snapshot_taker.cc
index cd0dbd3..184cceb 100644
--- a/chrome/browser/thumbnails/render_widget_snapshot_taker.cc
+++ b/chrome/browser/thumbnails/render_widget_snapshot_taker.cc
@@ -48,7 +48,7 @@ void RenderWidgetSnapshotTaker::AskForSnapshot(
float scale_factor = ui::GetScaleFactorScale(ui::GetScaleFactorForNativeView(
renderer->GetView()->GetNativeView()));
gfx::Size desired_size_in_pixel = gfx::ToFlooredSize(
- desired_size.Scale(scale_factor));
+ gfx::ScaleSize(desired_size, scale_factor));
scoped_ptr<TransportDIB> thumbnail_dib(TransportDIB::Create(
desired_size_in_pixel.GetArea() * 4, sequence_num));
diff --git a/chrome/browser/thumbnails/thumbnail_tab_helper.cc b/chrome/browser/thumbnails/thumbnail_tab_helper.cc
index 992a695..933ff28 100644
--- a/chrome/browser/thumbnails/thumbnail_tab_helper.cc
+++ b/chrome/browser/thumbnails/thumbnail_tab_helper.cc
@@ -88,8 +88,8 @@ gfx::Size GetCopySizeForThumbnail(content::RenderWidgetHostView* view) {
ui::GetScaleFactorForNativeView(view->GetNativeView());
switch (scale_factor) {
case ui::SCALE_FACTOR_100P:
- copy_size = gfx::ToFlooredSize(
- copy_size.Scale(ui::GetScaleFactorScale(ui::SCALE_FACTOR_200P)));
+ copy_size = gfx::ToFlooredSize(gfx::ScaleSize(
+ copy_size, ui::GetScaleFactorScale(ui::SCALE_FACTOR_200P)));
break;
case ui::SCALE_FACTOR_200P:
// Use the size as-is.
@@ -97,8 +97,8 @@ gfx::Size GetCopySizeForThumbnail(content::RenderWidgetHostView* view) {
default:
DLOG(WARNING) << "Unsupported scale factor. Use the same copy size as "
<< "ui::SCALE_FACTOR_100P";
- copy_size = gfx::ToFlooredSize(
- copy_size.Scale(ui::GetScaleFactorScale(ui::SCALE_FACTOR_200P)));
+ copy_size = gfx::ToFlooredSize(gfx::ScaleSize(
+ copy_size, ui::GetScaleFactorScale(ui::SCALE_FACTOR_200P)));
break;
}
return copy_size;
@@ -113,7 +113,7 @@ gfx::Size GetThumbnailSizeInPixel() {
// crbug.com/159157.
float max_scale_factor =
ui::GetScaleFactorScale(ui::GetMaxScaleFactor());
- return gfx::ToFlooredSize(thumbnail_size.Scale(max_scale_factor));
+ return gfx::ToFlooredSize(gfx::ScaleSize(thumbnail_size, max_scale_factor));
}
// Returns the clipping rectangle that is used for creating a thumbnail with
diff --git a/content/browser/renderer_host/backing_store_aura.cc b/content/browser/renderer_host/backing_store_aura.cc
index 82d78d7..e025e92 100644
--- a/content/browser/renderer_host/backing_store_aura.cc
+++ b/content/browser/renderer_host/backing_store_aura.cc
@@ -29,7 +29,8 @@ BackingStoreAura::BackingStoreAura(RenderWidgetHost* widget,
: BackingStore(widget, size) {
device_scale_factor_ =
ui::GetScaleFactorScale(GetScaleFactorForView(widget->GetView()));
- gfx::Size pixel_size = gfx::ToFlooredSize(size.Scale(device_scale_factor_));
+ gfx::Size pixel_size = gfx::ToFlooredSize(
+ gfx::ScaleSize(size, device_scale_factor_));
bitmap_.setConfig(SkBitmap::kARGB_8888_Config,
pixel_size.width(), pixel_size.height());
bitmap_.allocPixels();
@@ -51,10 +52,11 @@ void BackingStoreAura::ScaleFactorChanged(float device_scale_factor) {
return;
gfx::Size old_pixel_size = gfx::ToFlooredSize(
- size().Scale(device_scale_factor_));
+ gfx::ScaleSize(size(), device_scale_factor_));
device_scale_factor_ = device_scale_factor;
- gfx::Size pixel_size = gfx::ToFlooredSize(size().Scale(device_scale_factor_));
+ gfx::Size pixel_size = gfx::ToFlooredSize(
+ gfx::ScaleSize(size(), device_scale_factor_));
SkBitmap new_bitmap;
new_bitmap.setConfig(SkBitmap::kARGB_8888_Config,
pixel_size.width(), pixel_size.height());
@@ -76,7 +78,8 @@ void BackingStoreAura::ScaleFactorChanged(float device_scale_factor) {
size_t BackingStoreAura::MemorySize() {
// NOTE: The computation may be different when the canvas is a subrectangle of
// a larger bitmap.
- return gfx::ToFlooredSize(size().Scale(device_scale_factor_)).GetArea() * 4;
+ return gfx::ToFlooredSize(
+ gfx::ScaleSize(size(), device_scale_factor_)).GetArea() * 4;
}
void BackingStoreAura::PaintToBackingStore(
diff --git a/content/browser/renderer_host/backing_store_mac.mm b/content/browser/renderer_host/backing_store_mac.mm
index 66095ca..33bff14 100644
--- a/content/browser/renderer_host/backing_store_mac.mm
+++ b/content/browser/renderer_host/backing_store_mac.mm
@@ -70,7 +70,8 @@ void BackingStoreMac::ScaleFactorChanged(float device_scale_factor) {
}
size_t BackingStoreMac::MemorySize() {
- return gfx::ToFlooredSize(size().Scale(device_scale_factor_)).GetArea() * 4;
+ return gfx::ToFlooredSize(
+ gfx::ScaleSize(size(), device_scale_factor_)).GetArea() * 4;
}
void BackingStoreMac::PaintToBackingStore(
@@ -89,7 +90,7 @@ void BackingStoreMac::PaintToBackingStore(
return;
gfx::Size pixel_size = gfx::ToFlooredSize(
- size().Scale(device_scale_factor_));
+ gfx::ScaleSize(size(), device_scale_factor_));
gfx::Rect pixel_bitmap_rect = ToFlooredRectDeprecated(
gfx::ScaleRect(bitmap_rect, scale_factor));
@@ -248,7 +249,7 @@ CGLayerRef BackingStoreMac::CreateCGLayer() {
DCHECK(cg_context);
// Note: This takes the backingScaleFactor of cg_context into account. The
- // bitmap backing |layer| with be size().Scale(2) in HiDPI mode automatically.
+ // bitmap backing |layer| will be size() * 2 in HiDPI mode automatically.
CGLayerRef layer = CGLayerCreateWithContext(cg_context,
size().ToCGSize(),
NULL);
@@ -258,7 +259,8 @@ CGLayerRef BackingStoreMac::CreateCGLayer() {
}
CGContextRef BackingStoreMac::CreateCGBitmapContext() {
- gfx::Size pixel_size = gfx::ToFlooredSize(size().Scale(device_scale_factor_));
+ gfx::Size pixel_size = gfx::ToFlooredSize(
+ gfx::ScaleSize(size(), device_scale_factor_));
// A CGBitmapContext serves as a stand-in for the layer before the view is
// in a containing window.
CGContextRef context = CGBitmapContextCreate(NULL,
diff --git a/content/browser/renderer_host/compositing_iosurface_mac.mm b/content/browser/renderer_host/compositing_iosurface_mac.mm
index db49a82..d747876 100644
--- a/content/browser/renderer_host/compositing_iosurface_mac.mm
+++ b/content/browser/renderer_host/compositing_iosurface_mac.mm
@@ -329,13 +329,13 @@ void CompositingIOSurfaceMac::DrawIOSurface(NSView* view, float scale_factor) {
[glContext_ setView:view];
gfx::Size window_size(NSSizeToCGSize([view frame].size));
gfx::Size pixel_window_size = gfx::ToFlooredSize(
- window_size.Scale(scale_factor));
+ gfx::ScaleSize(window_size, scale_factor));
glViewport(0, 0, pixel_window_size.width(), pixel_window_size.height());
// TODO: After a resolution change, the DPI-ness of the view and the
// IOSurface might not be in sync.
io_surface_size_ = gfx::ToFlooredSize(
- pixel_io_surface_size_.Scale(1.0 / scale_factor));
+ gfx::ScaleSize(pixel_io_surface_size_, 1.0 / scale_factor));
quad_.set_size(io_surface_size_, pixel_io_surface_size_);
glMatrixMode(GL_PROJECTION);
diff --git a/content/browser/renderer_host/dip_util.cc b/content/browser/renderer_host/dip_util.cc
index 726241a..575232c 100644
--- a/content/browser/renderer_host/dip_util.cc
+++ b/content/browser/renderer_host/dip_util.cc
@@ -36,7 +36,7 @@ gfx::Point ConvertPointToDIP(const RenderWidgetHostView* view,
gfx::Size ConvertSizeToDIP(const RenderWidgetHostView* view,
const gfx::Size& size_in_pixel) {
return gfx::ToFlooredSize(
- size_in_pixel.Scale(1.0f / GetScaleForView(view)));
+ gfx::ScaleSize(size_in_pixel, 1.0f / GetScaleForView(view)));
}
gfx::Rect ConvertRectToDIP(const RenderWidgetHostView* view,
@@ -53,7 +53,8 @@ gfx::Point ConvertPointToPixel(const RenderWidgetHostView* view,
gfx::Size ConvertSizeToPixel(const RenderWidgetHostView* view,
const gfx::Size& size_in_dip) {
- return gfx::ToFlooredSize(size_in_dip.Scale(GetScaleForView(view)));
+ return gfx::ToFlooredSize(
+ gfx::ScaleSize(size_in_dip, GetScaleForView(view)));
}
gfx::Rect ConvertRectToPixel(const RenderWidgetHostView* view,
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
index ff7187a..cf1e3ec 100644
--- a/content/browser/renderer_host/render_widget_host_impl.cc
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -1499,7 +1499,7 @@ void RenderWidgetHostImpl::OnMsgUpdateRect(
if (dib) {
DCHECK(!params.bitmap_rect.IsEmpty());
gfx::Size pixel_size = gfx::ToFlooredSize(
- params.bitmap_rect.size().Scale(params.scale_factor));
+ gfx::ScaleSize(params.bitmap_rect.size(), params.scale_factor));
const size_t size = pixel_size.height() * pixel_size.width() * 4;
if (dib->size() < size) {
DLOG(WARNING) << "Transport DIB too small for given rectangle";
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
index 7827061..961f512 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -858,7 +858,8 @@ void RenderWidgetHostViewMac::CopyFromCompositingSurface(
return;
float scale = ScaleFactor(cocoa_view_);
- gfx::Size dst_pixel_size = gfx::ToFlooredSize(dst_size.Scale(scale));
+ gfx::Size dst_pixel_size = gfx::ToFlooredSize(
+ gfx::ScaleSize(dst_size, scale));
if (!output->Allocate(
dst_pixel_size.width(), dst_pixel_size.height(), true))
return;
diff --git a/content/renderer/browser_plugin/browser_plugin_backing_store.cc b/content/renderer/browser_plugin/browser_plugin_backing_store.cc
index 4bf8969..2c8938c 100644
--- a/content/renderer/browser_plugin/browser_plugin_backing_store.cc
+++ b/content/renderer/browser_plugin/browser_plugin_backing_store.cc
@@ -20,7 +20,7 @@ BrowserPluginBackingStore::BrowserPluginBackingStore(
float scale_factor)
: size_(size),
scale_factor_(scale_factor) {
- gfx::Size pixel_size = gfx::ToFlooredSize(size.Scale(scale_factor));
+ gfx::Size pixel_size = gfx::ToFlooredSize(gfx::ScaleSize(size, scale_factor));
bitmap_.setConfig(SkBitmap::kARGB_8888_Config,
pixel_size.width(), pixel_size.height());
bitmap_.allocPixels();
diff --git a/content/renderer/disambiguation_popup_helper.cc b/content/renderer/disambiguation_popup_helper.cc
index 1399518..75bb913 100644
--- a/content/renderer/disambiguation_popup_helper.cc
+++ b/content/renderer/disambiguation_popup_helper.cc
@@ -66,7 +66,7 @@ gfx::Rect CropZoomArea(const gfx::Rect& zoom_rect,
gfx::Size max_size = viewport_size;
max_size.Enlarge(-2 * kDisambiguationPopupBoundsMargin,
-2 * kDisambiguationPopupBoundsMargin);
- max_size = ToCeiledSize(max_size.Scale(1.0 / scale));
+ max_size = ToCeiledSize(ScaleSize(max_size, 1.0 / scale));
int left = touch_point.x() - zoom_rect.x();
int right = zoom_rect.right() - touch_point.x();
diff --git a/content/renderer/disambiguation_popup_helper_unittest.cc b/content/renderer/disambiguation_popup_helper_unittest.cc
index 2aaeb84..b3da46a 100644
--- a/content/renderer/disambiguation_popup_helper_unittest.cc
+++ b/content/renderer/disambiguation_popup_helper_unittest.cc
@@ -39,7 +39,7 @@ TEST_F(DisambiguationPopupHelperUnittest, ClipByViewport) {
EXPECT_TRUE(gfx::Rect(kViewportSize_).Contains(zoom_rect));
EXPECT_LE(kDisambiguationPopupMinScale, scale);
- gfx::Size scaled_size = ToCeiledSize(zoom_rect.size().Scale(scale));
+ gfx::Size scaled_size = ToCeiledSize(ScaleSize(zoom_rect.size(), scale));
EXPECT_TRUE(gfx::Rect(kViewportSize_).Contains(gfx::Rect(scaled_size)));
}
@@ -56,7 +56,7 @@ TEST_F(DisambiguationPopupHelperUnittest, MiniTarget) {
EXPECT_EQ(kDisambiguationPopupMaxScale, scale);
EXPECT_TRUE(zoom_rect.Contains(target_rects[0]));
- gfx::Size scaled_size = ToCeiledSize(zoom_rect.size().Scale(scale));
+ gfx::Size scaled_size = ToCeiledSize(ScaleSize(zoom_rect.size(), scale));
EXPECT_TRUE(gfx::Rect(kViewportSize_).Contains(gfx::Rect(scaled_size)));
}
@@ -74,7 +74,7 @@ TEST_F(DisambiguationPopupHelperUnittest, LongLinks) {
EXPECT_EQ(kDisambiguationPopupMaxScale, scale);
EXPECT_TRUE(zoom_rect.Contains(tap_rect));
- gfx::Size scaled_size = ToCeiledSize(zoom_rect.size().Scale(scale));
+ gfx::Size scaled_size = ToCeiledSize(ScaleSize(zoom_rect.size(), scale));
EXPECT_TRUE(gfx::Rect(kViewportSize_).Contains(gfx::Rect(scaled_size)));
}
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index a3c5cf06..6c4573f 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -6337,7 +6337,7 @@ bool RenderViewImpl::didTapMultipleTargets(
return false;
gfx::Size canvas_size = zoom_rect.size();
- canvas_size = ToCeiledSize(canvas_size.Scale(scale));
+ canvas_size = ToCeiledSize(gfx::ScaleSize(canvas_size, scale));
TransportDIB* transport_dib = NULL;
{
scoped_ptr<skia::PlatformCanvas> canvas(
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index c95d78f..58f76e8 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -1544,9 +1544,9 @@ void RenderWidget::OnMsgPaintAtSize(const TransportDIB::Handle& dib_handle,
TransportDIB::CreateWithHandle(dib_handle));
gfx::Size page_size_in_pixel = gfx::ToFlooredSize(
- page_size.Scale(device_scale_factor_));
+ gfx::ScaleSize(page_size, device_scale_factor_));
gfx::Size desired_size_in_pixel = gfx::ToFlooredSize(
- desired_size.Scale(device_scale_factor_));
+ gfx::ScaleSize(desired_size, device_scale_factor_));
gfx::Size canvas_size = page_size_in_pixel;
float x_scale = static_cast<float>(desired_size_in_pixel.width()) /
static_cast<float>(canvas_size.width());
diff --git a/content/renderer/render_widget_fullscreen_pepper.cc b/content/renderer/render_widget_fullscreen_pepper.cc
index b14c9e5..58cb9da 100644
--- a/content/renderer/render_widget_fullscreen_pepper.cc
+++ b/content/renderer/render_widget_fullscreen_pepper.cc
@@ -508,7 +508,8 @@ void RenderWidgetFullscreenPepper::OnResize(const gfx::Size& size,
const gfx::Rect& resizer_rect,
bool is_fullscreen) {
if (context_) {
- gfx::Size pixel_size = gfx::ToFlooredSize(size.Scale(deviceScaleFactor()));
+ gfx::Size pixel_size = gfx::ToFlooredSize(
+ gfx::ScaleSize(size, deviceScaleFactor()));
context_->reshape(pixel_size.width(), pixel_size.height());
context_->viewport(0, 0, pixel_size.width(), pixel_size.height());
}
@@ -601,7 +602,8 @@ const float kTexCoords[] = {
} // anonymous namespace
bool RenderWidgetFullscreenPepper::InitContext() {
- gfx::Size pixel_size = gfx::ToFlooredSize(size().Scale(deviceScaleFactor()));
+ gfx::Size pixel_size = gfx::ToFlooredSize(
+ gfx::ScaleSize(size(), deviceScaleFactor()));
context_->reshape(pixel_size.width(), pixel_size.height());
context_->viewport(0, 0, pixel_size.width(), pixel_size.height());
diff --git a/ui/compositor/dip_util.cc b/ui/compositor/dip_util.cc
index 5adf7c4..104a5da 100644
--- a/ui/compositor/dip_util.cc
+++ b/ui/compositor/dip_util.cc
@@ -32,7 +32,7 @@ gfx::Point ConvertPointToDIP(const Layer* layer,
gfx::Size ConvertSizeToDIP(const Layer* layer,
const gfx::Size& size_in_pixel) {
return gfx::ToFlooredSize(
- size_in_pixel.Scale(1.0f / GetDeviceScaleFactor(layer)));
+ gfx::ScaleSize(size_in_pixel, 1.0f / GetDeviceScaleFactor(layer)));
}
gfx::Rect ConvertRectToDIP(const Layer* layer,
@@ -49,7 +49,8 @@ gfx::Point ConvertPointToPixel(const Layer* layer,
gfx::Size ConvertSizeToPixel(const Layer* layer,
const gfx::Size& size_in_dip) {
- return gfx::ToFlooredSize(size_in_dip.Scale(GetDeviceScaleFactor(layer)));
+ return gfx::ToFlooredSize(
+ gfx::ScaleSize(size_in_dip, GetDeviceScaleFactor(layer)));
}
gfx::Rect ConvertRectToPixel(const Layer* layer,
diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc
index d3dc6ca..2a88db5 100644
--- a/ui/compositor/layer.cc
+++ b/ui/compositor/layer.cc
@@ -767,8 +767,9 @@ void Layer::RecomputeDrawsContentAndUVRect() {
} else {
DCHECK(texture_);
+ float texture_scale_factor = 1.0f / texture_->device_scale_factor();
gfx::Size texture_size = gfx::ToFlooredSize(
- texture_->size().Scale(1.0f / texture_->device_scale_factor()));
+ gfx::ScaleSize(texture_->size(), texture_scale_factor));
gfx::Size size(std::min(bounds().width(), texture_size.width()),
std::min(bounds().height(), texture_size.height()));
diff --git a/ui/gfx/canvas.cc b/ui/gfx/canvas.cc
index bf41bc1..eb11b37 100644
--- a/ui/gfx/canvas.cc
+++ b/ui/gfx/canvas.cc
@@ -29,8 +29,8 @@ Canvas::Canvas(const gfx::Size& size,
: scale_factor_(scale_factor),
owned_canvas_(NULL),
canvas_(NULL) {
- gfx::Size pixel_size = gfx::ToFlooredSize(size.Scale(
- ui::GetScaleFactorScale(scale_factor)));
+ gfx::Size pixel_size = gfx::ToFlooredSize(
+ gfx::ScaleSize(size, ui::GetScaleFactorScale(scale_factor)));
owned_canvas_.reset(new skia::PlatformCanvas(pixel_size.width(),
pixel_size.height(),
is_opaque));
@@ -77,7 +77,7 @@ void Canvas::RecreateBackingCanvas(const gfx::Size& size,
bool is_opaque) {
scale_factor_ = scale_factor;
gfx::Size pixel_size = gfx::ToFlooredSize(
- size.Scale(ui::GetScaleFactorScale(scale_factor)));
+ gfx::ScaleSize(size, ui::GetScaleFactorScale(scale_factor)));
owned_canvas_.reset(new skia::PlatformCanvas(pixel_size.width(),
pixel_size.height(),
is_opaque));
diff --git a/ui/gfx/display.cc b/ui/gfx/display.cc
index e647f65..ef3f250 100644
--- a/ui/gfx/display.cc
+++ b/ui/gfx/display.cc
@@ -89,7 +89,7 @@ void Display::SetScaleAndBounds(
bounds_in_pixel_ = bounds_in_pixel;
#endif
bounds_ = gfx::Rect(gfx::ToFlooredSize(
- bounds_in_pixel.size().Scale(1.0f / device_scale_factor_)));
+ gfx::ScaleSize(bounds_in_pixel.size(), 1.0f / device_scale_factor_)));
UpdateWorkAreaFromInsets(insets);
}
@@ -109,7 +109,7 @@ void Display::UpdateWorkAreaFromInsets(const gfx::Insets& insets) {
}
gfx::Size Display::GetSizeInPixel() const {
- return gfx::ToFlooredSize(size().Scale(device_scale_factor_));
+ return gfx::ToFlooredSize(gfx::ScaleSize(size(), device_scale_factor_));
}
std::string Display::ToString() const {
diff --git a/ui/gfx/image/image_skia_operations.cc b/ui/gfx/image/image_skia_operations.cc
index a2395da..75848c3 100644
--- a/ui/gfx/image/image_skia_operations.cc
+++ b/ui/gfx/image/image_skia_operations.cc
@@ -327,7 +327,7 @@ class ResizeSource : public ImageSkiaSource {
const float scale = ui::GetScaleFactorScale(scale_factor);
const Size target_pixel_size = gfx::ToFlooredSize(
- target_dip_size_.Scale(scale));
+ gfx::ScaleSize(target_dip_size_, scale));
const SkBitmap resized = skia::ImageOperations::Resize(
image_rep.sk_bitmap(),
resize_method_,
diff --git a/ui/gfx/rect_f.h b/ui/gfx/rect_f.h
index 7595091..2bc367c 100644
--- a/ui/gfx/rect_f.h
+++ b/ui/gfx/rect_f.h
@@ -28,7 +28,7 @@ class UI_EXPORT RectF
~RectF();
- /// Scales the rectangle by |scale|.
+ // Scales the rectangle by |scale|.
void Scale(float scale) {
Scale(scale, scale);
}
@@ -36,7 +36,7 @@ class UI_EXPORT RectF
void Scale(float x_scale, float y_scale) {
set_origin(ScalePoint(origin(), x_scale, y_scale));
- SizeF new_size = size().Scale(x_scale, y_scale);
+ SizeF new_size = gfx::ScaleSize(size(), x_scale, y_scale);
new_size.ClampToNonNegative();
set_size(new_size);
}
diff --git a/ui/gfx/size.h b/ui/gfx/size.h
index 4425207..a525251 100644
--- a/ui/gfx/size.h
+++ b/ui/gfx/size.h
@@ -47,14 +47,6 @@ class UI_EXPORT Size : public SizeBase<Size, int> {
return SizeF(width(), height());
}
- SizeF Scale(float scale) const WARN_UNUSED_RESULT {
- return Scale(scale, scale);
- }
-
- SizeF Scale(float x_scale, float y_scale) const WARN_UNUSED_RESULT {
- return SizeF(width() * x_scale, height() * y_scale);
- }
-
std::string ToString() const;
};
diff --git a/ui/gfx/size_f.cc b/ui/gfx/size_f.cc
index 96c1867..03c34ec 100644
--- a/ui/gfx/size_f.cc
+++ b/ui/gfx/size_f.cc
@@ -24,4 +24,10 @@ std::string SizeF::ToString() const {
return base::StringPrintf("%fx%f", width(), height());
}
+SizeF ScaleSize(const SizeF& s, float x_scale, float y_scale) {
+ SizeF scaled_s(s);
+ scaled_s.Scale(x_scale, y_scale);
+ return scaled_s;
+}
+
} // namespace gfx
diff --git a/ui/gfx/size_f.h b/ui/gfx/size_f.h
index f9ac6bd..4580501 100644
--- a/ui/gfx/size_f.h
+++ b/ui/gfx/size_f.h
@@ -19,12 +19,12 @@ class UI_EXPORT SizeF : public SizeBase<SizeF, float> {
SizeF(float width, float height);
~SizeF();
- SizeF Scale(float scale) const WARN_UNUSED_RESULT {
- return Scale(scale, scale);
+ void Scale(float scale) {
+ Scale(scale, scale);
}
- SizeF Scale(float x_scale, float y_scale) const WARN_UNUSED_RESULT {
- return SizeF(width() * x_scale, height() * y_scale);
+ void Scale(float x_scale, float y_scale) {
+ SetSize(width() * x_scale, height() * y_scale);
}
std::string ToString() const;
@@ -38,6 +38,12 @@ inline bool operator!=(const SizeF& lhs, const SizeF& rhs) {
return !(lhs == rhs);
}
+UI_EXPORT SizeF ScaleSize(const SizeF& p, float x_scale, float y_scale);
+
+inline SizeF ScaleSize(const SizeF& p, float scale) {
+ return ScaleSize(p, scale, scale);
+}
+
#if !defined(COMPILER_MSVC)
extern template class SizeBase<SizeF, float>;
#endif
diff --git a/webkit/glue/webcursor_aurax11.cc b/webkit/glue/webcursor_aurax11.cc
index d6e01af..5a910d1 100644
--- a/webkit/glue/webcursor_aurax11.cc
+++ b/webkit/glue/webcursor_aurax11.cc
@@ -31,7 +31,7 @@ const ui::PlatformCursor WebCursor::GetPlatformCursor() {
image = ui::SkBitmapToXcursorImage(&bitmap, hotspot_);
} else {
gfx::Size scaled_size = gfx::ToFlooredSize(
- custom_size_.Scale(scale_factor_));
+ gfx::ScaleSize(custom_size_, scale_factor_));
SkBitmap scaled_bitmap = skia::ImageOperations::Resize(bitmap,
skia::ImageOperations::RESIZE_BETTER,
scaled_size.width(),
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
index 0c0e30b..3de90b6 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
@@ -563,7 +563,8 @@ void PPB_Graphics2D_Impl::Paint(WebKit::WebCanvas* canvas,
SkAutoCanvasRestore auto_restore(canvas, true);
canvas->clipRect(sk_invalidate_rect);
gfx::Size pixel_image_size(image_data_->width(), image_data_->height());
- gfx::Size image_size = gfx::ToFlooredSize(pixel_image_size.Scale(scale_));
+ gfx::Size image_size = gfx::ToFlooredSize(
+ gfx::ScaleSize(pixel_image_size, scale_));
PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
if (!plugin_instance)