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/geometry/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
.Pass());
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
,
110 void AddRenderPassQuad(TestRenderPass
* to_pass
,
111 TestRenderPass
* contributing_pass
,
112 ResourceId mask_resource_id
,
113 const FilterOperations
& filters
,
114 gfx::Transform transform
,
115 SkXfermode::Mode blend_mode
) {
116 gfx::Rect output_rect
= contributing_pass
->output_rect
;
117 SharedQuadState
* shared_state
= to_pass
->CreateAndAppendSharedQuadState();
118 shared_state
->SetAll(transform
,
126 RenderPassDrawQuad
* quad
=
127 to_pass
->CreateAndAppendDrawQuad
<RenderPassDrawQuad
>();
128 gfx::Size
arbitrary_nonzero_size(1, 1);
129 quad
->SetNew(shared_state
,
132 contributing_pass
->id
,
134 gfx::Vector2dF(1.f
, 1.f
),
135 arbitrary_nonzero_size
,