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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 136 |
137 // If we were given data, then don't clobber it! | 137 // If we were given data, then don't clobber it! |
138 #ifndef NDEBUG | 138 #ifndef NDEBUG |
139 if (!context && is_opaque) { | 139 if (!context && is_opaque) { |
140 // To aid in finding bugs, we set the background color to something | 140 // To aid in finding bugs, we set the background color to something |
141 // obviously wrong so it will be noticable when it is not cleared | 141 // obviously wrong so it will be noticable when it is not cleared |
142 bitmap.eraseARGB(255, 0, 255, 128); // bright bluish green | 142 bitmap.eraseARGB(255, 0, 255, 128); // bright bluish green |
143 } | 143 } |
144 #endif | 144 #endif |
145 | 145 |
146 if (!context) | 146 if (!context) { |
147 context = CGContextForData(data, width, height); | 147 context = CGContextForData(data, width, height); |
148 else | 148 if (!context) |
| 149 return NULL; |
| 150 } else |
149 CGContextRetain(context); | 151 CGContextRetain(context); |
150 | 152 |
151 BitmapPlatformDevice* rv = new BitmapPlatformDevice( | 153 BitmapPlatformDevice* rv = new BitmapPlatformDevice( |
152 new BitmapPlatformDeviceData(context), bitmap); | 154 new BitmapPlatformDeviceData(context), bitmap); |
153 | 155 |
154 // The device object took ownership of the graphics context with its own | 156 // The device object took ownership of the graphics context with its own |
155 // CGContextRetain call. | 157 // CGContextRetain call. |
156 CGContextRelease(context); | 158 CGContextRelease(context); |
157 | 159 |
158 return rv; | 160 return rv; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 } | 238 } |
237 | 239 |
238 SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice( | 240 SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice( |
239 SkBitmap::Config config, int width, int height, bool isOpaque, | 241 SkBitmap::Config config, int width, int height, bool isOpaque, |
240 Usage /*usage*/) { | 242 Usage /*usage*/) { |
241 SkASSERT(config == SkBitmap::kARGB_8888_Config); | 243 SkASSERT(config == SkBitmap::kARGB_8888_Config); |
242 return BitmapPlatformDevice::Create(NULL, width, height, isOpaque); | 244 return BitmapPlatformDevice::Create(NULL, width, height, isOpaque); |
243 } | 245 } |
244 | 246 |
245 } // namespace skia | 247 } // namespace skia |
OLD | NEW |