OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <time.h> | 8 #include <time.h> |
9 | 9 |
10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 // Change the coordinate system to match WebCore's | 44 // Change the coordinate system to match WebCore's |
45 CGContextTranslateCTM(context, 0, height); | 45 CGContextTranslateCTM(context, 0, height); |
46 CGContextScaleCTM(context, 1.0, -1.0); | 46 CGContextScaleCTM(context, 1.0, -1.0); |
47 | 47 |
48 return context; | 48 return context; |
49 } | 49 } |
50 | 50 |
51 } // namespace | 51 } // namespace |
52 | 52 |
53 SkDevice* BitmapPlatformDeviceFactory::newDevice(SkCanvas* ignored, | |
54 SkBitmap::Config config, | |
55 int width, int height, | |
56 bool isOpaque, | |
57 bool isForLayer) { | |
58 SkASSERT(config == SkBitmap::kARGB_8888_Config); | |
59 return BitmapPlatformDevice::Create(NULL, width, height, isOpaque); | |
60 } | |
61 | |
62 BitmapPlatformDevice::BitmapPlatformDeviceData::BitmapPlatformDeviceData( | 53 BitmapPlatformDevice::BitmapPlatformDeviceData::BitmapPlatformDeviceData( |
63 CGContextRef bitmap) | 54 CGContextRef bitmap) |
64 : bitmap_context_(bitmap), | 55 : bitmap_context_(bitmap), |
65 config_dirty_(true) { // Want to load the config next time. | 56 config_dirty_(true) { // Want to load the config next time. |
66 SkASSERT(bitmap_context_); | 57 SkASSERT(bitmap_context_); |
67 // Initialize the clip region to the entire bitmap. | 58 // Initialize the clip region to the entire bitmap. |
68 | 59 |
69 SkIRect rect; | 60 SkIRect rect; |
70 rect.set(0, 0, | 61 rect.set(0, 0, |
71 CGBitmapContextGetWidth(bitmap_context_), | 62 CGBitmapContextGetWidth(bitmap_context_), |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 CGImageRelease(image); | 227 CGImageRelease(image); |
237 | 228 |
238 if (created_dc) | 229 if (created_dc) |
239 data_->ReleaseBitmapContext(); | 230 data_->ReleaseBitmapContext(); |
240 } | 231 } |
241 | 232 |
242 void BitmapPlatformDevice::onAccessBitmap(SkBitmap*) { | 233 void BitmapPlatformDevice::onAccessBitmap(SkBitmap*) { |
243 // Not needed in CoreGraphics | 234 // Not needed in CoreGraphics |
244 } | 235 } |
245 | 236 |
246 SkDeviceFactory* BitmapPlatformDevice::onNewDeviceFactory() { | 237 SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice( |
247 return SkNEW(BitmapPlatformDeviceFactory); | 238 SkBitmap::Config config, int width, int height, bool isOpaque, |
| 239 Usage /*usage*/) { |
| 240 SkASSERT(config == SkBitmap::kARGB_8888_Config); |
| 241 return BitmapPlatformDevice::Create(NULL, width, height, isOpaque); |
248 } | 242 } |
249 | 243 |
250 } // namespace skia | 244 } // namespace skia |
OLD | NEW |