Chromium Code Reviews| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 } | 80 } |
| 81 | 81 |
| 82 const SurfaceId& last_created_surface_id() const { | 82 const SurfaceId& last_created_surface_id() const { |
| 83 return last_created_surface_id_; | 83 return last_created_surface_id_; |
| 84 } | 84 } |
| 85 | 85 |
| 86 // SurfaceObserver implementation. | 86 // SurfaceObserver implementation. |
| 87 void OnSurfaceCreated(const SurfaceInfo& surface_info) override { | 87 void OnSurfaceCreated(const SurfaceInfo& surface_info) override { |
| 88 EXPECT_EQ(kArbitraryFrameSinkId, surface_info.id().frame_sink_id()); | 88 EXPECT_EQ(kArbitraryFrameSinkId, surface_info.id().frame_sink_id()); |
| 89 last_created_surface_id_ = surface_info.id(); | 89 last_created_surface_id_ = surface_info.id(); |
| 90 last_surface_info_ = surface_info; | |
| 90 } | 91 } |
| 91 | 92 |
| 92 void OnSurfaceDamaged(const SurfaceId& id, bool* changed) override { | 93 void OnSurfaceDamaged(const SurfaceId& id, bool* changed) override { |
| 93 *changed = true; | 94 *changed = true; |
| 94 } | 95 } |
| 95 | 96 |
| 96 ~SurfaceFactoryTest() override { | 97 ~SurfaceFactoryTest() override { |
| 97 manager_.RemoveObserver(this); | 98 manager_.RemoveObserver(this); |
| 98 factory_->EvictSurface(); | 99 factory_->EvictSurface(); |
| 99 } | 100 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 SurfaceId(factory_->frame_sink_id(), local_frame_id_)); | 149 SurfaceId(factory_->frame_sink_id(), local_frame_id_)); |
| 149 factory_->RefResources(surface->GetEligibleFrame().resource_list); | 150 factory_->RefResources(surface->GetEligibleFrame().resource_list); |
| 150 } | 151 } |
| 151 | 152 |
| 152 protected: | 153 protected: |
| 153 SurfaceManager manager_; | 154 SurfaceManager manager_; |
| 154 TestSurfaceFactoryClient client_; | 155 TestSurfaceFactoryClient client_; |
| 155 std::unique_ptr<SurfaceFactory> factory_; | 156 std::unique_ptr<SurfaceFactory> factory_; |
| 156 LocalFrameId local_frame_id_; | 157 LocalFrameId local_frame_id_; |
| 157 SurfaceId last_created_surface_id_; | 158 SurfaceId last_created_surface_id_; |
| 159 SurfaceInfo last_surface_info_; | |
| 158 | 160 |
| 159 // This is the sync token submitted with the frame. It should never be | 161 // This is the sync token submitted with the frame. It should never be |
| 160 // returned to the client. | 162 // returned to the client. |
| 161 const gpu::SyncToken frame_sync_token_; | 163 const gpu::SyncToken frame_sync_token_; |
| 162 | 164 |
| 163 // This is the sync token returned by the consumer. It should always be | 165 // This is the sync token returned by the consumer. It should always be |
| 164 // returned to the client. | 166 // returned to the client. |
| 165 const gpu::SyncToken consumer_sync_token_; | 167 const gpu::SyncToken consumer_sync_token_; |
| 166 }; | 168 }; |
| 167 | 169 |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 662 EXPECT_FALSE(called2); | 664 EXPECT_FALSE(called2); |
| 663 EXPECT_FALSE(called3); | 665 EXPECT_FALSE(called3); |
| 664 | 666 |
| 665 factory_->EvictSurface(); | 667 factory_->EvictSurface(); |
| 666 local_frame_id_ = LocalFrameId(); | 668 local_frame_id_ = LocalFrameId(); |
| 667 EXPECT_TRUE(called1); | 669 EXPECT_TRUE(called1); |
| 668 EXPECT_TRUE(called2); | 670 EXPECT_TRUE(called2); |
| 669 EXPECT_TRUE(called3); | 671 EXPECT_TRUE(called3); |
| 670 } | 672 } |
| 671 | 673 |
| 674 // Check whether the SurfaceInfo object is created and populated correctly | |
| 675 // after the frame submission. | |
| 676 TEST_F(SurfaceFactoryTest, SurfaceInfo) { | |
| 677 CompositorFrame frame; | |
| 678 | |
| 679 auto render_pass = RenderPass::Create(); | |
| 680 render_pass->SetNew(1, gfx::Rect(0, 0, 5, 6), gfx::Rect(), gfx::Transform()); | |
|
danakj
2017/01/24 22:37:19
nit: Rect(5,6) is a bit more consise than Rect(0,0
| |
| 681 frame.render_pass_list.push_back(std::move(render_pass)); | |
| 682 | |
| 683 render_pass = RenderPass::Create(); | |
| 684 render_pass->SetNew(2, gfx::Rect(0, 0, 7, 8), gfx::Rect(), gfx::Transform()); | |
| 685 frame.render_pass_list.push_back(std::move(render_pass)); | |
| 686 | |
| 687 frame.metadata.device_scale_factor = 2.5f; | |
| 688 | |
| 689 factory_->SubmitCompositorFrame(local_frame_id_, std::move(frame), | |
| 690 SurfaceFactory::DrawCallback()); | |
| 691 SurfaceId expected_surface_id(factory_->frame_sink_id(), local_frame_id_); | |
| 692 EXPECT_EQ(expected_surface_id, last_surface_info_.id()); | |
| 693 EXPECT_EQ(2.5f, last_surface_info_.device_scale_factor()); | |
| 694 EXPECT_EQ(gfx::Size(7, 8), last_surface_info_.size_in_pixels()); | |
| 695 } | |
| 696 | |
| 672 } // namespace | 697 } // namespace |
| 673 } // namespace cc | 698 } // namespace cc |
| OLD | NEW |