| 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 #ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_H_ | 5 #ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_H_ |
| 6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_H_ | 6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_H_ |
| 7 | 7 |
| 8 // This file provides an easy way to include the appropriate | 8 // This file provides an easy way to include the appropriate |
| 9 // BitmapPlatformDevice header file for your platform. | 9 // BitmapPlatformDevice header file for your platform. |
| 10 | 10 |
| 11 #include <stdint.h> | 11 #include <stdint.h> |
| 12 | 12 |
| 13 #if defined(WIN32) | 13 #if defined(WIN32) |
| 14 #include "skia/ext/bitmap_platform_device_win.h" | 14 #include "skia/ext/bitmap_platform_device_win.h" |
| 15 #elif defined(__APPLE__) | 15 #elif defined(__APPLE__) |
| 16 #include "skia/ext/bitmap_platform_device_mac.h" | 16 #include "skia/ext/bitmap_platform_device_mac.h" |
| 17 #elif defined(USE_CAIRO) | 17 #elif defined(USE_CAIRO) |
| 18 #include "skia/ext/bitmap_platform_device_cairo.h" | 18 #include "skia/ext/bitmap_platform_device_cairo.h" |
| 19 #else | 19 #else |
| 20 #include "skia/ext/bitmap_platform_device_skia.h" | 20 #include "skia/ext/bitmap_platform_device_skia.h" |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 namespace skia { | |
| 24 // Returns true if it is unsafe to attempt to allocate an offscreen buffer | |
| 25 // given these dimensions. | |
| 26 inline bool RasterDeviceTooBigToAllocate(int width, int height) { | |
| 27 | |
| 28 #ifndef SKIA_EXT_RASTER_DEVICE_ALLOCATION_MAX | |
| 29 #define SKIA_EXT_RASTER_DEVICE_ALLOCATION_MAX (2 * 256 * 1024 * 1024) | |
| 30 #endif | |
| 31 | |
| 32 int bytesPerPixel = 4; | |
| 33 int64_t bytes = (int64_t)width * height * bytesPerPixel; | |
| 34 return bytes > SKIA_EXT_RASTER_DEVICE_ALLOCATION_MAX; | |
| 35 } | |
| 36 } | |
| 37 | |
| 38 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_H_ | 23 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_H_ |
| OLD | NEW |