summaryrefslogtreecommitdiffstats
path: root/skia/ext/bitmap_platform_device.h
diff options
context:
space:
mode:
authorreed@google.com <reed@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-17 11:53:34 +0000
committerreed@google.com <reed@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-17 11:53:34 +0000
commit0bdd14bd924c945ec8a4d90bbd9a02aaddeee99e (patch)
treebcf11685703dc9ec345558a31ee569aaa6d2d827 /skia/ext/bitmap_platform_device.h
parentc41f7529fd4d7d5cd30231773d63fc519e2b4705 (diff)
downloadchromium_src-0bdd14bd924c945ec8a4d90bbd9a02aaddeee99e.zip
chromium_src-0bdd14bd924c945ec8a4d90bbd9a02aaddeee99e.tar.gz
chromium_src-0bdd14bd924c945ec8a4d90bbd9a02aaddeee99e.tar.bz2
repeat http://codereview.chromium.org/10908266/ but w/o the android change,
which broke a build. Review URL: https://codereview.chromium.org/10915300 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157105 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/ext/bitmap_platform_device.h')
-rw-r--r--skia/ext/bitmap_platform_device.h15
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_