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 browser is shutting down. No more requests should be made | |
David Trainor- moved to gerrit
2016/08/18 17:49:43
Should we enforce/DCHECK that we don't get calls a
Khushal
2016/08/18 18:29:13
We can internally enforce that we are not getting
| |
38 // after this. | |
39 FAILURE_BROWSER_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 | |
34 using ContextProviderCallback = | 49 using ContextProviderCallback = |
35 base::Callback<void(const scoped_refptr<cc::ContextProvider>&)>; | 50 base::Callback<void(const scoped_refptr<cc::ContextProvider>&, |
51 ContextCreationResult)>; | |
36 | 52 |
37 enum class ContextType { | 53 enum class ContextType { |
38 BLIMP_RENDER_COMPOSITOR_CONTEXT, | 54 BLIMP_RENDER_COMPOSITOR_CONTEXT, |
39 BLIMP_RENDER_WORKER_CONTEXT, | 55 BLIMP_RENDER_WORKER_CONTEXT, |
40 }; | 56 }; |
41 | 57 |
42 static ContextProviderFactory* GetInstance(); | 58 static ContextProviderFactory* GetInstance(); |
43 | 59 |
44 // This should only be called once, on startup. Ownership remains with the | 60 // This should only be called once, on startup. Ownership remains with the |
45 // caller. | 61 // caller. |
46 static void SetInstance(ContextProviderFactory* context_provider_factory); | 62 static void SetInstance(ContextProviderFactory* context_provider_factory); |
47 | 63 |
48 virtual ~ContextProviderFactory(){}; | 64 virtual ~ContextProviderFactory(){}; |
49 | 65 |
50 virtual scoped_refptr<cc::VulkanContextProvider> | 66 virtual scoped_refptr<cc::VulkanContextProvider> |
51 GetSharedVulkanContextProvider() = 0; | 67 GetSharedVulkanContextProvider() = 0; |
52 | 68 |
53 // Creates an offscreen ContextProvider for the compositor. Any shared | 69 // Creates an offscreen ContextProvider for the compositor. Any shared |
54 // contexts passed here *must* have been created using this factory. | 70 // contexts passed here *must* have been created using this factory. |
55 // The callback may be triggered synchronously if possible, and will always | 71 // The callback may be triggered synchronously if possible. If the context |
56 // have the context provider. | 72 // creation fails, a null context is passed with the specified reason. |
57 virtual void CreateOffscreenContextProvider( | 73 virtual void CreateOffscreenContextProvider( |
58 ContextType context_type, | 74 ContextType context_type, |
59 gpu::SharedMemoryLimits shared_memory_limits, | 75 gpu::SharedMemoryLimits shared_memory_limits, |
60 gpu::gles2::ContextCreationAttribHelper attributes, | 76 gpu::gles2::ContextCreationAttribHelper attributes, |
61 bool support_locking, | 77 bool support_locking, |
62 bool automatic_flushes, | 78 bool automatic_flushes, |
63 cc::ContextProvider* shared_context_provider, | 79 cc::ContextProvider* shared_context_provider, |
64 ContextProviderCallback result_callback) = 0; | 80 ContextProviderCallback result_callback) = 0; |
65 | 81 |
66 virtual cc::SurfaceManager* GetSurfaceManager() = 0; | 82 virtual cc::SurfaceManager* GetSurfaceManager() = 0; |
67 | 83 |
68 virtual uint32_t AllocateSurfaceClientId() = 0; | 84 virtual uint32_t AllocateSurfaceClientId() = 0; |
69 | 85 |
70 virtual cc::SharedBitmapManager* GetSharedBitmapManager() = 0; | 86 virtual cc::SharedBitmapManager* GetSharedBitmapManager() = 0; |
71 | 87 |
72 virtual gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() = 0; | 88 virtual gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() = 0; |
73 }; | 89 }; |
74 | 90 |
75 } // namespace ui | 91 } // namespace ui |
76 | 92 |
77 #endif // UI_ANDROID_CONTEXT_PROVIDER_FACTORY_H_ | 93 #endif // UI_ANDROID_CONTEXT_PROVIDER_FACTORY_H_ |
OLD | NEW |