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

Side by Side Diff: gpu/command_buffer/client/gl_in_process_context.cc

Issue 1859703002: convert //gpu to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: undo part of clang-format 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 #include "gpu/command_buffer/client/gl_in_process_context.h" 5 #include "gpu/command_buffer/client/gl_in_process_context.h"
6 6
7 #include <GLES2/gl2.h>
7 #include <stddef.h> 8 #include <stddef.h>
8 #include <stdint.h> 9 #include <stdint.h>
9 10
11 #include <memory>
10 #include <set> 12 #include <set>
11 #include <utility> 13 #include <utility>
12 #include <vector> 14 #include <vector>
13
14 #include <GLES2/gl2.h>
no sievers 2016/04/05 19:02:40 nit: can you leave GLES2/gl2.h here right above wh
Mostyn Bramley-Moore 2016/04/05 21:35:30 Done.
15 #ifndef GL_GLEXT_PROTOTYPES 15 #ifndef GL_GLEXT_PROTOTYPES
16 #define GL_GLEXT_PROTOTYPES 1 16 #define GL_GLEXT_PROTOTYPES 1
17 #endif 17 #endif
18 #include <GLES2/gl2ext.h> 18 #include <GLES2/gl2ext.h>
19 #include <GLES2/gl2extchromium.h> 19 #include <GLES2/gl2extchromium.h>
20 20
21 #include "base/bind.h" 21 #include "base/bind.h"
22 #include "base/bind_helpers.h" 22 #include "base/bind_helpers.h"
23 #include "base/lazy_instance.h" 23 #include "base/lazy_instance.h"
24 #include "base/logging.h" 24 #include "base/logging.h"
25 #include "base/macros.h" 25 #include "base/macros.h"
26 #include "base/memory/scoped_ptr.h"
27 #include "base/memory/weak_ptr.h" 26 #include "base/memory/weak_ptr.h"
28 #include "base/message_loop/message_loop.h" 27 #include "base/message_loop/message_loop.h"
29 #include "gpu/command_buffer/client/gles2_cmd_helper.h" 28 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
30 #include "gpu/command_buffer/client/gles2_implementation.h" 29 #include "gpu/command_buffer/client/gles2_implementation.h"
31 #include "gpu/command_buffer/client/transfer_buffer.h" 30 #include "gpu/command_buffer/client/transfer_buffer.h"
32 #include "gpu/command_buffer/common/command_buffer.h" 31 #include "gpu/command_buffer/common/command_buffer.h"
33 #include "gpu/command_buffer/common/constants.h" 32 #include "gpu/command_buffer/common/constants.h"
34 #include "ui/gfx/geometry/size.h" 33 #include "ui/gfx/geometry/size.h"
35 #include "ui/gl/gl_image.h" 34 #include "ui/gl/gl_image.h"
36 35
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture( 76 scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture(
78 uint32_t stream_id) override; 77 uint32_t stream_id) override;
79 uint32_t CreateStreamTexture(uint32_t texture_id) override; 78 uint32_t CreateStreamTexture(uint32_t texture_id) override;
80 #endif 79 #endif
81 80
82 private: 81 private:
83 void Destroy(); 82 void Destroy();
84 void OnContextLost(); 83 void OnContextLost();
85 void OnSignalSyncPoint(const base::Closure& callback); 84 void OnSignalSyncPoint(const base::Closure& callback);
86 85
87 scoped_ptr<gles2::GLES2CmdHelper> gles2_helper_; 86 std::unique_ptr<gles2::GLES2CmdHelper> gles2_helper_;
88 scoped_ptr<TransferBuffer> transfer_buffer_; 87 std::unique_ptr<TransferBuffer> transfer_buffer_;
89 scoped_ptr<gles2::GLES2Implementation> gles2_implementation_; 88 std::unique_ptr<gles2::GLES2Implementation> gles2_implementation_;
90 scoped_ptr<InProcessCommandBuffer> command_buffer_; 89 std::unique_ptr<InProcessCommandBuffer> command_buffer_;
91 90
92 const GLInProcessContextSharedMemoryLimits mem_limits_; 91 const GLInProcessContextSharedMemoryLimits mem_limits_;
93 bool context_lost_; 92 bool context_lost_;
94 base::Closure context_lost_callback_; 93 base::Closure context_lost_callback_;
95 base::Lock* lock_; 94 base::Lock* lock_;
96 95
97 DISALLOW_COPY_AND_ASSIGN(GLInProcessContextImpl); 96 DISALLOW_COPY_AND_ASSIGN(GLInProcessContextImpl);
98 }; 97 };
99 98
100 base::LazyInstance<base::Lock> g_all_shared_contexts_lock = 99 base::LazyInstance<base::Lock> g_all_shared_contexts_lock =
(...skipping 26 matching lines...) Expand all
127 command_buffer_->SetLock(lock); 126 command_buffer_->SetLock(lock);
128 lock_ = lock; 127 lock_ = lock;
129 } 128 }
130 129
131 void GLInProcessContextImpl::SetContextLostCallback( 130 void GLInProcessContextImpl::SetContextLostCallback(
132 const base::Closure& callback) { 131 const base::Closure& callback) {
133 context_lost_callback_ = callback; 132 context_lost_callback_ = callback;
134 } 133 }
135 134
136 void GLInProcessContextImpl::OnContextLost() { 135 void GLInProcessContextImpl::OnContextLost() {
137 scoped_ptr<base::AutoLock> lock; 136 std::unique_ptr<base::AutoLock> lock;
138 if (lock_) 137 if (lock_)
139 lock.reset(new base::AutoLock(*lock_)); 138 lock.reset(new base::AutoLock(*lock_));
140 context_lost_ = true; 139 context_lost_ = true;
141 if (!context_lost_callback_.is_null()) { 140 if (!context_lost_callback_.is_null()) {
142 context_lost_callback_.Run(); 141 context_lost_callback_.Run();
143 } 142 }
144 } 143 }
145 144
146 bool GLInProcessContextImpl::Initialize( 145 bool GLInProcessContextImpl::Initialize(
147 scoped_refptr<gfx::GLSurface> surface, 146 scoped_refptr<gfx::GLSurface> surface,
(...skipping 10 matching lines...) Expand all
158 DCHECK(!use_global_share_group || !share_context); 157 DCHECK(!use_global_share_group || !share_context);
159 DCHECK(size.width() >= 0 && size.height() >= 0); 158 DCHECK(size.width() >= 0 && size.height() >= 0);
160 159
161 std::vector<int32_t> attrib_vector; 160 std::vector<int32_t> attrib_vector;
162 attribs.Serialize(&attrib_vector); 161 attribs.Serialize(&attrib_vector);
163 162
164 base::Closure wrapped_callback = 163 base::Closure wrapped_callback =
165 base::Bind(&GLInProcessContextImpl::OnContextLost, AsWeakPtr()); 164 base::Bind(&GLInProcessContextImpl::OnContextLost, AsWeakPtr());
166 command_buffer_.reset(new InProcessCommandBuffer(service)); 165 command_buffer_.reset(new InProcessCommandBuffer(service));
167 166
168 scoped_ptr<base::AutoLock> scoped_shared_context_lock; 167 std::unique_ptr<base::AutoLock> scoped_shared_context_lock;
169 scoped_refptr<gles2::ShareGroup> share_group; 168 scoped_refptr<gles2::ShareGroup> share_group;
170 InProcessCommandBuffer* share_command_buffer = NULL; 169 InProcessCommandBuffer* share_command_buffer = NULL;
171 if (use_global_share_group) { 170 if (use_global_share_group) {
172 scoped_shared_context_lock.reset( 171 scoped_shared_context_lock.reset(
173 new base::AutoLock(g_all_shared_contexts_lock.Get())); 172 new base::AutoLock(g_all_shared_contexts_lock.Get()));
174 for (std::set<GLInProcessContextImpl*>::const_iterator it = 173 for (std::set<GLInProcessContextImpl*>::const_iterator it =
175 g_all_shared_contexts.Get().begin(); 174 g_all_shared_contexts.Get().begin();
176 it != g_all_shared_contexts.Get().end(); 175 it != g_all_shared_contexts.Get().end();
177 it++) { 176 it++) {
178 const GLInProcessContextImpl* context = *it; 177 const GLInProcessContextImpl* context = *it;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 const GLInProcessContextSharedMemoryLimits& memory_limits, 300 const GLInProcessContextSharedMemoryLimits& memory_limits,
302 GpuMemoryBufferManager* gpu_memory_buffer_manager, 301 GpuMemoryBufferManager* gpu_memory_buffer_manager,
303 ImageFactory* image_factory) { 302 ImageFactory* image_factory) {
304 DCHECK(!use_global_share_group || !share_context); 303 DCHECK(!use_global_share_group || !share_context);
305 if (surface.get()) { 304 if (surface.get()) {
306 DCHECK_EQ(surface->IsOffscreen(), is_offscreen); 305 DCHECK_EQ(surface->IsOffscreen(), is_offscreen);
307 DCHECK(surface->GetSize() == size); 306 DCHECK(surface->GetSize() == size);
308 DCHECK_EQ(gfx::kNullAcceleratedWidget, window); 307 DCHECK_EQ(gfx::kNullAcceleratedWidget, window);
309 } 308 }
310 309
311 scoped_ptr<GLInProcessContextImpl> context( 310 std::unique_ptr<GLInProcessContextImpl> context(
312 new GLInProcessContextImpl(memory_limits)); 311 new GLInProcessContextImpl(memory_limits));
313 if (!context->Initialize(surface, 312 if (!context->Initialize(surface,
314 is_offscreen, 313 is_offscreen,
315 use_global_share_group, 314 use_global_share_group,
316 share_context, 315 share_context,
317 window, 316 window,
318 size, 317 size,
319 attribs, 318 attribs,
320 gpu_preference, 319 gpu_preference,
321 service, 320 service,
322 gpu_memory_buffer_manager, 321 gpu_memory_buffer_manager,
323 image_factory)) 322 image_factory))
324 return NULL; 323 return NULL;
325 324
326 return context.release(); 325 return context.release();
327 } 326 }
328 327
329 } // namespace gpu 328 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698