15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file. 45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#ifndef CC_SURFACES_SURFACE_AGGREGATOR_TEST_HELPERS_H_ 65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define CC_SURFACES_SURFACE_AGGREGATOR_TEST_HELPERS_H_ 75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#include "cc/base/scoped_ptr_vector.h" 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "cc/quads/draw_quad.h" 1003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#include "cc/quads/render_pass_id.h" 11f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#include "cc/surfaces/surface_id.h" 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "third_party/skia/include/core/SkColor.h" 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/gfx/size.h" 145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace cc { 165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)class RenderPass; 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class Surface; 195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class TestRenderPass; 205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)typedef ScopedPtrVector<RenderPass> RenderPassList; 2203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace test { 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)struct Quad { 265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) static Quad SolidColorQuad(SkColor color) { 275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Quad quad; 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) quad.material = DrawQuad::SOLID_COLOR; 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) quad.color = color; 305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return quad; 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 33f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) static Quad SurfaceQuad(SurfaceId surface_id) { 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Quad quad; 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) quad.material = DrawQuad::SURFACE_CONTENT; 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) quad.surface_id = surface_id; 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return quad; 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 4003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) static Quad RenderPassQuad(RenderPassId id) { 415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Quad quad; 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) quad.material = DrawQuad::RENDER_PASS; 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) quad.render_pass_id = id; 445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return quad; 455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DrawQuad::Material material; 485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Set when material==DrawQuad::SURFACE_CONTENT. 49f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) SurfaceId surface_id; 505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Set when material==DrawQuad::SOLID_COLOR. 515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SkColor color; 525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Set when material==DrawQuad::RENDER_PASS. 5303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) RenderPassId render_pass_id; 545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) private: 565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Quad() 575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) : material(DrawQuad::INVALID), 585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) color(SK_ColorWHITE), 595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) render_pass_id(-1, -1) {} 605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)struct Pass { 6303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) Pass(Quad* quads, size_t quad_count, RenderPassId id) 645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) : quads(quads), quad_count(quad_count), id(id) {} 655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Pass(Quad* quads, size_t quad_count) 665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) : quads(quads), quad_count(quad_count), id(1, 1) {} 675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Quad* quads; 695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) size_t quad_count; 7003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) RenderPassId id; 715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void AddSurfaceQuad(TestRenderPass* pass, 745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const gfx::Size& surface_size, 755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int surface_id); 765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void AddQuadInPass(TestRenderPass* pass, Quad desc); 785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void AddPasses(RenderPassList* pass_list, 805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const gfx::Rect& output_rect, 815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Pass* passes, 825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) size_t pass_count); 835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 841320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid TestQuadMatchesExpectations(Quad expected_quad, const DrawQuad* quad); 855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 861320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid TestPassMatchesExpectations(Pass expected_pass, const RenderPass* pass); 875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void TestPassesMatchExpectations(Pass* expected_passes, 895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) size_t expected_pass_count, 901320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci const RenderPassList* passes); 915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace test 935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace cc 945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif // CC_SURFACES_SURFACE_AGGREGATOR_TEST_HELPERS_H_ 96