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 "webkit/common/cursors/webcursor.h" | 5 #include "webkit/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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 data = const_cast<char*>(&custom_data[0]); | 151 data = const_cast<char*>(&custom_data[0]); |
152 } | 152 } |
153 | 153 |
154 // If the size is empty, use a 1x1 transparent image. | 154 // If the size is empty, use a 1x1 transparent image. |
155 gfx::Size size = custom_size; | 155 gfx::Size size = custom_size; |
156 if (size.IsEmpty()) { | 156 if (size.IsEmpty()) { |
157 size.SetSize(1, 1); | 157 size.SetSize(1, 1); |
158 data = NULL; | 158 data = NULL; |
159 } | 159 } |
160 | 160 |
161 base::mac::ScopedCFTypeRef<CGColorSpaceRef> cg_color( | 161 base::ScopedCFTypeRef<CGColorSpaceRef> cg_color( |
162 CGColorSpaceCreateDeviceRGB()); | 162 CGColorSpaceCreateDeviceRGB()); |
163 // The settings here match SetCustomData() below; keep in sync. | 163 // The settings here match SetCustomData() below; keep in sync. |
164 base::mac::ScopedCFTypeRef<CGContextRef> context( | 164 base::ScopedCFTypeRef<CGContextRef> context(CGBitmapContextCreate( |
165 CGBitmapContextCreate(data, | 165 data, |
166 size.width(), | 166 size.width(), |
167 size.height(), | 167 size.height(), |
168 8, | 168 8, |
169 size.width()*4, | 169 size.width() * 4, |
170 cg_color.get(), | 170 cg_color.get(), |
171 kCGImageAlphaPremultipliedLast | | 171 kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big)); |
172 kCGBitmapByteOrder32Big)); | |
173 return CGBitmapContextCreateImage(context.get()); | 172 return CGBitmapContextCreateImage(context.get()); |
174 } | 173 } |
175 | 174 |
176 NSCursor* CreateCustomCursor(const std::vector<char>& custom_data, | 175 NSCursor* CreateCustomCursor(const std::vector<char>& custom_data, |
177 const gfx::Size& custom_size, | 176 const gfx::Size& custom_size, |
178 float custom_scale, | 177 float custom_scale, |
179 const gfx::Point& hotspot) { | 178 const gfx::Point& hotspot) { |
180 // If the data is missing, leave the backing transparent. | 179 // If the data is missing, leave the backing transparent. |
181 void* data = NULL; | 180 void* data = NULL; |
182 size_t data_size = 0; | 181 size_t data_size = 0; |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 return true; | 416 return true; |
418 } | 417 } |
419 | 418 |
420 void WebCursor::CleanupPlatformData() { | 419 void WebCursor::CleanupPlatformData() { |
421 return; | 420 return; |
422 } | 421 } |
423 | 422 |
424 void WebCursor::CopyPlatformData(const WebCursor& other) { | 423 void WebCursor::CopyPlatformData(const WebCursor& other) { |
425 return; | 424 return; |
426 } | 425 } |
OLD | NEW |