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

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

Issue 2949353003: Implement large cursors in Mushrome. (Closed)
Patch Set: rename everything to CursorSize Created 3 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/display/cursor_window_controller.h ('k') | ash/mus/bridge/shell_port_mash.h » ('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/ash_constants.h" 7 #include "ash/ash_constants.h"
8 #include "ash/display/mirror_window_controller.h" 8 #include "ash/display/mirror_window_controller.h"
9 #include "ash/display/window_tree_host_manager.h" 9 #include "ash/display/window_tree_host_manager.h"
10 #include "ash/public/cpp/shell_window_ids.h" 10 #include "ash/public/cpp/shell_window_ids.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 gfx::Size size_; 83 gfx::Size size_;
84 84
85 DISALLOW_COPY_AND_ASSIGN(CursorWindowDelegate); 85 DISALLOW_COPY_AND_ASSIGN(CursorWindowDelegate);
86 }; 86 };
87 87
88 CursorWindowController::CursorWindowController() 88 CursorWindowController::CursorWindowController()
89 : is_cursor_compositing_enabled_(false), 89 : is_cursor_compositing_enabled_(false),
90 container_(NULL), 90 container_(NULL),
91 cursor_type_(ui::CursorType::kNone), 91 cursor_type_(ui::CursorType::kNone),
92 visible_(true), 92 visible_(true),
93 cursor_set_(ui::CURSOR_SET_NORMAL), 93 cursor_size_(ui::CursorSize::kNormal),
94 large_cursor_size_in_dip_(ash::kDefaultLargeCursorSize), 94 large_cursor_size_in_dip_(ash::kDefaultLargeCursorSize),
95 delegate_(new CursorWindowDelegate()) {} 95 delegate_(new CursorWindowDelegate()) {}
96 96
97 CursorWindowController::~CursorWindowController() { 97 CursorWindowController::~CursorWindowController() {
98 SetContainer(NULL); 98 SetContainer(NULL);
99 } 99 }
100 100
101 void CursorWindowController::SetLargeCursorSizeInDip( 101 void CursorWindowController::SetLargeCursorSizeInDip(
102 int large_cursor_size_in_dip) { 102 int large_cursor_size_in_dip) {
103 large_cursor_size_in_dip = 103 large_cursor_size_in_dip =
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 183 }
184 184
185 void CursorWindowController::SetCursor(gfx::NativeCursor cursor) { 185 void CursorWindowController::SetCursor(gfx::NativeCursor cursor) {
186 if (cursor_type_ == cursor.native_type()) 186 if (cursor_type_ == cursor.native_type())
187 return; 187 return;
188 cursor_type_ = cursor.native_type(); 188 cursor_type_ = cursor.native_type();
189 UpdateCursorImage(); 189 UpdateCursorImage();
190 UpdateCursorVisibility(); 190 UpdateCursorVisibility();
191 } 191 }
192 192
193 void CursorWindowController::SetCursorSet(ui::CursorSetType cursor_set) { 193 void CursorWindowController::SetCursorSize(ui::CursorSize cursor_size) {
194 cursor_set_ = cursor_set; 194 cursor_size_ = cursor_size;
195 UpdateCursorImage(); 195 UpdateCursorImage();
196 } 196 }
197 197
198 void CursorWindowController::SetVisibility(bool visible) { 198 void CursorWindowController::SetVisibility(bool visible) {
199 visible_ = visible; 199 visible_ = visible;
200 UpdateCursorVisibility(); 200 UpdateCursorVisibility();
201 } 201 }
202 202
203 void CursorWindowController::SetContainer(aura::Window* container) { 203 void CursorWindowController::SetContainer(aura::Window* container) {
204 if (container_ == container) 204 if (container_ == container)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 const float original_scale = Shell::Get() 239 const float original_scale = Shell::Get()
240 ->display_manager() 240 ->display_manager()
241 ->GetDisplayInfo(display_.id()) 241 ->GetDisplayInfo(display_.id())
242 .device_scale_factor(); 242 .device_scale_factor();
243 // And use the nearest resource scale factor. 243 // And use the nearest resource scale factor.
244 cursor_scale = 244 cursor_scale =
245 ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactor(original_scale)); 245 ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactor(original_scale));
246 } 246 }
247 int resource_id; 247 int resource_id;
248 // TODO(hshi): support custom cursor set. 248 // TODO(hshi): support custom cursor set.
249 if (!ui::GetCursorDataFor(cursor_set_, cursor_type_, cursor_scale, 249 if (!ui::GetCursorDataFor(cursor_size_, cursor_type_, cursor_scale,
250 &resource_id, &hot_point_)) { 250 &resource_id, &hot_point_)) {
251 return; 251 return;
252 } 252 }
253 const gfx::ImageSkia* image = 253 const gfx::ImageSkia* image =
254 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id); 254 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id);
255 if (!is_cursor_compositing_enabled_) { 255 if (!is_cursor_compositing_enabled_) {
256 gfx::ImageSkia rotated = *image; 256 gfx::ImageSkia rotated = *image;
257 switch (display_.rotation()) { 257 switch (display_.rotation()) {
258 case display::Display::ROTATE_0: 258 case display::Display::ROTATE_0:
259 break; 259 break;
(...skipping 21 matching lines...) Expand all
281 delegate_->SetCursorImage( 281 delegate_->SetCursorImage(
282 image_rep.pixel_size(), 282 image_rep.pixel_size(),
283 gfx::ImageSkia::CreateFrom1xBitmap(image_rep.sk_bitmap())); 283 gfx::ImageSkia::CreateFrom1xBitmap(image_rep.sk_bitmap()));
284 } else { 284 } else {
285 gfx::ImageSkia resized = *image; 285 gfx::ImageSkia resized = *image;
286 286
287 // Rescale cursor size. This is used with the combination of accessibility 287 // Rescale cursor size. This is used with the combination of accessibility
288 // large cursor. We don't need to care about the case where cursor 288 // large cursor. We don't need to care about the case where cursor
289 // compositing is disabled as we always use cursor compositing if 289 // compositing is disabled as we always use cursor compositing if
290 // accessibility large cursor is enabled. 290 // accessibility large cursor is enabled.
291 if (cursor_set_ == ui::CursorSetType::CURSOR_SET_LARGE && 291 if (cursor_size_ == ui::CursorSize::kLarge &&
292 large_cursor_size_in_dip_ != image->size().width()) { 292 large_cursor_size_in_dip_ != image->size().width()) {
293 float rescale = static_cast<float>(large_cursor_size_in_dip_) / 293 float rescale = static_cast<float>(large_cursor_size_in_dip_) /
294 static_cast<float>(image->size().width()); 294 static_cast<float>(image->size().width());
295 resized = gfx::ImageSkiaOperations::CreateResizedImage( 295 resized = gfx::ImageSkiaOperations::CreateResizedImage(
296 *image, skia::ImageOperations::ResizeMethod::RESIZE_GOOD, 296 *image, skia::ImageOperations::ResizeMethod::RESIZE_GOOD,
297 gfx::ScaleToCeiledSize(image->size(), rescale)); 297 gfx::ScaleToCeiledSize(image->size(), rescale));
298 hot_point_ = gfx::ScaleToCeiledPoint(hot_point_, rescale); 298 hot_point_ = gfx::ScaleToCeiledPoint(hot_point_, rescale);
299 } 299 }
300 300
301 const gfx::ImageSkiaRep& image_rep = 301 const gfx::ImageSkiaRep& image_rep =
(...skipping 20 matching lines...) Expand all
322 cursor_window_->Show(); 322 cursor_window_->Show();
323 else 323 else
324 cursor_window_->Hide(); 324 cursor_window_->Hide();
325 } 325 }
326 326
327 const gfx::ImageSkia& CursorWindowController::GetCursorImageForTest() const { 327 const gfx::ImageSkia& CursorWindowController::GetCursorImageForTest() const {
328 return delegate_->cursor_image(); 328 return delegate_->cursor_image();
329 } 329 }
330 330
331 } // namespace ash 331 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/cursor_window_controller.h ('k') | ash/mus/bridge/shell_port_mash.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698