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 ContextCreationFailureReason { | |
35 GPU_PROCESS_INITIALIZATION_FAILURE, | |
36 BROWSER_SHUTDOWN, | |
37 GPU_SURFACE_HANDLE_LOST, | |
38 | |
39 // Set if the Context creation was successful. | |
40 FAILURE_NONE, | |
no sievers
2016/08/17 18:30:10
nit: how about |ContextCreationResult| and _SUCCES
Khushal
2016/08/17 21:24:56
That's much better. Done.
| |
41 }; | |
42 | |
34 using ContextProviderCallback = | 43 using ContextProviderCallback = |
35 base::Callback<void(const scoped_refptr<cc::ContextProvider>&)>; | 44 base::Callback<void(const scoped_refptr<cc::ContextProvider>&, |
45 ContextCreationFailureReason reason)>; | |
36 | 46 |
37 enum class ContextType { | 47 enum class ContextType { |
38 BLIMP_RENDER_COMPOSITOR_CONTEXT, | 48 BLIMP_RENDER_COMPOSITOR_CONTEXT, |
39 BLIMP_RENDER_WORKER_CONTEXT, | 49 BLIMP_RENDER_WORKER_CONTEXT, |
40 }; | 50 }; |
41 | 51 |
42 static ContextProviderFactory* GetInstance(); | 52 static ContextProviderFactory* GetInstance(); |
43 | 53 |
44 // This should only be called once, on startup. Ownership remains with the | 54 // This should only be called once, on startup. Ownership remains with the |
45 // caller. | 55 // caller. |
46 static void SetInstance(ContextProviderFactory* context_provider_factory); | 56 static void SetInstance(ContextProviderFactory* context_provider_factory); |
47 | 57 |
48 virtual ~ContextProviderFactory(){}; | 58 virtual ~ContextProviderFactory(){}; |
49 | 59 |
50 virtual scoped_refptr<cc::VulkanContextProvider> | 60 virtual scoped_refptr<cc::VulkanContextProvider> |
51 GetSharedVulkanContextProvider() = 0; | 61 GetSharedVulkanContextProvider() = 0; |
52 | 62 |
53 // Creates an offscreen ContextProvider for the compositor. Any shared | 63 // Creates an offscreen ContextProvider for the compositor. Any shared |
54 // contexts passed here *must* have been created using this factory. | 64 // contexts passed here *must* have been created using this factory. |
55 // The callback may be triggered synchronously if possible, and will always | 65 // The callback may be triggered synchronously if possible. If the context |
56 // have the context provider. | 66 // creation fails, a null context is passed with the specified reason. |
57 virtual void CreateOffscreenContextProvider( | 67 virtual void CreateOffscreenContextProvider( |
58 ContextType context_type, | 68 ContextType context_type, |
59 gpu::SharedMemoryLimits shared_memory_limits, | 69 gpu::SharedMemoryLimits shared_memory_limits, |
60 gpu::gles2::ContextCreationAttribHelper attributes, | 70 gpu::gles2::ContextCreationAttribHelper attributes, |
61 bool support_locking, | 71 bool support_locking, |
62 bool automatic_flushes, | 72 bool automatic_flushes, |
63 cc::ContextProvider* shared_context_provider, | 73 cc::ContextProvider* shared_context_provider, |
64 ContextProviderCallback result_callback) = 0; | 74 ContextProviderCallback result_callback) = 0; |
65 | 75 |
66 virtual cc::SurfaceManager* GetSurfaceManager() = 0; | 76 virtual cc::SurfaceManager* GetSurfaceManager() = 0; |
67 | 77 |
68 virtual uint32_t AllocateSurfaceClientId() = 0; | 78 virtual uint32_t AllocateSurfaceClientId() = 0; |
69 | 79 |
70 virtual cc::SharedBitmapManager* GetSharedBitmapManager() = 0; | 80 virtual cc::SharedBitmapManager* GetSharedBitmapManager() = 0; |
71 | 81 |
72 virtual gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() = 0; | 82 virtual gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() = 0; |
73 }; | 83 }; |
74 | 84 |
75 } // namespace ui | 85 } // namespace ui |
76 | 86 |
77 #endif // UI_ANDROID_CONTEXT_PROVIDER_FACTORY_H_ | 87 #endif // UI_ANDROID_CONTEXT_PROVIDER_FACTORY_H_ |
OLD | NEW |