Roll src/third_party/skia 03bee31:2253aa9
[chromium-blink-merge.git] / skia / ext / bitmap_platform_device.h
bloba0770f7171763e265b5910929a9a4ee6140eac78
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
3 // found in the LICENSE file.
5 #ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_H_
6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_H_
8 // This file provides an easy way to include the appropriate
9 // BitmapPlatformDevice header file for your platform.
11 #if defined(WIN32)
12 #include "skia/ext/bitmap_platform_device_win.h"
13 #elif defined(__APPLE__)
14 #include "skia/ext/bitmap_platform_device_mac.h"
15 #elif defined(USE_CAIRO)
16 #include "skia/ext/bitmap_platform_device_cairo.h"
17 #else
18 #include "skia/ext/bitmap_platform_device_skia.h"
19 #endif
21 namespace skia {
22 // Returns true if it is unsafe to attempt to allocate an offscreen buffer
23 // given these dimensions.
24 inline bool RasterDeviceTooBigToAllocate(int width, int height) {
26 #ifndef SKIA_EXT_RASTER_DEVICE_ALLOCATION_MAX
27 #define SKIA_EXT_RASTER_DEVICE_ALLOCATION_MAX (2 * 256 * 1024 * 1024)
28 #endif
30 int bytesPerPixel = 4;
31 int64_t bytes = (int64_t)width * height * bytesPerPixel;
32 return bytes > SKIA_EXT_RASTER_DEVICE_ALLOCATION_MAX;
36 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_H_