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

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

Powered by Google App Engine
This is Rietveld 408576698