| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "cc/output/begin_frame_args.h" | 10 #include "cc/output/begin_frame_args.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "ui/compositor/test/draw_waiter_for_test.h" | 21 #include "ui/compositor/test/draw_waiter_for_test.h" |
| 22 | 22 |
| 23 using testing::Mock; | 23 using testing::Mock; |
| 24 using testing::_; | 24 using testing::_; |
| 25 | 25 |
| 26 namespace ui { | 26 namespace ui { |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 class FakeCompositorFrameSink : public cc::SurfaceFactoryClient { | 29 class FakeCompositorFrameSink : public cc::SurfaceFactoryClient { |
| 30 public: | 30 public: |
| 31 FakeCompositorFrameSink(uint32_t client_id, cc::SurfaceManager* manager) | 31 FakeCompositorFrameSink(const cc::FrameSinkId& frame_sink_id, |
| 32 : client_id_(client_id), | 32 cc::SurfaceManager* manager) |
| 33 : frame_sink_id_(frame_sink_id), |
| 33 manager_(manager), | 34 manager_(manager), |
| 34 source_(nullptr), | 35 source_(nullptr), |
| 35 factory_(manager, this) { | 36 factory_(manager, this) { |
| 36 manager_->RegisterSurfaceClientId(client_id_); | 37 manager_->RegisterFrameSinkId(frame_sink_id_); |
| 37 manager_->RegisterSurfaceFactoryClient(client_id_, this); | 38 manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); |
| 38 } | 39 } |
| 39 | 40 |
| 40 ~FakeCompositorFrameSink() override { | 41 ~FakeCompositorFrameSink() override { |
| 41 manager_->UnregisterSurfaceFactoryClient(client_id_); | 42 manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); |
| 42 manager_->InvalidateSurfaceClientId(client_id_); | 43 manager_->InvalidateFrameSinkId(frame_sink_id_); |
| 43 } | 44 } |
| 44 | 45 |
| 45 void ReturnResources(const cc::ReturnedResourceArray& resources) override {} | 46 void ReturnResources(const cc::ReturnedResourceArray& resources) override {} |
| 46 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override { | 47 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override { |
| 47 DCHECK(!source_ || !begin_frame_source); | 48 DCHECK(!source_ || !begin_frame_source); |
| 48 source_ = begin_frame_source; | 49 source_ = begin_frame_source; |
| 49 }; | 50 }; |
| 50 | 51 |
| 51 private: | 52 private: |
| 52 const uint32_t client_id_; | 53 const cc::FrameSinkId frame_sink_id_; |
| 53 cc::SurfaceManager* const manager_; | 54 cc::SurfaceManager* const manager_; |
| 54 cc::BeginFrameSource* source_; | 55 cc::BeginFrameSource* source_; |
| 55 cc::SurfaceFactory factory_; | 56 cc::SurfaceFactory factory_; |
| 56 }; | 57 }; |
| 57 | 58 |
| 58 ACTION_P2(RemoveObserver, compositor, observer) { | 59 ACTION_P2(RemoveObserver, compositor, observer) { |
| 59 compositor->RemoveBeginFrameObserver(observer); | 60 compositor->RemoveBeginFrameObserver(observer); |
| 60 } | 61 } |
| 61 | 62 |
| 62 // Test fixture for tests that require a ui::Compositor with a real task | 63 // Test fixture for tests that require a ui::Compositor with a real task |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 EXPECT_EQ(gfx::kNullAcceleratedWidget, | 149 EXPECT_EQ(gfx::kNullAcceleratedWidget, |
| 149 compositor()->ReleaseAcceleratedWidget()); | 150 compositor()->ReleaseAcceleratedWidget()); |
| 150 compositor()->SetAcceleratedWidget(gfx::kNullAcceleratedWidget); | 151 compositor()->SetAcceleratedWidget(gfx::kNullAcceleratedWidget); |
| 151 compositor()->SetVisible(true); | 152 compositor()->SetVisible(true); |
| 152 compositor()->ScheduleDraw(); | 153 compositor()->ScheduleDraw(); |
| 153 DrawWaiterForTest::WaitForCompositingEnded(compositor()); | 154 DrawWaiterForTest::WaitForCompositingEnded(compositor()); |
| 154 compositor()->SetRootLayer(nullptr); | 155 compositor()->SetRootLayer(nullptr); |
| 155 } | 156 } |
| 156 | 157 |
| 157 } // namespace ui | 158 } // namespace ui |
| OLD | NEW |