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

Side by Side Diff: cc/test/test_compositor_frame_sink.h

Issue 2724383002: TestCompositorFrameSink should use CompositorFrameSinkSupport (Closed)
Patch Set: bring back PostTask Created 3 years, 9 months 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef CC_TEST_TEST_COMPOSITOR_FRAME_SINK_H_ 5 #ifndef CC_TEST_TEST_COMPOSITOR_FRAME_SINK_H_
6 #define CC_TEST_TEST_COMPOSITOR_FRAME_SINK_H_ 6 #define CC_TEST_TEST_COMPOSITOR_FRAME_SINK_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "cc/output/compositor_frame_sink.h" 10 #include "cc/output/compositor_frame_sink.h"
11 #include "cc/output/renderer_settings.h" 11 #include "cc/output/renderer_settings.h"
12 #include "cc/scheduler/begin_frame_source.h" 12 #include "cc/scheduler/begin_frame_source.h"
13 #include "cc/surfaces/compositor_frame_sink_support_client.h"
13 #include "cc/surfaces/display.h" 14 #include "cc/surfaces/display.h"
14 #include "cc/surfaces/display_client.h" 15 #include "cc/surfaces/display_client.h"
15 #include "cc/surfaces/local_surface_id_allocator.h" 16 #include "cc/surfaces/local_surface_id_allocator.h"
16 #include "cc/surfaces/surface_factory.h"
17 #include "cc/surfaces/surface_factory_client.h"
18 #include "cc/surfaces/surface_manager.h" 17 #include "cc/surfaces/surface_manager.h"
19 18
20 namespace base { 19 namespace base {
21 class SingleThreadTaskRunner; 20 class SingleThreadTaskRunner;
22 } 21 }
23 22
24 namespace cc { 23 namespace cc {
24 class CompositorFrameSinkSupport;
25 class CopyOutputRequest; 25 class CopyOutputRequest;
26 class OutputSurface; 26 class OutputSurface;
27 27
28 class TestCompositorFrameSinkClient { 28 class TestCompositorFrameSinkClient {
29 public: 29 public:
30 virtual ~TestCompositorFrameSinkClient() {} 30 virtual ~TestCompositorFrameSinkClient() {}
31 31
32 // This passes the ContextProvider being used by LayerTreeHostImpl which 32 // This passes the ContextProvider being used by LayerTreeHostImpl which
33 // can be used for the OutputSurface optionally. 33 // can be used for the OutputSurface optionally.
34 virtual std::unique_ptr<OutputSurface> CreateDisplayOutputSurface( 34 virtual std::unique_ptr<OutputSurface> CreateDisplayOutputSurface(
35 scoped_refptr<ContextProvider> compositor_context_provider) = 0; 35 scoped_refptr<ContextProvider> compositor_context_provider) = 0;
36 36
37 virtual void DisplayReceivedCompositorFrame(const CompositorFrame& frame) = 0; 37 virtual void DisplayReceivedCompositorFrame(const CompositorFrame& frame) = 0;
38 virtual void DisplayWillDrawAndSwap(bool will_draw_and_swap, 38 virtual void DisplayWillDrawAndSwap(bool will_draw_and_swap,
39 const RenderPassList& render_passes) = 0; 39 const RenderPassList& render_passes) = 0;
40 virtual void DisplayDidDrawAndSwap() = 0; 40 virtual void DisplayDidDrawAndSwap() = 0;
41 }; 41 };
42 42
43 // CompositorFrameSink that owns and forwards frames to a Display. 43 // CompositorFrameSink that owns and forwards frames to a Display.
44 class TestCompositorFrameSink : public CompositorFrameSink, 44 class TestCompositorFrameSink : public CompositorFrameSink,
45 public SurfaceFactoryClient, 45 public CompositorFrameSinkSupportClient,
46 public DisplayClient { 46 public DisplayClient,
47 public ExternalBeginFrameSourceClient {
47 public: 48 public:
48 // Pass true for |force_disable_reclaim_resources| to act like the Display 49 // Pass true for |force_disable_reclaim_resources| to act like the Display
49 // is out-of-process and can't return resources synchronously. 50 // is out-of-process and can't return resources synchronously.
50 TestCompositorFrameSink( 51 TestCompositorFrameSink(
51 scoped_refptr<ContextProvider> compositor_context_provider, 52 scoped_refptr<ContextProvider> compositor_context_provider,
52 scoped_refptr<ContextProvider> worker_context_provider, 53 scoped_refptr<ContextProvider> worker_context_provider,
53 SharedBitmapManager* shared_bitmap_manager, 54 SharedBitmapManager* shared_bitmap_manager,
54 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 55 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
55 const RendererSettings& renderer_settings, 56 const RendererSettings& renderer_settings,
56 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 57 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
(...skipping 13 matching lines...) Expand all
70 71
71 // Will be included with the next SubmitCompositorFrame. 72 // Will be included with the next SubmitCompositorFrame.
72 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> request); 73 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> request);
73 74
74 // CompositorFrameSink implementation. 75 // CompositorFrameSink implementation.
75 bool BindToClient(CompositorFrameSinkClient* client) override; 76 bool BindToClient(CompositorFrameSinkClient* client) override;
76 void DetachFromClient() override; 77 void DetachFromClient() override;
77 void SubmitCompositorFrame(CompositorFrame frame) override; 78 void SubmitCompositorFrame(CompositorFrame frame) override;
78 void ForceReclaimResources() override; 79 void ForceReclaimResources() override;
79 80
80 // SurfaceFactoryClient implementation. 81 // CompositorFrameSinkSupportClient implementation.
81 void ReturnResources(const ReturnedResourceArray& resources) override; 82 void DidReceiveCompositorFrameAck() override;
82 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override; 83 void OnBeginFrame(const BeginFrameArgs& args) override;
84 void ReclaimResources(const ReturnedResourceArray& resources) override;
85 void WillDrawSurface(const LocalSurfaceId& local_surface_id,
86 const gfx::Rect& damage_rect) override;
83 87
84 // DisplayClient implementation. 88 // DisplayClient implementation.
85 void DisplayOutputSurfaceLost() override; 89 void DisplayOutputSurfaceLost() override;
86 void DisplayWillDrawAndSwap(bool will_draw_and_swap, 90 void DisplayWillDrawAndSwap(bool will_draw_and_swap,
87 const RenderPassList& render_passes) override; 91 const RenderPassList& render_passes) override;
88 void DisplayDidDrawAndSwap() override; 92 void DisplayDidDrawAndSwap() override;
89 93
90 private: 94 private:
91 void DidDrawCallback(); 95 // ExternalBeginFrameSource implementation.
96 void OnNeedsBeginFrames(bool needs_begin_frames) override;
97 void OnDidFinishFrame(const BeginFrameAck& ack) override;
98
99 void SendCompositorFrameAckToClient();
92 100
93 const bool synchronous_composite_; 101 const bool synchronous_composite_;
94 const RendererSettings renderer_settings_; 102 const RendererSettings renderer_settings_;
95 103
96 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 104 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
97 105
98 FrameSinkId frame_sink_id_; 106 FrameSinkId frame_sink_id_;
99 // TODO(danakj): These don't need to be stored in unique_ptrs when 107 // TODO(danakj): These don't need to be stored in unique_ptrs when
100 // CompositorFrameSink is owned/destroyed on the compositor thread. 108 // CompositorFrameSink is owned/destroyed on the compositor thread.
101 std::unique_ptr<SurfaceManager> surface_manager_; 109 std::unique_ptr<SurfaceManager> surface_manager_;
102 std::unique_ptr<LocalSurfaceIdAllocator> local_surface_id_allocator_; 110 std::unique_ptr<LocalSurfaceIdAllocator> local_surface_id_allocator_;
103 LocalSurfaceId delegated_local_surface_id_; 111 LocalSurfaceId delegated_local_surface_id_;
104 112
105 // Uses surface_manager_. 113 // Uses surface_manager_.
106 std::unique_ptr<SurfaceFactory> surface_factory_; 114 std::unique_ptr<CompositorFrameSinkSupport> support_;
107 115
108 std::unique_ptr<SyntheticBeginFrameSource> begin_frame_source_; 116 std::unique_ptr<SyntheticBeginFrameSource> begin_frame_source_;
117 ExternalBeginFrameSource external_begin_frame_source_;
109 118
110 // Uses surface_manager_ and begin_frame_source_. 119 // Uses surface_manager_ and begin_frame_source_.
111 std::unique_ptr<Display> display_; 120 std::unique_ptr<Display> display_;
112 121
113 bool bound_ = false;
114 TestCompositorFrameSinkClient* test_client_ = nullptr; 122 TestCompositorFrameSinkClient* test_client_ = nullptr;
115 gfx::Size enlarge_pass_texture_amount_; 123 gfx::Size enlarge_pass_texture_amount_;
116 124
117 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests_; 125 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests_;
118 126
119 base::WeakPtrFactory<TestCompositorFrameSink> weak_ptr_factory_; 127 base::WeakPtrFactory<TestCompositorFrameSink> weak_ptr_factory_;
120 }; 128 };
121 129
122 } // namespace cc 130 } // namespace cc
123 131
124 #endif // CC_TEST_TEST_COMPOSITOR_FRAME_SINK_H_ 132 #endif // CC_TEST_TEST_COMPOSITOR_FRAME_SINK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698