Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: cc/quads/largest_draw_quad.cc

Issue 2324083003: Fix kLargestDrawQuadSize (Closed)
Patch Set: use a recursive variadic template Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/quads/draw_quad_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "cc/quads/debug_border_draw_quad.h" 11 #include "cc/quads/debug_border_draw_quad.h"
12 #include "cc/quads/picture_draw_quad.h" 12 #include "cc/quads/picture_draw_quad.h"
13 #include "cc/quads/render_pass_draw_quad.h" 13 #include "cc/quads/render_pass_draw_quad.h"
14 #include "cc/quads/solid_color_draw_quad.h" 14 #include "cc/quads/solid_color_draw_quad.h"
15 #include "cc/quads/stream_video_draw_quad.h" 15 #include "cc/quads/stream_video_draw_quad.h"
16 #include "cc/quads/surface_draw_quad.h" 16 #include "cc/quads/surface_draw_quad.h"
17 #include "cc/quads/texture_draw_quad.h" 17 #include "cc/quads/texture_draw_quad.h"
18 #include "cc/quads/tile_draw_quad.h" 18 #include "cc/quads/tile_draw_quad.h"
19 #include "cc/quads/yuv_video_draw_quad.h" 19 #include "cc/quads/yuv_video_draw_quad.h"
20 20
21 namespace { 21 namespace {
22 const size_t kLargestDrawQuadSize = 22 template <typename...>
23 sizeof(cc::YUVVideoDrawQuad) + sizeof(gfx::ColorSpace); 23 struct MaxSize {};
24 template <class T, class... Args>
25 struct MaxSize<T, Args...> {
26 static const size_t value = sizeof(T) > MaxSize<Args...>::value
27 ? sizeof(T)
28 : MaxSize<Args...>::value;
29 };
30 template <>
31 struct MaxSize<> {
32 static const size_t value = 0;
33 };
34
35 const size_t kLargestDrawQuadSize = MaxSize<cc::DebugBorderDrawQuad,
36 cc::PictureDrawQuad,
37 cc::RenderPassDrawQuad,
38 cc::SolidColorDrawQuad,
39 cc::StreamVideoDrawQuad,
40 cc::SurfaceDrawQuad,
41 cc::TextureDrawQuad,
42 cc::TileDrawQuad,
43 cc::YUVVideoDrawQuad>::value;
44
24 } // namespace 45 } // namespace
25 46
26 namespace cc { 47 namespace cc {
27 48
28 size_t LargestDrawQuadSize() { 49 size_t LargestDrawQuadSize() {
29 // Currently the largest quad is either a RenderPassDrawQuad or a
30 // StreamVideoDrawQuad depends on hardware structure.
31
32 // Use compile assert to make sure largest is actually larger than all other
33 // type of draw quads.
34 static_assert(sizeof(DebugBorderDrawQuad) <= kLargestDrawQuadSize,
35 "Largest Draw Quad size needs update. DebugBorderDrawQuad is "
36 "currently largest.");
37 static_assert(sizeof(PictureDrawQuad) <= kLargestDrawQuadSize,
38 "Largest Draw Quad size needs update. PictureDrawQuad is "
39 "currently largest.");
40 static_assert(sizeof(TextureDrawQuad) <= kLargestDrawQuadSize,
41 "Largest Draw Quad size needs update. TextureDrawQuad is "
42 "currently largest.");
43 static_assert(sizeof(SolidColorDrawQuad) <= kLargestDrawQuadSize,
44 "Largest Draw Quad size needs update. SolidColorDrawQuad is "
45 "currently largest.");
46 static_assert(sizeof(SurfaceDrawQuad) <= kLargestDrawQuadSize,
47 "Largest Draw Quad size needs update. SurfaceDrawQuad is "
48 "currently largest.");
49 static_assert(sizeof(TileDrawQuad) <= kLargestDrawQuadSize,
50 "Largest Draw Quad size needs update. TileDrawQuad is "
51 "currently largest.");
52 static_assert(sizeof(YUVVideoDrawQuad) <= kLargestDrawQuadSize,
53 "Largest Draw Quad size needs update. YUVVideoDrawQuad is "
54 "currently largest.");
55
56 return kLargestDrawQuadSize; 50 return kLargestDrawQuadSize;
57 } 51 }
58 52
59 } // namespace cc 53 } // namespace cc
OLDNEW
« no previous file with comments | « cc/quads/draw_quad_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698