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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 | 108 |
109 // We use this static factory function instead of the regular constructor so | 109 // We use this static factory function instead of the regular constructor so |
110 // that we can create the pixel data before calling the constructor. This is | 110 // that we can create the pixel data before calling the constructor. This is |
111 // required so that we can call the base class' constructor with the pixel | 111 // required so that we can call the base class' constructor with the pixel |
112 // data. | 112 // data. |
113 BitmapPlatformDevice* BitmapPlatformDevice::Create(CGContextRef context, | 113 BitmapPlatformDevice* BitmapPlatformDevice::Create(CGContextRef context, |
114 int width, | 114 int width, |
115 int height, | 115 int height, |
116 bool is_opaque) { | 116 bool is_opaque) { |
| 117 if (RasterDeviceTooBigToAllocate(width, height)) |
| 118 return NULL; |
| 119 |
117 SkBitmap bitmap; | 120 SkBitmap bitmap; |
118 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); | 121 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); |
119 if (bitmap.allocPixels() != true) | 122 if (bitmap.allocPixels() != true) |
120 return NULL; | 123 return NULL; |
121 | 124 |
122 void* data = NULL; | 125 void* data = NULL; |
123 if (context) { | 126 if (context) { |
124 data = CGBitmapContextGetData(context); | 127 data = CGBitmapContextGetData(context); |
125 bitmap.setPixels(data); | 128 bitmap.setPixels(data); |
126 } else { | 129 } else { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice( | 248 SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice( |
246 SkBitmap::Config config, int width, int height, bool isOpaque, | 249 SkBitmap::Config config, int width, int height, bool isOpaque, |
247 Usage /*usage*/) { | 250 Usage /*usage*/) { |
248 SkASSERT(config == SkBitmap::kARGB_8888_Config); | 251 SkASSERT(config == SkBitmap::kARGB_8888_Config); |
249 SkDevice* bitmap_device = BitmapPlatformDevice::CreateAndClear(width, height, | 252 SkDevice* bitmap_device = BitmapPlatformDevice::CreateAndClear(width, height, |
250 isOpaque); | 253 isOpaque); |
251 return bitmap_device; | 254 return bitmap_device; |
252 } | 255 } |
253 | 256 |
254 } // namespace skia | 257 } // namespace skia |
OLD | NEW |