Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 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. | |
| 4 | |
| 5 #include "cc/test/surface_hittest_test_helpers.h" | |
| 6 | |
| 7 #include "cc/output/compositor_frame.h" | |
| 8 #include "cc/output/delegated_frame_data.h" | |
| 9 #include "cc/quads/render_pass_draw_quad.h" | |
| 10 #include "cc/quads/shared_quad_state.h" | |
| 11 #include "cc/quads/solid_color_draw_quad.h" | |
| 12 #include "cc/quads/surface_draw_quad.h" | |
| 13 | |
| 14 namespace cc { | |
| 15 namespace test { | |
| 16 | |
| 17 void CreateSharedQuadState(RenderPass* pass, | |
| 18 const gfx::Transform& transform, | |
| 19 const gfx::Rect& root_rect) { | |
| 20 SharedQuadState* child_shared_state = pass->CreateAndAppendSharedQuadState(); | |
| 21 child_shared_state->SetAll(transform, root_rect.size(), root_rect, root_rect, | |
| 22 false, 1.0f, SkXfermode::kSrcOver_Mode, 0); | |
| 23 } | |
| 24 | |
| 25 void CreateSolidColorDrawQuad(RenderPass* pass, | |
| 26 const gfx::Transform& transform, | |
| 27 const gfx::Rect& root_rect, | |
| 28 const gfx::Rect& quad_rect) { | |
| 29 CreateSharedQuadState(pass, transform, root_rect); | |
| 30 SolidColorDrawQuad* color_quad = | |
| 31 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | |
| 32 color_quad->SetNew(pass->shared_quad_state_list.back(), quad_rect, quad_rect, | |
| 33 SK_ColorYELLOW, false); | |
| 34 } | |
| 35 | |
| 36 void CreateRenderPassDrawQuad(RenderPass* pass, | |
| 37 const gfx::Transform& transform, | |
| 38 const gfx::Rect& root_rect, | |
| 39 const gfx::Rect& quad_rect, | |
| 40 const RenderPassId& render_pass_id) { | |
| 41 CreateSharedQuadState(pass, transform, root_rect); | |
| 42 RenderPassDrawQuad* render_pass_quad = | |
| 43 pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); | |
| 44 render_pass_quad->SetNew(pass->shared_quad_state_list.back(), quad_rect, | |
| 45 quad_rect, render_pass_id, ResourceId(), | |
| 46 gfx::Vector2dF(), gfx::Size(), FilterOperations(), | |
| 47 gfx::Vector2dF(), FilterOperations()); | |
| 48 } | |
| 49 | |
| 50 void CreateSurfaceDrawQuad(RenderPass* pass, | |
| 51 const gfx::Transform& transform, | |
| 52 const gfx::Rect& root_rect, | |
| 53 const gfx::Rect& quad_rect, | |
| 54 SurfaceId surface_id) { | |
| 55 CreateSharedQuadState(pass, transform, root_rect); | |
| 56 SurfaceDrawQuad* surface_quad = | |
| 57 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | |
| 58 surface_quad->SetNew(pass->shared_quad_state_list.back(), quad_rect, | |
| 59 quad_rect, surface_id); | |
| 60 } | |
| 61 | |
| 62 void CreateRenderPass(const RenderPassId& render_pass_id, | |
| 63 const gfx::Rect& rect, | |
| 64 const gfx::Transform& transform_to_root_target, | |
| 65 RenderPassList* render_pass_list) { | |
| 66 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | |
| 67 render_pass->SetNew(render_pass_id, rect, rect, transform_to_root_target); | |
| 68 render_pass_list->push_back(render_pass.Pass()); | |
| 69 } | |
| 70 | |
| 71 scoped_ptr<CompositorFrame> CreateCompositorFrameWithRenderPassList( | |
| 72 RenderPassList* render_pass_list) { | |
| 73 scoped_ptr<DelegatedFrameData> root_delegated_frame_data( | |
| 74 new DelegatedFrameData); | |
| 75 root_delegated_frame_data->render_pass_list.swap(*render_pass_list); | |
| 76 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); | |
| 77 root_frame->delegated_frame_data = root_delegated_frame_data.Pass(); | |
| 78 return root_frame.Pass(); | |
|
danakj
2015/10/23 18:35:02
nit: return makes an rvalue, you don't need to Pas
Fady Samuel
2015/10/23 19:22:28
Done.
| |
| 79 } | |
| 80 | |
| 81 scoped_ptr<CompositorFrame> CreateCompositorFrame(const gfx::Rect& root_rect, | |
| 82 RenderPass** render_pass) { | |
| 83 RenderPassList render_pass_list; | |
| 84 RenderPassId root_id(1, 1); | |
| 85 CreateRenderPass(root_id, root_rect, gfx::Transform(), &render_pass_list); | |
| 86 | |
| 87 scoped_ptr<CompositorFrame> root_frame = | |
| 88 CreateCompositorFrameWithRenderPassList(&render_pass_list); | |
| 89 | |
| 90 *render_pass = root_frame->delegated_frame_data->render_pass_list.back(); | |
| 91 return root_frame.Pass(); | |
|
danakj
2015/10/23 18:35:02
nit: return makes an rvalue, you don't need to Pas
Fady Samuel
2015/10/23 19:22:28
Done.
| |
| 92 } | |
| 93 | |
| 94 } // namespace test | |
| 95 } // namespace cc | |
| OLD | NEW |