Revert "Merged all Chromoting Host code into remoting_core.dll (Windows)."
[chromium-blink-merge.git] / cc / test / render_pass_test_common.cc
bloba5b7d33daa64fea1c21f28f94ab8b044ece2eaf9
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/checkerboard_draw_quad.h"
8 #include "cc/debug_border_draw_quad.h"
9 #include "cc/io_surface_draw_quad.h"
10 #include "cc/render_pass_draw_quad.h"
11 #include "cc/solid_color_draw_quad.h"
12 #include "cc/shared_quad_state.h"
13 #include "cc/stream_video_draw_quad.h"
14 #include "cc/texture_draw_quad.h"
15 #include "cc/tile_draw_quad.h"
16 #include "cc/yuv_video_draw_quad.h"
17 #include "cc/resource_provider.h"
18 #include "ui/gfx/transform.h"
20 namespace cc {
22 void TestRenderPass::AppendQuad(scoped_ptr<cc::DrawQuad> quad) {
23 quad_list.push_back(quad.Pass());
26 void TestRenderPass::AppendSharedQuadState(
27 scoped_ptr<cc::SharedQuadState> state) {
28 shared_quad_state_list.push_back(state.Pass());
31 void TestRenderPass::AppendOneOfEveryQuadType(
32 cc::ResourceProvider* resourceProvider, RenderPass::Id child_pass) {
33 gfx::Rect rect(0, 0, 100, 100);
34 gfx::Rect opaque_rect(10, 10, 80, 80);
35 const float vertex_opacity[] = {1.0f, 1.0f, 1.0f, 1.0f};
36 cc::ResourceProvider::ResourceId texture_resource =
37 resourceProvider->createResource(
38 gfx::Size(20, 12),
39 resourceProvider->bestTextureFormat(),
40 ResourceProvider::TextureUsageAny);
41 resourceProvider->allocateForTesting(texture_resource);
42 unsigned texture_id = ResourceProvider::ScopedReadLockGL(
43 resourceProvider, texture_resource).textureId();
44 cc::ResourceProvider::ResourceId resource1 =
45 resourceProvider->createResource(
46 gfx::Size(45, 5),
47 resourceProvider->bestTextureFormat(),
48 ResourceProvider::TextureUsageAny);
49 resourceProvider->allocateForTesting(resource1);
50 cc::ResourceProvider::ResourceId resource2 =
51 resourceProvider->createResource(
52 gfx::Size(346, 61),
53 resourceProvider->bestTextureFormat(),
54 ResourceProvider::TextureUsageAny);
55 resourceProvider->allocateForTesting(resource2);
56 cc::ResourceProvider::ResourceId resource3 =
57 resourceProvider->createResource(
58 gfx::Size(12, 134),
59 resourceProvider->bestTextureFormat(),
60 ResourceProvider::TextureUsageAny);
61 resourceProvider->allocateForTesting(resource3);
62 cc::ResourceProvider::ResourceId resource4 =
63 resourceProvider->createResource(
64 gfx::Size(56, 12),
65 resourceProvider->bestTextureFormat(),
66 ResourceProvider::TextureUsageAny);
67 resourceProvider->allocateForTesting(resource4);
68 cc::ResourceProvider::ResourceId resource5 =
69 resourceProvider->createResource(
70 gfx::Size(73, 26),
71 resourceProvider->bestTextureFormat(),
72 ResourceProvider::TextureUsageAny);
73 resourceProvider->allocateForTesting(resource5);
75 scoped_ptr<cc::SharedQuadState> shared_state = cc::SharedQuadState::Create();
76 shared_state->SetAll(gfx::Transform(),
77 rect,
78 rect,
79 false,
80 1);
82 scoped_ptr<cc::CheckerboardDrawQuad> checkerboard_quad =
83 cc::CheckerboardDrawQuad::Create();
84 checkerboard_quad->SetNew(shared_state.get(),
85 rect,
86 SK_ColorRED);
87 AppendQuad(checkerboard_quad.PassAs<DrawQuad>());
89 scoped_ptr<cc::DebugBorderDrawQuad> debug_border_quad =
90 cc::DebugBorderDrawQuad::Create();
91 debug_border_quad->SetNew(shared_state.get(),
92 rect,
93 SK_ColorRED,
94 1);
95 AppendQuad(debug_border_quad.PassAs<DrawQuad>());
97 scoped_ptr<cc::IOSurfaceDrawQuad> io_surface_quad =
98 cc::IOSurfaceDrawQuad::Create();
99 io_surface_quad->SetNew(shared_state.get(),
100 rect,
101 opaque_rect,
102 gfx::Size(50, 50),
103 texture_id,
104 cc::IOSurfaceDrawQuad::FLIPPED);
105 AppendQuad(io_surface_quad.PassAs<DrawQuad>());
107 if (child_pass.layer_id) {
108 scoped_ptr<cc::RenderPassDrawQuad> render_pass_quad =
109 cc::RenderPassDrawQuad::Create();
110 render_pass_quad->SetNew(shared_state.get(),
111 rect,
112 child_pass,
113 false,
114 resource5,
115 rect,
116 gfx::RectF(),
117 WebKit::WebFilterOperations(),
118 skia::RefPtr<SkImageFilter>(),
119 WebKit::WebFilterOperations());
120 AppendQuad(render_pass_quad.PassAs<DrawQuad>());
122 scoped_ptr<cc::RenderPassDrawQuad> render_pass_replica_quad =
123 cc::RenderPassDrawQuad::Create();
124 render_pass_replica_quad->SetNew(shared_state.get(),
125 rect,
126 child_pass,
127 true,
128 resource5,
129 rect,
130 gfx::RectF(),
131 WebKit::WebFilterOperations(),
132 skia::RefPtr<SkImageFilter>(),
133 WebKit::WebFilterOperations());
134 AppendQuad(render_pass_replica_quad.PassAs<DrawQuad>());
137 scoped_ptr<cc::SolidColorDrawQuad> solid_color_quad =
138 cc::SolidColorDrawQuad::Create();
139 solid_color_quad->SetNew(shared_state.get(),
140 rect,
141 SK_ColorRED);
142 AppendQuad(solid_color_quad.PassAs<DrawQuad>());
144 scoped_ptr<cc::StreamVideoDrawQuad> stream_video_quad =
145 cc::StreamVideoDrawQuad::Create();
146 stream_video_quad->SetNew(shared_state.get(),
147 rect,
148 opaque_rect,
149 texture_id,
150 gfx::Transform());
151 AppendQuad(stream_video_quad.PassAs<DrawQuad>());
153 scoped_ptr<cc::TextureDrawQuad> texture_quad =
154 cc::TextureDrawQuad::Create();
155 texture_quad->SetNew(shared_state.get(),
156 rect,
157 opaque_rect,
158 resource1,
159 false,
160 gfx::PointF(0.f, 0.f),
161 gfx::PointF(1.f, 1.f),
162 vertex_opacity,
163 false);
164 AppendQuad(texture_quad.PassAs<DrawQuad>());
166 scoped_ptr<cc::TileDrawQuad> scaled_tile_quad =
167 cc::TileDrawQuad::Create();
168 scaled_tile_quad->SetNew(shared_state.get(),
169 rect,
170 opaque_rect,
171 resource2,
172 gfx::RectF(0, 0, 50, 50),
173 gfx::Size(50, 50),
174 false,
175 false,
176 false,
177 false,
178 false);
179 AppendQuad(scaled_tile_quad.PassAs<DrawQuad>());
181 scoped_ptr<cc::SharedQuadState> transformed_state = shared_state->Copy();
182 gfx::Transform rotation;
183 rotation.Rotate(45);
184 transformed_state->content_to_target_transform = transformed_state->content_to_target_transform * rotation;
185 scoped_ptr<cc::TileDrawQuad> transformed_tile_quad =
186 cc::TileDrawQuad::Create();
187 transformed_tile_quad->SetNew(transformed_state.get(),
188 rect,
189 opaque_rect,
190 resource3,
191 gfx::RectF(0, 0, 100, 100),
192 gfx::Size(100, 100),
193 false,
194 false,
195 false,
196 false,
197 false);
198 AppendQuad(transformed_tile_quad.PassAs<DrawQuad>());
200 scoped_ptr<cc::TileDrawQuad> tile_quad =
201 cc::TileDrawQuad::Create();
202 tile_quad->SetNew(shared_state.get(),
203 rect,
204 opaque_rect,
205 resource4,
206 gfx::RectF(0, 0, 100, 100),
207 gfx::Size(100, 100),
208 false,
209 false,
210 false,
211 false,
212 false);
213 AppendQuad(tile_quad.PassAs<DrawQuad>());
215 cc::VideoLayerImpl::FramePlane planes[3];
216 for (int i = 0; i < 3; ++i) {
217 planes[i].resourceId =
218 resourceProvider->createResource(
219 gfx::Size(20, 12),
220 resourceProvider->bestTextureFormat(),
221 ResourceProvider::TextureUsageAny);
222 resourceProvider->allocateForTesting(planes[i].resourceId);
223 planes[i].size = gfx::Size(100, 100);
224 planes[i].format = GL_LUMINANCE;
226 scoped_ptr<cc::YUVVideoDrawQuad> yuv_quad =
227 cc::YUVVideoDrawQuad::Create();
228 yuv_quad->SetNew(shared_state.get(),
229 rect,
230 opaque_rect,
231 gfx::Size(100, 100),
232 planes[0],
233 planes[1],
234 planes[2]);
235 AppendQuad(yuv_quad.PassAs<DrawQuad>());
237 AppendSharedQuadState(transformed_state.Pass());
238 AppendSharedQuadState(shared_state.Pass());
241 } // namespace cc