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/debug_border_draw_quad.h"
6 #include "cc/quads/render_pass.h"
7 #include "cc/quads/solid_color_draw_quad.h"
8 #include "cc/quads/surface_draw_quad.h"
9 #include "cc/quads/texture_draw_quad.h"
10 #include "cc/resources/resource_provider.h"
11 #include "gpu/command_buffer/common/mailbox.h"
12 #include "gpu/command_buffer/common/mailbox_holder.h"
13 #include "mojo/converters/geometry/geometry_type_converters.h"
14 #include "mojo/converters/surfaces/surfaces_type_converters.h"
15 #include "mojo/converters/transform/transform_type_converters.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/skia/include/core/SkColor.h"
18 #include "third_party/skia/include/core/SkXfermode.h"
23 TEST(SurfaceLibTest
, SurfaceIdConverterNullId
) {
24 cc::SurfaceId null_id
;
25 cc::SurfaceId round_trip
= SurfaceId::From(null_id
).To
<cc::SurfaceId
>();
26 EXPECT_TRUE(round_trip
.is_null());
29 TEST(SurfaceLibTest
, SurfaceIdConverterValidId
) {
30 cc::SurfaceId
valid_id(7);
31 cc::SurfaceId round_trip
= SurfaceId::From(valid_id
).To
<cc::SurfaceId
>();
32 EXPECT_FALSE(round_trip
.is_null());
33 EXPECT_EQ(valid_id
, round_trip
);
36 TEST(SurfaceLibTest
, Color
) {
37 SkColor arbitrary_color
= SK_ColorMAGENTA
;
38 SkColor round_trip
= Color::From(arbitrary_color
).To
<SkColor
>();
39 EXPECT_EQ(arbitrary_color
, round_trip
);
42 class SurfaceLibQuadTest
: public testing::Test
{
47 visible_rect(9, 11, 5, 7),
48 needs_blending(false) {
49 pass
= cc::RenderPass::Create();
50 sqs
= pass
->CreateAndAppendSharedQuadState();
55 gfx::Rect opaque_rect
;
56 gfx::Rect visible_rect
;
58 scoped_ptr
<cc::RenderPass
> pass
;
59 cc::SharedQuadState
* sqs
;
62 TEST_F(SurfaceLibQuadTest
, ColorQuad
) {
63 cc::SolidColorDrawQuad
* color_quad
=
64 pass
->CreateAndAppendDrawQuad
<cc::SolidColorDrawQuad
>();
65 SkColor arbitrary_color
= SK_ColorGREEN
;
66 bool force_anti_aliasing_off
= true;
67 color_quad
->SetAll(sqs
,
73 force_anti_aliasing_off
);
75 QuadPtr mojo_quad
= Quad::From
<cc::DrawQuad
>(*color_quad
);
76 ASSERT_FALSE(mojo_quad
.is_null());
77 EXPECT_EQ(MATERIAL_SOLID_COLOR
, mojo_quad
->material
);
78 EXPECT_EQ(Rect::From(rect
), mojo_quad
->rect
);
79 EXPECT_EQ(Rect::From(opaque_rect
), mojo_quad
->opaque_rect
);
80 EXPECT_EQ(Rect::From(visible_rect
), mojo_quad
->visible_rect
);
81 EXPECT_EQ(needs_blending
, mojo_quad
->needs_blending
);
82 ASSERT_TRUE(mojo_quad
->solid_color_quad_state
);
83 SolidColorQuadStatePtr
& mojo_color_state
= mojo_quad
->solid_color_quad_state
;
84 EXPECT_EQ(Color::From(arbitrary_color
), mojo_color_state
->color
);
85 EXPECT_EQ(force_anti_aliasing_off
, mojo_color_state
->force_anti_aliasing_off
);
88 TEST_F(SurfaceLibQuadTest
, SurfaceQuad
) {
89 cc::SurfaceDrawQuad
* surface_quad
=
90 pass
->CreateAndAppendDrawQuad
<cc::SurfaceDrawQuad
>();
91 cc::SurfaceId
arbitrary_id(5);
93 sqs
, rect
, opaque_rect
, visible_rect
, needs_blending
, arbitrary_id
);
95 QuadPtr mojo_quad
= Quad::From
<cc::DrawQuad
>(*surface_quad
);
96 ASSERT_FALSE(mojo_quad
.is_null());
97 EXPECT_EQ(MATERIAL_SURFACE_CONTENT
, mojo_quad
->material
);
98 ASSERT_TRUE(mojo_quad
->surface_quad_state
);
99 SurfaceQuadStatePtr
& mojo_surface_state
= mojo_quad
->surface_quad_state
;
100 EXPECT_EQ(SurfaceId::From(arbitrary_id
),
101 mojo_surface_state
->surface
);
104 TEST_F(SurfaceLibQuadTest
, TextureQuad
) {
105 cc::TextureDrawQuad
* texture_quad
=
106 pass
->CreateAndAppendDrawQuad
<cc::TextureDrawQuad
>();
107 unsigned resource_id
= 9;
108 bool premultiplied_alpha
= true;
109 gfx::PointF
uv_top_left(1.7f
, 2.1f
);
110 gfx::PointF
uv_bottom_right(-7.f
, 16.3f
);
111 SkColor background_color
= SK_ColorYELLOW
;
112 float vertex_opacity
[4] = {0.1f
, 0.5f
, 0.4f
, 0.8f
};
113 bool y_flipped
= false;
114 bool nearest_neighbor
= false;
115 bool allow_overlay
= false;
116 texture_quad
->SetAll(sqs
, rect
, opaque_rect
, visible_rect
, needs_blending
,
117 resource_id
, gfx::Size(), allow_overlay
,
118 premultiplied_alpha
, uv_top_left
, uv_bottom_right
,
119 background_color
, vertex_opacity
, y_flipped
,
122 QuadPtr mojo_quad
= Quad::From
<cc::DrawQuad
>(*texture_quad
);
123 ASSERT_FALSE(mojo_quad
.is_null());
124 EXPECT_EQ(MATERIAL_TEXTURE_CONTENT
, mojo_quad
->material
);
125 ASSERT_TRUE(mojo_quad
->texture_quad_state
);
126 TextureQuadStatePtr
& mojo_texture_state
= mojo_quad
->texture_quad_state
;
127 EXPECT_EQ(resource_id
, mojo_texture_state
->resource_id
);
128 EXPECT_EQ(premultiplied_alpha
, mojo_texture_state
->premultiplied_alpha
);
129 EXPECT_EQ(PointF::From(uv_top_left
), mojo_texture_state
->uv_top_left
);
130 EXPECT_EQ(PointF::From(uv_bottom_right
), mojo_texture_state
->uv_bottom_right
);
131 EXPECT_EQ(Color::From(background_color
),
132 mojo_texture_state
->background_color
);
133 for (size_t i
= 0; i
< 4; ++i
) {
134 EXPECT_EQ(vertex_opacity
[i
], mojo_texture_state
->vertex_opacity
[i
]) << i
;
136 EXPECT_EQ(y_flipped
, mojo_texture_state
->y_flipped
);
139 TEST_F(SurfaceLibQuadTest
, TextureQuadEmptyVertexOpacity
) {
140 QuadPtr mojo_texture_quad
= Quad::New();
141 mojo_texture_quad
->material
= MATERIAL_TEXTURE_CONTENT
;
142 TextureQuadStatePtr mojo_texture_state
= TextureQuadState::New();
143 mojo_texture_state
->background_color
= Color::New();
144 mojo_texture_quad
->texture_quad_state
= mojo_texture_state
.Pass();
145 PassPtr mojo_pass
= Pass::New();
146 mojo_pass
->id
= RenderPassId::New();
147 mojo_pass
->id
->layer_id
= 1;
148 mojo_pass
->id
->index
= 1u;
149 mojo_pass
->quads
.push_back(mojo_texture_quad
.Pass());
150 SharedQuadStatePtr mojo_sqs
= SharedQuadState::New();
151 mojo_pass
->shared_quad_states
.push_back(mojo_sqs
.Pass());
153 scoped_ptr
<cc::RenderPass
> pass
= mojo_pass
.To
<scoped_ptr
<cc::RenderPass
> >();
158 TEST_F(SurfaceLibQuadTest
, TextureQuadEmptyBackgroundColor
) {
159 QuadPtr mojo_texture_quad
= Quad::New();
160 mojo_texture_quad
->material
= MATERIAL_TEXTURE_CONTENT
;
161 TextureQuadStatePtr mojo_texture_state
= TextureQuadState::New();
162 mojo_texture_state
->vertex_opacity
= mojo::Array
<float>::New(4);
163 mojo_texture_quad
->texture_quad_state
= mojo_texture_state
.Pass();
164 PassPtr mojo_pass
= Pass::New();
165 mojo_pass
->id
= RenderPassId::New();
166 mojo_pass
->id
->layer_id
= 1;
167 mojo_pass
->id
->index
= 1u;
168 mojo_pass
->quads
.push_back(mojo_texture_quad
.Pass());
169 SharedQuadStatePtr mojo_sqs
= SharedQuadState::New();
170 mojo_pass
->shared_quad_states
.push_back(mojo_sqs
.Pass());
172 scoped_ptr
<cc::RenderPass
> pass
= mojo_pass
.To
<scoped_ptr
<cc::RenderPass
> >();
176 TEST(SurfaceLibTest
, SharedQuadState
) {
177 gfx::Transform quad_to_target_transform
;
178 quad_to_target_transform
.Scale3d(0.3f
, 0.7f
, 0.9f
);
179 gfx::Size
quad_layer_bounds(57, 39);
180 gfx::Rect
visible_quad_layer_rect(3, 7, 28, 42);
181 gfx::Rect
clip_rect(9, 12, 21, 31);
182 bool is_clipped
= true;
183 float opacity
= 0.65f
;
184 int sorting_context_id
= 13;
185 ::SkXfermode::Mode blend_mode
= ::SkXfermode::kSrcOver_Mode
;
186 scoped_ptr
<cc::RenderPass
> pass
= cc::RenderPass::Create();
187 cc::SharedQuadState
* sqs
= pass
->CreateAndAppendSharedQuadState();
188 sqs
->SetAll(quad_to_target_transform
, quad_layer_bounds
,
189 visible_quad_layer_rect
, clip_rect
, is_clipped
, opacity
,
190 blend_mode
, sorting_context_id
);
192 SharedQuadStatePtr mojo_sqs
= SharedQuadState::From(*sqs
);
193 ASSERT_FALSE(mojo_sqs
.is_null());
194 EXPECT_EQ(Transform::From(quad_to_target_transform
),
195 mojo_sqs
->quad_to_target_transform
);
196 EXPECT_EQ(Size::From(quad_layer_bounds
), mojo_sqs
->quad_layer_bounds
);
197 EXPECT_EQ(Rect::From(visible_quad_layer_rect
),
198 mojo_sqs
->visible_quad_layer_rect
);
199 EXPECT_EQ(Rect::From(clip_rect
), mojo_sqs
->clip_rect
);
200 EXPECT_EQ(is_clipped
, mojo_sqs
->is_clipped
);
201 EXPECT_EQ(opacity
, mojo_sqs
->opacity
);
202 EXPECT_EQ(sorting_context_id
, mojo_sqs
->sorting_context_id
);
205 TEST(SurfaceLibTest
, RenderPass
) {
206 scoped_ptr
<cc::RenderPass
> pass
= cc::RenderPass::Create();
207 cc::RenderPassId
pass_id(1, 6);
208 gfx::Rect
output_rect(4, 9, 13, 71);
209 gfx::Rect
damage_rect(9, 17, 41, 45);
210 gfx::Transform transform_to_root_target
;
211 transform_to_root_target
.SkewY(43.0);
212 bool has_transparent_background
= false;
213 pass
->SetAll(pass_id
,
216 transform_to_root_target
,
217 has_transparent_background
);
219 gfx::Transform quad_to_target_transform
;
220 quad_to_target_transform
.Scale3d(0.3f
, 0.7f
, 0.9f
);
221 gfx::Size
quad_layer_bounds(57, 39);
222 gfx::Rect
visible_quad_layer_rect(3, 7, 28, 42);
223 gfx::Rect
clip_rect(9, 12, 21, 31);
224 bool is_clipped
= true;
225 float opacity
= 0.65f
;
226 int sorting_context_id
= 13;
227 ::SkXfermode::Mode blend_mode
= ::SkXfermode::kSrcOver_Mode
;
228 cc::SharedQuadState
* sqs
= pass
->CreateAndAppendSharedQuadState();
229 sqs
->SetAll(quad_to_target_transform
, quad_layer_bounds
,
230 visible_quad_layer_rect
, clip_rect
, is_clipped
, opacity
,
231 blend_mode
, sorting_context_id
);
233 gfx::Rect
rect(5, 7, 13, 19);
234 gfx::Rect
opaque_rect(rect
);
235 gfx::Rect
visible_rect(9, 11, 5, 7);
236 bool needs_blending
= false;
238 cc::SolidColorDrawQuad
* color_quad
=
239 pass
->CreateAndAppendDrawQuad
<cc::SolidColorDrawQuad
>();
240 SkColor arbitrary_color
= SK_ColorGREEN
;
241 bool force_anti_aliasing_off
= true;
242 color_quad
->SetAll(pass
->shared_quad_state_list
.back(),
248 force_anti_aliasing_off
);
250 cc::SurfaceDrawQuad
* surface_quad
=
251 pass
->CreateAndAppendDrawQuad
<cc::SurfaceDrawQuad
>();
252 cc::SurfaceId
arbitrary_id(5);
253 surface_quad
->SetAll(
254 sqs
, rect
, opaque_rect
, visible_rect
, needs_blending
, arbitrary_id
);
256 cc::TextureDrawQuad
* texture_quad
=
257 pass
->CreateAndAppendDrawQuad
<cc::TextureDrawQuad
>();
258 unsigned resource_id
= 9;
259 bool premultiplied_alpha
= true;
260 gfx::PointF
uv_top_left(1.7f
, 2.1f
);
261 gfx::PointF
uv_bottom_right(-7.f
, 16.3f
);
262 SkColor background_color
= SK_ColorYELLOW
;
263 float vertex_opacity
[4] = {0.1f
, 0.5f
, 0.4f
, 0.8f
};
264 bool y_flipped
= false;
265 bool nearest_neighbor
= false;
266 bool allow_overlay
= false;
267 texture_quad
->SetAll(sqs
, rect
, opaque_rect
, visible_rect
, needs_blending
,
268 resource_id
, gfx::Size(), allow_overlay
,
269 premultiplied_alpha
, uv_top_left
, uv_bottom_right
,
270 background_color
, vertex_opacity
, y_flipped
,
273 PassPtr mojo_pass
= Pass::From(*pass
);
274 ASSERT_FALSE(mojo_pass
.is_null());
275 EXPECT_EQ(6u, mojo_pass
->id
->index
);
276 EXPECT_EQ(Rect::From(output_rect
), mojo_pass
->output_rect
);
277 EXPECT_EQ(Rect::From(damage_rect
), mojo_pass
->damage_rect
);
278 EXPECT_EQ(Transform::From(transform_to_root_target
),
279 mojo_pass
->transform_to_root_target
);
280 EXPECT_EQ(has_transparent_background
, mojo_pass
->has_transparent_background
);
281 ASSERT_EQ(1u, mojo_pass
->shared_quad_states
.size());
282 ASSERT_EQ(3u, mojo_pass
->quads
.size());
283 EXPECT_EQ(0u, mojo_pass
->quads
[0]->shared_quad_state_index
);
285 scoped_ptr
<cc::RenderPass
> round_trip_pass
=
286 mojo_pass
.To
<scoped_ptr
<cc::RenderPass
> >();
287 EXPECT_EQ(pass_id
, round_trip_pass
->id
);
288 EXPECT_EQ(output_rect
, round_trip_pass
->output_rect
);
289 EXPECT_EQ(damage_rect
, round_trip_pass
->damage_rect
);
290 EXPECT_EQ(transform_to_root_target
,
291 round_trip_pass
->transform_to_root_target
);
292 EXPECT_EQ(has_transparent_background
,
293 round_trip_pass
->has_transparent_background
);
294 ASSERT_EQ(1u, round_trip_pass
->shared_quad_state_list
.size());
295 ASSERT_EQ(3u, round_trip_pass
->quad_list
.size());
296 EXPECT_EQ(round_trip_pass
->shared_quad_state_list
.front(),
297 round_trip_pass
->quad_list
.front()->shared_quad_state
);
299 cc::SharedQuadState
* round_trip_sqs
=
300 round_trip_pass
->shared_quad_state_list
.front();
301 EXPECT_EQ(quad_to_target_transform
, round_trip_sqs
->quad_to_target_transform
);
302 EXPECT_EQ(quad_layer_bounds
, round_trip_sqs
->quad_layer_bounds
);
303 EXPECT_EQ(visible_quad_layer_rect
, round_trip_sqs
->visible_quad_layer_rect
);
304 EXPECT_EQ(clip_rect
, round_trip_sqs
->clip_rect
);
305 EXPECT_EQ(is_clipped
, round_trip_sqs
->is_clipped
);
306 EXPECT_EQ(opacity
, round_trip_sqs
->opacity
);
307 EXPECT_EQ(sorting_context_id
, round_trip_sqs
->sorting_context_id
);
309 cc::DrawQuad
* round_trip_quad
= round_trip_pass
->quad_list
.front();
310 // First is solid color quad.
311 ASSERT_EQ(cc::DrawQuad::SOLID_COLOR
, round_trip_quad
->material
);
312 EXPECT_EQ(rect
, round_trip_quad
->rect
);
313 EXPECT_EQ(opaque_rect
, round_trip_quad
->opaque_rect
);
314 EXPECT_EQ(visible_rect
, round_trip_quad
->visible_rect
);
315 EXPECT_EQ(needs_blending
, round_trip_quad
->needs_blending
);
316 const cc::SolidColorDrawQuad
* round_trip_color_quad
=
317 cc::SolidColorDrawQuad::MaterialCast(round_trip_quad
);
318 EXPECT_EQ(arbitrary_color
, round_trip_color_quad
->color
);
319 EXPECT_EQ(force_anti_aliasing_off
,
320 round_trip_color_quad
->force_anti_aliasing_off
);
322 round_trip_quad
= round_trip_pass
->quad_list
.ElementAt(1);
323 // Second is surface quad.
324 ASSERT_EQ(cc::DrawQuad::SURFACE_CONTENT
, round_trip_quad
->material
);
325 const cc::SurfaceDrawQuad
* round_trip_surface_quad
=
326 cc::SurfaceDrawQuad::MaterialCast(round_trip_quad
);
327 EXPECT_EQ(arbitrary_id
, round_trip_surface_quad
->surface_id
);
329 round_trip_quad
= round_trip_pass
->quad_list
.ElementAt(2);
330 // Third is texture quad.
331 ASSERT_EQ(cc::DrawQuad::TEXTURE_CONTENT
, round_trip_quad
->material
);
332 const cc::TextureDrawQuad
* round_trip_texture_quad
=
333 cc::TextureDrawQuad::MaterialCast(round_trip_quad
);
334 EXPECT_EQ(resource_id
, round_trip_texture_quad
->resource_id());
335 EXPECT_EQ(premultiplied_alpha
, round_trip_texture_quad
->premultiplied_alpha
);
336 EXPECT_EQ(uv_top_left
, round_trip_texture_quad
->uv_top_left
);
337 EXPECT_EQ(uv_bottom_right
, round_trip_texture_quad
->uv_bottom_right
);
338 EXPECT_EQ(background_color
, round_trip_texture_quad
->background_color
);
339 for (size_t i
= 0; i
< 4; ++i
) {
340 EXPECT_EQ(vertex_opacity
[i
], round_trip_texture_quad
->vertex_opacity
[i
])
343 EXPECT_EQ(y_flipped
, round_trip_texture_quad
->y_flipped
);
346 TEST(SurfaceLibTest
, Mailbox
) {
347 gpu::Mailbox mailbox
;
350 MailboxPtr mojo_mailbox
= Mailbox::From(mailbox
);
351 EXPECT_EQ(0, memcmp(mailbox
.name
, &mojo_mailbox
->name
.storage()[0], 64));
353 gpu::Mailbox round_trip_mailbox
= mojo_mailbox
.To
<gpu::Mailbox
>();
354 EXPECT_EQ(mailbox
, round_trip_mailbox
);
357 TEST(SurfaceLibTest
, MailboxEmptyName
) {
358 MailboxPtr mojo_mailbox
= Mailbox::New();
360 gpu::Mailbox converted_mailbox
= mojo_mailbox
.To
<gpu::Mailbox
>();
361 EXPECT_TRUE(converted_mailbox
.IsZero());
364 TEST(SurfaceLibTest
, MailboxHolder
) {
365 gpu::Mailbox mailbox
;
367 uint32_t texture_target
= GL_TEXTURE_2D
;
368 uint32_t sync_point
= 7u;
369 gpu::MailboxHolder
holder(mailbox
, texture_target
, sync_point
);
371 MailboxHolderPtr mojo_holder
= MailboxHolder::From(holder
);
372 EXPECT_EQ(texture_target
, mojo_holder
->texture_target
);
373 EXPECT_EQ(sync_point
, mojo_holder
->sync_point
);
375 gpu::MailboxHolder round_trip_holder
= mojo_holder
.To
<gpu::MailboxHolder
>();
376 EXPECT_EQ(mailbox
, round_trip_holder
.mailbox
);
377 EXPECT_EQ(texture_target
, round_trip_holder
.texture_target
);
378 EXPECT_EQ(sync_point
, round_trip_holder
.sync_point
);
381 TEST(SurfaceLibTest
, TransferableResource
) {
383 cc::ResourceFormat format
= cc::BGRA_8888
;
384 uint32_t filter
= 123u;
385 gfx::Size
size(17, 18);
386 gpu::MailboxHolder mailbox_holder
;
387 bool is_repeated
= false;
389 bool is_software
= false;
390 cc::TransferableResource resource
;
392 resource
.format
= format
;
393 resource
.filter
= filter
;
394 resource
.size
= size
;
395 resource
.mailbox_holder
= mailbox_holder
;
396 resource
.is_repeated
= is_repeated
;
397 resource
.is_software
= is_software
;
399 TransferableResourcePtr mojo_resource
= TransferableResource::From(resource
);
400 EXPECT_EQ(id
, mojo_resource
->id
);
401 EXPECT_EQ(static_cast<ResourceFormat
>(format
),
402 mojo_resource
->format
);
403 EXPECT_EQ(filter
, mojo_resource
->filter
);
404 EXPECT_EQ(Size::From(size
), mojo_resource
->size
);
405 EXPECT_EQ(is_repeated
, mojo_resource
->is_repeated
);
406 EXPECT_EQ(is_software
, mojo_resource
->is_software
);
408 cc::TransferableResource round_trip_resource
=
409 mojo_resource
.To
<cc::TransferableResource
>();
410 EXPECT_EQ(id
, round_trip_resource
.id
);
411 EXPECT_EQ(format
, round_trip_resource
.format
);
412 EXPECT_EQ(filter
, round_trip_resource
.filter
);
413 EXPECT_EQ(size
, round_trip_resource
.size
);
414 EXPECT_EQ(mailbox_holder
.mailbox
, round_trip_resource
.mailbox_holder
.mailbox
);
415 EXPECT_EQ(mailbox_holder
.texture_target
,
416 round_trip_resource
.mailbox_holder
.texture_target
);
417 EXPECT_EQ(mailbox_holder
.sync_point
,
418 round_trip_resource
.mailbox_holder
.sync_point
);
419 EXPECT_EQ(is_repeated
, round_trip_resource
.is_repeated
);
420 EXPECT_EQ(is_software
, round_trip_resource
.is_software
);
423 TEST(SurfaceLibTest
, ReturnedResource
) {
425 uint32_t sync_point
= 24u;
428 cc::ReturnedResource resource
;
430 resource
.sync_point
= sync_point
;
431 resource
.count
= count
;
432 resource
.lost
= lost
;
434 ReturnedResourcePtr mojo_resource
= ReturnedResource::From(resource
);
435 EXPECT_EQ(id
, mojo_resource
->id
);
436 EXPECT_EQ(sync_point
, mojo_resource
->sync_point
);
437 EXPECT_EQ(count
, mojo_resource
->count
);
438 EXPECT_EQ(lost
, mojo_resource
->lost
);
440 cc::ReturnedResource round_trip_resource
=
441 mojo_resource
.To
<cc::ReturnedResource
>();
442 EXPECT_EQ(id
, round_trip_resource
.id
);
443 EXPECT_EQ(sync_point
, round_trip_resource
.sync_point
);
444 EXPECT_EQ(count
, round_trip_resource
.count
);
445 EXPECT_EQ(lost
, round_trip_resource
.lost
);
448 TEST_F(SurfaceLibQuadTest
, DebugBorderQuad
) {
449 cc::DebugBorderDrawQuad
* debug_border_quad
=
450 pass
->CreateAndAppendDrawQuad
<cc::DebugBorderDrawQuad
>();
451 const SkColor arbitrary_color
= SK_ColorGREEN
;
453 debug_border_quad
->SetAll(sqs
,
461 QuadPtr mojo_quad
= Quad::From
<cc::DrawQuad
>(*debug_border_quad
);
462 ASSERT_FALSE(mojo_quad
.is_null());
463 EXPECT_EQ(MATERIAL_DEBUG_BORDER
, mojo_quad
->material
);
464 EXPECT_EQ(Rect::From(rect
), mojo_quad
->rect
);
465 EXPECT_EQ(Rect::From(opaque_rect
), mojo_quad
->opaque_rect
);
466 EXPECT_EQ(Rect::From(visible_rect
), mojo_quad
->visible_rect
);
467 EXPECT_EQ(needs_blending
, mojo_quad
->needs_blending
);
468 ASSERT_TRUE(mojo_quad
->debug_border_quad_state
);
469 DebugBorderQuadStatePtr
& mojo_debug_border_state
=
470 mojo_quad
->debug_border_quad_state
;
471 EXPECT_EQ(Color::From(arbitrary_color
), mojo_debug_border_state
->color
);
472 EXPECT_EQ(width
, mojo_debug_border_state
->width
);