GPU workaround to simulate Out of Memory errors with large textures
[chromium-blink-merge.git] / cc / quads / largest_draw_quad.cc
blob894be0fdbe49d704788c12d8fd3d3556e1c76085
1 // Copyright 2014 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 #include "cc/quads/largest_draw_quad.h"
7 #include <algorithm>
9 #include "cc/quads/checkerboard_draw_quad.h"
10 #include "cc/quads/debug_border_draw_quad.h"
11 #include "cc/quads/io_surface_draw_quad.h"
12 #include "cc/quads/picture_draw_quad.h"
13 #include "cc/quads/render_pass_draw_quad.h"
14 #include "cc/quads/solid_color_draw_quad.h"
15 #include "cc/quads/stream_video_draw_quad.h"
16 #include "cc/quads/surface_draw_quad.h"
17 #include "cc/quads/texture_draw_quad.h"
18 #include "cc/quads/tile_draw_quad.h"
19 #include "cc/quads/yuv_video_draw_quad.h"
21 namespace {
22 const size_t kLargestDrawQuadSize =
23 sizeof(cc::RenderPassDrawQuad) > sizeof(cc::StreamVideoDrawQuad)
24 ? sizeof(cc::RenderPassDrawQuad)
25 : sizeof(cc::StreamVideoDrawQuad);
26 } // namespace
28 namespace cc {
30 size_t LargestDrawQuadSize() {
31 // Currently the largest quad is either a RenderPassDrawQuad or a
32 // StreamVideoDrawQuad depends on hardware structure.
34 // Use compile assert to make sure largest is actually larger than all other
35 // type of draw quads.
36 static_assert(sizeof(CheckerboardDrawQuad) <= kLargestDrawQuadSize,
37 "Largest Draw Quad size needs update. CheckerboardDrawQuad is "
38 "currently largest.");
39 static_assert(sizeof(DebugBorderDrawQuad) <= kLargestDrawQuadSize,
40 "Largest Draw Quad size needs update. DebugBorderDrawQuad is "
41 "currently largest.");
42 static_assert(sizeof(IOSurfaceDrawQuad) <= kLargestDrawQuadSize,
43 "Largest Draw Quad size needs update. IOSurfaceDrawQuad is "
44 "currently largest.");
45 static_assert(sizeof(PictureDrawQuad) <= kLargestDrawQuadSize,
46 "Largest Draw Quad size needs update. PictureDrawQuad is "
47 "currently largest.");
48 static_assert(sizeof(TextureDrawQuad) <= kLargestDrawQuadSize,
49 "Largest Draw Quad size needs update. TextureDrawQuad is "
50 "currently largest.");
51 static_assert(sizeof(SolidColorDrawQuad) <= kLargestDrawQuadSize,
52 "Largest Draw Quad size needs update. SolidColorDrawQuad is "
53 "currently largest.");
54 static_assert(sizeof(SurfaceDrawQuad) <= kLargestDrawQuadSize,
55 "Largest Draw Quad size needs update. SurfaceDrawQuad is "
56 "currently largest.");
57 static_assert(sizeof(TileDrawQuad) <= kLargestDrawQuadSize,
58 "Largest Draw Quad size needs update. TileDrawQuad is "
59 "currently largest.");
60 static_assert(sizeof(YUVVideoDrawQuad) <= kLargestDrawQuadSize,
61 "Largest Draw Quad size needs update. YUVVideoDrawQuad is "
62 "currently largest.");
64 return kLargestDrawQuadSize;
67 } // namespace cc