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

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

Issue 9416017: Optionally clear PlatformCanvas instances. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Address style issues. Created 8 years, 10 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) 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/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } 195 }
196 196
197 SkBitmap CGImageToSkBitmap(CGImageRef image) { 197 SkBitmap CGImageToSkBitmap(CGImageRef image) {
198 if (!image) 198 if (!image)
199 return SkBitmap(); 199 return SkBitmap();
200 200
201 int width = CGImageGetWidth(image); 201 int width = CGImageGetWidth(image);
202 int height = CGImageGetHeight(image); 202 int height = CGImageGetHeight(image);
203 203
204 scoped_ptr<SkDevice> device( 204 scoped_ptr<SkDevice> device(
205 skia::BitmapPlatformDevice::Create(NULL, width, height, false)); 205 skia::BitmapPlatformDevice::Create(NULL, width, height,
206 skia::PlatformDevice::FLAGS_NONE));
206 207
207 CGContextRef context = skia::GetBitmapContext(device.get()); 208 CGContextRef context = skia::GetBitmapContext(device.get());
208 209
209 // We need to invert the y-axis of the canvas so that Core Graphics drawing 210 // We need to invert the y-axis of the canvas so that Core Graphics drawing
210 // happens right-side up. Skia has an upper-left origin and CG has a lower- 211 // happens right-side up. Skia has an upper-left origin and CG has a lower-
211 // left one. 212 // left one.
212 CGContextScaleCTM(context, 1.0, -1.0); 213 CGContextScaleCTM(context, 1.0, -1.0);
213 CGContextTranslateCTM(context, 0, -height); 214 CGContextTranslateCTM(context, 0, -height);
214 215
215 // We want to copy transparent pixels from |image|, instead of blending it 216 // We want to copy transparent pixels from |image|, instead of blending it
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 // Apply content matrix. 357 // Apply content matrix.
357 SkMatrix skMatrix = canvas_->getTotalMatrix(); 358 SkMatrix skMatrix = canvas_->getTotalMatrix();
358 skMatrix.postTranslate(-SkIntToScalar(pt.fX), -SkIntToScalar(pt.fY)); 359 skMatrix.postTranslate(-SkIntToScalar(pt.fX), -SkIntToScalar(pt.fY));
359 CGAffineTransform affine = SkMatrixToCGAffineTransform(skMatrix); 360 CGAffineTransform affine = SkMatrixToCGAffineTransform(skMatrix);
360 CGContextConcatCTM(cgContext_, affine); 361 CGContextConcatCTM(cgContext_, affine);
361 362
362 return cgContext_; 363 return cgContext_;
363 } 364 }
364 365
365 } // namespace gfx 366 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698