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 CHROME_BROWSER_ANDROID_BLIMP_CHROME_COMPOSITOR_DEPENDENCIES_H_ |
| 6 #define CHROME_BROWSER_ANDROID_BLIMP_CHROME_COMPOSITOR_DEPENDENCIES_H_ |
| 7 |
| 8 #include <list> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "base/memory/weak_ptr.h" |
| 12 #include "blimp/client/public/compositor/compositor_dependencies.h" |
| 13 |
| 14 namespace ui { |
| 15 class ContextProviderFactory; |
| 16 } // namespace ui |
| 17 |
| 18 // A wrapper for the Blimp compositor dependencies that passes through to the |
| 19 // ui::ContextProviderFactory. The ContextProviderFactory must outlive this |
| 20 // class. |
| 21 class ChromeCompositorDependencies |
| 22 : public blimp::client::CompositorDependencies { |
| 23 public: |
| 24 ChromeCompositorDependencies( |
| 25 ui::ContextProviderFactory* context_provider_factory); |
| 26 ~ChromeCompositorDependencies() override; |
| 27 |
| 28 // CompositorDependencies implementation. |
| 29 gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override; |
| 30 cc::SurfaceManager* GetSurfaceManager() override; |
| 31 uint32_t AllocateSurfaceClientId() override; |
| 32 void GetContextProviders(const ContextProviderCallback& callback) override; |
| 33 |
| 34 private: |
| 35 void OnWorkerContextCreated( |
| 36 const scoped_refptr<cc::ContextProvider>& worker_context); |
| 37 |
| 38 void HandleCompositorContextRequest(const ContextProviderCallback& callback); |
| 39 |
| 40 ui::ContextProviderFactory* context_provider_factory_; |
| 41 |
| 42 // The compositor needs both the compositor context and the worker context, |
| 43 // which is shared and cached in this class. So if we get a request, while |
| 44 // we are still waiting on a pending worker context request, we queue up all |
| 45 // the requests in |pending_requests_|, so we can then answer all of them |
| 46 // when a worker context becomes available. |
| 47 bool worker_context_request_pending_; |
| 48 |
| 49 // Worker context shared across all Blimp Compositors. |
| 50 scoped_refptr<cc::ContextProvider> shared_main_thread_worker_context_; |
| 51 |
| 52 std::list<ContextProviderCallback> pending_requests_; |
| 53 |
| 54 base::WeakPtrFactory<ChromeCompositorDependencies> weak_factory_; |
| 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(ChromeCompositorDependencies); |
| 57 }; |
| 58 |
| 59 #endif // CHROME_BROWSER_ANDROID_BLIMP_CHROME_COMPOSITOR_DEPENDENCIES_H_ |
OLD | NEW |