| 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/bitmap_platform_device_mac.h" | 5 #include "skia/ext/bitmap_platform_device_mac.h" |
| 6 | 6 |
| 7 #import <ApplicationServices/ApplicationServices.h> | 7 #import <ApplicationServices/ApplicationServices.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <time.h> | 9 #include <time.h> |
| 10 | 10 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 // We must save the state once so that we can use the restore/save trick | 237 // We must save the state once so that we can use the restore/save trick |
| 238 // in LoadConfig(). | 238 // in LoadConfig(). |
| 239 CGContextSaveGState(bitmap_context_); | 239 CGContextSaveGState(bitmap_context_); |
| 240 } | 240 } |
| 241 | 241 |
| 242 BitmapPlatformDevice::~BitmapPlatformDevice() { | 242 BitmapPlatformDevice::~BitmapPlatformDevice() { |
| 243 if (bitmap_context_) | 243 if (bitmap_context_) |
| 244 CGContextRelease(bitmap_context_); | 244 CGContextRelease(bitmap_context_); |
| 245 } | 245 } |
| 246 | 246 |
| 247 CGContextRef BitmapPlatformDevice::GetBitmapContext(const SkMatrix& transform, | 247 NativeDrawingContext BitmapPlatformDevice::BeginPlatformPaint( |
| 248 const SkIRect& clip_bounds)
{ | 248 const SkMatrix& transform, |
| 249 const SkIRect& clip_bounds) { |
| 249 LoadConfig(transform, clip_bounds); | 250 LoadConfig(transform, clip_bounds); |
| 250 return bitmap_context_; | 251 return bitmap_context_; |
| 251 } | 252 } |
| 252 | 253 |
| 253 SkBaseDevice* BitmapPlatformDevice::onCreateDevice(const CreateInfo& cinfo, | 254 SkBaseDevice* BitmapPlatformDevice::onCreateDevice(const CreateInfo& cinfo, |
| 254 const SkPaint*) { | 255 const SkPaint*) { |
| 255 const SkImageInfo& info = cinfo.fInfo; | 256 const SkImageInfo& info = cinfo.fInfo; |
| 256 const bool do_clear = !info.isOpaque(); | 257 const bool do_clear = !info.isOpaque(); |
| 257 SkASSERT(info.colorType() == kN32_SkColorType); | 258 SkASSERT(info.colorType() == kN32_SkColorType); |
| 258 return Create(NULL, info.width(), info.height(), info.isOpaque(), do_clear); | 259 return Create(NULL, info.width(), info.height(), info.isOpaque(), do_clear); |
| 259 } | 260 } |
| 260 | 261 |
| 261 // PlatformCanvas impl | 262 // PlatformCanvas impl |
| 262 | 263 |
| 263 std::unique_ptr<SkCanvas> CreatePlatformCanvasWithPixels( | 264 std::unique_ptr<SkCanvas> CreatePlatformCanvasWithPixels( |
| 264 int width, | 265 int width, |
| 265 int height, | 266 int height, |
| 266 bool is_opaque, | 267 bool is_opaque, |
| 267 uint8_t* data, | 268 uint8_t* data, |
| 268 OnFailureType failureType) { | 269 OnFailureType failureType) { |
| 269 sk_sp<SkBaseDevice> dev( | 270 sk_sp<SkBaseDevice> dev( |
| 270 BitmapPlatformDevice::CreateWithData(data, width, height, is_opaque)); | 271 BitmapPlatformDevice::CreateWithData(data, width, height, is_opaque)); |
| 271 return CreateCanvas(dev, failureType); | 272 return CreateCanvas(dev, failureType); |
| 272 } | 273 } |
| 273 | 274 |
| 274 } // namespace skia | 275 } // namespace skia |
| OLD | NEW |