| 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 UI_ANDROID_CONTEXT_PROVIDER_FACTORY_H_ | |
| 6 #define UI_ANDROID_CONTEXT_PROVIDER_FACTORY_H_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "cc/surfaces/frame_sink_id.h" | |
| 11 #include "ui/android/ui_android_export.h" | |
| 12 | |
| 13 namespace cc { | |
| 14 class ContextProvider; | |
| 15 class VulkanContextProvider; | |
| 16 class SurfaceManager; | |
| 17 } | |
| 18 | |
| 19 namespace gpu { | |
| 20 namespace gles2 { | |
| 21 struct ContextCreationAttribHelper; | |
| 22 } // namespace gles | |
| 23 | |
| 24 struct SharedMemoryLimits; | |
| 25 class GpuChannelHost; | |
| 26 class GpuMemoryBufferManager; | |
| 27 } // namespace gpu | |
| 28 | |
| 29 namespace ui { | |
| 30 | |
| 31 // This class is not thread-safe and should only be accessed from the UI thread. | |
| 32 class UI_ANDROID_EXPORT ContextProviderFactory { | |
| 33 public: | |
| 34 enum class GpuChannelHostResult { | |
| 35 FAILURE_GPU_PROCESS_INITIALIZATION_FAILED, | |
| 36 | |
| 37 // Used when the factory is shutting down. No more requests should be made | |
| 38 // to the factory after this response is dispatched. | |
| 39 FAILURE_FACTORY_SHUTDOWN, | |
| 40 | |
| 41 // Set if the Context creation was successful. | |
| 42 SUCCESS, | |
| 43 }; | |
| 44 | |
| 45 using GpuChannelHostCallback = | |
| 46 base::Callback<void(scoped_refptr<gpu::GpuChannelHost>, | |
| 47 GpuChannelHostResult)>; | |
| 48 | |
| 49 enum class ContextType { | |
| 50 BLIMP_RENDER_COMPOSITOR_CONTEXT, | |
| 51 BLIMP_RENDER_WORKER_CONTEXT, | |
| 52 }; | |
| 53 | |
| 54 static ContextProviderFactory* GetInstance(); | |
| 55 | |
| 56 // This should only be called once, on startup. Ownership remains with the | |
| 57 // caller. | |
| 58 static void SetInstance(ContextProviderFactory* context_provider_factory); | |
| 59 | |
| 60 virtual ~ContextProviderFactory(){}; | |
| 61 | |
| 62 virtual scoped_refptr<cc::VulkanContextProvider> | |
| 63 GetSharedVulkanContextProvider() = 0; | |
| 64 | |
| 65 // The callback may be triggered synchronously if possible. If the creation | |
| 66 // fails, a null host is passed with the specified reason. | |
| 67 virtual void RequestGpuChannelHost(GpuChannelHostCallback callback) = 0; | |
| 68 | |
| 69 // Creates an offscreen ContextProvider for the compositor. Any shared | |
| 70 // contexts passed here *must* have been created using this factory. | |
| 71 virtual scoped_refptr<cc::ContextProvider> CreateOffscreenContextProvider( | |
| 72 ContextType context_type, | |
| 73 gpu::SharedMemoryLimits shared_memory_limits, | |
| 74 gpu::gles2::ContextCreationAttribHelper attributes, | |
| 75 bool support_locking, | |
| 76 bool automatic_flushes, | |
| 77 cc::ContextProvider* shared_context_provider, | |
| 78 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host) = 0; | |
| 79 | |
| 80 virtual cc::SurfaceManager* GetSurfaceManager() = 0; | |
| 81 | |
| 82 virtual cc::FrameSinkId AllocateFrameSinkId() = 0; | |
| 83 | |
| 84 virtual gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() = 0; | |
| 85 }; | |
| 86 | |
| 87 } // namespace ui | |
| 88 | |
| 89 #endif // UI_ANDROID_CONTEXT_PROVIDER_FACTORY_H_ | |
| OLD | NEW |