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