1 // Copyright 2012 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 #include "cc/test/render_pass_test_utils.h"
7 #include "cc/quads/render_pass_draw_quad.h"
8 #include "cc/quads/shared_quad_state.h"
9 #include "cc/quads/solid_color_draw_quad.h"
10 #include "cc/resources/resource_provider.h"
11 #include "cc/test/render_pass_test_common.h"
12 #include "third_party/skia/include/core/SkColor.h"
13 #include "third_party/skia/include/core/SkImageFilter.h"
14 #include "ui/gfx/rect.h"
18 TestRenderPass
* AddRenderPass(RenderPassList
* pass_list
,
20 const gfx::Rect
& output_rect
,
21 const gfx::Transform
& root_transform
) {
22 scoped_ptr
<TestRenderPass
> pass(TestRenderPass::Create());
23 pass
->SetNew(id
, output_rect
, output_rect
, root_transform
);
24 TestRenderPass
* saved
= pass
.get();
25 pass_list
->push_back(pass
.PassAs
<RenderPass
>());
29 SolidColorDrawQuad
* AddQuad(TestRenderPass
* pass
,
30 const gfx::Rect
& rect
,
32 SharedQuadState
* shared_state
= pass
->CreateAndAppendSharedQuadState();
33 shared_state
->SetAll(gfx::Transform(),
39 SkXfermode::kSrcOver_Mode
,
41 SolidColorDrawQuad
* quad
=
42 pass
->CreateAndAppendDrawQuad
<SolidColorDrawQuad
>();
43 quad
->SetNew(shared_state
, rect
, rect
, color
, false);
47 SolidColorDrawQuad
* AddClippedQuad(TestRenderPass
* pass
,
48 const gfx::Rect
& rect
,
50 SharedQuadState
* shared_state
= pass
->CreateAndAppendSharedQuadState();
51 shared_state
->SetAll(gfx::Transform(),
57 SkXfermode::kSrcOver_Mode
,
59 SolidColorDrawQuad
* quad
=
60 pass
->CreateAndAppendDrawQuad
<SolidColorDrawQuad
>();
61 quad
->SetNew(shared_state
, rect
, rect
, color
, false);
65 SolidColorDrawQuad
* AddTransformedQuad(TestRenderPass
* pass
,
66 const gfx::Rect
& rect
,
68 const gfx::Transform
& transform
) {
69 SharedQuadState
* shared_state
= pass
->CreateAndAppendSharedQuadState();
70 shared_state
->SetAll(transform
,
76 SkXfermode::kSrcOver_Mode
,
78 SolidColorDrawQuad
* quad
=
79 pass
->CreateAndAppendDrawQuad
<SolidColorDrawQuad
>();
80 quad
->SetNew(shared_state
, rect
, rect
, color
, false);
84 void AddRenderPassQuad(TestRenderPass
* to_pass
,
85 TestRenderPass
* contributing_pass
) {
86 gfx::Rect output_rect
= contributing_pass
->output_rect
;
87 SharedQuadState
* shared_state
= to_pass
->CreateAndAppendSharedQuadState();
88 shared_state
->SetAll(gfx::Transform(),
94 SkXfermode::kSrcOver_Mode
,
96 RenderPassDrawQuad
* quad
=
97 to_pass
->CreateAndAppendDrawQuad
<RenderPassDrawQuad
>();
98 quad
->SetNew(shared_state
,
101 contributing_pass
->id
,
109 void AddRenderPassQuad(TestRenderPass
* to_pass
,
110 TestRenderPass
* contributing_pass
,
111 ResourceProvider::ResourceId mask_resource_id
,
112 const FilterOperations
& filters
,
113 gfx::Transform transform
) {
114 gfx::Rect output_rect
= contributing_pass
->output_rect
;
115 SharedQuadState
* shared_state
= to_pass
->CreateAndAppendSharedQuadState();
116 shared_state
->SetAll(transform
,
122 SkXfermode::kSrcOver_Mode
,
124 RenderPassDrawQuad
* quad
=
125 to_pass
->CreateAndAppendDrawQuad
<RenderPassDrawQuad
>();
126 quad
->SetNew(shared_state
,
129 contributing_pass
->id
,