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

Side by Side Diff: content/common/cursors/webcursor_mac.mm

Issue 1357423009: gfx: Make conversions from Size to SizeF be explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sizefconvert-gfx: . Created 5 years, 2 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
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 "content/common/cursors/webcursor.h" 5 #include "content/common/cursors/webcursor.h"
6 6
7 #import <AppKit/AppKit.h> 7 #import <AppKit/AppKit.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 SkBitmap bitmap; 153 SkBitmap bitmap;
154 if (bitmap.tryAllocN32Pixels(size.width(), size.height()) && data) 154 if (bitmap.tryAllocN32Pixels(size.width(), size.height()) && data)
155 memcpy(bitmap.getAddr32(0, 0), data, data_size); 155 memcpy(bitmap.getAddr32(0, 0), data, data_size);
156 else 156 else
157 bitmap.eraseARGB(0, 0, 0, 0); 157 bitmap.eraseARGB(0, 0, 0, 0);
158 158
159 // Convert from pixels to view units. 159 // Convert from pixels to view units.
160 if (custom_scale == 0) 160 if (custom_scale == 0)
161 custom_scale = 1; 161 custom_scale = 1;
162 NSSize dip_size = NSSizeFromCGSize(gfx::ToFlooredSize( 162 NSSize dip_size = NSSizeFromCGSize(
163 gfx::ScaleSize(custom_size, 1 / custom_scale)).ToCGSize()); 163 gfx::ScaleToFlooredSize(custom_size, 1 / custom_scale).ToCGSize());
164 NSPoint dip_hotspot = NSPointFromCGPoint(gfx::ToFlooredPoint( 164 NSPoint dip_hotspot = NSPointFromCGPoint(gfx::ToFlooredPoint(
165 gfx::ScalePoint(hotspot, 1 / custom_scale)).ToCGPoint()); 165 gfx::ScalePoint(hotspot, 1 / custom_scale)).ToCGPoint());
166 166
167 // Both the image and its representation need to have the same size for 167 // Both the image and its representation need to have the same size for
168 // cursors to appear in high resolution on retina displays. Note that the 168 // cursors to appear in high resolution on retina displays. Note that the
169 // size of a representation is not the same as pixelsWide or pixelsHigh. 169 // size of a representation is not the same as pixelsWide or pixelsHigh.
170 NSImage* cursor_image = gfx::SkBitmapToNSImage(bitmap); 170 NSImage* cursor_image = gfx::SkBitmapToNSImage(bitmap);
171 [cursor_image setSize:dip_size]; 171 [cursor_image setSize:dip_size];
172 [[[cursor_image representations] objectAtIndex:0] setSize:dip_size]; 172 [[[cursor_image representations] objectAtIndex:0] setSize:dip_size];
173 173
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 379
380 void WebCursor::CleanupPlatformData() { 380 void WebCursor::CleanupPlatformData() {
381 return; 381 return;
382 } 382 }
383 383
384 void WebCursor::CopyPlatformData(const WebCursor& other) { 384 void WebCursor::CopyPlatformData(const WebCursor& other) {
385 return; 385 return;
386 } 386 }
387 387
388 } // namespace content 388 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698