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

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

Issue 10790128: Revert 147915 - Cleanup gfx::Canvas now that 10562027 has landed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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
« no previous file with comments | « ui/base/clipboard/clipboard_gtk.cc ('k') | ui/base/clipboard/clipboard_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "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/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 scoped_nsobject<NSImage> image( 342 scoped_nsobject<NSImage> image(
343 [[NSImage alloc] initWithPasteboard:GetPasteboard()]); 343 [[NSImage alloc] initWithPasteboard:GetPasteboard()]);
344 if (!image.get()) 344 if (!image.get())
345 return SkBitmap(); 345 return SkBitmap();
346 346
347 gfx::ScopedNSGraphicsContextSaveGState scoped_state; 347 gfx::ScopedNSGraphicsContextSaveGState scoped_state;
348 [image setFlipped:YES]; 348 [image setFlipped:YES];
349 int width = [image size].width; 349 int width = [image size].width;
350 int height = [image size].height; 350 int height = [image size].height;
351 351
352 gfx::Canvas canvas(gfx::Size(width, height), ui::SCALE_FACTOR_100P, false); 352 gfx::Canvas canvas(gfx::Size(width, height), false);
353 { 353 {
354 skia::ScopedPlatformPaint scoped_platform_paint(canvas.sk_canvas()); 354 skia::ScopedPlatformPaint scoped_platform_paint(canvas.sk_canvas());
355 CGContextRef gc = scoped_platform_paint.GetPlatformSurface(); 355 CGContextRef gc = scoped_platform_paint.GetPlatformSurface();
356 NSGraphicsContext* cocoa_gc = 356 NSGraphicsContext* cocoa_gc =
357 [NSGraphicsContext graphicsContextWithGraphicsPort:gc flipped:NO]; 357 [NSGraphicsContext graphicsContextWithGraphicsPort:gc flipped:NO];
358 [NSGraphicsContext setCurrentContext:cocoa_gc]; 358 [NSGraphicsContext setCurrentContext:cocoa_gc];
359 [image drawInRect:NSMakeRect(0, 0, width, height) 359 [image drawInRect:NSMakeRect(0, 0, width, height)
360 fromRect:NSZeroRect 360 fromRect:NSZeroRect
361 operation:NSCompositeCopy 361 operation:NSCompositeCopy
362 fraction:1.0]; 362 fraction:1.0];
363 } 363 }
364 return canvas.ExtractImageRep().sk_bitmap(); 364 return canvas.ExtractBitmap();
365 } 365 }
366 366
367 void Clipboard::ReadCustomData(Buffer buffer, 367 void Clipboard::ReadCustomData(Buffer buffer,
368 const string16& type, 368 const string16& type,
369 string16* result) const { 369 string16* result) const {
370 DCHECK(CalledOnValidThread()); 370 DCHECK(CalledOnValidThread());
371 DCHECK_EQ(buffer, BUFFER_STANDARD); 371 DCHECK_EQ(buffer, BUFFER_STANDARD);
372 372
373 NSPasteboard* pb = GetPasteboard(); 373 NSPasteboard* pb = GetPasteboard();
374 if ([[pb types] containsObject:kWebCustomDataPboardType]) { 374 if ([[pb types] containsObject:kWebCustomDataPboardType]) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 return type; 469 return type;
470 } 470 }
471 471
472 // static 472 // static
473 const Clipboard::FormatType& Clipboard::GetWebCustomDataFormatType() { 473 const Clipboard::FormatType& Clipboard::GetWebCustomDataFormatType() {
474 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kWebCustomDataPboardType)); 474 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kWebCustomDataPboardType));
475 return type; 475 return type;
476 } 476 }
477 477
478 } // namespace ui 478 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/clipboard/clipboard_gtk.cc ('k') | ui/base/clipboard/clipboard_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698