Factor out a BluetoothChannelMac base class and a BluetoothRfcommChannelMac subclass.
[chromium-blink-merge.git] / cc / test / render_pass_test_common.cc
blobdd58b43b2387e5b9366bf706d1a772f12b821ead
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"
20 namespace cc {
22 void TestRenderPass::AppendQuad(scoped_ptr<DrawQuad> quad) {
23 quad_list.push_back(quad.Pass());
26 void TestRenderPass::AppendOneOfEveryQuadType(
27 ResourceProvider* resource_provider,
28 RenderPass::Id child_pass) {
29 gfx::Rect rect(0, 0, 100, 100);
30 gfx::Rect opaque_rect(10, 10, 80, 80);
31 gfx::Rect visible_rect(0, 0, 100, 100);
32 const float vertex_opacity[] = {1.0f, 1.0f, 1.0f, 1.0f};
33 ResourceProvider::ResourceId resource1 = resource_provider->CreateResource(
34 gfx::Size(45, 5),
35 GL_CLAMP_TO_EDGE,
36 ResourceProvider::TextureUsageAny,
37 resource_provider->best_texture_format());
38 resource_provider->AllocateForTesting(resource1);
39 ResourceProvider::ResourceId resource2 = resource_provider->CreateResource(
40 gfx::Size(346, 61),
41 GL_CLAMP_TO_EDGE,
42 ResourceProvider::TextureUsageAny,
43 resource_provider->best_texture_format());
44 resource_provider->AllocateForTesting(resource2);
45 ResourceProvider::ResourceId resource3 = resource_provider->CreateResource(
46 gfx::Size(12, 134),
47 GL_CLAMP_TO_EDGE,
48 ResourceProvider::TextureUsageAny,
49 resource_provider->best_texture_format());
50 resource_provider->AllocateForTesting(resource3);
51 ResourceProvider::ResourceId resource4 = resource_provider->CreateResource(
52 gfx::Size(56, 12),
53 GL_CLAMP_TO_EDGE,
54 ResourceProvider::TextureUsageAny,
55 resource_provider->best_texture_format());
56 resource_provider->AllocateForTesting(resource4);
57 ResourceProvider::ResourceId resource5 = resource_provider->CreateResource(
58 gfx::Size(73, 26),
59 GL_CLAMP_TO_EDGE,
60 ResourceProvider::TextureUsageAny,
61 resource_provider->best_texture_format());
62 resource_provider->AllocateForTesting(resource5);
63 ResourceProvider::ResourceId resource6 = resource_provider->CreateResource(
64 gfx::Size(64, 92),
65 GL_CLAMP_TO_EDGE,
66 ResourceProvider::TextureUsageAny,
67 resource_provider->best_texture_format());
68 resource_provider->AllocateForTesting(resource6);
69 ResourceProvider::ResourceId resource7 = resource_provider->CreateResource(
70 gfx::Size(9, 14),
71 GL_CLAMP_TO_EDGE,
72 ResourceProvider::TextureUsageAny,
73 resource_provider->best_texture_format());
74 resource_provider->AllocateForTesting(resource7);
76 SharedQuadState* shared_state = this->CreateAndAppendSharedQuadState();
77 shared_state->SetAll(gfx::Transform(),
78 rect.size(),
79 rect,
80 rect,
81 false,
83 SkXfermode::kSrcOver_Mode);
85 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad =
86 CheckerboardDrawQuad::Create();
87 checkerboard_quad->SetNew(shared_state, rect, visible_rect, SK_ColorRED);
88 AppendQuad(checkerboard_quad.PassAs<DrawQuad>());
90 scoped_ptr<DebugBorderDrawQuad> debug_border_quad =
91 DebugBorderDrawQuad::Create();
92 debug_border_quad->SetNew(shared_state, rect, visible_rect, SK_ColorRED, 1);
93 AppendQuad(debug_border_quad.PassAs<DrawQuad>());
95 scoped_ptr<IOSurfaceDrawQuad> io_surface_quad = IOSurfaceDrawQuad::Create();
96 io_surface_quad->SetNew(shared_state,
97 rect,
98 opaque_rect,
99 visible_rect,
100 gfx::Size(50, 50),
101 resource7,
102 IOSurfaceDrawQuad::FLIPPED);
103 AppendQuad(io_surface_quad.PassAs<DrawQuad>());
105 if (child_pass.layer_id) {
106 scoped_ptr<RenderPassDrawQuad> render_pass_quad =
107 RenderPassDrawQuad::Create();
108 render_pass_quad->SetNew(shared_state,
109 rect,
110 visible_rect,
111 child_pass,
112 false,
113 resource5,
114 rect,
115 gfx::RectF(),
116 FilterOperations(),
117 FilterOperations());
118 AppendQuad(render_pass_quad.PassAs<DrawQuad>());
120 scoped_ptr<RenderPassDrawQuad> render_pass_replica_quad =
121 RenderPassDrawQuad::Create();
122 render_pass_replica_quad->SetNew(shared_state,
123 rect,
124 visible_rect,
125 child_pass,
126 true,
127 resource5,
128 rect,
129 gfx::RectF(),
130 FilterOperations(),
131 FilterOperations());
132 AppendQuad(render_pass_replica_quad.PassAs<DrawQuad>());
135 scoped_ptr<SolidColorDrawQuad> solid_color_quad =
136 SolidColorDrawQuad::Create();
137 solid_color_quad->SetNew(
138 shared_state, rect, visible_rect, SK_ColorRED, false);
139 AppendQuad(solid_color_quad.PassAs<DrawQuad>());
141 scoped_ptr<StreamVideoDrawQuad> stream_video_quad =
142 StreamVideoDrawQuad::Create();
143 stream_video_quad->SetNew(shared_state,
144 rect,
145 opaque_rect,
146 visible_rect,
147 resource6,
148 gfx::Transform());
149 AppendQuad(stream_video_quad.PassAs<DrawQuad>());
151 scoped_ptr<TextureDrawQuad> texture_quad = TextureDrawQuad::Create();
152 texture_quad->SetNew(shared_state,
153 rect,
154 opaque_rect,
155 visible_rect,
156 resource1,
157 false,
158 gfx::PointF(0.f, 0.f),
159 gfx::PointF(1.f, 1.f),
160 SK_ColorTRANSPARENT,
161 vertex_opacity,
162 false);
163 AppendQuad(texture_quad.PassAs<DrawQuad>());
165 scoped_ptr<TileDrawQuad> scaled_tile_quad = TileDrawQuad::Create();
166 scaled_tile_quad->SetNew(shared_state,
167 rect,
168 opaque_rect,
169 visible_rect,
170 resource2,
171 gfx::RectF(0, 0, 50, 50),
172 gfx::Size(50, 50),
173 false);
174 AppendQuad(scaled_tile_quad.PassAs<DrawQuad>());
176 SharedQuadState* transformed_state = this->CreateAndAppendSharedQuadState();
177 transformed_state->CopyFrom(shared_state);
178 gfx::Transform rotation;
179 rotation.Rotate(45);
180 transformed_state->content_to_target_transform =
181 transformed_state->content_to_target_transform * rotation;
182 scoped_ptr<TileDrawQuad> transformed_tile_quad = TileDrawQuad::Create();
183 transformed_tile_quad->SetNew(transformed_state,
184 rect,
185 opaque_rect,
186 visible_rect,
187 resource3,
188 gfx::RectF(0, 0, 100, 100),
189 gfx::Size(100, 100),
190 false);
191 AppendQuad(transformed_tile_quad.PassAs<DrawQuad>());
193 SharedQuadState* shared_state2 = this->CreateAndAppendSharedQuadState();
194 shared_state->SetAll(gfx::Transform(),
195 rect.size(),
196 rect,
197 rect,
198 false,
200 SkXfermode::kSrcOver_Mode);
202 scoped_ptr<TileDrawQuad> tile_quad = TileDrawQuad::Create();
203 tile_quad->SetNew(shared_state2,
204 rect,
205 opaque_rect,
206 visible_rect,
207 resource4,
208 gfx::RectF(0, 0, 100, 100),
209 gfx::Size(100, 100),
210 false);
211 AppendQuad(tile_quad.PassAs<DrawQuad>());
213 ResourceProvider::ResourceId plane_resources[4];
214 for (int i = 0; i < 4; ++i) {
215 plane_resources[i] =
216 resource_provider->CreateResource(
217 gfx::Size(20, 12),
218 GL_CLAMP_TO_EDGE,
219 ResourceProvider::TextureUsageAny,
220 resource_provider->best_texture_format());
221 resource_provider->AllocateForTesting(plane_resources[i]);
223 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601;
224 scoped_ptr<YUVVideoDrawQuad> yuv_quad = YUVVideoDrawQuad::Create();
225 yuv_quad->SetNew(shared_state2,
226 rect,
227 opaque_rect,
228 visible_rect,
229 gfx::RectF(0, 0, 100, 100),
230 plane_resources[0],
231 plane_resources[1],
232 plane_resources[2],
233 plane_resources[3],
234 color_space);
235 AppendQuad(yuv_quad.PassAs<DrawQuad>());
238 } // namespace cc