| 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/surfaces/surface_factory.h" | 5 #include "cc/surfaces/surface_factory.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
| 7 #include <utility> | 10 #include <utility> |
| 8 | 11 |
| 9 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/macros.h" |
| 10 #include "cc/output/compositor_frame.h" | 14 #include "cc/output/compositor_frame.h" |
| 11 #include "cc/output/copy_output_request.h" | 15 #include "cc/output/copy_output_request.h" |
| 12 #include "cc/output/copy_output_result.h" | 16 #include "cc/output/copy_output_result.h" |
| 13 #include "cc/output/delegated_frame_data.h" | 17 #include "cc/output/delegated_frame_data.h" |
| 14 #include "cc/resources/resource_provider.h" | 18 #include "cc/resources/resource_provider.h" |
| 15 #include "cc/surfaces/surface.h" | 19 #include "cc/surfaces/surface.h" |
| 16 #include "cc/surfaces/surface_factory_client.h" | 20 #include "cc/surfaces/surface_factory_client.h" |
| 17 #include "cc/surfaces/surface_manager.h" | 21 #include "cc/surfaces/surface_manager.h" |
| 18 #include "cc/test/scheduler_test_common.h" | 22 #include "cc/test/scheduler_test_common.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 EXPECT_EQ(2, surface->frame_index()); | 397 EXPECT_EQ(2, surface->frame_index()); |
| 394 scoped_ptr<CompositorFrame> frame(new CompositorFrame); | 398 scoped_ptr<CompositorFrame> frame(new CompositorFrame); |
| 395 frame->delegated_frame_data.reset(new DelegatedFrameData); | 399 frame->delegated_frame_data.reset(new DelegatedFrameData); |
| 396 | 400 |
| 397 factory_->SubmitCompositorFrame(surface_id, std::move(frame), | 401 factory_->SubmitCompositorFrame(surface_id, std::move(frame), |
| 398 SurfaceFactory::DrawCallback()); | 402 SurfaceFactory::DrawCallback()); |
| 399 EXPECT_EQ(2, surface->frame_index()); | 403 EXPECT_EQ(2, surface->frame_index()); |
| 400 factory_->Destroy(surface_id); | 404 factory_->Destroy(surface_id); |
| 401 } | 405 } |
| 402 | 406 |
| 403 void DrawCallback(uint32* execute_count, | 407 void DrawCallback(uint32_t* execute_count, |
| 404 SurfaceDrawStatus* result, | 408 SurfaceDrawStatus* result, |
| 405 SurfaceDrawStatus drawn) { | 409 SurfaceDrawStatus drawn) { |
| 406 *execute_count += 1; | 410 *execute_count += 1; |
| 407 *result = drawn; | 411 *result = drawn; |
| 408 } | 412 } |
| 409 | 413 |
| 410 // Tests doing a DestroyAll before shutting down the factory; | 414 // Tests doing a DestroyAll before shutting down the factory; |
| 411 TEST_F(SurfaceFactoryTest, DestroyAll) { | 415 TEST_F(SurfaceFactoryTest, DestroyAll) { |
| 412 SurfaceId id(7); | 416 SurfaceId id(7); |
| 413 factory_->Create(id); | 417 factory_->Create(id); |
| 414 | 418 |
| 415 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 419 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
| 416 TransferableResource resource; | 420 TransferableResource resource; |
| 417 resource.id = 1; | 421 resource.id = 1; |
| 418 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; | 422 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; |
| 419 frame_data->resource_list.push_back(resource); | 423 frame_data->resource_list.push_back(resource); |
| 420 scoped_ptr<CompositorFrame> frame(new CompositorFrame); | 424 scoped_ptr<CompositorFrame> frame(new CompositorFrame); |
| 421 frame->delegated_frame_data = std::move(frame_data); | 425 frame->delegated_frame_data = std::move(frame_data); |
| 422 uint32 execute_count = 0; | 426 uint32_t execute_count = 0; |
| 423 SurfaceDrawStatus drawn = SurfaceDrawStatus::DRAW_SKIPPED; | 427 SurfaceDrawStatus drawn = SurfaceDrawStatus::DRAW_SKIPPED; |
| 424 | 428 |
| 425 factory_->SubmitCompositorFrame( | 429 factory_->SubmitCompositorFrame( |
| 426 id, std::move(frame), base::Bind(&DrawCallback, &execute_count, &drawn)); | 430 id, std::move(frame), base::Bind(&DrawCallback, &execute_count, &drawn)); |
| 427 | 431 |
| 428 surface_id_ = SurfaceId(); | 432 surface_id_ = SurfaceId(); |
| 429 factory_->DestroyAll(); | 433 factory_->DestroyAll(); |
| 430 EXPECT_EQ(1u, execute_count); | 434 EXPECT_EQ(1u, execute_count); |
| 431 EXPECT_EQ(SurfaceDrawStatus::DRAW_SKIPPED, drawn); | 435 EXPECT_EQ(SurfaceDrawStatus::DRAW_SKIPPED, drawn); |
| 432 } | 436 } |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 surface_id_ = SurfaceId(); | 620 surface_id_ = SurfaceId(); |
| 617 factory_->DestroyAll(); | 621 factory_->DestroyAll(); |
| 618 | 622 |
| 619 EXPECT_EQ(&bfs, client_.begin_frame_source()); | 623 EXPECT_EQ(&bfs, client_.begin_frame_source()); |
| 620 factory_.reset(); | 624 factory_.reset(); |
| 621 EXPECT_EQ(nullptr, client_.begin_frame_source()); | 625 EXPECT_EQ(nullptr, client_.begin_frame_source()); |
| 622 } | 626 } |
| 623 | 627 |
| 624 } // namespace | 628 } // namespace |
| 625 } // namespace cc | 629 } // namespace cc |
| OLD | NEW |