[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / cc / surfaces / surface_aggregator_test_helpers.h
blob6d00c4f70f6175d552600d1f7f79792e414d3821
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 #ifndef CC_SURFACES_SURFACE_AGGREGATOR_TEST_HELPERS_H_
6 #define CC_SURFACES_SURFACE_AGGREGATOR_TEST_HELPERS_H_
8 #include "cc/base/scoped_ptr_vector.h"
9 #include "cc/quads/draw_quad.h"
10 #include "cc/quads/render_pass_id.h"
11 #include "cc/surfaces/surface_id.h"
12 #include "third_party/skia/include/core/SkColor.h"
13 #include "ui/gfx/geometry/size.h"
15 namespace cc {
17 class RenderPass;
18 class Surface;
19 class TestRenderPass;
21 typedef ScopedPtrVector<RenderPass> RenderPassList;
23 namespace test {
25 struct Quad {
26 static Quad SolidColorQuad(SkColor color) {
27 Quad quad;
28 quad.material = DrawQuad::SOLID_COLOR;
29 quad.color = color;
30 return quad;
33 static Quad SurfaceQuad(SurfaceId surface_id, float opacity) {
34 Quad quad;
35 quad.material = DrawQuad::SURFACE_CONTENT;
36 quad.opacity = opacity;
37 quad.surface_id = surface_id;
38 return quad;
41 static Quad RenderPassQuad(RenderPassId id) {
42 Quad quad;
43 quad.material = DrawQuad::RENDER_PASS;
44 quad.render_pass_id = id;
45 return quad;
48 DrawQuad::Material material;
49 // Set when material==DrawQuad::SURFACE_CONTENT.
50 SurfaceId surface_id;
51 float opacity;
52 // Set when material==DrawQuad::SOLID_COLOR.
53 SkColor color;
54 // Set when material==DrawQuad::RENDER_PASS.
55 RenderPassId render_pass_id;
57 private:
58 Quad() : material(DrawQuad::INVALID), opacity(1.f), color(SK_ColorWHITE) {}
61 struct Pass {
62 Pass(Quad* quads, size_t quad_count, RenderPassId id)
63 : quads(quads), quad_count(quad_count), id(id) {}
64 Pass(Quad* quads, size_t quad_count)
65 : quads(quads), quad_count(quad_count), id(1, 1) {}
67 Quad* quads;
68 size_t quad_count;
69 RenderPassId id;
72 void AddSurfaceQuad(TestRenderPass* pass,
73 const gfx::Size& surface_size,
74 int surface_id);
76 void AddQuadInPass(TestRenderPass* pass, Quad desc);
78 void AddPasses(RenderPassList* pass_list,
79 const gfx::Rect& output_rect,
80 Pass* passes,
81 size_t pass_count);
83 void TestQuadMatchesExpectations(Quad expected_quad, const DrawQuad* quad);
85 void TestPassMatchesExpectations(Pass expected_pass, const RenderPass* pass);
87 void TestPassesMatchExpectations(Pass* expected_passes,
88 size_t expected_pass_count,
89 const RenderPassList* passes);
91 } // namespace test
92 } // namespace cc
94 #endif // CC_SURFACES_SURFACE_AGGREGATOR_TEST_HELPERS_H_