| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include <time.h> | 8 #include <time.h> |
| 8 | 9 |
| 9 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| 10 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
| 11 #include "skia/ext/bitmap_platform_device_data.h" | 12 #include "skia/ext/bitmap_platform_device_data.h" |
| 12 #include "skia/ext/skia_utils_mac.h" | 13 #include "skia/ext/skia_utils_mac.h" |
| 13 #include "third_party/skia/include/core/SkMatrix.h" | 14 #include "third_party/skia/include/core/SkMatrix.h" |
| 14 #include "third_party/skia/include/core/SkRegion.h" | 15 #include "third_party/skia/include/core/SkRegion.h" |
| 15 #include "third_party/skia/include/core/SkTypes.h" | 16 #include "third_party/skia/include/core/SkTypes.h" |
| 16 #include "third_party/skia/include/core/SkUtils.h" | 17 #include "third_party/skia/include/core/SkUtils.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 // We must save the state once so that we can use the restore/save trick | 76 // We must save the state once so that we can use the restore/save trick |
| 76 // in LoadConfig(). | 77 // in LoadConfig(). |
| 77 CGContextSaveGState(bitmap_context_); | 78 CGContextSaveGState(bitmap_context_); |
| 78 } | 79 } |
| 79 | 80 |
| 80 BitmapPlatformDevice::BitmapPlatformDeviceData::~BitmapPlatformDeviceData() { | 81 BitmapPlatformDevice::BitmapPlatformDeviceData::~BitmapPlatformDeviceData() { |
| 81 if (bitmap_context_) | 82 if (bitmap_context_) |
| 82 CGContextRelease(bitmap_context_); | 83 CGContextRelease(bitmap_context_); |
| 83 } | 84 } |
| 84 | 85 |
| 86 void BitmapPlatformDevice::BitmapPlatformDeviceData::ReleaseBitmapContext() { |
| 87 SkASSERT(bitmap_context_); |
| 88 CGContextRelease(bitmap_context_); |
| 89 bitmap_context_ = NULL; |
| 90 } |
| 91 |
| 85 void BitmapPlatformDevice::BitmapPlatformDeviceData::SetMatrixClip( | 92 void BitmapPlatformDevice::BitmapPlatformDeviceData::SetMatrixClip( |
| 86 const SkMatrix& transform, | 93 const SkMatrix& transform, |
| 87 const SkRegion& region) { | 94 const SkRegion& region) { |
| 88 transform_ = transform; | 95 transform_ = transform; |
| 89 clip_region_ = region; | 96 clip_region_ = region; |
| 90 config_dirty_ = true; | 97 config_dirty_ = true; |
| 91 } | 98 } |
| 92 | 99 |
| 93 void BitmapPlatformDevice::BitmapPlatformDeviceData::LoadConfig() { | 100 void BitmapPlatformDevice::BitmapPlatformDeviceData::LoadConfig() { |
| 94 if (!config_dirty_ || !bitmap_context_) | 101 if (!config_dirty_ || !bitmap_context_) |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 SkAutoLockPixels lock(bitmap); | 271 SkAutoLockPixels lock(bitmap); |
| 265 uint32_t* data = bitmap.getAddr32(0, 0); | 272 uint32_t* data = bitmap.getAddr32(0, 0); |
| 266 return static_cast<SkColor>(data[x + y * width()]); | 273 return static_cast<SkColor>(data[x + y * width()]); |
| 267 } | 274 } |
| 268 | 275 |
| 269 void BitmapPlatformDevice::onAccessBitmap(SkBitmap*) { | 276 void BitmapPlatformDevice::onAccessBitmap(SkBitmap*) { |
| 270 // Not needed in CoreGraphics | 277 // Not needed in CoreGraphics |
| 271 } | 278 } |
| 272 | 279 |
| 273 } // namespace skia | 280 } // namespace skia |
| OLD | NEW |