OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_ANDROID_CONTEXT_PROVIDER_FACTORY_H_ | 5 #ifndef UI_ANDROID_CONTEXT_PROVIDER_FACTORY_H_ |
6 #define UI_ANDROID_CONTEXT_PROVIDER_FACTORY_H_ | 6 #define UI_ANDROID_CONTEXT_PROVIDER_FACTORY_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "ui/android/ui_android_export.h" | 10 #include "ui/android/ui_android_export.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 struct SharedMemoryLimits; | 25 struct SharedMemoryLimits; |
26 class GpuMemoryBufferManager; | 26 class GpuMemoryBufferManager; |
27 } // namespace gpu | 27 } // namespace gpu |
28 | 28 |
29 namespace ui { | 29 namespace ui { |
30 | 30 |
31 // This class is not thread-safe and should only be accessed from the UI thread. | 31 // This class is not thread-safe and should only be accessed from the UI thread. |
32 class UI_ANDROID_EXPORT ContextProviderFactory { | 32 class UI_ANDROID_EXPORT ContextProviderFactory { |
33 public: | 33 public: |
34 enum class ContextCreationResult { | |
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 // The GpuSurfaceHandle for the request was lost before the context could be | |
42 // created. This is used for on-screen context requests only. | |
43 FAILURE_GPU_SURFACE_HANDLE_LOST, | |
44 | |
45 // Set if the Context creation was successful. | |
46 SUCCESS, | |
47 }; | |
48 | |
49 using ContextProviderCallback = | 34 using ContextProviderCallback = |
50 base::Callback<void(const scoped_refptr<cc::ContextProvider>&, | 35 base::Callback<void(const scoped_refptr<cc::ContextProvider>&)>; |
51 ContextCreationResult)>; | |
52 | 36 |
53 enum class ContextType { | 37 enum class ContextType { |
54 BLIMP_RENDER_COMPOSITOR_CONTEXT, | 38 BLIMP_RENDER_COMPOSITOR_CONTEXT, |
55 BLIMP_RENDER_WORKER_CONTEXT, | 39 BLIMP_RENDER_WORKER_CONTEXT, |
56 }; | 40 }; |
57 | 41 |
58 static ContextProviderFactory* GetInstance(); | 42 static ContextProviderFactory* GetInstance(); |
59 | 43 |
60 // This should only be called once, on startup. Ownership remains with the | 44 // This should only be called once, on startup. Ownership remains with the |
61 // caller. | 45 // caller. |
62 static void SetInstance(ContextProviderFactory* context_provider_factory); | 46 static void SetInstance(ContextProviderFactory* context_provider_factory); |
63 | 47 |
64 virtual ~ContextProviderFactory(){}; | 48 virtual ~ContextProviderFactory(){}; |
65 | 49 |
66 virtual scoped_refptr<cc::VulkanContextProvider> | 50 virtual scoped_refptr<cc::VulkanContextProvider> |
67 GetSharedVulkanContextProvider() = 0; | 51 GetSharedVulkanContextProvider() = 0; |
68 | 52 |
69 // Creates an offscreen ContextProvider for the compositor. Any shared | 53 // Creates an offscreen ContextProvider for the compositor. Any shared |
70 // contexts passed here *must* have been created using this factory. | 54 // contexts passed here *must* have been created using this factory. |
71 // The callback may be triggered synchronously if possible. If the context | 55 // The callback may be triggered synchronously if possible, and will always |
72 // creation fails, a null context is passed with the specified reason. | 56 // have the context provider. |
73 virtual void CreateOffscreenContextProvider( | 57 virtual void CreateOffscreenContextProvider( |
74 ContextType context_type, | 58 ContextType context_type, |
75 gpu::SharedMemoryLimits shared_memory_limits, | 59 gpu::SharedMemoryLimits shared_memory_limits, |
76 gpu::gles2::ContextCreationAttribHelper attributes, | 60 gpu::gles2::ContextCreationAttribHelper attributes, |
77 bool support_locking, | 61 bool support_locking, |
78 bool automatic_flushes, | 62 bool automatic_flushes, |
79 cc::ContextProvider* shared_context_provider, | 63 cc::ContextProvider* shared_context_provider, |
80 ContextProviderCallback result_callback) = 0; | 64 ContextProviderCallback result_callback) = 0; |
81 | 65 |
82 virtual cc::SurfaceManager* GetSurfaceManager() = 0; | 66 virtual cc::SurfaceManager* GetSurfaceManager() = 0; |
83 | 67 |
84 virtual uint32_t AllocateSurfaceClientId() = 0; | 68 virtual uint32_t AllocateSurfaceClientId() = 0; |
85 | 69 |
86 virtual cc::SharedBitmapManager* GetSharedBitmapManager() = 0; | 70 virtual cc::SharedBitmapManager* GetSharedBitmapManager() = 0; |
87 | 71 |
88 virtual gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() = 0; | 72 virtual gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() = 0; |
89 }; | 73 }; |
90 | 74 |
91 } // namespace ui | 75 } // namespace ui |
92 | 76 |
93 #endif // UI_ANDROID_CONTEXT_PROVIDER_FACTORY_H_ | 77 #endif // UI_ANDROID_CONTEXT_PROVIDER_FACTORY_H_ |
OLD | NEW |