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

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

Issue 2337913003: Fork cc::OutputSurface into cc::CompositorFrameSink. (Closed)
Patch Set: cfsfork: rebase Created 4 years, 3 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_DELEGATING_OUTPUT_SURFACE_H_ 5 #ifndef CC_TEST_TEST_COMPOSITOR_FRAME_SINK_H_
6 #define CC_TEST_TEST_DELEGATING_OUTPUT_SURFACE_H_ 6 #define CC_TEST_TEST_COMPOSITOR_FRAME_SINK_H_
7 7
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "cc/output/output_surface.h" 9 #include "cc/output/compositor_frame_sink.h"
10 #include "cc/output/renderer_settings.h" 10 #include "cc/output/renderer_settings.h"
11 #include "cc/scheduler/begin_frame_source.h" 11 #include "cc/scheduler/begin_frame_source.h"
12 #include "cc/surfaces/display.h" 12 #include "cc/surfaces/display.h"
13 #include "cc/surfaces/display_client.h" 13 #include "cc/surfaces/display_client.h"
14 #include "cc/surfaces/surface_factory.h" 14 #include "cc/surfaces/surface_factory.h"
15 #include "cc/surfaces/surface_factory_client.h" 15 #include "cc/surfaces/surface_factory_client.h"
16 #include "cc/surfaces/surface_id_allocator.h" 16 #include "cc/surfaces/surface_id_allocator.h"
17 #include "cc/surfaces/surface_manager.h" 17 #include "cc/surfaces/surface_manager.h"
18 18
19 namespace cc { 19 namespace cc {
20 class CopyOutputRequest; 20 class CopyOutputRequest;
21 class OutputSurface;
21 22
22 class TestDelegatingOutputSurfaceClient { 23 class TestCompositorFrameSinkClient {
23 public: 24 public:
24 virtual ~TestDelegatingOutputSurfaceClient() {} 25 virtual ~TestCompositorFrameSinkClient() {}
25 26
26 virtual void DisplayReceivedCompositorFrame(const CompositorFrame& frame) = 0; 27 virtual void DisplayReceivedCompositorFrame(const CompositorFrame& frame) = 0;
27 virtual void DisplayWillDrawAndSwap(bool will_draw_and_swap, 28 virtual void DisplayWillDrawAndSwap(bool will_draw_and_swap,
28 const RenderPassList& render_passes) = 0; 29 const RenderPassList& render_passes) = 0;
29 virtual void DisplayDidDrawAndSwap() = 0; 30 virtual void DisplayDidDrawAndSwap() = 0;
30 }; 31 };
31 32
32 // Delegating output surface that owns and forwards frames to a Display. 33 // CompositorFrameSink that owns and forwards frames to a Display.
33 class TestDelegatingOutputSurface : public OutputSurface, 34 class TestCompositorFrameSink : public CompositorFrameSink,
34 public SurfaceFactoryClient, 35 public SurfaceFactoryClient,
35 public DisplayClient { 36 public DisplayClient {
36 public: 37 public:
37 // Pass true for |force_disable_reclaim_resources| to act like the Display 38 // Pass true for |force_disable_reclaim_resources| to act like the Display
38 // is out-of-process and can't return resources synchronously. 39 // is out-of-process and can't return resources synchronously.
39 TestDelegatingOutputSurface( 40 TestCompositorFrameSink(
40 scoped_refptr<ContextProvider> compositor_context_provider, 41 scoped_refptr<ContextProvider> compositor_context_provider,
41 scoped_refptr<ContextProvider> worker_context_provider, 42 scoped_refptr<ContextProvider> worker_context_provider,
42 std::unique_ptr<OutputSurface> display_output_surface, 43 std::unique_ptr<OutputSurface> display_output_surface,
43 SharedBitmapManager* shared_bitmap_manager, 44 SharedBitmapManager* shared_bitmap_manager,
44 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 45 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
45 const RendererSettings& renderer_settings, 46 const RendererSettings& renderer_settings,
46 base::SingleThreadTaskRunner* task_runner, 47 base::SingleThreadTaskRunner* task_runner,
47 bool synchronous_composite, 48 bool synchronous_composite,
48 bool force_disable_reclaim_resources); 49 bool force_disable_reclaim_resources);
49 ~TestDelegatingOutputSurface() override; 50 ~TestCompositorFrameSink() override;
50 51
51 void SetClient(TestDelegatingOutputSurfaceClient* client) { 52 void SetClient(TestCompositorFrameSinkClient* client) {
52 test_client_ = client; 53 test_client_ = client;
53 } 54 }
54 void SetEnlargePassTextureAmount(const gfx::Size& s) { 55 void SetEnlargePassTextureAmount(const gfx::Size& s) {
55 enlarge_pass_texture_amount_ = s; 56 enlarge_pass_texture_amount_ = s;
56 } 57 }
57 58
58 Display* display() const { return display_.get(); } 59 Display* display() const { return display_.get(); }
59 60
60 // Will be submitted with the next SwapBuffers. 61 // Will be submitted with the next SwapBuffers.
61 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> request); 62 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> request);
62 63
63 // OutputSurface implementation. 64 // CompositorFrameSink implementation.
64 bool BindToClient(OutputSurfaceClient* client) override; 65 bool BindToClient(CompositorFrameSinkClient* client) override;
65 void DetachFromClient() override; 66 void DetachFromClient() override;
66 void SwapBuffers(CompositorFrame frame) override; 67 void SwapBuffers(CompositorFrame frame) override;
67 void ForceReclaimResources() override; 68 void ForceReclaimResources() override;
68 void BindFramebuffer() override; 69 void BindFramebuffer() override;
69 uint32_t GetFramebufferCopyTextureFormat() override; 70 uint32_t GetFramebufferCopyTextureFormat() override;
70 71
71 // SurfaceFactoryClient implementation. 72 // SurfaceFactoryClient implementation.
72 void ReturnResources(const ReturnedResourceArray& resources) override; 73 void ReturnResources(const ReturnedResourceArray& resources) override;
73 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override; 74 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override;
74 75
75 // DisplayClient implementation. 76 // DisplayClient implementation.
76 void DisplayOutputSurfaceLost() override; 77 void DisplayOutputSurfaceLost() override;
77 void DisplayWillDrawAndSwap(bool will_draw_and_swap, 78 void DisplayWillDrawAndSwap(bool will_draw_and_swap,
78 const RenderPassList& render_passes) override; 79 const RenderPassList& render_passes) override;
79 void DisplayDidDrawAndSwap() override; 80 void DisplayDidDrawAndSwap() override;
80 81
81 private: 82 private:
82 void DidDrawCallback(bool synchronous); 83 void DidDrawCallback(bool synchronous);
83 84
84 // TODO(danakj): These don't need to be stored in unique_ptrs when 85 // TODO(danakj): These don't need to be stored in unique_ptrs when
85 // OutputSurface is owned/destroyed on the compositor thread. 86 // CompositorFrameSink is owned/destroyed on the compositor thread.
86 std::unique_ptr<SurfaceManager> surface_manager_; 87 std::unique_ptr<SurfaceManager> surface_manager_;
87 std::unique_ptr<SurfaceIdAllocator> surface_id_allocator_; 88 std::unique_ptr<SurfaceIdAllocator> surface_id_allocator_;
88 SurfaceId delegated_surface_id_; 89 SurfaceId delegated_surface_id_;
89 90
90 // Uses surface_manager_. 91 // Uses surface_manager_.
91 std::unique_ptr<SurfaceFactory> surface_factory_; 92 std::unique_ptr<SurfaceFactory> surface_factory_;
92 93
93 // Uses surface_manager_. 94 // Uses surface_manager_.
94 std::unique_ptr<Display> display_; 95 std::unique_ptr<Display> display_;
95 96
96 bool bound_ = false; 97 bool bound_ = false;
97 TestDelegatingOutputSurfaceClient* test_client_ = nullptr; 98 TestCompositorFrameSinkClient* test_client_ = nullptr;
98 gfx::Size enlarge_pass_texture_amount_; 99 gfx::Size enlarge_pass_texture_amount_;
99 100
100 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests_; 101 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests_;
101 102
102 base::WeakPtrFactory<TestDelegatingOutputSurface> weak_ptrs_; 103 base::WeakPtrFactory<TestCompositorFrameSink> weak_ptrs_;
103 }; 104 };
104 105
105 } // namespace cc 106 } // namespace cc
106 107
107 #endif // CC_TEST_TEST_DELEGATING_OUTPUT_SURFACE_H_ 108 #endif // CC_TEST_TEST_COMPOSITOR_FRAME_SINK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698