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

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

Issue 7019013: Removal of dependencies on PlatformDevice classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Addressing comments. Created 9 years, 7 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 "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/mac/scoped_cftyperef.h" 10 #include "base/mac/scoped_cftyperef.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 SkColorGetA(color) / 255.0); 184 SkColorGetA(color) / 255.0);
185 } 185 }
186 186
187 SkBitmap CGImageToSkBitmap(CGImageRef image) { 187 SkBitmap CGImageToSkBitmap(CGImageRef image) {
188 if (!image) 188 if (!image)
189 return SkBitmap(); 189 return SkBitmap();
190 190
191 int width = CGImageGetWidth(image); 191 int width = CGImageGetWidth(image);
192 int height = CGImageGetHeight(image); 192 int height = CGImageGetHeight(image);
193 193
194 scoped_ptr<skia::BitmapPlatformDevice> device( 194 scoped_ptr<SkDevice> device(
195 skia::BitmapPlatformDevice::Create(NULL, width, height, false)); 195 skia::BitmapPlatformDevice::Create(NULL, width, height, false));
196 196
197 CGContextRef context = device->GetBitmapContext(); 197 CGContextRef context = skia::GetBitmapContext(device.get());
198 198
199 // We need to invert the y-axis of the canvas so that Core Graphics drawing 199 // We need to invert the y-axis of the canvas so that Core Graphics drawing
200 // happens right-side up. Skia has an upper-left origin and CG has a lower- 200 // happens right-side up. Skia has an upper-left origin and CG has a lower-
201 // left one. 201 // left one.
202 CGContextScaleCTM(context, 1.0, -1.0); 202 CGContextScaleCTM(context, 1.0, -1.0);
203 CGContextTranslateCTM(context, 0, -height); 203 CGContextTranslateCTM(context, 0, -height);
204 204
205 // We want to copy transparent pixels from |image|, instead of blending it 205 // We want to copy transparent pixels from |image|, instead of blending it
206 // onto uninitialized pixels. 206 // onto uninitialized pixels.
207 CGContextSetBlendMode(context, kCGBlendModeCopy); 207 CGContextSetBlendMode(context, kCGBlendModeCopy);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 [image setSize:min_size]; 278 [image setSize:min_size];
279 return [image.release() autorelease]; 279 return [image.release() autorelease];
280 } 280 }
281 281
282 SkBitmap AppplicationIconAtSize(int size) { 282 SkBitmap AppplicationIconAtSize(int size) {
283 NSImage* image = [NSImage imageNamed:@"NSApplicationIcon"]; 283 NSImage* image = [NSImage imageNamed:@"NSApplicationIcon"];
284 return NSImageToSkBitmap(image, NSMakeSize(size, size), /* is_opaque=*/true); 284 return NSImageToSkBitmap(image, NSMakeSize(size, size), /* is_opaque=*/true);
285 } 285 }
286 286
287 } // namespace gfx 287 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698