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