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

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: 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') | ui/gfx/rect.h » ('J')
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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 const gfx::Display& MultiDisplayManager::GetDisplayMatching( 342 const gfx::Display& MultiDisplayManager::GetDisplayMatching(
343 const gfx::Rect& rect) const { 343 const gfx::Rect& rect) const {
344 if (rect.IsEmpty()) 344 if (rect.IsEmpty())
345 return GetDisplayNearestPoint(rect.origin()); 345 return GetDisplayNearestPoint(rect.origin());
346 346
347 int max = 0; 347 int max = 0;
348 const gfx::Display* matching = 0; 348 const gfx::Display* matching = 0;
349 for (std::vector<gfx::Display>::const_iterator iter = displays_.begin(); 349 for (std::vector<gfx::Display>::const_iterator iter = displays_.begin();
350 iter != displays_.end(); ++iter) { 350 iter != displays_.end(); ++iter) {
351 const gfx::Display& display = *iter; 351 const gfx::Display& display = *iter;
352 gfx::Rect intersect = display.bounds(); 352 gfx::Rect intersect = gfx::Intersection(display.bounds(), rect);
353 intersect.Intersect(rect);
354 int area = intersect.width() * intersect.height(); 353 int area = intersect.width() * intersect.height();
355 if (area > max) { 354 if (area > max) {
356 max = area; 355 max = area;
357 matching = &(*iter); 356 matching = &(*iter);
358 } 357 }
359 } 358 }
360 // Fallback to the primary display if there is no matching display. 359 // Fallback to the primary display if there is no matching display.
361 return matching ? *matching : DisplayController::GetPrimaryDisplay(); 360 return matching ? *matching : DisplayController::GetPrimaryDisplay();
362 } 361 }
363 362
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 DisplayList::iterator iter_to_update = to_update->begin(); 498 DisplayList::iterator iter_to_update = to_update->begin();
500 DisplayList::const_iterator iter = displays_.begin(); 499 DisplayList::const_iterator iter = displays_.begin();
501 for (; iter != displays_.end() && iter_to_update != to_update->end(); 500 for (; iter != displays_.end() && iter_to_update != to_update->end();
502 ++iter, ++iter_to_update) { 501 ++iter, ++iter_to_update) {
503 (*iter_to_update).set_id((*iter).id()); 502 (*iter_to_update).set_id((*iter).id());
504 } 503 }
505 } 504 }
506 505
507 } // namespace internal 506 } // namespace internal
508 } // namespace ash 507 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/launcher/launcher_view_unittest.cc » ('j') | ui/gfx/rect.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698