OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/base/clipboard/clipboard.h" | 5 #include "ui/base/clipboard/clipboard.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 if (!image.get()) | 251 if (!image.get()) |
252 return SkBitmap(); | 252 return SkBitmap(); |
253 | 253 |
254 gfx::ScopedNSGraphicsContextSaveGState scoped_state; | 254 gfx::ScopedNSGraphicsContextSaveGState scoped_state; |
255 [image setFlipped:YES]; | 255 [image setFlipped:YES]; |
256 int width = [image size].width; | 256 int width = [image size].width; |
257 int height = [image size].height; | 257 int height = [image size].height; |
258 | 258 |
259 gfx::CanvasSkia canvas(width, height, false); | 259 gfx::CanvasSkia canvas(width, height, false); |
260 { | 260 { |
261 skia::ScopedPlatformPaint scoped_platform_paint(&canvas); | 261 skia::ScopedPlatformPaint scoped_platform_paint(canvas.sk_canvas()); |
262 CGContextRef gc = scoped_platform_paint.GetPlatformSurface(); | 262 CGContextRef gc = scoped_platform_paint.GetPlatformSurface(); |
263 NSGraphicsContext* cocoa_gc = | 263 NSGraphicsContext* cocoa_gc = |
264 [NSGraphicsContext graphicsContextWithGraphicsPort:gc flipped:NO]; | 264 [NSGraphicsContext graphicsContextWithGraphicsPort:gc flipped:NO]; |
265 [NSGraphicsContext setCurrentContext:cocoa_gc]; | 265 [NSGraphicsContext setCurrentContext:cocoa_gc]; |
266 [image drawInRect:NSMakeRect(0, 0, width, height) | 266 [image drawInRect:NSMakeRect(0, 0, width, height) |
267 fromRect:NSZeroRect | 267 fromRect:NSZeroRect |
268 operation:NSCompositeCopy | 268 operation:NSCompositeCopy |
269 fraction:1.0]; | 269 fraction:1.0]; |
270 } | 270 } |
271 return canvas.ExtractBitmap(); | 271 return canvas.ExtractBitmap(); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 } | 378 } |
379 | 379 |
380 // static | 380 // static |
381 Clipboard::FormatType Clipboard::GetWebKitSmartPasteFormatType() { | 381 Clipboard::FormatType Clipboard::GetWebKitSmartPasteFormatType() { |
382 static const std::string type = | 382 static const std::string type = |
383 base::SysNSStringToUTF8(kWebSmartPastePboardType); | 383 base::SysNSStringToUTF8(kWebSmartPastePboardType); |
384 return type; | 384 return type; |
385 } | 385 } |
386 | 386 |
387 } // namespace ui | 387 } // namespace ui |
OLD | NEW |