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 <time.h> | 8 #include <time.h> |
9 | 9 |
10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); | 118 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); |
119 if (bitmap.allocPixels() != true) | 119 if (bitmap.allocPixels() != true) |
120 return NULL; | 120 return NULL; |
121 | 121 |
122 void* data = NULL; | 122 void* data = NULL; |
123 if (context) { | 123 if (context) { |
124 data = CGBitmapContextGetData(context); | 124 data = CGBitmapContextGetData(context); |
125 bitmap.setPixels(data); | 125 bitmap.setPixels(data); |
126 } else { | 126 } else { |
127 data = bitmap.getPixels(); | 127 data = bitmap.getPixels(); |
128 | |
129 // Note: The Windows implementation clears the Bitmap later on. | |
130 // This bears mentioning since removal of this line makes the | |
131 // unit tests only fail periodically (or when MallocPreScribble is set). | |
132 bitmap.eraseARGB(0, 0, 0, 0); | |
133 } | 128 } |
134 | 129 |
135 bitmap.setIsOpaque(is_opaque); | 130 bitmap.setIsOpaque(is_opaque); |
136 | 131 |
137 // If we were given data, then don't clobber it! | 132 // If we were given data, then don't clobber it! |
138 #ifndef NDEBUG | 133 #ifndef NDEBUG |
139 if (!context && is_opaque) { | 134 if (!context && is_opaque) { |
140 // To aid in finding bugs, we set the background color to something | 135 // 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 | 136 // obviously wrong so it will be noticable when it is not cleared |
142 bitmap.eraseARGB(255, 0, 255, 128); // bright bluish green | 137 bitmap.eraseARGB(255, 0, 255, 128); // bright bluish green |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 | 230 |
236 const SkBitmap& BitmapPlatformDevice::onAccessBitmap(SkBitmap* bitmap) { | 231 const SkBitmap& BitmapPlatformDevice::onAccessBitmap(SkBitmap* bitmap) { |
237 // Not needed in CoreGraphics | 232 // Not needed in CoreGraphics |
238 return *bitmap; | 233 return *bitmap; |
239 } | 234 } |
240 | 235 |
241 SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice( | 236 SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice( |
242 SkBitmap::Config config, int width, int height, bool isOpaque, | 237 SkBitmap::Config config, int width, int height, bool isOpaque, |
243 Usage /*usage*/) { | 238 Usage /*usage*/) { |
244 SkASSERT(config == SkBitmap::kARGB_8888_Config); | 239 SkASSERT(config == SkBitmap::kARGB_8888_Config); |
245 return BitmapPlatformDevice::Create(NULL, width, height, isOpaque); | 240 SkDevice* bitmap_device = BitmapPlatformDevice::Create(NULL, width, height, |
| 241 isOpaque); |
| 242 bitmap_device->accessBitmap(true).eraseARGB(0, 0, 0, 0); |
| 243 return bitmap_device; |
246 } | 244 } |
247 | 245 |
248 } // namespace skia | 246 } // namespace skia |
OLD | NEW |