1 // Copyright 2014 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/quads/checkerboard_draw_quad.h"
6 #include "cc/quads/debug_border_draw_quad.h"
7 #include "cc/quads/render_pass.h"
8 #include "cc/quads/solid_color_draw_quad.h"
9 #include "cc/quads/surface_draw_quad.h"
10 #include "cc/quads/texture_draw_quad.h"
11 #include "cc/resources/resource_provider.h"
12 #include "gpu/command_buffer/common/mailbox.h"
13 #include "gpu/command_buffer/common/mailbox_holder.h"
14 #include "mojo/converters/geometry/geometry_type_converters.h"
15 #include "mojo/converters/surfaces/surfaces_type_converters.h"
16 #include "mojo/converters/transform/transform_type_converters.h"
17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "third_party/skia/include/core/SkColor.h"
19 #include "third_party/skia/include/core/SkXfermode.h"
24 TEST(SurfaceLibTest
, SurfaceIdConverterNullId
) {
25 cc::SurfaceId null_id
;
26 cc::SurfaceId round_trip
= SurfaceId::From(null_id
).To
<cc::SurfaceId
>();
27 EXPECT_TRUE(round_trip
.is_null());
30 TEST(SurfaceLibTest
, SurfaceIdConverterValidId
) {
31 cc::SurfaceId
valid_id(7);
32 cc::SurfaceId round_trip
= SurfaceId::From(valid_id
).To
<cc::SurfaceId
>();
33 EXPECT_FALSE(round_trip
.is_null());
34 EXPECT_EQ(valid_id
, round_trip
);
37 TEST(SurfaceLibTest
, Color
) {
38 SkColor arbitrary_color
= SK_ColorMAGENTA
;
39 SkColor round_trip
= Color::From(arbitrary_color
).To
<SkColor
>();
40 EXPECT_EQ(arbitrary_color
, round_trip
);
43 class SurfaceLibQuadTest
: public testing::Test
{
48 visible_rect(9, 11, 5, 7),
49 needs_blending(false) {
50 pass
= cc::RenderPass::Create();
51 sqs
= pass
->CreateAndAppendSharedQuadState();
56 gfx::Rect opaque_rect
;
57 gfx::Rect visible_rect
;
59 scoped_ptr
<cc::RenderPass
> pass
;
60 cc::SharedQuadState
* sqs
;
63 TEST_F(SurfaceLibQuadTest
, ColorQuad
) {
64 cc::SolidColorDrawQuad
* color_quad
=
65 pass
->CreateAndAppendDrawQuad
<cc::SolidColorDrawQuad
>();
66 SkColor arbitrary_color
= SK_ColorGREEN
;
67 bool force_anti_aliasing_off
= true;
68 color_quad
->SetAll(sqs
,
74 force_anti_aliasing_off
);
76 QuadPtr mojo_quad
= Quad::From
<cc::DrawQuad
>(*color_quad
);
77 ASSERT_FALSE(mojo_quad
.is_null());
78 EXPECT_EQ(MATERIAL_SOLID_COLOR
, mojo_quad
->material
);
79 EXPECT_EQ(Rect::From(rect
), mojo_quad
->rect
);
80 EXPECT_EQ(Rect::From(opaque_rect
), mojo_quad
->opaque_rect
);
81 EXPECT_EQ(Rect::From(visible_rect
), mojo_quad
->visible_rect
);
82 EXPECT_EQ(needs_blending
, mojo_quad
->needs_blending
);
83 ASSERT_TRUE(mojo_quad
->solid_color_quad_state
);
84 SolidColorQuadStatePtr
& mojo_color_state
= mojo_quad
->solid_color_quad_state
;
85 EXPECT_EQ(Color::From(arbitrary_color
), mojo_color_state
->color
);
86 EXPECT_EQ(force_anti_aliasing_off
, mojo_color_state
->force_anti_aliasing_off
);
89 TEST_F(SurfaceLibQuadTest
, SurfaceQuad
) {
90 cc::SurfaceDrawQuad
* surface_quad
=
91 pass
->CreateAndAppendDrawQuad
<cc::SurfaceDrawQuad
>();
92 cc::SurfaceId
arbitrary_id(5);
94 sqs
, rect
, opaque_rect
, visible_rect
, needs_blending
, arbitrary_id
);
96 QuadPtr mojo_quad
= Quad::From
<cc::DrawQuad
>(*surface_quad
);
97 ASSERT_FALSE(mojo_quad
.is_null());
98 EXPECT_EQ(MATERIAL_SURFACE_CONTENT
, mojo_quad
->material
);
99 ASSERT_TRUE(mojo_quad
->surface_quad_state
);
100 SurfaceQuadStatePtr
& mojo_surface_state
= mojo_quad
->surface_quad_state
;
101 EXPECT_EQ(SurfaceId::From(arbitrary_id
),
102 mojo_surface_state
->surface
);
105 TEST_F(SurfaceLibQuadTest
, TextureQuad
) {
106 cc::TextureDrawQuad
* texture_quad
=
107 pass
->CreateAndAppendDrawQuad
<cc::TextureDrawQuad
>();
108 unsigned resource_id
= 9;
109 bool premultiplied_alpha
= true;
110 gfx::PointF
uv_top_left(1.7f
, 2.1f
);
111 gfx::PointF
uv_bottom_right(-7.f
, 16.3f
);
112 SkColor background_color
= SK_ColorYELLOW
;
113 float vertex_opacity
[4] = {0.1f
, 0.5f
, 0.4f
, 0.8f
};
114 bool y_flipped
= false;
115 bool nearest_neighbor
= false;
116 bool allow_overlay
= false;
117 texture_quad
->SetAll(sqs
, rect
, opaque_rect
, visible_rect
, needs_blending
,
118 resource_id
, gfx::Size(), allow_overlay
,
119 premultiplied_alpha
, uv_top_left
, uv_bottom_right
,
120 background_color
, vertex_opacity
, y_flipped
,
123 QuadPtr mojo_quad
= Quad::From
<cc::DrawQuad
>(*texture_quad
);
124 ASSERT_FALSE(mojo_quad
.is_null());
125 EXPECT_EQ(MATERIAL_TEXTURE_CONTENT
, mojo_quad
->material
);
126 ASSERT_TRUE(mojo_quad
->texture_quad_state
);
127 TextureQuadStatePtr
& mojo_texture_state
= mojo_quad
->texture_quad_state
;
128 EXPECT_EQ(resource_id
, mojo_texture_state
->resource_id
);
129 EXPECT_EQ(premultiplied_alpha
, mojo_texture_state
->premultiplied_alpha
);
130 EXPECT_EQ(PointF::From(uv_top_left
), mojo_texture_state
->uv_top_left
);
131 EXPECT_EQ(PointF::From(uv_bottom_right
), mojo_texture_state
->uv_bottom_right
);
132 EXPECT_EQ(Color::From(background_color
),
133 mojo_texture_state
->background_color
);
134 for (size_t i
= 0; i
< 4; ++i
) {
135 EXPECT_EQ(vertex_opacity
[i
], mojo_texture_state
->vertex_opacity
[i
]) << i
;
137 EXPECT_EQ(y_flipped
, mojo_texture_state
->y_flipped
);
140 TEST_F(SurfaceLibQuadTest
, TextureQuadEmptyVertexOpacity
) {
141 QuadPtr mojo_texture_quad
= Quad::New();
142 mojo_texture_quad
->material
= MATERIAL_TEXTURE_CONTENT
;
143 TextureQuadStatePtr mojo_texture_state
= TextureQuadState::New();
144 mojo_texture_state
->background_color
= Color::New();
145 mojo_texture_quad
->texture_quad_state
= mojo_texture_state
.Pass();
146 PassPtr mojo_pass
= Pass::New();
147 mojo_pass
->id
= RenderPassId::New();
148 mojo_pass
->id
->layer_id
= 1;
149 mojo_pass
->id
->index
= 1u;
150 mojo_pass
->quads
.push_back(mojo_texture_quad
.Pass());
151 SharedQuadStatePtr mojo_sqs
= SharedQuadState::New();
152 mojo_pass
->shared_quad_states
.push_back(mojo_sqs
.Pass());
154 scoped_ptr
<cc::RenderPass
> pass
= mojo_pass
.To
<scoped_ptr
<cc::RenderPass
> >();
159 TEST_F(SurfaceLibQuadTest
, TextureQuadEmptyBackgroundColor
) {
160 QuadPtr mojo_texture_quad
= Quad::New();
161 mojo_texture_quad
->material
= MATERIAL_TEXTURE_CONTENT
;
162 TextureQuadStatePtr mojo_texture_state
= TextureQuadState::New();
163 mojo_texture_state
->vertex_opacity
= mojo::Array
<float>::New(4);
164 mojo_texture_quad
->texture_quad_state
= mojo_texture_state
.Pass();
165 PassPtr mojo_pass
= Pass::New();
166 mojo_pass
->id
= RenderPassId::New();
167 mojo_pass
->id
->layer_id
= 1;
168 mojo_pass
->id
->index
= 1u;
169 mojo_pass
->quads
.push_back(mojo_texture_quad
.Pass());
170 SharedQuadStatePtr mojo_sqs
= SharedQuadState::New();
171 mojo_pass
->shared_quad_states
.push_back(mojo_sqs
.Pass());
173 scoped_ptr
<cc::RenderPass
> pass
= mojo_pass
.To
<scoped_ptr
<cc::RenderPass
> >();
177 TEST(SurfaceLibTest
, SharedQuadState
) {
178 gfx::Transform quad_to_target_transform
;
179 quad_to_target_transform
.Scale3d(0.3f
, 0.7f
, 0.9f
);
180 gfx::Size
quad_layer_bounds(57, 39);
181 gfx::Rect
visible_quad_layer_rect(3, 7, 28, 42);
182 gfx::Rect
clip_rect(9, 12, 21, 31);
183 bool is_clipped
= true;
184 float opacity
= 0.65f
;
185 int sorting_context_id
= 13;
186 ::SkXfermode::Mode blend_mode
= ::SkXfermode::kSrcOver_Mode
;
187 scoped_ptr
<cc::RenderPass
> pass
= cc::RenderPass::Create();
188 cc::SharedQuadState
* sqs
= pass
->CreateAndAppendSharedQuadState();
189 sqs
->SetAll(quad_to_target_transform
, quad_layer_bounds
,
190 visible_quad_layer_rect
, clip_rect
, is_clipped
, opacity
,
191 blend_mode
, sorting_context_id
);
193 SharedQuadStatePtr mojo_sqs
= SharedQuadState::From(*sqs
);
194 ASSERT_FALSE(mojo_sqs
.is_null());
195 EXPECT_EQ(Transform::From(quad_to_target_transform
),
196 mojo_sqs
->quad_to_target_transform
);
197 EXPECT_EQ(Size::From(quad_layer_bounds
), mojo_sqs
->quad_layer_bounds
);
198 EXPECT_EQ(Rect::From(visible_quad_layer_rect
),
199 mojo_sqs
->visible_quad_layer_rect
);
200 EXPECT_EQ(Rect::From(clip_rect
), mojo_sqs
->clip_rect
);
201 EXPECT_EQ(is_clipped
, mojo_sqs
->is_clipped
);
202 EXPECT_EQ(opacity
, mojo_sqs
->opacity
);
203 EXPECT_EQ(sorting_context_id
, mojo_sqs
->sorting_context_id
);
206 TEST(SurfaceLibTest
, RenderPass
) {
207 scoped_ptr
<cc::RenderPass
> pass
= cc::RenderPass::Create();
208 cc::RenderPassId
pass_id(1, 6);
209 gfx::Rect
output_rect(4, 9, 13, 71);
210 gfx::Rect
damage_rect(9, 17, 41, 45);
211 gfx::Transform transform_to_root_target
;
212 transform_to_root_target
.SkewY(43.0);
213 bool has_transparent_background
= false;
214 pass
->SetAll(pass_id
,
217 transform_to_root_target
,
218 has_transparent_background
);
220 gfx::Transform quad_to_target_transform
;
221 quad_to_target_transform
.Scale3d(0.3f
, 0.7f
, 0.9f
);
222 gfx::Size
quad_layer_bounds(57, 39);
223 gfx::Rect
visible_quad_layer_rect(3, 7, 28, 42);
224 gfx::Rect
clip_rect(9, 12, 21, 31);
225 bool is_clipped
= true;
226 float opacity
= 0.65f
;
227 int sorting_context_id
= 13;
228 ::SkXfermode::Mode blend_mode
= ::SkXfermode::kSrcOver_Mode
;
229 cc::SharedQuadState
* sqs
= pass
->CreateAndAppendSharedQuadState();
230 sqs
->SetAll(quad_to_target_transform
, quad_layer_bounds
,
231 visible_quad_layer_rect
, clip_rect
, is_clipped
, opacity
,
232 blend_mode
, sorting_context_id
);
234 gfx::Rect
rect(5, 7, 13, 19);
235 gfx::Rect
opaque_rect(rect
);
236 gfx::Rect
visible_rect(9, 11, 5, 7);
237 bool needs_blending
= false;
239 cc::SolidColorDrawQuad
* color_quad
=
240 pass
->CreateAndAppendDrawQuad
<cc::SolidColorDrawQuad
>();
241 SkColor arbitrary_color
= SK_ColorGREEN
;
242 bool force_anti_aliasing_off
= true;
243 color_quad
->SetAll(pass
->shared_quad_state_list
.back(),
249 force_anti_aliasing_off
);
251 cc::SurfaceDrawQuad
* surface_quad
=
252 pass
->CreateAndAppendDrawQuad
<cc::SurfaceDrawQuad
>();
253 cc::SurfaceId
arbitrary_id(5);
254 surface_quad
->SetAll(
255 sqs
, rect
, opaque_rect
, visible_rect
, needs_blending
, arbitrary_id
);
257 cc::TextureDrawQuad
* texture_quad
=
258 pass
->CreateAndAppendDrawQuad
<cc::TextureDrawQuad
>();
259 unsigned resource_id
= 9;
260 bool premultiplied_alpha
= true;
261 gfx::PointF
uv_top_left(1.7f
, 2.1f
);
262 gfx::PointF
uv_bottom_right(-7.f
, 16.3f
);
263 SkColor background_color
= SK_ColorYELLOW
;
264 float vertex_opacity
[4] = {0.1f
, 0.5f
, 0.4f
, 0.8f
};
265 bool y_flipped
= false;
266 bool nearest_neighbor
= false;
267 bool allow_overlay
= false;
268 texture_quad
->SetAll(sqs
, rect
, opaque_rect
, visible_rect
, needs_blending
,
269 resource_id
, gfx::Size(), allow_overlay
,
270 premultiplied_alpha
, uv_top_left
, uv_bottom_right
,
271 background_color
, vertex_opacity
, y_flipped
,
274 PassPtr mojo_pass
= Pass::From(*pass
);
275 ASSERT_FALSE(mojo_pass
.is_null());
276 EXPECT_EQ(6u, mojo_pass
->id
->index
);
277 EXPECT_EQ(Rect::From(output_rect
), mojo_pass
->output_rect
);
278 EXPECT_EQ(Rect::From(damage_rect
), mojo_pass
->damage_rect
);
279 EXPECT_EQ(Transform::From(transform_to_root_target
),
280 mojo_pass
->transform_to_root_target
);
281 EXPECT_EQ(has_transparent_background
, mojo_pass
->has_transparent_background
);
282 ASSERT_EQ(1u, mojo_pass
->shared_quad_states
.size());
283 ASSERT_EQ(3u, mojo_pass
->quads
.size());
284 EXPECT_EQ(0u, mojo_pass
->quads
[0]->shared_quad_state_index
);
286 scoped_ptr
<cc::RenderPass
> round_trip_pass
=
287 mojo_pass
.To
<scoped_ptr
<cc::RenderPass
> >();
288 EXPECT_EQ(pass_id
, round_trip_pass
->id
);
289 EXPECT_EQ(output_rect
, round_trip_pass
->output_rect
);
290 EXPECT_EQ(damage_rect
, round_trip_pass
->damage_rect
);
291 EXPECT_EQ(transform_to_root_target
,
292 round_trip_pass
->transform_to_root_target
);
293 EXPECT_EQ(has_transparent_background
,
294 round_trip_pass
->has_transparent_background
);
295 ASSERT_EQ(1u, round_trip_pass
->shared_quad_state_list
.size());
296 ASSERT_EQ(3u, round_trip_pass
->quad_list
.size());
297 EXPECT_EQ(round_trip_pass
->shared_quad_state_list
.front(),
298 round_trip_pass
->quad_list
.front()->shared_quad_state
);
300 cc::SharedQuadState
* round_trip_sqs
=
301 round_trip_pass
->shared_quad_state_list
.front();
302 EXPECT_EQ(quad_to_target_transform
, round_trip_sqs
->quad_to_target_transform
);
303 EXPECT_EQ(quad_layer_bounds
, round_trip_sqs
->quad_layer_bounds
);
304 EXPECT_EQ(visible_quad_layer_rect
, round_trip_sqs
->visible_quad_layer_rect
);
305 EXPECT_EQ(clip_rect
, round_trip_sqs
->clip_rect
);
306 EXPECT_EQ(is_clipped
, round_trip_sqs
->is_clipped
);
307 EXPECT_EQ(opacity
, round_trip_sqs
->opacity
);
308 EXPECT_EQ(sorting_context_id
, round_trip_sqs
->sorting_context_id
);
310 cc::DrawQuad
* round_trip_quad
= round_trip_pass
->quad_list
.front();
311 // First is solid color quad.
312 ASSERT_EQ(cc::DrawQuad::SOLID_COLOR
, round_trip_quad
->material
);
313 EXPECT_EQ(rect
, round_trip_quad
->rect
);
314 EXPECT_EQ(opaque_rect
, round_trip_quad
->opaque_rect
);
315 EXPECT_EQ(visible_rect
, round_trip_quad
->visible_rect
);
316 EXPECT_EQ(needs_blending
, round_trip_quad
->needs_blending
);
317 const cc::SolidColorDrawQuad
* round_trip_color_quad
=
318 cc::SolidColorDrawQuad::MaterialCast(round_trip_quad
);
319 EXPECT_EQ(arbitrary_color
, round_trip_color_quad
->color
);
320 EXPECT_EQ(force_anti_aliasing_off
,
321 round_trip_color_quad
->force_anti_aliasing_off
);
323 round_trip_quad
= round_trip_pass
->quad_list
.ElementAt(1);
324 // Second is surface quad.
325 ASSERT_EQ(cc::DrawQuad::SURFACE_CONTENT
, round_trip_quad
->material
);
326 const cc::SurfaceDrawQuad
* round_trip_surface_quad
=
327 cc::SurfaceDrawQuad::MaterialCast(round_trip_quad
);
328 EXPECT_EQ(arbitrary_id
, round_trip_surface_quad
->surface_id
);
330 round_trip_quad
= round_trip_pass
->quad_list
.ElementAt(2);
331 // Third is texture quad.
332 ASSERT_EQ(cc::DrawQuad::TEXTURE_CONTENT
, round_trip_quad
->material
);
333 const cc::TextureDrawQuad
* round_trip_texture_quad
=
334 cc::TextureDrawQuad::MaterialCast(round_trip_quad
);
335 EXPECT_EQ(resource_id
, round_trip_texture_quad
->resource_id());
336 EXPECT_EQ(premultiplied_alpha
, round_trip_texture_quad
->premultiplied_alpha
);
337 EXPECT_EQ(uv_top_left
, round_trip_texture_quad
->uv_top_left
);
338 EXPECT_EQ(uv_bottom_right
, round_trip_texture_quad
->uv_bottom_right
);
339 EXPECT_EQ(background_color
, round_trip_texture_quad
->background_color
);
340 for (size_t i
= 0; i
< 4; ++i
) {
341 EXPECT_EQ(vertex_opacity
[i
], round_trip_texture_quad
->vertex_opacity
[i
])
344 EXPECT_EQ(y_flipped
, round_trip_texture_quad
->y_flipped
);
347 TEST(SurfaceLibTest
, Mailbox
) {
348 gpu::Mailbox mailbox
;
351 MailboxPtr mojo_mailbox
= Mailbox::From(mailbox
);
352 EXPECT_EQ(0, memcmp(mailbox
.name
, &mojo_mailbox
->name
.storage()[0], 64));
354 gpu::Mailbox round_trip_mailbox
= mojo_mailbox
.To
<gpu::Mailbox
>();
355 EXPECT_EQ(mailbox
, round_trip_mailbox
);
358 TEST(SurfaceLibTest
, MailboxEmptyName
) {
359 MailboxPtr mojo_mailbox
= Mailbox::New();
361 gpu::Mailbox converted_mailbox
= mojo_mailbox
.To
<gpu::Mailbox
>();
362 EXPECT_TRUE(converted_mailbox
.IsZero());
365 TEST(SurfaceLibTest
, MailboxHolder
) {
366 gpu::Mailbox mailbox
;
368 uint32_t texture_target
= GL_TEXTURE_2D
;
369 uint32_t sync_point
= 7u;
370 gpu::MailboxHolder
holder(mailbox
, texture_target
, sync_point
);
372 MailboxHolderPtr mojo_holder
= MailboxHolder::From(holder
);
373 EXPECT_EQ(texture_target
, mojo_holder
->texture_target
);
374 EXPECT_EQ(sync_point
, mojo_holder
->sync_point
);
376 gpu::MailboxHolder round_trip_holder
= mojo_holder
.To
<gpu::MailboxHolder
>();
377 EXPECT_EQ(mailbox
, round_trip_holder
.mailbox
);
378 EXPECT_EQ(texture_target
, round_trip_holder
.texture_target
);
379 EXPECT_EQ(sync_point
, round_trip_holder
.sync_point
);
382 TEST(SurfaceLibTest
, TransferableResource
) {
384 cc::ResourceFormat format
= cc::BGRA_8888
;
385 uint32_t filter
= 123u;
386 gfx::Size
size(17, 18);
387 gpu::MailboxHolder mailbox_holder
;
388 bool is_repeated
= false;
390 bool is_software
= false;
391 cc::TransferableResource resource
;
393 resource
.format
= format
;
394 resource
.filter
= filter
;
395 resource
.size
= size
;
396 resource
.mailbox_holder
= mailbox_holder
;
397 resource
.is_repeated
= is_repeated
;
398 resource
.is_software
= is_software
;
400 TransferableResourcePtr mojo_resource
= TransferableResource::From(resource
);
401 EXPECT_EQ(id
, mojo_resource
->id
);
402 EXPECT_EQ(static_cast<ResourceFormat
>(format
),
403 mojo_resource
->format
);
404 EXPECT_EQ(filter
, mojo_resource
->filter
);
405 EXPECT_EQ(Size::From(size
), mojo_resource
->size
);
406 EXPECT_EQ(is_repeated
, mojo_resource
->is_repeated
);
407 EXPECT_EQ(is_software
, mojo_resource
->is_software
);
409 cc::TransferableResource round_trip_resource
=
410 mojo_resource
.To
<cc::TransferableResource
>();
411 EXPECT_EQ(id
, round_trip_resource
.id
);
412 EXPECT_EQ(format
, round_trip_resource
.format
);
413 EXPECT_EQ(filter
, round_trip_resource
.filter
);
414 EXPECT_EQ(size
, round_trip_resource
.size
);
415 EXPECT_EQ(mailbox_holder
.mailbox
, round_trip_resource
.mailbox_holder
.mailbox
);
416 EXPECT_EQ(mailbox_holder
.texture_target
,
417 round_trip_resource
.mailbox_holder
.texture_target
);
418 EXPECT_EQ(mailbox_holder
.sync_point
,
419 round_trip_resource
.mailbox_holder
.sync_point
);
420 EXPECT_EQ(is_repeated
, round_trip_resource
.is_repeated
);
421 EXPECT_EQ(is_software
, round_trip_resource
.is_software
);
424 TEST(SurfaceLibTest
, ReturnedResource
) {
426 uint32_t sync_point
= 24u;
429 cc::ReturnedResource resource
;
431 resource
.sync_point
= sync_point
;
432 resource
.count
= count
;
433 resource
.lost
= lost
;
435 ReturnedResourcePtr mojo_resource
= ReturnedResource::From(resource
);
436 EXPECT_EQ(id
, mojo_resource
->id
);
437 EXPECT_EQ(sync_point
, mojo_resource
->sync_point
);
438 EXPECT_EQ(count
, mojo_resource
->count
);
439 EXPECT_EQ(lost
, mojo_resource
->lost
);
441 cc::ReturnedResource round_trip_resource
=
442 mojo_resource
.To
<cc::ReturnedResource
>();
443 EXPECT_EQ(id
, round_trip_resource
.id
);
444 EXPECT_EQ(sync_point
, round_trip_resource
.sync_point
);
445 EXPECT_EQ(count
, round_trip_resource
.count
);
446 EXPECT_EQ(lost
, round_trip_resource
.lost
);
449 TEST_F(SurfaceLibQuadTest
, DebugBorderQuad
) {
450 cc::DebugBorderDrawQuad
* debug_border_quad
=
451 pass
->CreateAndAppendDrawQuad
<cc::DebugBorderDrawQuad
>();
452 const SkColor arbitrary_color
= SK_ColorGREEN
;
454 debug_border_quad
->SetAll(sqs
,
462 QuadPtr mojo_quad
= Quad::From
<cc::DrawQuad
>(*debug_border_quad
);
463 ASSERT_FALSE(mojo_quad
.is_null());
464 EXPECT_EQ(MATERIAL_DEBUG_BORDER
, mojo_quad
->material
);
465 EXPECT_EQ(Rect::From(rect
), mojo_quad
->rect
);
466 EXPECT_EQ(Rect::From(opaque_rect
), mojo_quad
->opaque_rect
);
467 EXPECT_EQ(Rect::From(visible_rect
), mojo_quad
->visible_rect
);
468 EXPECT_EQ(needs_blending
, mojo_quad
->needs_blending
);
469 ASSERT_TRUE(mojo_quad
->debug_border_quad_state
);
470 DebugBorderQuadStatePtr
& mojo_debug_border_state
=
471 mojo_quad
->debug_border_quad_state
;
472 EXPECT_EQ(Color::From(arbitrary_color
), mojo_debug_border_state
->color
);
473 EXPECT_EQ(width
, mojo_debug_border_state
->width
);
476 TEST_F(SurfaceLibQuadTest
, CheckerboardQuad
) {
477 cc::CheckerboardDrawQuad
* checkerboard_quad
=
478 pass
->CreateAndAppendDrawQuad
<cc::CheckerboardDrawQuad
>();
479 const SkColor arbitrary_color
= SK_ColorGREEN
;
480 const float scale
= 1.0f
;
481 checkerboard_quad
->SetAll(sqs
,
489 QuadPtr mojo_quad
= Quad::From
<cc::DrawQuad
>(*checkerboard_quad
);
490 ASSERT_FALSE(mojo_quad
.is_null());
491 EXPECT_EQ(MATERIAL_CHECKERBOARD
, mojo_quad
->material
);
492 EXPECT_EQ(Rect::From(rect
), mojo_quad
->rect
);
493 EXPECT_EQ(Rect::From(opaque_rect
), mojo_quad
->opaque_rect
);
494 EXPECT_EQ(Rect::From(visible_rect
), mojo_quad
->visible_rect
);
495 EXPECT_EQ(needs_blending
, mojo_quad
->needs_blending
);
496 ASSERT_TRUE(mojo_quad
->checkerboard_quad_state
);
497 CheckerboardQuadStatePtr
& mojo_checkerboard_state
=
498 mojo_quad
->checkerboard_quad_state
;
499 EXPECT_EQ(Color::From(arbitrary_color
), mojo_checkerboard_state
->color
);
500 EXPECT_EQ(scale
, mojo_checkerboard_state
->scale
);