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> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 gpu::SyncToken GenTestSyncToken(int id) { | 60 gpu::SyncToken GenTestSyncToken(int id) { |
61 gpu::SyncToken token; | 61 gpu::SyncToken token; |
62 token.Set(gpu::CommandBufferNamespace::GPU_IO, 0, | 62 token.Set(gpu::CommandBufferNamespace::GPU_IO, 0, |
63 gpu::CommandBufferId::FromUnsafeValue(id), 1); | 63 gpu::CommandBufferId::FromUnsafeValue(id), 1); |
64 return token; | 64 return token; |
65 } | 65 } |
66 | 66 |
67 class SurfaceFactoryTest : public testing::Test, public SurfaceDamageObserver { | 67 class SurfaceFactoryTest : public testing::Test, public SurfaceDamageObserver { |
68 public: | 68 public: |
69 SurfaceFactoryTest() | 69 SurfaceFactoryTest() |
70 : factory_(new SurfaceFactory(&manager_, &client_)), | 70 : factory_( |
| 71 new SurfaceFactory(kArbitraryFrameSinkId, &manager_, &client_)), |
71 surface_id_(kArbitraryFrameSinkId, 3, 0), | 72 surface_id_(kArbitraryFrameSinkId, 3, 0), |
72 frame_sync_token_(GenTestSyncToken(4)), | 73 frame_sync_token_(GenTestSyncToken(4)), |
73 consumer_sync_token_(GenTestSyncToken(5)) { | 74 consumer_sync_token_(GenTestSyncToken(5)) { |
74 manager_.AddObserver(this); | 75 manager_.AddObserver(this); |
75 factory_->Create(surface_id_); | 76 factory_->Create(surface_id_); |
76 } | 77 } |
77 | 78 |
78 // SurfaceDamageObserver implementation. | 79 // SurfaceDamageObserver implementation. |
79 void OnSurfaceDamaged(const SurfaceId& id, bool* changed) override { | 80 void OnSurfaceDamaged(const SurfaceId& id, bool* changed) override { |
80 *changed = true; | 81 *changed = true; |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 factory_->Create(id2); | 510 factory_->Create(id2); |
510 DCHECK(manager_.GetSurfaceForId(id2)); | 511 DCHECK(manager_.GetSurfaceForId(id2)); |
511 manager_.GetSurfaceForId(id2)->AddDestructionDependency( | 512 manager_.GetSurfaceForId(id2)->AddDestructionDependency( |
512 SurfaceSequence(FrameSinkId(0, 0), 6)); | 513 SurfaceSequence(FrameSinkId(0, 0), 6)); |
513 factory_->Destroy(id2); | 514 factory_->Destroy(id2); |
514 DCHECK(!manager_.GetSurfaceForId(id2)); | 515 DCHECK(!manager_.GetSurfaceForId(id2)); |
515 } | 516 } |
516 | 517 |
517 // Tests that Surface ID namespace invalidation correctly allows | 518 // Tests that Surface ID namespace invalidation correctly allows |
518 // Sequences to be ignored. | 519 // Sequences to be ignored. |
519 TEST_F(SurfaceFactoryTest, InvalidClientId) { | 520 TEST_F(SurfaceFactoryTest, InvalidFrameSinkId) { |
520 FrameSinkId frame_sink_id(9, 9); | 521 FrameSinkId frame_sink_id(1234, 5678); |
521 SurfaceId id(frame_sink_id, 5, 0); | 522 |
| 523 SurfaceId id(factory_->frame_sink_id(), 5, 0); |
522 factory_->Create(id); | 524 factory_->Create(id); |
523 | 525 |
524 manager_.RegisterFrameSinkId(frame_sink_id); | 526 manager_.RegisterFrameSinkId(frame_sink_id); |
525 manager_.GetSurfaceForId(id)->AddDestructionDependency( | 527 manager_.GetSurfaceForId(id)->AddDestructionDependency( |
526 SurfaceSequence(frame_sink_id, 4)); | 528 SurfaceSequence(frame_sink_id, 4)); |
527 factory_->Destroy(id); | 529 factory_->Destroy(id); |
528 | 530 |
529 // Verify the dependency has prevented the surface from getting destroyed. | 531 // Verify the dependency has prevented the surface from getting destroyed. |
530 EXPECT_TRUE(manager_.GetSurfaceForId(id)); | 532 EXPECT_TRUE(manager_.GetSurfaceForId(id)); |
531 | 533 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 | 640 |
639 factory_->Destroy(surface_id_); | 641 factory_->Destroy(surface_id_); |
640 surface_id_ = SurfaceId(); | 642 surface_id_ = SurfaceId(); |
641 EXPECT_TRUE(called1); | 643 EXPECT_TRUE(called1); |
642 EXPECT_TRUE(called2); | 644 EXPECT_TRUE(called2); |
643 EXPECT_TRUE(called3); | 645 EXPECT_TRUE(called3); |
644 } | 646 } |
645 | 647 |
646 } // namespace | 648 } // namespace |
647 } // namespace cc | 649 } // namespace cc |
OLD | NEW |