| 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/output/compositor_frame.h" | 5 #include "cc/output/compositor_frame.h" |
| 6 #include "cc/output/delegated_frame_data.h" | 6 #include "cc/output/delegated_frame_data.h" |
| 7 #include "cc/surfaces/surface.h" | 7 #include "cc/surfaces/surface.h" |
| 8 #include "cc/surfaces/surface_factory.h" | 8 #include "cc/surfaces/surface_factory.h" |
| 9 #include "cc/surfaces/surface_factory_client.h" | 9 #include "cc/surfaces/surface_factory_client.h" |
| 10 #include "cc/surfaces/surface_manager.h" | 10 #include "cc/surfaces/surface_manager.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 DISALLOW_COPY_AND_ASSIGN(TestSurfaceFactoryClient); | 36 DISALLOW_COPY_AND_ASSIGN(TestSurfaceFactoryClient); |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 class SurfaceFactoryTest : public testing::Test { | 39 class SurfaceFactoryTest : public testing::Test { |
| 40 public: | 40 public: |
| 41 SurfaceFactoryTest() : factory_(&manager_, &client_), surface_id_(3) { | 41 SurfaceFactoryTest() : factory_(&manager_, &client_), surface_id_(3) { |
| 42 factory_.Create(surface_id_, gfx::Size(5, 5)); | 42 factory_.Create(surface_id_, gfx::Size(5, 5)); |
| 43 } | 43 } |
| 44 | 44 |
| 45 virtual ~SurfaceFactoryTest() { factory_.Destroy(surface_id_); } | 45 virtual ~SurfaceFactoryTest() { |
| 46 if (!surface_id_.is_null()) |
| 47 factory_.Destroy(surface_id_); |
| 48 } |
| 46 | 49 |
| 47 void SubmitFrameWithResources(ResourceProvider::ResourceId* resource_ids, | 50 void SubmitFrameWithResources(ResourceProvider::ResourceId* resource_ids, |
| 48 size_t num_resource_ids) { | 51 size_t num_resource_ids) { |
| 49 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 52 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
| 50 for (size_t i = 0u; i < num_resource_ids; ++i) { | 53 for (size_t i = 0u; i < num_resource_ids; ++i) { |
| 51 TransferableResource resource; | 54 TransferableResource resource; |
| 52 resource.id = resource_ids[i]; | 55 resource.id = resource_ids[i]; |
| 53 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; | 56 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; |
| 54 frame_data->resource_list.push_back(resource); | 57 frame_data->resource_list.push_back(resource); |
| 55 } | 58 } |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 { | 351 { |
| 349 SCOPED_TRACE("fourth frame, second unref"); | 352 SCOPED_TRACE("fourth frame, second unref"); |
| 350 ResourceProvider::ResourceId expected_returned_ids[] = {12, 13}; | 353 ResourceProvider::ResourceId expected_returned_ids[] = {12, 13}; |
| 351 int expected_returned_counts[] = {2, 2}; | 354 int expected_returned_counts[] = {2, 2}; |
| 352 CheckReturnedResourcesMatchExpected(expected_returned_ids, | 355 CheckReturnedResourcesMatchExpected(expected_returned_ids, |
| 353 expected_returned_counts, | 356 expected_returned_counts, |
| 354 arraysize(expected_returned_counts)); | 357 arraysize(expected_returned_counts)); |
| 355 } | 358 } |
| 356 } | 359 } |
| 357 | 360 |
| 358 // Tests shutting down the factory with a surface with outstanding refs still in | 361 // Tests doing a DestroyAll before shutting down the factory; |
| 359 // the map. | 362 TEST_F(SurfaceFactoryTest, DestroyAll) { |
| 360 TEST_F(SurfaceFactoryTest, DestroyWithResourceRefs) { | |
| 361 SurfaceId id(7); | 363 SurfaceId id(7); |
| 362 factory_.Create(id, gfx::Size(1, 1)); | 364 factory_.Create(id, gfx::Size(1, 1)); |
| 363 | 365 |
| 364 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 366 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
| 365 TransferableResource resource; | 367 TransferableResource resource; |
| 366 resource.id = 1; | 368 resource.id = 1; |
| 367 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; | 369 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; |
| 368 frame_data->resource_list.push_back(resource); | 370 frame_data->resource_list.push_back(resource); |
| 369 scoped_ptr<CompositorFrame> frame(new CompositorFrame); | 371 scoped_ptr<CompositorFrame> frame(new CompositorFrame); |
| 370 frame->delegated_frame_data = frame_data.Pass(); | 372 frame->delegated_frame_data = frame_data.Pass(); |
| 371 factory_.SubmitFrame(id, frame.Pass(), base::Closure()); | 373 factory_.SubmitFrame(id, frame.Pass(), base::Closure()); |
| 374 |
| 375 surface_id_ = SurfaceId(); |
| 376 factory_.DestroyAll(); |
| 372 } | 377 } |
| 373 | 378 |
| 374 TEST_F(SurfaceFactoryTest, DestroySequence) { | 379 TEST_F(SurfaceFactoryTest, DestroySequence) { |
| 375 SurfaceId id2(5); | 380 SurfaceId id2(5); |
| 376 factory_.Create(id2, gfx::Size(5, 5)); | 381 factory_.Create(id2, gfx::Size(5, 5)); |
| 377 | 382 |
| 378 // Check that waiting before the sequence is satisfied works. | 383 // Check that waiting before the sequence is satisfied works. |
| 379 std::set<SurfaceSequence> sequence; | 384 std::set<SurfaceSequence> sequence; |
| 380 sequence.insert(SurfaceSequence(0, 4)); | 385 sequence.insert(SurfaceSequence(0, 4)); |
| 381 factory_.DestroyOnSequence(id2, sequence); | 386 factory_.DestroyOnSequence(id2, sequence); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 393 factory_.Create(id2, gfx::Size(5, 5)); | 398 factory_.Create(id2, gfx::Size(5, 5)); |
| 394 sequence.clear(); | 399 sequence.clear(); |
| 395 sequence.insert(SurfaceSequence(0, 6)); | 400 sequence.insert(SurfaceSequence(0, 6)); |
| 396 DCHECK(manager_.GetSurfaceForId(id2)); | 401 DCHECK(manager_.GetSurfaceForId(id2)); |
| 397 factory_.DestroyOnSequence(id2, sequence); | 402 factory_.DestroyOnSequence(id2, sequence); |
| 398 DCHECK(!manager_.GetSurfaceForId(id2)); | 403 DCHECK(!manager_.GetSurfaceForId(id2)); |
| 399 } | 404 } |
| 400 | 405 |
| 401 } // namespace | 406 } // namespace |
| 402 } // namespace cc | 407 } // namespace cc |
| OLD | NEW |