| OLD | NEW |
| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 count:4]; | 183 count:4]; |
| 184 } | 184 } |
| 185 | 185 |
| 186 SkBitmap CGImageToSkBitmap(CGImageRef image) { | 186 SkBitmap CGImageToSkBitmap(CGImageRef image) { |
| 187 if (!image) | 187 if (!image) |
| 188 return SkBitmap(); | 188 return SkBitmap(); |
| 189 | 189 |
| 190 int width = CGImageGetWidth(image); | 190 int width = CGImageGetWidth(image); |
| 191 int height = CGImageGetHeight(image); | 191 int height = CGImageGetHeight(image); |
| 192 | 192 |
| 193 scoped_ptr<SkBaseDevice> device( | 193 scoped_ptr<skia::BitmapPlatformDevice> device( |
| 194 skia::BitmapPlatformDevice::Create(NULL, width, height, false)); | 194 skia::BitmapPlatformDevice::Create(NULL, width, height, false)); |
| 195 | 195 |
| 196 CGContextRef context = skia::GetBitmapContext(device.get()); | 196 CGContextRef context = device->GetBitmapContext(); |
| 197 | 197 |
| 198 // We need to invert the y-axis of the canvas so that Core Graphics drawing | 198 // We need to invert the y-axis of the canvas so that Core Graphics drawing |
| 199 // happens right-side up. Skia has an upper-left origin and CG has a lower- | 199 // happens right-side up. Skia has an upper-left origin and CG has a lower- |
| 200 // left one. | 200 // left one. |
| 201 CGContextScaleCTM(context, 1.0, -1.0); | 201 CGContextScaleCTM(context, 1.0, -1.0); |
| 202 CGContextTranslateCTM(context, 0, -height); | 202 CGContextTranslateCTM(context, 0, -height); |
| 203 | 203 |
| 204 // We want to copy transparent pixels from |image|, instead of blending it | 204 // We want to copy transparent pixels from |image|, instead of blending it |
| 205 // onto uninitialized pixels. | 205 // onto uninitialized pixels. |
| 206 CGContextSetBlendMode(context, kCGBlendModeCopy); | 206 CGContextSetBlendMode(context, kCGBlendModeCopy); |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 CGContextConcatCTM(cgContext_, SkMatrixToCGAffineTransform(matrix)); | 460 CGContextConcatCTM(cgContext_, SkMatrixToCGAffineTransform(matrix)); |
| 461 | 461 |
| 462 return cgContext_; | 462 return cgContext_; |
| 463 } | 463 } |
| 464 | 464 |
| 465 bool SkiaBitLocker::hasEmptyClipRegion() const { | 465 bool SkiaBitLocker::hasEmptyClipRegion() const { |
| 466 return canvas_->isClipEmpty(); | 466 return canvas_->isClipEmpty(); |
| 467 } | 467 } |
| 468 | 468 |
| 469 } // namespace gfx | 469 } // namespace gfx |
| OLD | NEW |