| OLD | NEW |
| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 if (custom_scale == 0) | 162 if (custom_scale == 0) |
| 163 custom_scale = 1; | 163 custom_scale = 1; |
| 164 NSSize dip_size = NSSizeFromCGSize( | 164 NSSize dip_size = NSSizeFromCGSize( |
| 165 gfx::ScaleToFlooredSize(custom_size, 1 / custom_scale).ToCGSize()); | 165 gfx::ScaleToFlooredSize(custom_size, 1 / custom_scale).ToCGSize()); |
| 166 NSPoint dip_hotspot = NSPointFromCGPoint( | 166 NSPoint dip_hotspot = NSPointFromCGPoint( |
| 167 gfx::ScaleToFlooredPoint(hotspot, 1 / custom_scale).ToCGPoint()); | 167 gfx::ScaleToFlooredPoint(hotspot, 1 / custom_scale).ToCGPoint()); |
| 168 | 168 |
| 169 // Both the image and its representation need to have the same size for | 169 // Both the image and its representation need to have the same size for |
| 170 // cursors to appear in high resolution on retina displays. Note that the | 170 // cursors to appear in high resolution on retina displays. Note that the |
| 171 // size of a representation is not the same as pixelsWide or pixelsHigh. | 171 // size of a representation is not the same as pixelsWide or pixelsHigh. |
| 172 NSImage* cursor_image = gfx::SkBitmapToNSImage(bitmap); | 172 NSImage* cursor_image = skia::SkBitmapToNSImage(bitmap); |
| 173 [cursor_image setSize:dip_size]; | 173 [cursor_image setSize:dip_size]; |
| 174 [[[cursor_image representations] objectAtIndex:0] setSize:dip_size]; | 174 [[[cursor_image representations] objectAtIndex:0] setSize:dip_size]; |
| 175 | 175 |
| 176 NSCursor* cursor = [[NSCursor alloc] initWithImage:cursor_image | 176 NSCursor* cursor = [[NSCursor alloc] initWithImage:cursor_image |
| 177 hotSpot:dip_hotspot]; | 177 hotSpot:dip_hotspot]; |
| 178 | 178 |
| 179 return [cursor autorelease]; | 179 return [cursor autorelease]; |
| 180 } | 180 } |
| 181 | 181 |
| 182 } // namespace | 182 } // namespace |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 if ([rep isKindOfClass:[NSBitmapImageRep class]]) { | 347 if ([rep isKindOfClass:[NSBitmapImageRep class]]) { |
| 348 cg_image = [rep CGImage]; | 348 cg_image = [rep CGImage]; |
| 349 break; | 349 break; |
| 350 } | 350 } |
| 351 } | 351 } |
| 352 | 352 |
| 353 if (cg_image) { | 353 if (cg_image) { |
| 354 cursor_info.type = WebCursorInfo::TypeCustom; | 354 cursor_info.type = WebCursorInfo::TypeCustom; |
| 355 NSPoint hot_spot = [cursor hotSpot]; | 355 NSPoint hot_spot = [cursor hotSpot]; |
| 356 cursor_info.hotspot = gfx::Point(hot_spot.x, hot_spot.y); | 356 cursor_info.hotspot = gfx::Point(hot_spot.x, hot_spot.y); |
| 357 cursor_info.custom_image = gfx::CGImageToSkBitmap(cg_image); | 357 cursor_info.custom_image = skia::CGImageToSkBitmap(cg_image); |
| 358 } else { | 358 } else { |
| 359 cursor_info.type = WebCursorInfo::TypePointer; | 359 cursor_info.type = WebCursorInfo::TypePointer; |
| 360 } | 360 } |
| 361 } | 361 } |
| 362 | 362 |
| 363 InitFromCursorInfo(cursor_info); | 363 InitFromCursorInfo(cursor_info); |
| 364 } | 364 } |
| 365 | 365 |
| 366 void WebCursor::InitPlatformData() { | 366 void WebCursor::InitPlatformData() { |
| 367 return; | 367 return; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 381 | 381 |
| 382 void WebCursor::CleanupPlatformData() { | 382 void WebCursor::CleanupPlatformData() { |
| 383 return; | 383 return; |
| 384 } | 384 } |
| 385 | 385 |
| 386 void WebCursor::CopyPlatformData(const WebCursor& other) { | 386 void WebCursor::CopyPlatformData(const WebCursor& other) { |
| 387 return; | 387 return; |
| 388 } | 388 } |
| 389 | 389 |
| 390 } // namespace content | 390 } // namespace content |
| OLD | NEW |