summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/display/multi_display_manager.cc3
-rw-r--r--ash/launcher/launcher_view_unittest.cc5
-rw-r--r--ash/system/drive/tray_drive.cc12
-rw-r--r--ash/wm/partial_screenshot_view.cc5
-rw-r--r--ash/wm/workspace/workspace_window_resizer.cc4
-rw-r--r--cc/delegated_renderer_layer_impl.cc3
-rw-r--r--cc/direct_renderer.cc3
-rw-r--r--cc/draw_quad.cc3
-rw-r--r--cc/software_renderer.cc3
-rw-r--r--chrome/browser/instant/instant_controller.cc3
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc4
-rw-r--r--chrome/browser/ui/views/toolbar_view.cc4
-rw-r--r--content/browser/renderer_host/backing_store_aura.cc21
-rw-r--r--content/browser/renderer_host/backing_store_mac.mm10
-rw-r--r--content/browser/renderer_host/render_widget_host_view_aura.cc10
-rw-r--r--content/browser/renderer_host/render_widget_host_view_gtk.cc7
-rw-r--r--content/browser/renderer_host/render_widget_host_view_mac.mm8
-rw-r--r--content/browser/renderer_host/render_widget_host_view_win.cc7
-rw-r--r--content/common/gpu/image_transport_surface.cc4
-rw-r--r--content/renderer/browser_plugin/browser_plugin_backing_store.cc16
-rw-r--r--content/renderer/paint_aggregator.cc11
-rw-r--r--content/renderer/paint_aggregator_unittest.cc12
-rw-r--r--content/renderer/render_widget.cc21
-rw-r--r--content/renderer/webplugin_delegate_proxy.cc13
-rw-r--r--ui/app_list/page_switcher.cc3
-rw-r--r--ui/app_list/search_result_view.cc3
-rw-r--r--ui/gfx/blit.cc4
-rw-r--r--ui/gfx/image/image_skia_operations.cc12
-rw-r--r--ui/gfx/rect.cc18
-rw-r--r--ui/gfx/rect.h4
-rw-r--r--ui/gfx/rect_f.cc24
-rw-r--r--ui/gfx/rect_f.h9
-rw-r--r--ui/gfx/rect_unittest.cc12
-rw-r--r--ui/gfx/screen_gtk.cc3
-rw-r--r--ui/gfx/screen_mac.mm3
-rw-r--r--ui/views/animation/bounds_animator.cc3
-rw-r--r--ui/views/animation/bounds_animator_unittest.cc4
-rw-r--r--ui/views/widget/root_view.cc3
-rw-r--r--webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc3
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc10
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.cc22
-rw-r--r--webkit/plugins/webview_plugin.cc3
42 files changed, 164 insertions, 171 deletions
diff --git a/ash/display/multi_display_manager.cc b/ash/display/multi_display_manager.cc
index d93321b..5911ae9 100644
--- a/ash/display/multi_display_manager.cc
+++ b/ash/display/multi_display_manager.cc
@@ -360,8 +360,7 @@ const gfx::Display& MultiDisplayManager::GetDisplayMatching(
for (std::vector<gfx::Display>::const_iterator iter = displays_.begin();
iter != displays_.end(); ++iter) {
const gfx::Display& display = *iter;
- gfx::Rect intersect = display.bounds();
- intersect.Intersect(rect);
+ gfx::Rect intersect = gfx::IntersectRects(display.bounds(), rect);
int area = intersect.width() * intersect.height();
if (area > max) {
max = area;
diff --git a/ash/launcher/launcher_view_unittest.cc b/ash/launcher/launcher_view_unittest.cc
index 3e1e806..468e8f9 100644
--- a/ash/launcher/launcher_view_unittest.cc
+++ b/ash/launcher/launcher_view_unittest.cc
@@ -645,9 +645,8 @@ TEST_F(LauncherViewTest, ShouldHideTooltipTest) {
gfx::Rect app_button_rect = GetButtonByID(app_button_id)->GetMirroredBounds();
gfx::Rect tab_button_rect = GetButtonByID(tab_button_id)->GetMirroredBounds();
ASSERT_FALSE(app_button_rect.Intersects(tab_button_rect));
- gfx::Rect union_rect = app_button_rect;
- union_rect.Union(tab_button_rect);
- EXPECT_FALSE(launcher_view_->ShouldHideTooltip(union_rect.CenterPoint()));
+ EXPECT_FALSE(launcher_view_->ShouldHideTooltip(
+ gfx::UnionRects(app_button_rect, tab_button_rect).CenterPoint()));
// The tooltip should hide if it's outside of all buttons.
gfx::Rect all_area;
diff --git a/ash/system/drive/tray_drive.cc b/ash/system/drive/tray_drive.cc
index 489427e..d829dac 100644
--- a/ash/system/drive/tray_drive.cc
+++ b/ash/system/drive/tray_drive.cc
@@ -220,8 +220,8 @@ class DriveDetailedView : public TrayDetailsView,
kBottomPadding -
status_img_->GetPreferredSize().height())/2),
status_img_->GetPreferredSize());
- bounds_status.Intersect(child_area);
- status_img_->SetBoundsRect(bounds_status);
+ status_img_->SetBoundsRect(
+ gfx::IntersectRects(bounds_status, child_area));
pos_x += status_img_->bounds().width() + kHorizontalPadding;
gfx::Rect bounds_label(pos_x,
@@ -231,8 +231,8 @@ class DriveDetailedView : public TrayDetailsView,
status_img_->GetPreferredSize().width() -
cancel_button_->GetPreferredSize().width(),
label_container_->GetPreferredSize().height());
- bounds_label.Intersect(child_area);
- label_container_->SetBoundsRect(bounds_label);
+ label_container_->SetBoundsRect(
+ gfx::IntersectRects(bounds_label, child_area));
pos_x += label_container_->bounds().width() + kHorizontalPadding;
gfx::Rect bounds_button(
@@ -241,8 +241,8 @@ class DriveDetailedView : public TrayDetailsView,
kBottomPadding -
cancel_button_->GetPreferredSize().height())/2),
cancel_button_->GetPreferredSize());
- bounds_button.Intersect(child_area);
- cancel_button_->SetBoundsRect(bounds_button);
+ cancel_button_->SetBoundsRect(
+ gfx::IntersectRects(bounds_button, child_area));
}
// views::ButtonListener overrides.
diff --git a/ash/wm/partial_screenshot_view.cc b/ash/wm/partial_screenshot_view.cc
index dd0bd1da..a02ca7e 100644
--- a/ash/wm/partial_screenshot_view.cc
+++ b/ash/wm/partial_screenshot_view.cc
@@ -121,10 +121,9 @@ void PartialScreenshotView::OnMouseReleased(const ui::MouseEvent& event) {
is_dragging_ = false;
if (screenshot_delegate_) {
aura::RootWindow *root_window = Shell::GetPrimaryRootWindow();
- gfx::Rect root_window_screenshot_rect = root_window->bounds();
- root_window_screenshot_rect.Intersect(GetScreenshotRect());
screenshot_delegate_->HandleTakePartialScreenshot(
- root_window, root_window_screenshot_rect);
+ root_window,
+ gfx::IntersectRects(root_window->bounds(), GetScreenshotRect()));
}
}
diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc
index 4a7e9cc..67145f5 100644
--- a/ash/wm/workspace/workspace_window_resizer.cc
+++ b/ash/wm/workspace/workspace_window_resizer.cc
@@ -707,8 +707,8 @@ void WorkspaceWindowResizer::UpdateDragPhantomWindow(const gfx::Rect& bounds,
const gfx::Rect root_bounds_in_screen(another_root->GetBoundsInScreen());
const gfx::Rect bounds_in_screen =
ScreenAsh::ConvertRectToScreen(window()->parent(), bounds);
- gfx::Rect bounds_in_another_root = root_bounds_in_screen;
- bounds_in_another_root.Intersect(bounds_in_screen);
+ gfx::Rect bounds_in_another_root =
+ gfx::IntersectRects(root_bounds_in_screen, bounds_in_screen);
const float fraction_in_another_window =
(bounds_in_another_root.width() * bounds_in_another_root.height()) /
diff --git a/cc/delegated_renderer_layer_impl.cc b/cc/delegated_renderer_layer_impl.cc
index 693bd58..1ac5f0f 100644
--- a/cc/delegated_renderer_layer_impl.cc
+++ b/cc/delegated_renderer_layer_impl.cc
@@ -58,8 +58,7 @@ void DelegatedRendererLayerImpl::setRenderPasses(ScopedPtrVector<RenderPass>& re
if (!m_renderPassesInDrawOrder.isEmpty()) {
gfx::RectF newRootDamage = m_renderPassesInDrawOrder.last()->damageRect();
- newRootDamage.Union(oldRootDamage);
- m_renderPassesInDrawOrder.last()->setDamageRect(newRootDamage);
+ m_renderPassesInDrawOrder.last()->setDamageRect(gfx::UnionRects(oldRootDamage, newRootDamage));
}
}
diff --git a/cc/direct_renderer.cc b/cc/direct_renderer.cc
index ac3ea3c3..d534c1a 100644
--- a/cc/direct_renderer.cc
+++ b/cc/direct_renderer.cc
@@ -186,8 +186,7 @@ void DirectRenderer::drawRenderPass(DrawingFrame& frame, const RenderPass* rende
const QuadList& quadList = renderPass->quadList();
for (QuadList::constBackToFrontIterator it = quadList.backToFrontBegin(); it != quadList.backToFrontEnd(); ++it) {
- gfx::RectF quadScissorRect = frame.scissorRectInRenderPassSpace;
- quadScissorRect.Intersect((*it)->clippedRectInTarget());
+ gfx::RectF quadScissorRect = gfx::IntersectRects(frame.scissorRectInRenderPassSpace, (*it)->clippedRectInTarget());
if (!quadScissorRect.IsEmpty()) {
enableScissorTestRect(moveScissorToWindowSpace(frame, quadScissorRect));
drawQuad(frame, *it);
diff --git a/cc/draw_quad.cc b/cc/draw_quad.cc
index e350c69..13a1c45 100644
--- a/cc/draw_quad.cc
+++ b/cc/draw_quad.cc
@@ -43,8 +43,7 @@ gfx::Rect DrawQuad::opaqueRect() const
void DrawQuad::setQuadVisibleRect(gfx::Rect quadVisibleRect)
{
- m_quadVisibleRect = quadVisibleRect;
- m_quadVisibleRect.Intersect(m_quadRect);
+ m_quadVisibleRect = gfx::IntersectRects(quadVisibleRect, m_quadRect);
}
unsigned DrawQuad::size() const
diff --git a/cc/software_renderer.cc b/cc/software_renderer.cc
index 7781b55..52256cc 100644
--- a/cc/software_renderer.cc
+++ b/cc/software_renderer.cc
@@ -255,8 +255,7 @@ void SoftwareRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureD
// FIXME: Add support for non-premultiplied alpha.
ResourceProvider::ScopedReadLockSoftware quadResourceLock(m_resourceProvider, quad->resourceId());
- gfx::RectF uvRect = quad->uvRect();
- uvRect.Scale(quad->quadRect().width(), quad->quadRect().height());
+ gfx::RectF uvRect = gfx::ScaleRect(quad->uvRect(), quad->quadRect().width(), quad->quadRect().height());
SkIRect skUvRect = toSkIRect(gfx::ToEnclosingRect(uvRect));
if (quad->flipped())
m_skCurrentCanvas->scale(1, -1);
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc
index 61f6d3b..3d3279a 100644
--- a/chrome/browser/instant/instant_controller.cc
+++ b/chrome/browser/instant/instant_controller.cc
@@ -744,8 +744,7 @@ void InstantController::SendBoundsToPage() {
last_omnibox_bounds_ = omnibox_bounds_;
gfx::Rect preview_bounds = browser_->GetInstantBounds();
- gfx::Rect intersection = omnibox_bounds_;
- intersection.Intersect(preview_bounds);
+ gfx::Rect intersection = gfx::IntersectRects(omnibox_bounds_, preview_bounds);
// Translate into window coordinates.
if (!intersection.IsEmpty()) {
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
index 5ba5bd1..0c2ef75 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
@@ -1497,8 +1497,8 @@ class BookmarkBarViewTest17 : public BookmarkBarViewEventTestBase {
// sure the click is always on the child menu.
gfx::Rect context_rect = context_menu->GetSubmenu()->GetBoundsInScreen();
gfx::Rect child_menu_rect = child_menu->GetBoundsInScreen();
- gfx::Rect clickable_rect = child_menu_rect;
- clickable_rect.Subtract(context_rect);
+ gfx::Rect clickable_rect =
+ gfx::SubtractRects(child_menu_rect, context_rect);
ASSERT_FALSE(clickable_rect.IsEmpty());
observer_.set_task(CreateEventTask(this, &BookmarkBarViewTest17::Step4));
MoveMouseAndPress(clickable_rect.CenterPoint(), ui_controls::RIGHT,
diff --git a/chrome/browser/ui/views/toolbar_view.cc b/chrome/browser/ui/views/toolbar_view.cc
index a8826e3..51beff2 100644
--- a/chrome/browser/ui/views/toolbar_view.cc
+++ b/chrome/browser/ui/views/toolbar_view.cc
@@ -444,8 +444,8 @@ void ToolbarView::LayoutForSearch() {
// Note that parent of |location_bar_container_| i.e. BrowserView can't clip
// its children, else it loses the 3D shadows.
gfx::Rect parent_rect = location_bar_container_->parent()->GetLocalBounds();
- gfx::Rect intersect_rect = parent_rect;
- intersect_rect.Intersect(location_container_bounds);
+ gfx::Rect intersect_rect =
+ gfx::IntersectRects(parent_rect, location_container_bounds);
// If the two bounds don't intersect, set bounds of |location_bar_container_|
// to 0.
location_bar_container_->SetBoundsRect(intersect_rect);
diff --git a/content/browser/renderer_host/backing_store_aura.cc b/content/browser/renderer_host/backing_store_aura.cc
index 5d1149a..82d78d7 100644
--- a/content/browser/renderer_host/backing_store_aura.cc
+++ b/content/browser/renderer_host/backing_store_aura.cc
@@ -91,9 +91,8 @@ void BackingStoreAura::PaintToBackingStore(
if (bitmap_rect.IsEmpty())
return;
- gfx::RectF scaled_bitmap_rect = bitmap_rect;
- scaled_bitmap_rect.Scale(scale_factor);
- gfx::Rect pixel_bitmap_rect = gfx::ToEnclosedRect(scaled_bitmap_rect);
+ gfx::Rect pixel_bitmap_rect = gfx::ToEnclosedRect(
+ gfx::ScaleRect(bitmap_rect, scale_factor));
const int width = pixel_bitmap_rect.width();
const int height = pixel_bitmap_rect.height();
@@ -113,19 +112,16 @@ void BackingStoreAura::PaintToBackingStore(
sk_bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
sk_bitmap.setPixels(dib->memory());
for (size_t i = 0; i < copy_rects.size(); i++) {
- gfx::RectF scaled_copy_rect = copy_rects[i];
- scaled_copy_rect.Scale(scale_factor);
- const gfx::Rect pixel_copy_rect = gfx::ToEnclosingRect(scaled_copy_rect);
+ const gfx::Rect pixel_copy_rect = gfx::ToEnclosingRect(
+ gfx::ScaleRect(copy_rects[i], scale_factor));
int x = pixel_copy_rect.x() - pixel_bitmap_rect.x();
int y = pixel_copy_rect.y() - pixel_bitmap_rect.y();
SkIRect srcrect = SkIRect::MakeXYWH(x, y,
pixel_copy_rect.width(),
pixel_copy_rect.height());
- gfx::RectF scaled_copy_dst_rect = copy_rects[i];
- scaled_copy_dst_rect.Scale(device_scale_factor_);
- const gfx::Rect pixel_copy_dst_rect =
- gfx::ToEnclosingRect(scaled_copy_dst_rect);
+ const gfx::Rect pixel_copy_dst_rect = gfx::ToEnclosingRect(
+ gfx::ScaleRect(copy_rects[i], device_scale_factor_));
SkRect dstrect = SkRect::MakeXYWH(
SkIntToScalar(pixel_copy_dst_rect.x()),
SkIntToScalar(pixel_copy_dst_rect.y()),
@@ -138,9 +134,8 @@ void BackingStoreAura::PaintToBackingStore(
void BackingStoreAura::ScrollBackingStore(int dx, int dy,
const gfx::Rect& clip_rect,
const gfx::Size& view_size) {
- gfx::RectF scaled_clip_rect = clip_rect;
- scaled_clip_rect.Scale(device_scale_factor_);
- gfx::Rect pixel_rect = gfx::ToEnclosingRect(scaled_clip_rect);
+ gfx::Rect pixel_rect = gfx::ToEnclosingRect(
+ gfx::ScaleRect(clip_rect, device_scale_factor_));
int pixel_dx = dx * device_scale_factor_;
int pixel_dy = dy * device_scale_factor_;
diff --git a/content/browser/renderer_host/backing_store_mac.mm b/content/browser/renderer_host/backing_store_mac.mm
index 8ae91f5..66095ca 100644
--- a/content/browser/renderer_host/backing_store_mac.mm
+++ b/content/browser/renderer_host/backing_store_mac.mm
@@ -90,9 +90,8 @@ void BackingStoreMac::PaintToBackingStore(
gfx::Size pixel_size = gfx::ToFlooredSize(
size().Scale(device_scale_factor_));
- gfx::RectF scaled_bitmap_rect = bitmap_rect;
- scaled_bitmap_rect.Scale(scale_factor);
- gfx::Rect pixel_bitmap_rect = ToFlooredRectDeprecated(scaled_bitmap_rect);
+ gfx::Rect pixel_bitmap_rect = ToFlooredRectDeprecated(
+ gfx::ScaleRect(bitmap_rect, scale_factor));
size_t bitmap_byte_count =
pixel_bitmap_rect.width() * pixel_bitmap_rect.height() * 4;
@@ -111,9 +110,8 @@ void BackingStoreMac::PaintToBackingStore(
for (size_t i = 0; i < copy_rects.size(); i++) {
const gfx::Rect& copy_rect = copy_rects[i];
- gfx::RectF scaled_copy_rect = copy_rect;
- scaled_copy_rect.Scale(scale_factor);
- gfx::Rect pixel_copy_rect = ToFlooredRectDeprecated(scaled_copy_rect);
+ gfx::Rect pixel_copy_rect = ToFlooredRectDeprecated(
+ gfx::ScaleRect(copy_rect, scale_factor));
// Only the subpixels given by copy_rect have pixels to copy.
base::mac::ScopedCFTypeRef<CGImageRef> image(
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index 6987fcc..e64076e 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -587,8 +587,7 @@ void RenderWidgetHostViewAura::DidUpdateBackingStore(
SchedulePaintIfNotInClip(scroll_rect, clip_rect);
for (size_t i = 0; i < copy_rects.size(); ++i) {
- gfx::Rect rect = copy_rects[i];
- rect.Subtract(scroll_rect);
+ gfx::Rect rect = gfx::SubtractRects(copy_rects[i], scroll_rect);
if (rect.IsEmpty())
continue;
@@ -1193,8 +1192,8 @@ gfx::Rect RenderWidgetHostViewAura::ConvertRectToScreen(const gfx::Rect& rect) {
}
gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() {
- gfx::Rect rect = selection_start_rect_;
- rect.Union(selection_end_rect_);
+ const gfx::Rect rect =
+ gfx::UnionRects(selection_start_rect_, selection_end_rect_);
return ConvertRectToScreen(rect);
}
@@ -1838,8 +1837,7 @@ void RenderWidgetHostViewAura::SchedulePaintIfNotInClip(
const gfx::Rect& rect,
const gfx::Rect& clip) {
if (!clip.IsEmpty()) {
- gfx::Rect to_paint = rect;
- to_paint.Subtract(clip);
+ gfx::Rect to_paint = gfx::SubtractRects(rect, clip);
if (!to_paint.IsEmpty())
window_->SchedulePaintInRect(to_paint);
} else {
diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.cc b/content/browser/renderer_host/render_widget_host_view_gtk.cc
index b429496..8491663 100644
--- a/content/browser/renderer_host/render_widget_host_view_gtk.cc
+++ b/content/browser/renderer_host/render_widget_host_view_gtk.cc
@@ -865,8 +865,7 @@ void RenderWidgetHostViewGtk::DidUpdateBackingStore(
for (size_t i = 0; i < copy_rects.size(); ++i) {
// Avoid double painting. NOTE: This is only relevant given the call to
// Paint(scroll_rect) above.
- gfx::Rect rect = copy_rects[i];
- rect.Subtract(scroll_rect);
+ gfx::Rect rect = gfx::SubtractRects(copy_rects[i], scroll_rect);
if (rect.IsEmpty())
continue;
@@ -969,9 +968,7 @@ void RenderWidgetHostViewGtk::SelectionBoundsChanged(
WebKit::WebTextDirection start_direction,
const gfx::Rect& end_rect,
WebKit::WebTextDirection end_direction) {
- gfx::Rect combined_rect = start_rect;
- combined_rect.Union(end_rect);
- im_context_->UpdateCaretBounds(combined_rect);
+ im_context_->UpdateCaretBounds(gfx::UnionRects(start_rect, end_rect));
}
GdkEventButton* RenderWidgetHostViewGtk::GetLastMouseDown() {
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 8e49716..94c9d0f 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -859,9 +859,8 @@ void RenderWidgetHostViewMac::CopyFromCompositingSurface(
gfx::Rect src_gl_subrect = src_subrect;
src_gl_subrect.set_y(GetViewBounds().height() - src_subrect.bottom());
- gfx::RectF scaled_src_gl_subrect = src_gl_subrect;
- scaled_src_gl_subrect.Scale(scale);
- gfx::Rect src_pixel_gl_subrect = gfx::ToEnclosingRect(scaled_src_gl_subrect);
+ gfx::Rect src_pixel_gl_subrect = gfx::ToEnclosingRect(
+ gfx::ScaleRect(src_gl_subrect, scale));
compositing_iosurface_->CopyTo(
src_pixel_gl_subrect,
dst_pixel_size,
@@ -2278,8 +2277,7 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) {
// smaller and the renderer hasn't yet repainted.
int yOffset = NSHeight([self bounds]) - backingStore->size().height();
- gfx::Rect paintRect = bitmapRect;
- paintRect.Intersect(damagedRect);
+ gfx::Rect paintRect = gfx::IntersectRects(bitmapRect, damagedRect);
if (!paintRect.IsEmpty()) {
// if we have a CGLayer, draw that into the window
if (backingStore->cg_layer()) {
diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc
index 33d9832..4438f1d 100644
--- a/content/browser/renderer_host/render_widget_host_view_win.cc
+++ b/content/browser/renderer_host/render_widget_host_view_win.cc
@@ -777,8 +777,7 @@ void RenderWidgetHostViewWin::SelectionBoundsChanged(
text_input_type_ != ui::TEXT_INPUT_TYPE_PASSWORD);
// Only update caret position if the input method is enabled.
if (is_enabled) {
- caret_rect_ = start_rect;
- caret_rect_.Union(end_rect);
+ caret_rect_ = gfx::UnionRects(start_rect, end_rect);
ime_input_.UpdateCaretRect(m_hWnd, caret_rect_);
}
}
@@ -1364,8 +1363,8 @@ void RenderWidgetHostViewWin::OnPaint(HDC unused_dc) {
}
for (DWORD i = 0; i < region_data->rdh.nCount; ++i) {
- gfx::Rect paint_rect = bitmap_rect;
- paint_rect.Intersect(gfx::Rect(region_rects[i]));
+ gfx::Rect paint_rect =
+ gfx::IntersectRects(bitmap_rect, gfx::Rect(region_rects[i]));
if (!paint_rect.IsEmpty()) {
BitBlt(paint_dc.m_hDC,
paint_rect.x(),
diff --git a/content/common/gpu/image_transport_surface.cc b/content/common/gpu/image_transport_surface.cc
index 47bb204..d5c1aff 100644
--- a/content/common/gpu/image_transport_surface.cc
+++ b/content/common/gpu/image_transport_surface.cc
@@ -32,8 +32,8 @@ void ImageTransportSurface::GetRegionsToCopy(
const gfx::Rect& previous_damage_rect,
const gfx::Rect& new_damage_rect,
std::vector<gfx::Rect>* regions) {
- gfx::Rect intersection = previous_damage_rect;
- intersection.Intersect(new_damage_rect);
+ gfx::Rect intersection =
+ gfx::IntersectRects(previous_damage_rect, new_damage_rect);
if (intersection.IsEmpty()) {
regions->push_back(previous_damage_rect);
diff --git a/content/renderer/browser_plugin/browser_plugin_backing_store.cc b/content/renderer/browser_plugin/browser_plugin_backing_store.cc
index d54a186..210b6f5 100644
--- a/content/renderer/browser_plugin/browser_plugin_backing_store.cc
+++ b/content/renderer/browser_plugin/browser_plugin_backing_store.cc
@@ -37,10 +37,8 @@ void BrowserPluginBackingStore::PaintToBackingStore(
if (bitmap_rect.IsEmpty())
return;
- gfx::RectF scaled_bitmap_rect = bitmap_rect;
- scaled_bitmap_rect.Scale(scale_factor_);
- gfx::Rect pixel_bitmap_rect =
- gfx::ToFlooredRectDeprecated(scaled_bitmap_rect);
+ gfx::Rect pixel_bitmap_rect = gfx::ToFlooredRectDeprecated(
+ gfx::ScaleRect(bitmap_rect, scale_factor_));
const int width = pixel_bitmap_rect.width();
const int height = pixel_bitmap_rect.height();
@@ -59,9 +57,8 @@ void BrowserPluginBackingStore::PaintToBackingStore(
sk_bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
sk_bitmap.setPixels(dib->memory());
for (size_t i = 0; i < copy_rects.size(); i++) {
- gfx::RectF scaled_copy_rect = copy_rects[i];
- scaled_copy_rect.Scale(scale_factor_);
- const gfx::Rect& pixel_copy_rect = gfx::ToEnclosingRect(scaled_copy_rect);
+ const gfx::Rect& pixel_copy_rect = gfx::ToEnclosingRect(
+ gfx::ScaleRect(copy_rects[i], scale_factor_));
int x = pixel_copy_rect.x() - pixel_bitmap_rect.x();
int y = pixel_copy_rect.y() - pixel_bitmap_rect.y();
SkIRect srcrect = SkIRect::MakeXYWH(x, y,
@@ -82,9 +79,8 @@ void BrowserPluginBackingStore::ScrollBackingStore(
int dy,
const gfx::Rect& clip_rect,
const gfx::Size& view_size) {
- gfx::RectF scaled_clip_rect = clip_rect;
- scaled_clip_rect.Scale(scale_factor_);
- gfx::Rect pixel_rect = gfx::ToEnclosingRect(scaled_clip_rect);
+ gfx::Rect pixel_rect = gfx::ToEnclosingRect(
+ gfx::ScaleRect(clip_rect, scale_factor_));
int pixel_dx = dx * scale_factor_;
int pixel_dy = dy * scale_factor_;
diff --git a/content/renderer/paint_aggregator.cc b/content/renderer/paint_aggregator.cc
index 5ed988e..949e349 100644
--- a/content/renderer/paint_aggregator.cc
+++ b/content/renderer/paint_aggregator.cc
@@ -77,8 +77,7 @@ gfx::Rect PaintAggregator::PendingUpdate::GetScrollDamage() const {
}
// In case the scroll offset exceeds the width/height of the scroll rect
- damaged_rect.Intersect(scroll_rect);
- return damaged_rect;
+ return gfx::IntersectRects(scroll_rect, damaged_rect);
}
gfx::Rect PaintAggregator::PendingUpdate::GetPaintBounds() const {
@@ -123,8 +122,7 @@ void PaintAggregator::InvalidateRect(const gfx::Rect& rect) {
return;
if (rect.Intersects(existing_rect) || rect.SharesEdgeWith(existing_rect)) {
// Re-invalidate in case the union intersects other paint rects.
- gfx::Rect combined_rect = existing_rect;
- combined_rect.Union(rect);
+ gfx::Rect combined_rect = gfx::UnionRects(existing_rect, rect);
update_.paint_rects.erase(update_.paint_rects.begin() + i);
InvalidateRect(combined_rect);
return;
@@ -141,9 +139,8 @@ void PaintAggregator::InvalidateRect(const gfx::Rect& rect) {
if (ShouldInvalidateScrollRect(rect)) {
InvalidateScrollRect();
} else if (update_.scroll_rect.Contains(rect)) {
- gfx::Rect paint_rect = rect;
- paint_rect.Subtract(update_.GetScrollDamage());
- update_.paint_rects[update_.paint_rects.size() - 1] = paint_rect;
+ update_.paint_rects[update_.paint_rects.size() - 1] =
+ gfx::SubtractRects(rect, update_.GetScrollDamage());
if (update_.paint_rects[update_.paint_rects.size() - 1].IsEmpty())
update_.paint_rects.erase(update_.paint_rects.end() - 1);
}
diff --git a/content/renderer/paint_aggregator_unittest.cc b/content/renderer/paint_aggregator_unittest.cc
index 7261822..5e0ec86 100644
--- a/content/renderer/paint_aggregator_unittest.cc
+++ b/content/renderer/paint_aggregator_unittest.cc
@@ -37,8 +37,7 @@ TEST(PaintAggregator, DoubleDisjointInvalidation) {
greg.InvalidateRect(r1);
greg.InvalidateRect(r2);
- gfx::Rect expected_bounds = r1;
- expected_bounds.Union(r2);
+ gfx::Rect expected_bounds = gfx::UnionRects(r1, r2);
EXPECT_TRUE(greg.HasPendingUpdate());
PaintAggregator::PendingUpdate update;
@@ -62,8 +61,7 @@ TEST(PaintAggregator, DisjointInvalidationsCombined) {
greg.InvalidateRect(r1);
greg.InvalidateRect(r2);
- gfx::Rect expected_bounds = r1;
- expected_bounds.Union(r2);
+ gfx::Rect expected_bounds = gfx::UnionRects(r1, r2);
EXPECT_TRUE(greg.HasPendingUpdate());
PaintAggregator::PendingUpdate update;
@@ -279,8 +277,7 @@ TEST(PaintAggregator, OverlappingPaintBeforeScroll) {
gfx::Rect scroll_rect(0, 0, 10, 10);
greg.ScrollRect(2, 0, scroll_rect);
- gfx::Rect expected_paint_rect = scroll_rect;
- expected_paint_rect.Union(paint_rect);
+ gfx::Rect expected_paint_rect = gfx::UnionRects(scroll_rect, paint_rect);
EXPECT_TRUE(greg.HasPendingUpdate());
PaintAggregator::PendingUpdate update;
@@ -301,8 +298,7 @@ TEST(PaintAggregator, OverlappingPaintAfterScroll) {
gfx::Rect paint_rect(4, 4, 10, 2);
greg.InvalidateRect(paint_rect);
- gfx::Rect expected_paint_rect = scroll_rect;
- expected_paint_rect.Union(paint_rect);
+ gfx::Rect expected_paint_rect = gfx::UnionRects(scroll_rect, paint_rect);
EXPECT_TRUE(greg.HasPendingUpdate());
PaintAggregator::PendingUpdate update;
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index f5e90eb..d14aea8 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -375,13 +375,11 @@ void RenderWidget::OnChangeResizeRect(const gfx::Rect& resizer_rect) {
if (resizer_rect_ != resizer_rect) {
gfx::Rect view_rect(size_);
- gfx::Rect old_damage_rect = view_rect;
- old_damage_rect.Intersect(resizer_rect_);
+ gfx::Rect old_damage_rect = gfx::IntersectRects(view_rect, resizer_rect_);
if (!old_damage_rect.IsEmpty())
paint_aggregator_.InvalidateRect(old_damage_rect);
- gfx::Rect new_damage_rect = view_rect;
- new_damage_rect.Intersect(resizer_rect);
+ gfx::Rect new_damage_rect = gfx::IntersectRects(view_rect, resizer_rect);
if (!new_damage_rect.IsEmpty())
paint_aggregator_.InvalidateRect(new_damage_rect);
@@ -949,8 +947,7 @@ void RenderWidget::DoDeferredUpdate() {
paint_aggregator_.PopPendingUpdate(&update);
gfx::Rect scroll_damage = update.GetScrollDamage();
- gfx::Rect bounds = update.GetPaintBounds();
- bounds.Union(scroll_damage);
+ gfx::Rect bounds = gfx::UnionRects(update.GetPaintBounds(), scroll_damage);
// Notify derived classes that we're about to initiate a paint.
WillInitiatePaint();
@@ -996,10 +993,8 @@ void RenderWidget::DoDeferredUpdate() {
pending_update_params_->scale_factor = dib_scale_factor;
} else if (!is_accelerated_compositing_active_) {
// Compute a buffer for painting and cache it.
- gfx::RectF scaled_bounds = bounds;
- scaled_bounds.Scale(device_scale_factor_);
- gfx::Rect pixel_bounds =
- gfx::ToFlooredRectDeprecated(scaled_bounds);
+ gfx::Rect pixel_bounds = gfx::ToFlooredRectDeprecated(
+ gfx::ScaleRect(bounds, device_scale_factor_));
scoped_ptr<skia::PlatformCanvas> canvas(
RenderProcess::current()->GetDrawingCanvas(&current_paint_buf_,
pixel_bounds));
@@ -1079,8 +1074,7 @@ void RenderWidget::didInvalidateRect(const WebRect& rect) {
"width", rect.width, "height", rect.height);
// The invalidated rect might be outside the bounds of the view.
gfx::Rect view_rect(size_);
- gfx::Rect damaged_rect = view_rect;
- damaged_rect.Intersect(rect);
+ gfx::Rect damaged_rect = gfx::IntersectRects(view_rect, rect);
if (damaged_rect.IsEmpty())
return;
@@ -1120,8 +1114,7 @@ void RenderWidget::didScrollRect(int dx, int dy, const WebRect& clip_rect) {
// The scrolled rect might be outside the bounds of the view.
gfx::Rect view_rect(size_);
- gfx::Rect damaged_rect = view_rect;
- damaged_rect.Intersect(clip_rect);
+ gfx::Rect damaged_rect = gfx::IntersectRects(view_rect, clip_rect);
if (damaged_rect.IsEmpty())
return;
diff --git a/content/renderer/webplugin_delegate_proxy.cc b/content/renderer/webplugin_delegate_proxy.cc
index 31365aa..5e5bf67 100644
--- a/content/renderer/webplugin_delegate_proxy.cc
+++ b/content/renderer/webplugin_delegate_proxy.cc
@@ -739,8 +739,7 @@ void WebPluginDelegateProxy::Paint(WebKit::WebCanvas* canvas,
const gfx::Rect& damaged_rect) {
// Limit the damaged rectangle to whatever is contained inside the plugin
// rectangle, as that's the rectangle that we'll actually draw.
- gfx::Rect rect = damaged_rect;
- rect.Intersect(plugin_rect_);
+ gfx::Rect rect = gfx::IntersectRects(damaged_rect, plugin_rect_);
// If the plugin is no longer connected (channel crashed) draw a crashed
// plugin bitmap
@@ -854,8 +853,7 @@ bool WebPluginDelegateProxy::BackgroundChanged(
// intersect their rects first.
gfx::Rect bitmap_rect(static_cast<int>(-xf.eDx), static_cast<int>(-xf.eDy),
bitmap.bmWidth, bitmap.bmHeight);
- gfx::Rect check_rect = rect;
- check_rect.Intersect(bitmap_rect);
+ gfx::Rect check_rect = gfx::IntersectRects(rect, bitmap_rect);
int row_byte_size = check_rect.width() * (bitmap.bmBitsPixel / 8);
for (int y = check_rect.y(); y < check_rect.bottom(); y++) {
char* hdc_row_start = static_cast<char*>(bitmap.bmBits) +
@@ -900,8 +898,7 @@ bool WebPluginDelegateProxy::BackgroundChanged(
#endif
// According to comments in the Windows code, the damage rect that we're given
// may project outside the image, so intersect their rects.
- gfx::Rect content_rect = rect;
- content_rect.Intersect(full_content_rect);
+ gfx::Rect content_rect = gfx::IntersectRects(rect, full_content_rect);
#if defined(OS_MACOSX)
const unsigned char* page_bytes = static_cast<const unsigned char*>(
@@ -1191,8 +1188,8 @@ void WebPluginDelegateProxy::OnInvalidateRect(const gfx::Rect& rect) {
// Clip the invalidation rect to the plugin bounds; the plugin may have been
// resized since the invalidate message was sent.
- gfx::Rect clipped_rect = rect;
- clipped_rect.Intersect(gfx::Rect(plugin_rect_.size()));
+ gfx::Rect clipped_rect =
+ gfx::IntersectRects(rect, gfx::Rect(plugin_rect_.size()));
invalidate_pending_ = true;
// The plugin is blocked on the renderer because the invalidate message it has
diff --git a/ui/app_list/page_switcher.cc b/ui/app_list/page_switcher.cc
index ba98671..1517d39 100644
--- a/ui/app_list/page_switcher.cc
+++ b/ui/app_list/page_switcher.cc
@@ -189,8 +189,7 @@ void PageSwitcher::Layout() {
rect.y(),
buttons_size.width(),
rect.height());
- rect.Intersect(buttons_bounds);
- buttons_->SetBoundsRect(rect);
+ buttons_->SetBoundsRect(gfx::IntersectRects(rect, buttons_bounds));
}
void PageSwitcher::CalculateButtonWidthAndSpacing(int contents_width) {
diff --git a/ui/app_list/search_result_view.cc b/ui/app_list/search_result_view.cc
index 7e4559d..eb6547d 100644
--- a/ui/app_list/search_result_view.cc
+++ b/ui/app_list/search_result_view.cc
@@ -200,8 +200,7 @@ void SearchResultView::OnPaint(gfx::Canvas* canvas) {
canvas->FillRect(content_rect, kHoverAndPushedColor);
}
- gfx::Rect border_bottom(rect);
- border_bottom.Subtract(content_rect);
+ gfx::Rect border_bottom = gfx::SubtractRects(rect, content_rect);
canvas->FillRect(border_bottom,
selected ? kSelectedBorderColor : kBorderColor);
diff --git a/ui/gfx/blit.cc b/ui/gfx/blit.cc
index 0c6e6b6..41da3f5 100644
--- a/ui/gfx/blit.cc
+++ b/ui/gfx/blit.cc
@@ -152,8 +152,8 @@ void ScrollCanvas(SkCanvas* canvas,
SkAutoLockPixels lock(bitmap);
// We expect all coords to be inside the canvas, so clip here.
- gfx::Rect clip = in_clip;
- clip.Intersect(gfx::Rect(0, 0, bitmap.width(), bitmap.height()));
+ gfx::Rect clip = gfx::IntersectRects(
+ in_clip, gfx::Rect(0, 0, bitmap.width(), bitmap.height()));
// Compute the set of pixels we'll actually end up painting.
gfx::Rect dest_rect = clip;
diff --git a/ui/gfx/image/image_skia_operations.cc b/ui/gfx/image/image_skia_operations.cc
index 029304b..a2395da 100644
--- a/ui/gfx/image/image_skia_operations.cc
+++ b/ui/gfx/image/image_skia_operations.cc
@@ -288,11 +288,9 @@ class ExtractSubsetImageSource: public gfx::ImageSkiaSource {
// gfx::ImageSkiaSource overrides:
virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE {
ImageSkiaRep image_rep = image_.GetRepresentation(scale_factor);
- gfx::RectF scaled_subset_bounds = subset_bounds_;
- scaled_subset_bounds.Scale(
- ui::GetScaleFactorScale(image_rep.scale_factor()));
- SkIRect subset_bounds_in_pixel = RectToSkIRect(
- ToFlooredRectDeprecated(scaled_subset_bounds));
+ float scale_to_pixel = ui::GetScaleFactorScale(image_rep.scale_factor());
+ SkIRect subset_bounds_in_pixel = RectToSkIRect(ToFlooredRectDeprecated(
+ gfx::ScaleRect(subset_bounds_, scale_to_pixel)));
SkBitmap dst;
bool success = image_rep.sk_bitmap().extractSubset(&dst,
subset_bounds_in_pixel);
@@ -432,8 +430,8 @@ ImageSkia ImageSkiaOperations::CreateButtonBackground(SkColor color,
// static
ImageSkia ImageSkiaOperations::ExtractSubset(const ImageSkia& image,
const Rect& subset_bounds) {
- gfx::Rect clipped_bounds = subset_bounds;
- clipped_bounds.Intersect(gfx::Rect(image.size()));
+ gfx::Rect clipped_bounds =
+ gfx::IntersectRects(subset_bounds, gfx::Rect(image.size()));
if (image.isNull() || clipped_bounds.IsEmpty()) {
return ImageSkia();
}
diff --git a/ui/gfx/rect.cc b/ui/gfx/rect.cc
index b46a9d7..551e6f6 100644
--- a/ui/gfx/rect.cc
+++ b/ui/gfx/rect.cc
@@ -88,4 +88,22 @@ std::string Rect::ToString() const {
size().ToString().c_str());
}
+Rect IntersectRects(const Rect& a, const Rect& b) {
+ Rect result = a;
+ result.Intersect(b);
+ return result;
+}
+
+Rect UnionRects(const Rect& a, const Rect& b) {
+ Rect result = a;
+ result.Union(b);
+ return result;
+}
+
+Rect SubtractRects(const Rect& a, const Rect& b) {
+ Rect result = a;
+ result.Subtract(b);
+ return result;
+}
+
} // namespace gfx
diff --git a/ui/gfx/rect.h b/ui/gfx/rect.h
index 2eab239..bf56896 100644
--- a/ui/gfx/rect.h
+++ b/ui/gfx/rect.h
@@ -75,6 +75,10 @@ inline bool operator!=(const Rect& lhs, const Rect& rhs) {
return !(lhs == rhs);
}
+UI_EXPORT Rect IntersectRects(const Rect& a, const Rect& b);
+UI_EXPORT Rect UnionRects(const Rect& a, const Rect& b);
+UI_EXPORT Rect SubtractRects(const Rect& a, const Rect& b);
+
#if !defined(COMPILER_MSVC)
extern template class RectBase<Rect, Point, Size, Insets, int>;
#endif
diff --git a/ui/gfx/rect_f.cc b/ui/gfx/rect_f.cc
index 8503924..6035391 100644
--- a/ui/gfx/rect_f.cc
+++ b/ui/gfx/rect_f.cc
@@ -42,4 +42,28 @@ std::string RectF::ToString() const {
size().ToString().c_str());
}
+RectF IntersectRects(const RectF& a, const RectF& b) {
+ RectF result = a;
+ result.Intersect(b);
+ return result;
+}
+
+RectF UnionRects(const RectF& a, const RectF& b) {
+ RectF result = a;
+ result.Union(b);
+ return result;
+}
+
+RectF SubtractRects(const RectF& a, const RectF& b) {
+ RectF result = a;
+ result.Subtract(b);
+ return result;
+}
+
+RectF ScaleRect(const RectF& r, float x_scale, float y_scale) {
+ RectF result = r;
+ result.Scale(x_scale, y_scale);
+ return result;
+}
+
} // namespace gfx
diff --git a/ui/gfx/rect_f.h b/ui/gfx/rect_f.h
index 4ee1098..8439eb1 100644
--- a/ui/gfx/rect_f.h
+++ b/ui/gfx/rect_f.h
@@ -49,6 +49,15 @@ inline bool operator!=(const RectF& lhs, const RectF& rhs) {
return !(lhs == rhs);
}
+UI_EXPORT RectF IntersectRects(const RectF& a, const RectF& b);
+UI_EXPORT RectF UnionRects(const RectF& a, const RectF& b);
+UI_EXPORT RectF SubtractRects(const RectF& a, const RectF& b);
+UI_EXPORT RectF ScaleRect(const RectF& r, float x_scale, float y_scale);
+
+inline RectF ScaleRect(const RectF& r, float scale) {
+ return ScaleRect(r, scale, scale);
+}
+
#if !defined(COMPILER_MSVC)
extern template class RectBase<RectF, PointF, SizeF, InsetsF, float>;
#endif
diff --git a/ui/gfx/rect_unittest.cc b/ui/gfx/rect_unittest.cc
index 6bdbb3b..b83d8a4 100644
--- a/ui/gfx/rect_unittest.cc
+++ b/ui/gfx/rect_unittest.cc
@@ -107,8 +107,7 @@ TEST(RectTest, Intersect) {
gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1);
gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2);
gfx::Rect r3(tests[i].x3, tests[i].y3, tests[i].w3, tests[i].h3);
- gfx::Rect ir = r1;
- ir.Intersect(r2);
+ gfx::Rect ir = gfx::IntersectRects(r1, r2);
EXPECT_EQ(r3.x(), ir.x());
EXPECT_EQ(r3.y(), ir.y());
EXPECT_EQ(r3.width(), ir.width());
@@ -157,8 +156,7 @@ TEST(RectTest, Union) {
gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1);
gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2);
gfx::Rect r3(tests[i].x3, tests[i].y3, tests[i].w3, tests[i].h3);
- gfx::Rect u = r1;
- u.Union(r2);
+ gfx::Rect u = gfx::UnionRects(r1, r2);
EXPECT_EQ(r3.x(), u.x());
EXPECT_EQ(r3.y(), u.y());
EXPECT_EQ(r3.width(), u.width());
@@ -446,8 +444,7 @@ TEST(RectTest, ScaleRect) {
gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1);
gfx::RectF r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2);
- gfx::RectF scaled = r1;
- scaled.Scale(tests[i].scale);
+ gfx::RectF scaled = gfx::ScaleRect(r1, tests[i].scale);
EXPECT_FLOAT_AND_NAN_EQ(r2.x(), scaled.x());
EXPECT_FLOAT_AND_NAN_EQ(r2.y(), scaled.y());
EXPECT_FLOAT_AND_NAN_EQ(r2.width(), scaled.width());
@@ -602,8 +599,7 @@ TEST(RectTest, ToRectF) {
gfx::Rect a(10, 20, 30, 40);
gfx::RectF b(10, 20, 30, 40);
- gfx::RectF intersect = b;
- intersect.Intersect(a);
+ gfx::RectF intersect = gfx::IntersectRects(a, b);
EXPECT_EQ(b.ToString(), intersect.ToString());
EXPECT_EQ(a, b);
diff --git a/ui/gfx/screen_gtk.cc b/ui/gfx/screen_gtk.cc
index f3c3b1b..5aefb15 100644
--- a/ui/gfx/screen_gtk.cc
+++ b/ui/gfx/screen_gtk.cc
@@ -157,8 +157,7 @@ class ScreenGtk : public gfx::Screen {
gfx::Display display(0, bounds);
gfx::Rect rect;
if (GetScreenWorkArea(&rect)) {
- bounds.Intersect(rect);
- display.set_work_area(bounds);
+ display.set_work_area(gfx::IntersectRects(rect, bounds));
} else {
// Return the best we've got.
display.set_work_area(bounds);
diff --git a/ui/gfx/screen_mac.mm b/ui/gfx/screen_mac.mm
index d3301f1..595ca3e 100644
--- a/ui/gfx/screen_mac.mm
+++ b/ui/gfx/screen_mac.mm
@@ -39,8 +39,7 @@ NSScreen* GetMatchingScreen(const gfx::Rect& match_rect) {
for (NSScreen* screen in [NSScreen screens]) {
gfx::Rect monitor_area = ConvertCoordinateSystem([screen frame]);
- gfx::Rect intersection = monitor_area;
- intersection.Intersect(match_rect);
+ gfx::Rect intersection = gfx::IntersectRects(monitor_area, match_rect);
int area = intersection.width() * intersection.height();
if (area > max_area) {
max_area = area;
diff --git a/ui/views/animation/bounds_animator.cc b/ui/views/animation/bounds_animator.cc
index 037b9d6..c064cc8 100644
--- a/ui/views/animation/bounds_animator.cc
+++ b/ui/views/animation/bounds_animator.cc
@@ -235,8 +235,7 @@ void BoundsAnimator::AnimationProgressed(const Animation* animation) {
gfx::Rect new_bounds =
animation->CurrentValueBetween(data.start_bounds, data.target_bounds);
if (new_bounds != view->bounds()) {
- gfx::Rect total_bounds = view->bounds();
- total_bounds.Union(new_bounds);
+ gfx::Rect total_bounds = gfx::UnionRects(new_bounds, view->bounds());
// Build up the region to repaint in repaint_bounds_. We'll do the repaint
// when all animations complete (in AnimationContainerProgressed).
diff --git a/ui/views/animation/bounds_animator_unittest.cc b/ui/views/animation/bounds_animator_unittest.cc
index 2dbfc48..c9431f8 100644
--- a/ui/views/animation/bounds_animator_unittest.cc
+++ b/ui/views/animation/bounds_animator_unittest.cc
@@ -129,8 +129,8 @@ TEST_F(BoundsAnimatorTest, AnimateViewTo) {
// The parent should have been told to repaint as the animation progressed.
// The resulting rect is the union of the original and target bounds.
- target_bounds.Union(initial_bounds);
- EXPECT_EQ(target_bounds, parent()->dirty_rect());
+ EXPECT_EQ(gfx::UnionRects(target_bounds, initial_bounds),
+ parent()->dirty_rect());
}
// Make sure an AnimationDelegate is deleted when canceled.
diff --git a/ui/views/widget/root_view.cc b/ui/views/widget/root_view.cc
index ec6dc50..706409c 100644
--- a/ui/views/widget/root_view.cc
+++ b/ui/views/widget/root_view.cc
@@ -191,8 +191,7 @@ void RootView::SchedulePaintInRect(const gfx::Rect& rect) {
layer()->SchedulePaint(rect);
} else {
gfx::Rect xrect = ConvertRectToParent(rect);
- gfx::Rect invalid_rect = GetLocalBounds();
- invalid_rect.Intersect(xrect);
+ gfx::Rect invalid_rect = gfx::IntersectRects(GetLocalBounds(), xrect);
if (!invalid_rect.IsEmpty())
widget_->SchedulePaintInRect(invalid_rect);
}
diff --git a/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc b/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc
index 869ea9f..382a975 100644
--- a/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc
+++ b/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc
@@ -355,8 +355,7 @@ void WebPluginDelegateImpl::WindowlessPaint(cairo_t* context,
// "real" means as seen by Chrome
// "apparent" means as seen by the plugin.
- gfx::Rect draw_rect = window_rect_;
- draw_rect.Intersect(damage_rect);
+ gfx::Rect draw_rect = gfx::IntersectRects(window_rect_, damage_rect);
// clip_rect_ is relative to the plugin
gfx::Rect clip_rect_window = clip_rect_;
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 0b858c6..c0c6c78 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -1174,14 +1174,12 @@ bool PluginInstance::GetBitmapForOptimizedPluginPaint(
gfx::Rect pixel_plugin_backing_store_rect(
0, 0, image_data->width(), image_data->height());
float scale = GetBoundGraphics2D()->GetScale();
- gfx::RectF scaled_backing_store_rect = pixel_plugin_backing_store_rect;
- scaled_backing_store_rect.Scale(scale);
- gfx::Rect plugin_backing_store_rect =
- gfx::ToEnclosedRect(scaled_backing_store_rect);
+ gfx::Rect plugin_backing_store_rect = gfx::ToEnclosedRect(
+ gfx::ScaleRect(pixel_plugin_backing_store_rect, scale));
gfx::Rect clip_page = PP_ToGfxRect(view_data_.clip_rect);
- gfx::Rect plugin_paint_rect = plugin_backing_store_rect;
- plugin_paint_rect.Intersect(clip_page);
+ gfx::Rect plugin_paint_rect =
+ gfx::IntersectRects(plugin_backing_store_rect, clip_page);
if (!plugin_paint_rect.Contains(relative_paint_bounds))
return false;
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
index 923b88d..aaad035 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
@@ -376,8 +376,7 @@ int32_t PPB_Graphics2D_Impl::Flush(scoped_refptr<TrackedCallback> callback,
// Set |no_update_visible| to false if the change overlaps the visible
// area.
- gfx::Rect visible_changed_rect = clip;
- visible_changed_rect.Intersect(op_rect);
+ gfx::Rect visible_changed_rect = gfx::IntersectRects(clip, op_rect);
if (!visible_changed_rect.IsEmpty())
no_update_visible = false;
@@ -561,8 +560,7 @@ void PPB_Graphics2D_Impl::Paint(WebKit::WebCanvas* canvas,
CGContextDrawImage(canvas, bitmap_rect, image);
#else
- gfx::Rect invalidate_rect = plugin_rect;
- invalidate_rect.Intersect(paint_rect);
+ gfx::Rect invalidate_rect = gfx::IntersectRects(plugin_rect, paint_rect);
SkRect sk_invalidate_rect = gfx::RectToSkRect(invalidate_rect);
SkAutoCanvasRestore auto_restore(canvas, true);
canvas->clipRect(sk_invalidate_rect);
@@ -649,20 +647,20 @@ bool PPB_Graphics2D_Impl::ConvertToLogicalPixels(float scale,
// Take the enclosing rectangle after scaling so a rectangle scaled down then
// scaled back up by the inverse scale would fully contain the entire area
// affected by the original rectangle.
- gfx::RectF scaled_rect = *op_rect;
- scaled_rect.Scale(scale);
- *op_rect = gfx::ToEnclosingRect(scaled_rect);
+ *op_rect = gfx::ToEnclosingRect(gfx::ScaleRect(*op_rect, scale));
if (delta) {
gfx::Point original_delta = *delta;
float inverse_scale = 1.0f / scale;
*delta = gfx::ToFlooredPoint(delta->Scale(scale));
- gfx::RectF inverse_scaled_rect = *op_rect;
- inverse_scaled_rect.Scale(inverse_scale);
- if (original_rect != gfx::ToEnclosingRect(inverse_scaled_rect) ||
- original_delta != gfx::ToFlooredPoint(delta->Scale(inverse_scale))) {
+ gfx::Rect inverse_scaled_rect =
+ gfx::ToEnclosingRect(gfx::ScaleRect(*op_rect, inverse_scale));
+ if (original_rect != inverse_scaled_rect)
+ return false;
+ gfx::Point inverse_scaled_point =
+ gfx::ToFlooredPoint(delta->Scale(inverse_scale));
+ if (original_delta != inverse_scaled_point)
return false;
- }
}
return true;
diff --git a/webkit/plugins/webview_plugin.cc b/webkit/plugins/webview_plugin.cc
index 9888b73..4e5c8c4 100644
--- a/webkit/plugins/webview_plugin.cc
+++ b/webkit/plugins/webview_plugin.cc
@@ -120,8 +120,7 @@ bool WebViewPlugin::getFormValue(WebString& value) {
}
void WebViewPlugin::paint(WebCanvas* canvas, const WebRect& rect) {
- gfx::Rect paintRect = rect_;
- paintRect.Intersect(rect);
+ gfx::Rect paintRect = gfx::IntersectRects(rect_, rect);
if (paintRect.IsEmpty())
return;