Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: content/browser/renderer_host/context_provider_factory_impl_android.h

Issue 2190033002: content: Add ContextProviderFactory to create a render ContextProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: copy ctor. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "content/common/gpu/client/command_buffer_metrics.h"
15 #include "gpu/command_buffer/client/shared_memory_limits.h"
16 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
17 #include "ui/android/context_provider_factory.h"
18
19 namespace base {
20 template <typename T>
21 struct DefaultSingletonTraits;
22 }
23
24 namespace cc {
25 class VulkanInProcessContextProvider;
26 }
27
28 namespace gpu {
29 class GpuChannelHost;
30 }
31
32 namespace content {
33 class ContextProviderCommandBuffer;
34
35 class CONTENT_EXPORT ContextProviderFactoryImpl
36 : public ui::ContextProviderFactory {
37 public:
38 static ContextProviderFactoryImpl* GetInstance();
39
40 ~ContextProviderFactoryImpl() override;
41
42 void CreateDisplayContextProvider(
43 gfx::AcceleratedWidget widget,
44 gpu::SharedMemoryLimits shared_memory_limits,
45 gpu::gles2::ContextCreationAttribHelper attributes,
46 bool support_locking,
47 bool automatic_flushes,
48 ContextProviderCallback result_callback);
49
50 // ContextProviderFactory implementation.
51 scoped_refptr<cc::VulkanContextProvider> GetSharedVulkanContextProvider()
52 override;
53 void CreateOffscreenContextProvider(
54 ContextType context_type,
55 gpu::SharedMemoryLimits shared_memory_limits,
56 gpu::gles2::ContextCreationAttribHelper attributes,
57 bool support_locking,
58 bool automatic_flushes,
59 cc::ContextProvider* shared_context_provider,
60 ContextProviderCallback result_callback) override;
61 cc::SurfaceManager* GetSurfaceManager() override;
62 uint32_t AllocateSurfaceClientId() override;
63 cc::SharedBitmapManager* GetSharedBitmapManager() override;
64 gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override;
65
66 private:
67 friend struct base::DefaultSingletonTraits<ContextProviderFactoryImpl>;
68
69 void CreateContextProviderInternal(
70 command_buffer_metrics::ContextType context_type,
71 gfx::AcceleratedWidget widget,
72 gpu::SharedMemoryLimits shared_memory_limits,
73 gpu::gles2::ContextCreationAttribHelper attributes,
74 bool support_locking,
75 bool automatic_flushes,
76 cc::ContextProvider* shared_context_provider,
77 ContextProviderCallback result_callback);
78
79 struct ContextProvidersRequest {
80 ContextProvidersRequest();
81 ContextProvidersRequest(const ContextProvidersRequest& other);
82 ~ContextProvidersRequest();
83
84 command_buffer_metrics::ContextType context_type;
85 gfx::AcceleratedWidget widget;
86 gpu::SharedMemoryLimits shared_memory_limits;
87 gpu::gles2::ContextCreationAttribHelper attributes;
88 bool support_locking;
89 bool automatic_flushes;
90 cc::ContextProvider* shared_context_provider;
91 ContextProviderCallback result_callback;
92 };
93
94 ContextProviderFactoryImpl();
95
96 // Will return nullptr if the Gpu channel has not been established.
97 gpu::GpuChannelHost* EnsureGpuChannelEstablished();
98 void OnGpuChannelEstablished();
99 void OnGpuChannelTimeout();
100
101 void HandlePendingRequests();
102
103 std::list<ContextProvidersRequest> context_provider_requests_;
104
105 scoped_refptr<ContextProviderCommandBuffer> shared_worker_context_provider_;
106
107 scoped_refptr<cc::VulkanContextProvider> shared_vulkan_context_provider_;
108
109 bool in_handle_pending_requests_;
110
111 base::OneShotTimer establish_gpu_channel_timeout_;
112
113 std::unique_ptr<cc::SurfaceManager> surface_manager_;
114 int surface_client_id_;
115
116 base::WeakPtrFactory<ContextProviderFactoryImpl> weak_factory_;
117
118 DISALLOW_COPY_AND_ASSIGN(ContextProviderFactoryImpl);
119 };
120
121 } // namespace content
122
123 #endif // CONTENT_BROWSER_RENDERER_HOST_CONTEXT_PROVIDER_FACTORY_IMPL_ANDROID_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698