Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(477)

Side by Side Diff: ash/display/multi_display_manager.cc

Issue 11270042: Add non-member non-mutating methods for common gfx::Rect operations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ash/launcher/launcher_view_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/display/multi_display_manager.h" 5 #include "ash/display/multi_display_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/display/display_controller.h" 10 #include "ash/display/display_controller.h"
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 const gfx::Display& MultiDisplayManager::GetDisplayMatching( 353 const gfx::Display& MultiDisplayManager::GetDisplayMatching(
354 const gfx::Rect& rect) const { 354 const gfx::Rect& rect) const {
355 if (rect.IsEmpty()) 355 if (rect.IsEmpty())
356 return GetDisplayNearestPoint(rect.origin()); 356 return GetDisplayNearestPoint(rect.origin());
357 357
358 int max = 0; 358 int max = 0;
359 const gfx::Display* matching = 0; 359 const gfx::Display* matching = 0;
360 for (std::vector<gfx::Display>::const_iterator iter = displays_.begin(); 360 for (std::vector<gfx::Display>::const_iterator iter = displays_.begin();
361 iter != displays_.end(); ++iter) { 361 iter != displays_.end(); ++iter) {
362 const gfx::Display& display = *iter; 362 const gfx::Display& display = *iter;
363 gfx::Rect intersect = display.bounds(); 363 gfx::Rect intersect = gfx::IntersectRects(display.bounds(), rect);
364 intersect.Intersect(rect);
365 int area = intersect.width() * intersect.height(); 364 int area = intersect.width() * intersect.height();
366 if (area > max) { 365 if (area > max) {
367 max = area; 366 max = area;
368 matching = &(*iter); 367 matching = &(*iter);
369 } 368 }
370 } 369 }
371 // Fallback to the primary display if there is no matching display. 370 // Fallback to the primary display if there is no matching display.
372 return matching ? *matching : DisplayController::GetPrimaryDisplay(); 371 return matching ? *matching : DisplayController::GetPrimaryDisplay();
373 } 372 }
374 373
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 DisplayList::iterator iter_to_update = to_update->begin(); 545 DisplayList::iterator iter_to_update = to_update->begin();
547 DisplayList::const_iterator iter = displays_.begin(); 546 DisplayList::const_iterator iter = displays_.begin();
548 for (; iter != displays_.end() && iter_to_update != to_update->end(); 547 for (; iter != displays_.end() && iter_to_update != to_update->end();
549 ++iter, ++iter_to_update) { 548 ++iter, ++iter_to_update) {
550 (*iter_to_update).set_id((*iter).id()); 549 (*iter_to_update).set_id((*iter).id());
551 } 550 }
552 } 551 }
553 552
554 } // namespace internal 553 } // namespace internal
555 } // namespace ash 554 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/launcher/launcher_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698