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

Side by Side Diff: skia/ext/skia_utils_mac.mm

Issue 149473: Draw the image at the origin rather than one pixel to the right.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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 | « no previous file | no next file » | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "skia/ext/skia_utils_mac.h" 5 #include "skia/ext/skia_utils_mac.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/scoped_cftyperef.h" 10 #include "base/scoped_cftyperef.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 scoped_ptr<skia::BitmapPlatformDevice> device( 93 scoped_ptr<skia::BitmapPlatformDevice> device(
94 skia::BitmapPlatformDevice::Create(NULL, width, height, false)); 94 skia::BitmapPlatformDevice::Create(NULL, width, height, false));
95 95
96 CGContextRef context = device->GetBitmapContext(); 96 CGContextRef context = device->GetBitmapContext();
97 97
98 // We need to invert the y-axis of the canvas so that Core Graphics drawing 98 // We need to invert the y-axis of the canvas so that Core Graphics drawing
99 // happens right-side up. Skia has an upper-left origin and CG has a lower- 99 // happens right-side up. Skia has an upper-left origin and CG has a lower-
100 // left one. 100 // left one.
101 CGContextScaleCTM(context, 1.0, -1.0); 101 CGContextScaleCTM(context, 1.0, -1.0);
102 CGContextTranslateCTM(context, 1, -height); 102 CGContextTranslateCTM(context, 0, -height);
103 103
104 // We want to copy transparent pixels from |image|, instead of blending it 104 // We want to copy transparent pixels from |image|, instead of blending it
105 // onto uninitialized pixels. 105 // onto uninitialized pixels.
106 CGContextSetBlendMode(context, kCGBlendModeCopy); 106 CGContextSetBlendMode(context, kCGBlendModeCopy);
107 107
108 CGRect rect = CGRectMake(0, 0, width, height); 108 CGRect rect = CGRectMake(0, 0, width, height);
109 CGContextDrawImage(context, rect, image); 109 CGContextDrawImage(context, rect, image);
110 110
111 // Because |device| will be cleaned up and will take its pixels with it, we 111 // Because |device| will be cleaned up and will take its pixels with it, we
112 // copy it to the stack and return it. 112 // copy it to the stack and return it.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 // Now convert to NSImage. 174 // Now convert to NSImage.
175 NSBitmapImageRep* bitmap = [[[NSBitmapImageRep alloc] 175 NSBitmapImageRep* bitmap = [[[NSBitmapImageRep alloc]
176 initWithCGImage:cgimage] autorelease]; 176 initWithCGImage:cgimage] autorelease];
177 CFRelease(cgimage); 177 CFRelease(cgimage);
178 NSImage* image = [[[NSImage alloc] init] autorelease]; 178 NSImage* image = [[[NSImage alloc] init] autorelease];
179 [image addRepresentation:bitmap]; 179 [image addRepresentation:bitmap];
180 return image; 180 return image;
181 } 181 }
182 182
183 } // namespace gfx 183 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698