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

Side by Side Diff: content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h

Issue 1900993002: Move SharedMemoryLimits out of WebGraphicsContext3DCommandBufferImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@limits
Patch Set: move-limits: types Created 4 years, 8 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ 5 #ifndef CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_
6 #define CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ 6 #define CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 13 matching lines...) Expand all
24 #include "gpu/ipc/common/surface_handle.h" 24 #include "gpu/ipc/common/surface_handle.h"
25 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" 25 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
26 #include "third_party/WebKit/public/platform/WebString.h" 26 #include "third_party/WebKit/public/platform/WebString.h"
27 #include "ui/gl/gpu_preference.h" 27 #include "ui/gl/gpu_preference.h"
28 #include "url/gurl.h" 28 #include "url/gurl.h"
29 29
30 namespace gpu { 30 namespace gpu {
31 31
32 class ContextSupport; 32 class ContextSupport;
33 class GpuChannelHost; 33 class GpuChannelHost;
34 struct SharedMemoryLimits;
34 class TransferBuffer; 35 class TransferBuffer;
35 36
36 namespace gles2 { 37 namespace gles2 {
37 class GLES2CmdHelper; 38 class GLES2CmdHelper;
38 class GLES2Implementation; 39 class GLES2Implementation;
39 class GLES2Interface; 40 class GLES2Interface;
40 } 41 }
41 } 42 }
42 43
43 namespace content { 44 namespace content {
44 45
45 const size_t kDefaultCommandBufferSize = 1024 * 1024; 46 const size_t kDefaultCommandBufferSize = 1024 * 1024;
46 const size_t kDefaultStartTransferBufferSize = 1 * 1024 * 1024; 47 const size_t kDefaultStartTransferBufferSize = 1 * 1024 * 1024;
47 const size_t kDefaultMinTransferBufferSize = 1 * 256 * 1024; 48 const size_t kDefaultMinTransferBufferSize = 1 * 256 * 1024;
48 const size_t kDefaultMaxTransferBufferSize = 16 * 1024 * 1024; 49 const size_t kDefaultMaxTransferBufferSize = 16 * 1024 * 1024;
49 50
50 class WebGraphicsContext3DCommandBufferImpl 51 class WebGraphicsContext3DCommandBufferImpl
51 : public gpu_blink::WebGraphicsContext3DImpl { 52 : public gpu_blink::WebGraphicsContext3DImpl {
52 public: 53 public:
53 enum MappedMemoryReclaimLimit { 54 enum MappedMemoryReclaimLimit {
54 kNoLimit = 0, 55 kNoLimit = 0,
55 }; 56 };
56 57
57 struct CONTENT_EXPORT SharedMemoryLimits {
58 SharedMemoryLimits();
59
60 size_t command_buffer_size;
61 size_t start_transfer_buffer_size;
62 size_t min_transfer_buffer_size;
63 size_t max_transfer_buffer_size;
64 size_t mapped_memory_reclaim_limit;
65 };
66
67 class ShareGroup : public base::RefCountedThreadSafe<ShareGroup> { 58 class ShareGroup : public base::RefCountedThreadSafe<ShareGroup> {
68 public: 59 public:
69 ShareGroup(); 60 ShareGroup();
70 61
71 WebGraphicsContext3DCommandBufferImpl* GetAnyContextLocked() { 62 WebGraphicsContext3DCommandBufferImpl* GetAnyContextLocked() {
72 // In order to ensure that the context returned is not removed while 63 // In order to ensure that the context returned is not removed while
73 // in use, the share group's lock should be aquired before calling this 64 // in use, the share group's lock should be aquired before calling this
74 // function. 65 // function.
75 lock_.AssertAcquired(); 66 lock_.AssertAcquired();
76 if (contexts_.empty()) 67 if (contexts_.empty())
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 }; 100 };
110 101
111 CONTENT_EXPORT WebGraphicsContext3DCommandBufferImpl( 102 CONTENT_EXPORT WebGraphicsContext3DCommandBufferImpl(
112 gpu::SurfaceHandle surface_handle, 103 gpu::SurfaceHandle surface_handle,
113 const GURL& active_url, 104 const GURL& active_url,
114 gpu::GpuChannelHost* host, 105 gpu::GpuChannelHost* host,
115 const gpu::gles2::ContextCreationAttribHelper& attributes, 106 const gpu::gles2::ContextCreationAttribHelper& attributes,
116 gfx::GpuPreference gpu_preference, 107 gfx::GpuPreference gpu_preference,
117 bool share_resources, 108 bool share_resources,
118 bool automatic_flushes, 109 bool automatic_flushes,
119 const SharedMemoryLimits& limits,
120 WebGraphicsContext3DCommandBufferImpl* share_context); 110 WebGraphicsContext3DCommandBufferImpl* share_context);
121 111
122 ~WebGraphicsContext3DCommandBufferImpl() override; 112 ~WebGraphicsContext3DCommandBufferImpl() override;
123 113
124 gpu::CommandBufferProxyImpl* GetCommandBufferProxy() { 114 gpu::CommandBufferProxyImpl* GetCommandBufferProxy() {
125 return command_buffer_.get(); 115 return command_buffer_.get();
126 } 116 }
127 117
128 CONTENT_EXPORT gpu::ContextSupport* GetContextSupport(); 118 CONTENT_EXPORT gpu::ContextSupport* GetContextSupport();
129 119
130 gpu::gles2::GLES2Implementation* GetImplementation() { 120 gpu::gles2::GLES2Implementation* GetImplementation() {
131 return real_gl_.get(); 121 return real_gl_.get();
132 } 122 }
133 123
134 size_t GetMappedMemoryLimit() { 124 CONTENT_EXPORT bool InitializeOnCurrentThread(
135 return mem_limits_.mapped_memory_reclaim_limit; 125 const gpu::SharedMemoryLimits& memory_limits);
136 }
137
138 CONTENT_EXPORT bool InitializeOnCurrentThread();
139 126
140 void SetContextType(CommandBufferContextType type) { 127 void SetContextType(CommandBufferContextType type) {
141 context_type_ = type; 128 context_type_ = type;
142 } 129 }
143 private: 130 private:
144 // These are the same error codes as used by EGL. 131 // These are the same error codes as used by EGL.
145 enum Error { 132 enum Error {
146 SUCCESS = 0x3000, 133 SUCCESS = 0x3000,
147 BAD_ATTRIBUTE = 0x3004, 134 BAD_ATTRIBUTE = 0x3004,
148 CONTEXT_LOST = 0x300E 135 CONTEXT_LOST = 0x300E
149 }; 136 };
150 137
151 // Initialize the underlying GL context. May be called multiple times; second 138 // Initialize the underlying GL context. May be called multiple times; second
152 // and subsequent calls are ignored. Must be called from the thread that is 139 // and subsequent calls are ignored. Must be called from the thread that is
153 // going to use this object to issue GL commands (which might not be the main 140 // going to use this object to issue GL commands (which might not be the main
154 // thread). 141 // thread).
155 bool MaybeInitializeGL(); 142 bool MaybeInitializeGL(const gpu::SharedMemoryLimits& memory_limits);
156 143
157 bool InitializeCommandBuffer( 144 bool InitializeCommandBuffer(
158 WebGraphicsContext3DCommandBufferImpl* share_context); 145 WebGraphicsContext3DCommandBufferImpl* share_context);
159 146
160 void Destroy(); 147 void Destroy();
161 148
162 // Create a CommandBufferProxy that renders directly to a view. The view and 149 // Create a CommandBufferProxy that renders directly to a view. The view and
163 // the associated window must not be destroyed until the returned 150 // the associated window must not be destroyed until the returned
164 // CommandBufferProxy has been destroyed, otherwise the GPU process might 151 // CommandBufferProxy has been destroyed, otherwise the GPU process might
165 // attempt to render to an invalid window handle. 152 // attempt to render to an invalid window handle.
166 // 153 //
167 // NOTE: on Mac OS X, this entry point is only used to set up the 154 // NOTE: on Mac OS X, this entry point is only used to set up the
168 // accelerated compositor's output. On this platform, we actually pass 155 // accelerated compositor's output. On this platform, we actually pass
169 // a gpu::SurfaceHandle in place of the gfx::NativeViewId, 156 // a gpu::SurfaceHandle in place of the gfx::NativeViewId,
170 // because the facility to allocate a fake PluginWindowHandle is 157 // because the facility to allocate a fake PluginWindowHandle is
171 // already in place. We could add more entry points and messages to 158 // already in place. We could add more entry points and messages to
172 // allocate both fake PluginWindowHandles and NativeViewIds and map 159 // allocate both fake PluginWindowHandles and NativeViewIds and map
173 // from fake NativeViewIds to PluginWindowHandles, but this seems like 160 // from fake NativeViewIds to PluginWindowHandles, but this seems like
174 // unnecessary complexity at the moment. 161 // unnecessary complexity at the moment.
175 bool CreateContext(); 162 bool CreateContext(const gpu::SharedMemoryLimits& memory_limits);
176 163
177 void OnContextLost(); 164 void OnContextLost();
178 165
179 bool automatic_flushes_; 166 bool automatic_flushes_;
180 gpu::gles2::ContextCreationAttribHelper attributes_; 167 gpu::gles2::ContextCreationAttribHelper attributes_;
181 168
182 // State needed by MaybeInitializeGL. 169 // State needed by MaybeInitializeGL.
183 scoped_refptr<gpu::GpuChannelHost> host_; 170 scoped_refptr<gpu::GpuChannelHost> host_;
184 gpu::SurfaceHandle surface_handle_; 171 gpu::SurfaceHandle surface_handle_;
185 GURL active_url_; 172 GURL active_url_;
186 CommandBufferContextType context_type_; 173 CommandBufferContextType context_type_;
187 174
188 gfx::GpuPreference gpu_preference_; 175 gfx::GpuPreference gpu_preference_;
189 176
190 std::unique_ptr<gpu::CommandBufferProxyImpl> command_buffer_; 177 std::unique_ptr<gpu::CommandBufferProxyImpl> command_buffer_;
191 std::unique_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; 178 std::unique_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_;
192 std::unique_ptr<gpu::TransferBuffer> transfer_buffer_; 179 std::unique_ptr<gpu::TransferBuffer> transfer_buffer_;
193 std::unique_ptr<gpu::gles2::GLES2Implementation> real_gl_; 180 std::unique_ptr<gpu::gles2::GLES2Implementation> real_gl_;
194 std::unique_ptr<gpu::gles2::GLES2Interface> trace_gl_; 181 std::unique_ptr<gpu::gles2::GLES2Interface> trace_gl_;
195 SharedMemoryLimits mem_limits_;
196 scoped_refptr<ShareGroup> share_group_; 182 scoped_refptr<ShareGroup> share_group_;
197 183
198 // Member variables should appear before the WeakPtrFactory, to ensure 184 // Member variables should appear before the WeakPtrFactory, to ensure
199 // that any WeakPtrs to Controller are invalidated before its members 185 // that any WeakPtrs to Controller are invalidated before its members
200 // variable's destructors are executed, rendering them invalid. 186 // variable's destructors are executed, rendering them invalid.
201 base::WeakPtrFactory<WebGraphicsContext3DCommandBufferImpl> weak_ptr_factory_; 187 base::WeakPtrFactory<WebGraphicsContext3DCommandBufferImpl> weak_ptr_factory_;
202 }; 188 };
203 189
204 } // namespace content 190 } // namespace content
205 191
206 #endif // CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ 192 #endif // CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698