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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } | 144 } |
145 | 145 |
146 // If the size is empty, use a 1x1 transparent image. | 146 // If the size is empty, use a 1x1 transparent image. |
147 gfx::Size size = custom_size; | 147 gfx::Size size = custom_size; |
148 if (size.IsEmpty()) { | 148 if (size.IsEmpty()) { |
149 size.SetSize(1, 1); | 149 size.SetSize(1, 1); |
150 data = NULL; | 150 data = NULL; |
151 } | 151 } |
152 | 152 |
153 SkBitmap bitmap; | 153 SkBitmap bitmap; |
154 if (bitmap.tryAllocN32Pixels(size.width(), size.height()) && data) | 154 SkImageInfo image_info = SkImageInfo::MakeN32(size.width(), size.height(), |
| 155 kUnpremul_SkAlphaType); |
| 156 if (bitmap.tryAllocPixels(image_info) && data) |
155 memcpy(bitmap.getAddr32(0, 0), data, data_size); | 157 memcpy(bitmap.getAddr32(0, 0), data, data_size); |
156 else | 158 else |
157 bitmap.eraseARGB(0, 0, 0, 0); | 159 bitmap.eraseARGB(0, 0, 0, 0); |
158 | 160 |
159 // Convert from pixels to view units. | 161 // Convert from pixels to view units. |
160 if (custom_scale == 0) | 162 if (custom_scale == 0) |
161 custom_scale = 1; | 163 custom_scale = 1; |
162 NSSize dip_size = NSSizeFromCGSize( | 164 NSSize dip_size = NSSizeFromCGSize( |
163 gfx::ScaleToFlooredSize(custom_size, 1 / custom_scale).ToCGSize()); | 165 gfx::ScaleToFlooredSize(custom_size, 1 / custom_scale).ToCGSize()); |
164 NSPoint dip_hotspot = NSPointFromCGPoint(gfx::ToFlooredPoint( | 166 NSPoint dip_hotspot = NSPointFromCGPoint(gfx::ToFlooredPoint( |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 | 381 |
380 void WebCursor::CleanupPlatformData() { | 382 void WebCursor::CleanupPlatformData() { |
381 return; | 383 return; |
382 } | 384 } |
383 | 385 |
384 void WebCursor::CopyPlatformData(const WebCursor& other) { | 386 void WebCursor::CopyPlatformData(const WebCursor& other) { |
385 return; | 387 return; |
386 } | 388 } |
387 | 389 |
388 } // namespace content | 390 } // namespace content |
OLD | NEW |