| 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 CONTENT_BROWSER_RENDERER_HOST_CONTEXT_PROVIDER_FACTORY_IMPL_ANDROID_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_CONTEXT_PROVIDER_FACTORY_IMPL_ANDROID_H_ |
| 7 |
| 8 #include <list> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/timer/timer.h" |
| 13 #include "content/common/content_export.h" |
| 14 #include "gpu/command_buffer/client/shared_memory_limits.h" |
| 15 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 16 #include "ui/android/context_provider_factory.h" |
| 17 |
| 18 namespace base { |
| 19 template <typename T> |
| 20 struct DefaultSingletonTraits; |
| 21 } |
| 22 |
| 23 namespace cc { |
| 24 class VulkanInProcessContextProvider; |
| 25 } |
| 26 |
| 27 namespace gpu { |
| 28 class GpuChannelHost; |
| 29 } |
| 30 |
| 31 namespace content { |
| 32 class ContextProviderCommandBuffer; |
| 33 |
| 34 class CONTENT_EXPORT ContextProviderFactoryImpl |
| 35 : public ui::ContextProviderFactory { |
| 36 public: |
| 37 static ContextProviderFactoryImpl* GetInstance(); |
| 38 |
| 39 ~ContextProviderFactoryImpl() override; |
| 40 |
| 41 void CreateDisplayContextProvider( |
| 42 gfx::AcceleratedWidget widget, |
| 43 gpu::SharedMemoryLimits shared_memory_limits, |
| 44 gpu::gles2::ContextCreationAttribHelper attributes, |
| 45 bool support_locking, |
| 46 bool automatic_flushes, |
| 47 ContextProviderCallback result_callback); |
| 48 |
| 49 // ContextProviderFactory implementation. |
| 50 scoped_refptr<cc::VulkanContextProvider> GetSharedVulkanContextProvider() |
| 51 override; |
| 52 void CreateOffscreenContextProvider( |
| 53 gpu::SharedMemoryLimits shared_memory_limits, |
| 54 gpu::gles2::ContextCreationAttribHelper attributes, |
| 55 bool support_locking, |
| 56 bool automatic_flushes, |
| 57 cc::ContextProvider* shared_context_provider, |
| 58 ContextProviderCallback result_callback) override; |
| 59 cc::SurfaceManager* GetSurfaceManager() override; |
| 60 uint32_t AllocateSurfaceClientId() override; |
| 61 cc::SharedBitmapManager* GetSharedBitmapManager() override; |
| 62 gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override; |
| 63 |
| 64 private: |
| 65 friend struct base::DefaultSingletonTraits<ContextProviderFactoryImpl>; |
| 66 |
| 67 void CreateContextProviderInternal( |
| 68 gfx::AcceleratedWidget widget, |
| 69 gpu::SharedMemoryLimits shared_memory_limits, |
| 70 gpu::gles2::ContextCreationAttribHelper attributes, |
| 71 bool support_locking, |
| 72 bool automatic_flushes, |
| 73 cc::ContextProvider* shared_context_provider, |
| 74 ContextProviderCallback result_callback); |
| 75 |
| 76 struct ContextProvidersRequest { |
| 77 ContextProvidersRequest(); |
| 78 ~ContextProvidersRequest(); |
| 79 |
| 80 gfx::AcceleratedWidget widget; |
| 81 gpu::SharedMemoryLimits shared_memory_limits; |
| 82 gpu::gles2::ContextCreationAttribHelper attributes; |
| 83 bool support_locking; |
| 84 bool automatic_flushes; |
| 85 cc::ContextProvider* shared_context_provider; |
| 86 ContextProviderCallback result_callback; |
| 87 }; |
| 88 |
| 89 ContextProviderFactoryImpl(); |
| 90 |
| 91 // Will return nullptr if the Gpu channel has not been established. |
| 92 gpu::GpuChannelHost* EnsureGpuChannelEstablished(); |
| 93 void OnGpuChannelEstablished(); |
| 94 void OnGpuChannelTimeout(); |
| 95 |
| 96 void HandlePendingRequests(); |
| 97 |
| 98 std::list<ContextProvidersRequest> context_provider_requests_; |
| 99 |
| 100 scoped_refptr<ContextProviderCommandBuffer> shared_worker_context_provider_; |
| 101 |
| 102 scoped_refptr<cc::VulkanContextProvider> shared_vulkan_context_provider_; |
| 103 |
| 104 bool in_handle_pending_requests_; |
| 105 |
| 106 base::OneShotTimer establish_gpu_channel_timeout_; |
| 107 |
| 108 std::unique_ptr<cc::SurfaceManager> surface_manager_; |
| 109 int surface_client_id_; |
| 110 |
| 111 base::WeakPtrFactory<ContextProviderFactoryImpl> weak_factory_; |
| 112 |
| 113 DISALLOW_COPY_AND_ASSIGN(ContextProviderFactoryImpl); |
| 114 }; |
| 115 |
| 116 } // namespace content |
| 117 |
| 118 #endif // CONTENT_BROWSER_RENDERER_HOST_CONTEXT_PROVIDER_FACTORY_IMPL_ANDROID_H
_ |
| OLD | NEW |