diff options
author | reed@google.com <reed@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-15 02:28:26 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-15 02:28:26 +0000 |
commit | 37c81cc079396af325b8fe1851a0d6c629cd089a (patch) | |
tree | 0f2a3246d3a12f0fb816ea846c3a0ce1c28989af /skia/ext/bitmap_platform_device.h | |
parent | e4e06e3984958a9eda5e01fed51e29139440d951 (diff) | |
download | chromium_src-37c81cc079396af325b8fe1851a0d6c629cd089a.zip chromium_src-37c81cc079396af325b8fe1851a0d6c629cd089a.tar.gz chromium_src-37c81cc079396af325b8fe1851a0d6c629cd089a.tar.bz2 |
Add define to limit recommended offscreen allocations. This avoids some failures
where our out-of-memory handlers do not kick in properly.
BUG=134626
Review URL: https://codereview.chromium.org/10908266
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156969 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/ext/bitmap_platform_device.h')
-rw-r--r-- | skia/ext/bitmap_platform_device.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/skia/ext/bitmap_platform_device.h b/skia/ext/bitmap_platform_device.h index 6b119c1..56e4176 100644 --- a/skia/ext/bitmap_platform_device.h +++ b/skia/ext/bitmap_platform_device.h @@ -18,4 +18,19 @@ #include "skia/ext/bitmap_platform_device_linux.h" #endif +namespace skia { + // Returns true if it is unsafe to attempt to allocate an offscreen buffer + // given these dimensions. + inline bool RasterDeviceTooBigToAllocate(int width, int height) { + +#ifndef SKIA_EXT_RASTER_DEVICE_ALLOCATION_MAX +#define SKIA_EXT_RASTER_DEVICE_ALLOCATION_MAX (2 * 256 * 1024 * 1024) +#endif + + int bytesPerPixel = 4; + int64_t bytes = (int64_t)width * height * bytesPerPixel; + return bytes > SKIA_EXT_RASTER_DEVICE_ALLOCATION_MAX; + } +} + #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_H_ |