Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1411)

Side by Side Diff: cc/surfaces/surface_factory_unittest.cc

Issue 812543002: Update from https://crrev.com/308331 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/surfaces/surface_factory.cc ('k') | cc/surfaces/surfaces_pixeltest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/bind.h"
5 #include "cc/output/compositor_frame.h" 6 #include "cc/output/compositor_frame.h"
6 #include "cc/output/delegated_frame_data.h" 7 #include "cc/output/delegated_frame_data.h"
7 #include "cc/surfaces/surface.h" 8 #include "cc/surfaces/surface.h"
8 #include "cc/surfaces/surface_factory.h" 9 #include "cc/surfaces/surface_factory.h"
9 #include "cc/surfaces/surface_factory_client.h" 10 #include "cc/surfaces/surface_factory_client.h"
10 #include "cc/surfaces/surface_manager.h" 11 #include "cc/surfaces/surface_manager.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/gfx/geometry/size.h" 13 #include "ui/gfx/geometry/size.h"
13 14
14 namespace cc { 15 namespace cc {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 size_t num_resource_ids) { 52 size_t num_resource_ids) {
52 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); 53 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
53 for (size_t i = 0u; i < num_resource_ids; ++i) { 54 for (size_t i = 0u; i < num_resource_ids; ++i) {
54 TransferableResource resource; 55 TransferableResource resource;
55 resource.id = resource_ids[i]; 56 resource.id = resource_ids[i];
56 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; 57 resource.mailbox_holder.texture_target = GL_TEXTURE_2D;
57 frame_data->resource_list.push_back(resource); 58 frame_data->resource_list.push_back(resource);
58 } 59 }
59 scoped_ptr<CompositorFrame> frame(new CompositorFrame); 60 scoped_ptr<CompositorFrame> frame(new CompositorFrame);
60 frame->delegated_frame_data = frame_data.Pass(); 61 frame->delegated_frame_data = frame_data.Pass();
61 factory_.SubmitFrame(surface_id_, frame.Pass(), base::Closure()); 62 factory_.SubmitFrame(surface_id_, frame.Pass(),
63 SurfaceFactory::DrawCallback());
62 } 64 }
63 65
64 void UnrefResources(ResourceProvider::ResourceId* ids_to_unref, 66 void UnrefResources(ResourceProvider::ResourceId* ids_to_unref,
65 int* counts_to_unref, 67 int* counts_to_unref,
66 size_t num_ids_to_unref) { 68 size_t num_ids_to_unref) {
67 ReturnedResourceArray unref_array; 69 ReturnedResourceArray unref_array;
68 for (size_t i = 0; i < num_ids_to_unref; ++i) { 70 for (size_t i = 0; i < num_ids_to_unref; ++i) {
69 ReturnedResource resource; 71 ReturnedResource resource;
70 resource.id = ids_to_unref[i]; 72 resource.id = ids_to_unref[i];
71 resource.count = counts_to_unref[i]; 73 resource.count = counts_to_unref[i];
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 { 353 {
352 SCOPED_TRACE("fourth frame, second unref"); 354 SCOPED_TRACE("fourth frame, second unref");
353 ResourceProvider::ResourceId expected_returned_ids[] = {12, 13}; 355 ResourceProvider::ResourceId expected_returned_ids[] = {12, 13};
354 int expected_returned_counts[] = {2, 2}; 356 int expected_returned_counts[] = {2, 2};
355 CheckReturnedResourcesMatchExpected(expected_returned_ids, 357 CheckReturnedResourcesMatchExpected(expected_returned_ids,
356 expected_returned_counts, 358 expected_returned_counts,
357 arraysize(expected_returned_counts)); 359 arraysize(expected_returned_counts));
358 } 360 }
359 } 361 }
360 362
363 void DrawCallback(bool* executed, bool* result, bool drawn) {
364 *executed = true;
365 *result = drawn;
366 }
367
361 // Tests doing a DestroyAll before shutting down the factory; 368 // Tests doing a DestroyAll before shutting down the factory;
362 TEST_F(SurfaceFactoryTest, DestroyAll) { 369 TEST_F(SurfaceFactoryTest, DestroyAll) {
363 SurfaceId id(7); 370 SurfaceId id(7);
364 factory_.Create(id); 371 factory_.Create(id);
365 372
366 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); 373 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
367 TransferableResource resource; 374 TransferableResource resource;
368 resource.id = 1; 375 resource.id = 1;
369 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; 376 resource.mailbox_holder.texture_target = GL_TEXTURE_2D;
370 frame_data->resource_list.push_back(resource); 377 frame_data->resource_list.push_back(resource);
371 scoped_ptr<CompositorFrame> frame(new CompositorFrame); 378 scoped_ptr<CompositorFrame> frame(new CompositorFrame);
372 frame->delegated_frame_data = frame_data.Pass(); 379 frame->delegated_frame_data = frame_data.Pass();
373 factory_.SubmitFrame(id, frame.Pass(), base::Closure()); 380 bool executed = false;
381 bool drawn = false;
382
383 factory_.SubmitFrame(id, frame.Pass(),
384 base::Bind(&DrawCallback, &executed, &drawn));
374 385
375 surface_id_ = SurfaceId(); 386 surface_id_ = SurfaceId();
387 EXPECT_FALSE(executed);
376 factory_.DestroyAll(); 388 factory_.DestroyAll();
389 EXPECT_TRUE(executed);
390 EXPECT_FALSE(drawn);
377 } 391 }
378 392
379 TEST_F(SurfaceFactoryTest, DestroySequence) { 393 TEST_F(SurfaceFactoryTest, DestroySequence) {
380 SurfaceId id2(5); 394 SurfaceId id2(5);
381 factory_.Create(id2); 395 factory_.Create(id2);
382 396
383 // Check that waiting before the sequence is satisfied works. 397 // Check that waiting before the sequence is satisfied works.
384 manager_.GetSurfaceForId(id2) 398 manager_.GetSurfaceForId(id2)
385 ->AddDestructionDependency(SurfaceSequence(0, 4)); 399 ->AddDestructionDependency(SurfaceSequence(0, 4));
386 factory_.Destroy(id2); 400 factory_.Destroy(id2);
387 401
388 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); 402 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
389 scoped_ptr<CompositorFrame> frame(new CompositorFrame); 403 scoped_ptr<CompositorFrame> frame(new CompositorFrame);
390 frame->metadata.satisfies_sequences.push_back(6); 404 frame->metadata.satisfies_sequences.push_back(6);
391 frame->metadata.satisfies_sequences.push_back(4); 405 frame->metadata.satisfies_sequences.push_back(4);
392 frame->delegated_frame_data = frame_data.Pass(); 406 frame->delegated_frame_data = frame_data.Pass();
393 DCHECK(manager_.GetSurfaceForId(id2)); 407 DCHECK(manager_.GetSurfaceForId(id2));
394 factory_.SubmitFrame(surface_id_, frame.Pass(), base::Closure()); 408 factory_.SubmitFrame(surface_id_, frame.Pass(),
409 SurfaceFactory::DrawCallback());
395 DCHECK(!manager_.GetSurfaceForId(id2)); 410 DCHECK(!manager_.GetSurfaceForId(id2));
396 411
397 // Check that waiting after the sequence is satisfied works. 412 // Check that waiting after the sequence is satisfied works.
398 factory_.Create(id2); 413 factory_.Create(id2);
399 DCHECK(manager_.GetSurfaceForId(id2)); 414 DCHECK(manager_.GetSurfaceForId(id2));
400 manager_.GetSurfaceForId(id2) 415 manager_.GetSurfaceForId(id2)
401 ->AddDestructionDependency(SurfaceSequence(0, 6)); 416 ->AddDestructionDependency(SurfaceSequence(0, 6));
402 factory_.Destroy(id2); 417 factory_.Destroy(id2);
403 DCHECK(!manager_.GetSurfaceForId(id2)); 418 DCHECK(!manager_.GetSurfaceForId(id2));
404 } 419 }
405 420
406 } // namespace 421 } // namespace
407 } // namespace cc 422 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_factory.cc ('k') | cc/surfaces/surfaces_pixeltest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698