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

Side by Side Diff: ui/base/clipboard/clipboard_mac.mm

Issue 8122013: Allow CanvasSkia to bind to an existing SkCanvas. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: 1 more fix Created 9 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 | Annotate | Revision Log
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698