| OLD | NEW |
| (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 BLIMP_CLIENT_CORE_COMPOSITOR_DELEGATED_OUTPUT_SURFACE_H_ | |
| 6 #define BLIMP_CLIENT_CORE_COMPOSITOR_DELEGATED_OUTPUT_SURFACE_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "blimp/client/core/compositor/blimp_output_surface.h" | |
| 13 #include "cc/output/output_surface.h" | |
| 14 | |
| 15 namespace base { | |
| 16 class SingleThreadTaskRunner; | |
| 17 } // namespace base | |
| 18 | |
| 19 namespace cc { | |
| 20 class BeginFrameSource; | |
| 21 class ContextProvider; | |
| 22 } // namespace cc | |
| 23 | |
| 24 namespace blimp { | |
| 25 namespace client { | |
| 26 | |
| 27 // This class is created on the main thread, but then becomes bound to the | |
| 28 // compositor thread and will be destroyed there (soon, crbug.com/640730). | |
| 29 class DelegatedOutputSurface : public cc::OutputSurface, | |
| 30 public BlimpOutputSurface { | |
| 31 public: | |
| 32 DelegatedOutputSurface( | |
| 33 scoped_refptr<cc::ContextProvider> compositor_context_provider, | |
| 34 scoped_refptr<cc::ContextProvider> worker_context_provider, | |
| 35 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | |
| 36 base::WeakPtr<BlimpOutputSurfaceClient> client); | |
| 37 | |
| 38 ~DelegatedOutputSurface() override; | |
| 39 | |
| 40 // cc::OutputSurface implementation. | |
| 41 uint32_t GetFramebufferCopyTextureFormat() override; | |
| 42 bool BindToClient(cc::OutputSurfaceClient* client) override; | |
| 43 void SwapBuffers(cc::CompositorFrame frame) override; | |
| 44 void DetachFromClient() override; | |
| 45 | |
| 46 // BlimpOutputSurface implementation. | |
| 47 void ReclaimCompositorResources( | |
| 48 const cc::ReturnedResourceArray& resources) override; | |
| 49 | |
| 50 private: | |
| 51 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | |
| 52 base::WeakPtr<BlimpOutputSurfaceClient> blimp_client_; | |
| 53 | |
| 54 bool bound_to_client_; | |
| 55 | |
| 56 // This OutputSurface is responsible for providing the BeginFrameSource to | |
| 57 // drive frame creation. This will be built on the compositor impl thread at | |
| 58 // BindToClient call time. | |
| 59 std::unique_ptr<cc::BeginFrameSource> begin_frame_source_; | |
| 60 | |
| 61 base::WeakPtrFactory<DelegatedOutputSurface> weak_factory_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(DelegatedOutputSurface); | |
| 64 }; | |
| 65 | |
| 66 } // namespace client | |
| 67 } // namespace blimp | |
| 68 | |
| 69 #endif // BLIMP_CLIENT_CORE_COMPOSITOR_DELEGATED_OUTPUT_SURFACE_H_ | |
| OLD | NEW |