Chromium Code Reviews| 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 356 useDeviceBits_ = deviceBits.getPixels(); | 356 useDeviceBits_ = deviceBits.getPixels(); |
| 357 if (useDeviceBits_) { | 357 if (useDeviceBits_) { |
| 358 bitmap_ = deviceBits; | 358 bitmap_ = deviceBits; |
| 359 bitmap_.lockPixels(); | 359 bitmap_.lockPixels(); |
| 360 } else { | 360 } else { |
| 361 bitmap_.setConfig( | 361 bitmap_.setConfig( |
| 362 SkBitmap::kARGB_8888_Config, deviceBits.width(), deviceBits.height()); | 362 SkBitmap::kARGB_8888_Config, deviceBits.width(), deviceBits.height()); |
| 363 bitmap_.allocPixels(); | 363 bitmap_.allocPixels(); |
| 364 bitmap_.eraseColor(0); | 364 bitmap_.eraseColor(0); |
| 365 } | 365 } |
| 366 base::mac::ScopedCFTypeRef<CGColorSpaceRef> color_space( | |
|
Robert Sesek
2013/03/04 14:47:53
It looks like the naming convention in skia is cam
Nico
2013/03/04 14:52:35
Yes, but this file is chromium code, not skia code
| |
| 367 CGColorSpaceCreateDeviceRGB()); | |
| 366 cgContext_ = CGBitmapContextCreate(bitmap_.getPixels(), bitmap_.width(), | 368 cgContext_ = CGBitmapContextCreate(bitmap_.getPixels(), bitmap_.width(), |
| 367 bitmap_.height(), 8, bitmap_.rowBytes(), CGColorSpaceCreateDeviceRGB(), | 369 bitmap_.height(), 8, bitmap_.rowBytes(), color_space, |
| 368 kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst); | 370 kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst); |
| 369 | 371 |
| 370 // Apply device matrix. | 372 // Apply device matrix. |
| 371 CGAffineTransform contentsTransform = CGAffineTransformMakeScale(1, -1); | 373 CGAffineTransform contentsTransform = CGAffineTransformMakeScale(1, -1); |
| 372 contentsTransform = CGAffineTransformTranslate(contentsTransform, 0, | 374 contentsTransform = CGAffineTransformTranslate(contentsTransform, 0, |
| 373 -device->height()); | 375 -device->height()); |
| 374 CGContextConcatCTM(cgContext_, contentsTransform); | 376 CGContextConcatCTM(cgContext_, contentsTransform); |
| 375 | 377 |
| 376 const SkIPoint& pt = device->getOrigin(); | 378 const SkIPoint& pt = device->getOrigin(); |
| 377 // Skip applying the clip when not writing directly to device. | 379 // Skip applying the clip when not writing directly to device. |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 403 // Apply content matrix. | 405 // Apply content matrix. |
| 404 SkMatrix skMatrix = canvas_->getTotalMatrix(); | 406 SkMatrix skMatrix = canvas_->getTotalMatrix(); |
| 405 skMatrix.postTranslate(-SkIntToScalar(pt.fX), -SkIntToScalar(pt.fY)); | 407 skMatrix.postTranslate(-SkIntToScalar(pt.fX), -SkIntToScalar(pt.fY)); |
| 406 CGAffineTransform affine = SkMatrixToCGAffineTransform(skMatrix); | 408 CGAffineTransform affine = SkMatrixToCGAffineTransform(skMatrix); |
| 407 CGContextConcatCTM(cgContext_, affine); | 409 CGContextConcatCTM(cgContext_, affine); |
| 408 | 410 |
| 409 return cgContext_; | 411 return cgContext_; |
| 410 } | 412 } |
| 411 | 413 |
| 412 } // namespace gfx | 414 } // namespace gfx |
| OLD | NEW |