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

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

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months 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
« no previous file with comments | « ash/dip_unittest.cc ('k') | ash/display/display_change_observer_chromeos.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/cursor_window_controller.h" 5 #include "ash/display/cursor_window_controller.h"
6 6
7 #include "ash/common/shell_window_ids.h" 7 #include "ash/common/shell_window_ids.h"
8 #include "ash/display/display_manager.h" 8 #include "ash/display/display_manager.h"
9 #include "ash/display/mirror_window_controller.h" 9 #include "ash/display/mirror_window_controller.h"
10 #include "ash/display/window_tree_host_manager.h" 10 #include "ash/display/window_tree_host_manager.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 DISALLOW_COPY_AND_ASSIGN(CursorWindowDelegate); 78 DISALLOW_COPY_AND_ASSIGN(CursorWindowDelegate);
79 }; 79 };
80 80
81 CursorWindowController::CursorWindowController() 81 CursorWindowController::CursorWindowController()
82 : is_cursor_compositing_enabled_(false), 82 : is_cursor_compositing_enabled_(false),
83 container_(NULL), 83 container_(NULL),
84 cursor_type_(ui::kCursorNone), 84 cursor_type_(ui::kCursorNone),
85 visible_(true), 85 visible_(true),
86 cursor_set_(ui::CURSOR_SET_NORMAL), 86 cursor_set_(ui::CURSOR_SET_NORMAL),
87 delegate_(new CursorWindowDelegate()) { 87 delegate_(new CursorWindowDelegate()) {}
88 }
89 88
90 CursorWindowController::~CursorWindowController() { 89 CursorWindowController::~CursorWindowController() {
91 SetContainer(NULL); 90 SetContainer(NULL);
92 } 91 }
93 92
94 void CursorWindowController::SetCursorCompositingEnabled(bool enabled) { 93 void CursorWindowController::SetCursorCompositingEnabled(bool enabled) {
95 if (is_cursor_compositing_enabled_ != enabled) { 94 if (is_cursor_compositing_enabled_ != enabled) {
96 is_cursor_compositing_enabled_ = enabled; 95 is_cursor_compositing_enabled_ = enabled;
97 if (display_.is_valid()) 96 if (display_.is_valid())
98 UpdateCursorImage(); 97 UpdateCursorImage();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 return; 131 return;
133 } 132 }
134 133
135 display_ = display; 134 display_ = display;
136 aura::Window* root_window = Shell::GetInstance() 135 aura::Window* root_window = Shell::GetInstance()
137 ->window_tree_host_manager() 136 ->window_tree_host_manager()
138 ->GetRootWindowForDisplayId(display.id()); 137 ->GetRootWindowForDisplayId(display.id());
139 if (!root_window) 138 if (!root_window)
140 return; 139 return;
141 140
142 SetContainer(GetRootWindowController(root_window)->GetContainer( 141 SetContainer(GetRootWindowController(root_window)
143 kShellWindowId_MouseCursorContainer)); 142 ->GetContainer(kShellWindowId_MouseCursorContainer));
144 SetBoundsInScreen(display.bounds()); 143 SetBoundsInScreen(display.bounds());
145 // Updates the hot point based on the current display. 144 // Updates the hot point based on the current display.
146 UpdateCursorImage(); 145 UpdateCursorImage();
147 } 146 }
148 147
149 void CursorWindowController::UpdateLocation() { 148 void CursorWindowController::UpdateLocation() {
150 if (!cursor_window_) 149 if (!cursor_window_)
151 return; 150 return;
152 gfx::Point point = aura::Env::GetInstance()->last_mouse_location(); 151 gfx::Point point = aura::Env::GetInstance()->last_mouse_location();
153 if (!is_cursor_compositing_enabled_) { 152 if (!is_cursor_compositing_enabled_) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 const gfx::ImageSkia* image = 231 const gfx::ImageSkia* image =
233 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id); 232 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id);
234 if (!is_cursor_compositing_enabled_) { 233 if (!is_cursor_compositing_enabled_) {
235 gfx::ImageSkia rotated = *image; 234 gfx::ImageSkia rotated = *image;
236 switch (display_.rotation()) { 235 switch (display_.rotation()) {
237 case display::Display::ROTATE_0: 236 case display::Display::ROTATE_0:
238 break; 237 break;
239 case display::Display::ROTATE_90: 238 case display::Display::ROTATE_90:
240 rotated = gfx::ImageSkiaOperations::CreateRotatedImage( 239 rotated = gfx::ImageSkiaOperations::CreateRotatedImage(
241 *image, SkBitmapOperations::ROTATION_90_CW); 240 *image, SkBitmapOperations::ROTATION_90_CW);
242 hot_point_.SetPoint( 241 hot_point_.SetPoint(rotated.width() - hot_point_.y(), hot_point_.x());
243 rotated.width() - hot_point_.y(),
244 hot_point_.x());
245 break; 242 break;
246 case display::Display::ROTATE_180: 243 case display::Display::ROTATE_180:
247 rotated = gfx::ImageSkiaOperations::CreateRotatedImage( 244 rotated = gfx::ImageSkiaOperations::CreateRotatedImage(
248 *image, SkBitmapOperations::ROTATION_180_CW); 245 *image, SkBitmapOperations::ROTATION_180_CW);
249 hot_point_.SetPoint( 246 hot_point_.SetPoint(rotated.height() - hot_point_.x(),
250 rotated.height() - hot_point_.x(), 247 rotated.width() - hot_point_.y());
251 rotated.width() - hot_point_.y());
252 break; 248 break;
253 case display::Display::ROTATE_270: 249 case display::Display::ROTATE_270:
254 rotated = gfx::ImageSkiaOperations::CreateRotatedImage( 250 rotated = gfx::ImageSkiaOperations::CreateRotatedImage(
255 *image, SkBitmapOperations::ROTATION_270_CW); 251 *image, SkBitmapOperations::ROTATION_270_CW);
256 hot_point_.SetPoint( 252 hot_point_.SetPoint(hot_point_.y(), rotated.height() - hot_point_.x());
257 hot_point_.y(),
258 rotated.height() - hot_point_.x());
259 break; 253 break;
260 } 254 }
261 // Note that mirror window's scale factor is always 1.0f, therefore we 255 // Note that mirror window's scale factor is always 1.0f, therefore we
262 // need to take 2x's image and paint as if it's 1x image. 256 // need to take 2x's image and paint as if it's 1x image.
263 const gfx::ImageSkiaRep& image_rep = 257 const gfx::ImageSkiaRep& image_rep =
264 rotated.GetRepresentation(cursor_scale); 258 rotated.GetRepresentation(cursor_scale);
265 delegate_->SetCursorImage( 259 delegate_->SetCursorImage(
266 image_rep.pixel_size(), 260 image_rep.pixel_size(),
267 gfx::ImageSkia::CreateFrom1xBitmap(image_rep.sk_bitmap())); 261 gfx::ImageSkia::CreateFrom1xBitmap(image_rep.sk_bitmap()));
268 } else { 262 } else {
(...skipping 19 matching lines...) Expand all
288 cursor_window_->Show(); 282 cursor_window_->Show();
289 else 283 else
290 cursor_window_->Hide(); 284 cursor_window_->Hide();
291 } 285 }
292 286
293 const gfx::ImageSkia& CursorWindowController::GetCursorImageForTest() const { 287 const gfx::ImageSkia& CursorWindowController::GetCursorImageForTest() const {
294 return delegate_->cursor_image(); 288 return delegate_->cursor_image();
295 } 289 }
296 290
297 } // namespace ash 291 } // namespace ash
OLDNEW
« no previous file with comments | « ash/dip_unittest.cc ('k') | ash/display/display_change_observer_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698