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_common.h"
7 #include "cc/quads/checkerboard_draw_quad.h"
8 #include "cc/quads/debug_border_draw_quad.h"
9 #include "cc/quads/io_surface_draw_quad.h"
10 #include "cc/quads/render_pass_draw_quad.h"
11 #include "cc/quads/shared_quad_state.h"
12 #include "cc/quads/solid_color_draw_quad.h"
13 #include "cc/quads/stream_video_draw_quad.h"
14 #include "cc/quads/texture_draw_quad.h"
15 #include "cc/quads/tile_draw_quad.h"
16 #include "cc/quads/yuv_video_draw_quad.h"
17 #include "cc/resources/resource_provider.h"
18 #include "ui/gfx/transform.h"
22 void TestRenderPass::AppendOneOfEveryQuadType(
23 ResourceProvider
* resource_provider
,
24 RenderPass::Id child_pass
) {
25 gfx::Rect
rect(0, 0, 100, 100);
26 gfx::Rect
opaque_rect(10, 10, 80, 80);
27 gfx::Rect
visible_rect(0, 0, 100, 100);
28 const float vertex_opacity
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
29 ResourceProvider::ResourceId resource1
= resource_provider
->CreateResource(
32 ResourceProvider::TextureUsageAny
,
33 resource_provider
->best_texture_format());
34 resource_provider
->AllocateForTesting(resource1
);
35 ResourceProvider::ResourceId resource2
= resource_provider
->CreateResource(
38 ResourceProvider::TextureUsageAny
,
39 resource_provider
->best_texture_format());
40 resource_provider
->AllocateForTesting(resource2
);
41 ResourceProvider::ResourceId resource3
= resource_provider
->CreateResource(
44 ResourceProvider::TextureUsageAny
,
45 resource_provider
->best_texture_format());
46 resource_provider
->AllocateForTesting(resource3
);
47 ResourceProvider::ResourceId resource4
= resource_provider
->CreateResource(
50 ResourceProvider::TextureUsageAny
,
51 resource_provider
->best_texture_format());
52 resource_provider
->AllocateForTesting(resource4
);
53 ResourceProvider::ResourceId resource5
= resource_provider
->CreateResource(
56 ResourceProvider::TextureUsageAny
,
57 resource_provider
->best_texture_format());
58 resource_provider
->AllocateForTesting(resource5
);
59 ResourceProvider::ResourceId resource6
= resource_provider
->CreateResource(
62 ResourceProvider::TextureUsageAny
,
63 resource_provider
->best_texture_format());
64 resource_provider
->AllocateForTesting(resource6
);
65 ResourceProvider::ResourceId resource7
= resource_provider
->CreateResource(
68 ResourceProvider::TextureUsageAny
,
69 resource_provider
->best_texture_format());
70 resource_provider
->AllocateForTesting(resource7
);
72 SharedQuadState
* shared_state
= this->CreateAndAppendSharedQuadState();
73 shared_state
->SetAll(gfx::Transform(),
79 SkXfermode::kSrcOver_Mode
,
82 CheckerboardDrawQuad
* checkerboard_quad
=
83 this->CreateAndAppendDrawQuad
<CheckerboardDrawQuad
>();
84 checkerboard_quad
->SetNew(shared_state
, rect
, visible_rect
, SK_ColorRED
);
86 DebugBorderDrawQuad
* debug_border_quad
=
87 this->CreateAndAppendDrawQuad
<DebugBorderDrawQuad
>();
88 debug_border_quad
->SetNew(shared_state
, rect
, visible_rect
, SK_ColorRED
, 1);
90 IOSurfaceDrawQuad
* io_surface_quad
=
91 this->CreateAndAppendDrawQuad
<IOSurfaceDrawQuad
>();
92 io_surface_quad
->SetNew(shared_state
,
98 IOSurfaceDrawQuad::FLIPPED
);
100 if (child_pass
.layer_id
) {
101 RenderPassDrawQuad
* render_pass_quad
=
102 this->CreateAndAppendDrawQuad
<RenderPassDrawQuad
>();
103 render_pass_quad
->SetNew(shared_state
,
114 RenderPassDrawQuad
* render_pass_replica_quad
=
115 this->CreateAndAppendDrawQuad
<RenderPassDrawQuad
>();
116 render_pass_replica_quad
->SetNew(shared_state
,
128 SolidColorDrawQuad
* solid_color_quad
=
129 this->CreateAndAppendDrawQuad
<SolidColorDrawQuad
>();
130 solid_color_quad
->SetNew(
131 shared_state
, rect
, visible_rect
, SK_ColorRED
, false);
133 StreamVideoDrawQuad
* stream_video_quad
=
134 this->CreateAndAppendDrawQuad
<StreamVideoDrawQuad
>();
135 stream_video_quad
->SetNew(shared_state
,
142 TextureDrawQuad
* texture_quad
=
143 this->CreateAndAppendDrawQuad
<TextureDrawQuad
>();
144 texture_quad
->SetNew(shared_state
,
150 gfx::PointF(0.f
, 0.f
),
151 gfx::PointF(1.f
, 1.f
),
156 TileDrawQuad
* scaled_tile_quad
=
157 this->CreateAndAppendDrawQuad
<TileDrawQuad
>();
158 scaled_tile_quad
->SetNew(shared_state
,
163 gfx::RectF(0, 0, 50, 50),
167 SharedQuadState
* transformed_state
= this->CreateAndAppendSharedQuadState();
168 transformed_state
->CopyFrom(shared_state
);
169 gfx::Transform rotation
;
171 transformed_state
->content_to_target_transform
=
172 transformed_state
->content_to_target_transform
* rotation
;
173 TileDrawQuad
* transformed_tile_quad
=
174 this->CreateAndAppendDrawQuad
<TileDrawQuad
>();
175 transformed_tile_quad
->SetNew(transformed_state
,
180 gfx::RectF(0, 0, 100, 100),
184 SharedQuadState
* shared_state2
= this->CreateAndAppendSharedQuadState();
185 shared_state
->SetAll(gfx::Transform(),
191 SkXfermode::kSrcOver_Mode
,
194 TileDrawQuad
* tile_quad
= this->CreateAndAppendDrawQuad
<TileDrawQuad
>();
195 tile_quad
->SetNew(shared_state2
,
200 gfx::RectF(0, 0, 100, 100),
204 ResourceProvider::ResourceId plane_resources
[4];
205 for (int i
= 0; i
< 4; ++i
) {
207 resource_provider
->CreateResource(
210 ResourceProvider::TextureUsageAny
,
211 resource_provider
->best_texture_format());
212 resource_provider
->AllocateForTesting(plane_resources
[i
]);
214 YUVVideoDrawQuad::ColorSpace color_space
= YUVVideoDrawQuad::REC_601
;
215 YUVVideoDrawQuad
* yuv_quad
=
216 this->CreateAndAppendDrawQuad
<YUVVideoDrawQuad
>();
217 yuv_quad
->SetNew(shared_state2
,
221 gfx::RectF(0, 0, 100, 100),