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

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

Issue 10834382: mac: Remove implicit conversion from ImageSkia to SkBitmap. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge Created 8 years, 4 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 | « skia/ext/skia_utils_mac.h ('k') | ui/gfx/image/image_skia.h » ('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 "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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 207 }
208 208
209 SkBitmap NSImageRepToSkBitmap( 209 SkBitmap NSImageRepToSkBitmap(
210 NSImageRep* image_rep, NSSize size, bool is_opaque) { 210 NSImageRep* image_rep, NSSize size, bool is_opaque) {
211 return NSImageOrNSImageRepToSkBitmap(nil, image_rep, size, is_opaque); 211 return NSImageOrNSImageRepToSkBitmap(nil, image_rep, size, is_opaque);
212 } 212 }
213 213
214 NSBitmapImageRep* SkBitmapToNSBitmapImageRep(const SkBitmap& skiaBitmap) { 214 NSBitmapImageRep* SkBitmapToNSBitmapImageRep(const SkBitmap& skiaBitmap) {
215 base::mac::ScopedCFTypeRef<CGColorSpaceRef> color_space( 215 base::mac::ScopedCFTypeRef<CGColorSpaceRef> color_space(
216 CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB)); 216 CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB));
217 return SkBitmapToNSBitmapImageRepWithColorSpace(skiaBitmap, color_space);
218 }
217 219
220 NSBitmapImageRep* SkBitmapToNSBitmapImageRepWithColorSpace(
221 const SkBitmap& skiaBitmap,
222 CGColorSpaceRef colorSpace) {
218 // First convert SkBitmap to CGImageRef. 223 // First convert SkBitmap to CGImageRef.
219 base::mac::ScopedCFTypeRef<CGImageRef> cgimage( 224 base::mac::ScopedCFTypeRef<CGImageRef> cgimage(
220 SkCreateCGImageRefWithColorspace(skiaBitmap, color_space)); 225 SkCreateCGImageRefWithColorspace(skiaBitmap, colorSpace));
221 226
222 // Now convert to NSBitmapImageRep. 227 // Now convert to NSBitmapImageRep.
223 scoped_nsobject<NSBitmapImageRep> bitmap( 228 scoped_nsobject<NSBitmapImageRep> bitmap(
224 [[NSBitmapImageRep alloc] initWithCGImage:cgimage]); 229 [[NSBitmapImageRep alloc] initWithCGImage:cgimage]);
225 return [bitmap.release() autorelease]; 230 return [bitmap.release() autorelease];
226 } 231 }
227 232
228 NSImage* SkBitmapToNSImageWithColorSpace(const SkBitmap& skiaBitmap, 233 NSImage* SkBitmapToNSImageWithColorSpace(const SkBitmap& skiaBitmap,
229 CGColorSpaceRef colorSpace) { 234 CGColorSpaceRef colorSpace) {
230 if (skiaBitmap.isNull()) 235 if (skiaBitmap.isNull())
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 // Apply content matrix. 409 // Apply content matrix.
405 SkMatrix skMatrix = canvas_->getTotalMatrix(); 410 SkMatrix skMatrix = canvas_->getTotalMatrix();
406 skMatrix.postTranslate(-SkIntToScalar(pt.fX), -SkIntToScalar(pt.fY)); 411 skMatrix.postTranslate(-SkIntToScalar(pt.fX), -SkIntToScalar(pt.fY));
407 CGAffineTransform affine = SkMatrixToCGAffineTransform(skMatrix); 412 CGAffineTransform affine = SkMatrixToCGAffineTransform(skMatrix);
408 CGContextConcatCTM(cgContext_, affine); 413 CGContextConcatCTM(cgContext_, affine);
409 414
410 return cgContext_; 415 return cgContext_;
411 } 416 }
412 417
413 } // namespace gfx 418 } // namespace gfx
OLDNEW
« no previous file with comments | « skia/ext/skia_utils_mac.h ('k') | ui/gfx/image/image_skia.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698