| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/quads/render_pass.h" | 5 #include "cc/quads/render_pass.h" |
| 6 #include "cc/quads/solid_color_draw_quad.h" | 6 #include "cc/quads/solid_color_draw_quad.h" |
| 7 #include "cc/quads/surface_draw_quad.h" | 7 #include "cc/quads/surface_draw_quad.h" |
| 8 #include "cc/quads/texture_draw_quad.h" | 8 #include "cc/quads/texture_draw_quad.h" |
| 9 #include "gpu/command_buffer/common/mailbox.h" | 9 #include "gpu/command_buffer/common/mailbox.h" |
| 10 #include "gpu/command_buffer/common/mailbox_holder.h" | 10 #include "gpu/command_buffer/common/mailbox_holder.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 EXPECT_EQ(PointF::From(uv_top_left), mojo_texture_state->uv_top_left); | 136 EXPECT_EQ(PointF::From(uv_top_left), mojo_texture_state->uv_top_left); |
| 137 EXPECT_EQ(PointF::From(uv_bottom_right), mojo_texture_state->uv_bottom_right); | 137 EXPECT_EQ(PointF::From(uv_bottom_right), mojo_texture_state->uv_bottom_right); |
| 138 EXPECT_EQ(surfaces::Color::From(background_color), | 138 EXPECT_EQ(surfaces::Color::From(background_color), |
| 139 mojo_texture_state->background_color); | 139 mojo_texture_state->background_color); |
| 140 for (size_t i = 0; i < 4; ++i) { | 140 for (size_t i = 0; i < 4; ++i) { |
| 141 EXPECT_EQ(vertex_opacity[i], mojo_texture_state->vertex_opacity[i]) << i; | 141 EXPECT_EQ(vertex_opacity[i], mojo_texture_state->vertex_opacity[i]) << i; |
| 142 } | 142 } |
| 143 EXPECT_EQ(flipped, mojo_texture_state->flipped); | 143 EXPECT_EQ(flipped, mojo_texture_state->flipped); |
| 144 } | 144 } |
| 145 | 145 |
| 146 TEST_F(SurfaceLibQuadTest, TextureQuadEmptyVertexOpacity) { |
| 147 surfaces::QuadPtr mojo_texture_quad = surfaces::Quad::New(); |
| 148 mojo_texture_quad->material = surfaces::MATERIAL_TEXTURE_CONTENT; |
| 149 surfaces::TextureQuadStatePtr mojo_texture_state = |
| 150 surfaces::TextureQuadState::New(); |
| 151 mojo_texture_state->background_color = surfaces::Color::New(); |
| 152 mojo_texture_quad->texture_quad_state = mojo_texture_state.Pass(); |
| 153 surfaces::PassPtr mojo_pass = surfaces::Pass::New(); |
| 154 mojo_pass->quads.push_back(mojo_texture_quad.Pass()); |
| 155 surfaces::SharedQuadStatePtr mojo_sqs = surfaces::SharedQuadState::New(); |
| 156 mojo_pass->shared_quad_states.push_back(mojo_sqs.Pass()); |
| 157 |
| 158 scoped_ptr<cc::RenderPass> pass = ConvertTo(mojo_pass.Pass()); |
| 159 EXPECT_FALSE(pass); |
| 160 } |
| 161 |
| 162 TEST_F(SurfaceLibQuadTest, TextureQuadEmptyBackgroundColor) { |
| 163 surfaces::QuadPtr mojo_texture_quad = surfaces::Quad::New(); |
| 164 mojo_texture_quad->material = surfaces::MATERIAL_TEXTURE_CONTENT; |
| 165 surfaces::TextureQuadStatePtr mojo_texture_state = |
| 166 surfaces::TextureQuadState::New(); |
| 167 mojo_texture_state->vertex_opacity = mojo::Array<float>::New(4); |
| 168 mojo_texture_quad->texture_quad_state = mojo_texture_state.Pass(); |
| 169 surfaces::PassPtr mojo_pass = surfaces::Pass::New(); |
| 170 mojo_pass->quads.push_back(mojo_texture_quad.Pass()); |
| 171 surfaces::SharedQuadStatePtr mojo_sqs = surfaces::SharedQuadState::New(); |
| 172 mojo_pass->shared_quad_states.push_back(mojo_sqs.Pass()); |
| 173 |
| 174 scoped_ptr<cc::RenderPass> pass = ConvertTo(mojo_pass.Pass()); |
| 175 EXPECT_FALSE(pass); |
| 176 } |
| 177 |
| 146 TEST(SurfaceLibTest, SharedQuadState) { | 178 TEST(SurfaceLibTest, SharedQuadState) { |
| 147 gfx::Transform content_to_target_transform; | 179 gfx::Transform content_to_target_transform; |
| 148 content_to_target_transform.Scale3d(0.3f, 0.7f, 0.9f); | 180 content_to_target_transform.Scale3d(0.3f, 0.7f, 0.9f); |
| 149 gfx::Size content_bounds(57, 39); | 181 gfx::Size content_bounds(57, 39); |
| 150 gfx::Rect visible_content_rect(3, 7, 28, 42); | 182 gfx::Rect visible_content_rect(3, 7, 28, 42); |
| 151 gfx::Rect clip_rect(9, 12, 21, 31); | 183 gfx::Rect clip_rect(9, 12, 21, 31); |
| 152 bool is_clipped = true; | 184 bool is_clipped = true; |
| 153 float opacity = 0.65f; | 185 float opacity = 0.65f; |
| 154 int sorting_context_id = 13; | 186 int sorting_context_id = 13; |
| 155 SkXfermode::Mode blend_mode = SkXfermode::kSrcOver_Mode; | 187 SkXfermode::Mode blend_mode = SkXfermode::kSrcOver_Mode; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 << i; | 357 << i; |
| 326 } | 358 } |
| 327 EXPECT_EQ(flipped, round_trip_texture_quad->flipped); | 359 EXPECT_EQ(flipped, round_trip_texture_quad->flipped); |
| 328 } | 360 } |
| 329 | 361 |
| 330 TEST(SurfaceLibTest, Mailbox) { | 362 TEST(SurfaceLibTest, Mailbox) { |
| 331 gpu::Mailbox mailbox; | 363 gpu::Mailbox mailbox; |
| 332 mailbox.Generate(); | 364 mailbox.Generate(); |
| 333 | 365 |
| 334 surfaces::MailboxPtr mojo_mailbox = surfaces::Mailbox::From(mailbox); | 366 surfaces::MailboxPtr mojo_mailbox = surfaces::Mailbox::From(mailbox); |
| 335 EXPECT_EQ(0, memcmp(mailbox.name, mojo_mailbox->name.storage().data(), 64)); | 367 EXPECT_EQ(0, memcmp(mailbox.name, &mojo_mailbox->name.storage()[0], 64)); |
| 336 | 368 |
| 337 gpu::Mailbox round_trip_mailbox = mojo_mailbox.To<gpu::Mailbox>(); | 369 gpu::Mailbox round_trip_mailbox = mojo_mailbox.To<gpu::Mailbox>(); |
| 338 EXPECT_EQ(mailbox, round_trip_mailbox); | 370 EXPECT_EQ(mailbox, round_trip_mailbox); |
| 339 } | 371 } |
| 340 | 372 |
| 373 TEST(SurfaceLibTest, MailboxEmptyName) { |
| 374 surfaces::MailboxPtr mojo_mailbox = surfaces::Mailbox::New(); |
| 375 |
| 376 gpu::Mailbox converted_mailbox = mojo_mailbox.To<gpu::Mailbox>(); |
| 377 EXPECT_TRUE(converted_mailbox.IsZero()); |
| 378 } |
| 379 |
| 341 TEST(SurfaceLibTest, MailboxHolder) { | 380 TEST(SurfaceLibTest, MailboxHolder) { |
| 342 gpu::Mailbox mailbox; | 381 gpu::Mailbox mailbox; |
| 343 mailbox.Generate(); | 382 mailbox.Generate(); |
| 344 uint32_t texture_target = GL_TEXTURE_2D; | 383 uint32_t texture_target = GL_TEXTURE_2D; |
| 345 uint32_t sync_point = 7u; | 384 uint32_t sync_point = 7u; |
| 346 gpu::MailboxHolder holder(mailbox, texture_target, sync_point); | 385 gpu::MailboxHolder holder(mailbox, texture_target, sync_point); |
| 347 | 386 |
| 348 surfaces::MailboxHolderPtr mojo_holder = | 387 surfaces::MailboxHolderPtr mojo_holder = |
| 349 surfaces::MailboxHolder::From(holder); | 388 surfaces::MailboxHolder::From(holder); |
| 350 EXPECT_EQ(texture_target, mojo_holder->texture_target); | 389 EXPECT_EQ(texture_target, mojo_holder->texture_target); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 cc::ReturnedResource round_trip_resource = | 459 cc::ReturnedResource round_trip_resource = |
| 421 mojo_resource.To<cc::ReturnedResource>(); | 460 mojo_resource.To<cc::ReturnedResource>(); |
| 422 EXPECT_EQ(id, round_trip_resource.id); | 461 EXPECT_EQ(id, round_trip_resource.id); |
| 423 EXPECT_EQ(sync_point, round_trip_resource.sync_point); | 462 EXPECT_EQ(sync_point, round_trip_resource.sync_point); |
| 424 EXPECT_EQ(count, round_trip_resource.count); | 463 EXPECT_EQ(count, round_trip_resource.count); |
| 425 EXPECT_EQ(lost, round_trip_resource.lost); | 464 EXPECT_EQ(lost, round_trip_resource.lost); |
| 426 } | 465 } |
| 427 | 466 |
| 428 } // namespace | 467 } // namespace |
| 429 } // namespace mojo | 468 } // namespace mojo |
| OLD | NEW |