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

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

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 const gpu::gles2::ContextCreationAttribHelper& attribs, 59 const gpu::gles2::ContextCreationAttribHelper& attribs,
60 gfx::GpuPreference gpu_preference, 60 gfx::GpuPreference gpu_preference,
61 const scoped_refptr<InProcessCommandBuffer::Service>& service, 61 const scoped_refptr<InProcessCommandBuffer::Service>& service,
62 GpuMemoryBufferManager* gpu_memory_buffer_manager, 62 GpuMemoryBufferManager* gpu_memory_buffer_manager,
63 ImageFactory* image_factory); 63 ImageFactory* image_factory);
64 64
65 // GLInProcessContext implementation: 65 // GLInProcessContext implementation:
66 void SetContextLostCallback(const base::Closure& callback) override; 66 void SetContextLostCallback(const base::Closure& callback) override;
67 gles2::GLES2Implementation* GetImplementation() override; 67 gles2::GLES2Implementation* GetImplementation() override;
68 size_t GetMappedMemoryLimit() override; 68 size_t GetMappedMemoryLimit() override;
69 void SetLock(base::Lock* lock) override;
69 70
70 #if defined(OS_ANDROID) 71 #if defined(OS_ANDROID)
71 scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture( 72 scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture(
72 uint32 stream_id) override; 73 uint32 stream_id) override;
73 #endif 74 #endif
74 75
75 private: 76 private:
76 void Destroy(); 77 void Destroy();
77 void OnContextLost(); 78 void OnContextLost();
78 void OnSignalSyncPoint(const base::Closure& callback); 79 void OnSignalSyncPoint(const base::Closure& callback);
79 80
80 scoped_ptr<gles2::GLES2CmdHelper> gles2_helper_; 81 scoped_ptr<gles2::GLES2CmdHelper> gles2_helper_;
81 scoped_ptr<TransferBuffer> transfer_buffer_; 82 scoped_ptr<TransferBuffer> transfer_buffer_;
82 scoped_ptr<gles2::GLES2Implementation> gles2_implementation_; 83 scoped_ptr<gles2::GLES2Implementation> gles2_implementation_;
83 scoped_ptr<InProcessCommandBuffer> command_buffer_; 84 scoped_ptr<InProcessCommandBuffer> command_buffer_;
84 85
85 const GLInProcessContextSharedMemoryLimits mem_limits_; 86 const GLInProcessContextSharedMemoryLimits mem_limits_;
86 bool context_lost_; 87 bool context_lost_;
87 base::Closure context_lost_callback_; 88 base::Closure context_lost_callback_;
89 base::Lock* lock_;
88 90
89 DISALLOW_COPY_AND_ASSIGN(GLInProcessContextImpl); 91 DISALLOW_COPY_AND_ASSIGN(GLInProcessContextImpl);
90 }; 92 };
91 93
92 base::LazyInstance<base::Lock> g_all_shared_contexts_lock = 94 base::LazyInstance<base::Lock> g_all_shared_contexts_lock =
93 LAZY_INSTANCE_INITIALIZER; 95 LAZY_INSTANCE_INITIALIZER;
94 base::LazyInstance<std::set<GLInProcessContextImpl*> > g_all_shared_contexts = 96 base::LazyInstance<std::set<GLInProcessContextImpl*> > g_all_shared_contexts =
95 LAZY_INSTANCE_INITIALIZER; 97 LAZY_INSTANCE_INITIALIZER;
96 98
97 GLInProcessContextImpl::GLInProcessContextImpl( 99 GLInProcessContextImpl::GLInProcessContextImpl(
98 const GLInProcessContextSharedMemoryLimits& mem_limits) 100 const GLInProcessContextSharedMemoryLimits& mem_limits)
99 : mem_limits_(mem_limits), context_lost_(false) { 101 : mem_limits_(mem_limits), context_lost_(false), lock_(nullptr) {
100 } 102 }
101 103
102 GLInProcessContextImpl::~GLInProcessContextImpl() { 104 GLInProcessContextImpl::~GLInProcessContextImpl() {
103 { 105 {
104 base::AutoLock lock(g_all_shared_contexts_lock.Get()); 106 base::AutoLock lock(g_all_shared_contexts_lock.Get());
105 g_all_shared_contexts.Get().erase(this); 107 g_all_shared_contexts.Get().erase(this);
106 } 108 }
107 Destroy(); 109 Destroy();
108 } 110 }
109 111
110 gles2::GLES2Implementation* GLInProcessContextImpl::GetImplementation() { 112 gles2::GLES2Implementation* GLInProcessContextImpl::GetImplementation() {
111 return gles2_implementation_.get(); 113 return gles2_implementation_.get();
112 } 114 }
113 115
114 size_t GLInProcessContextImpl::GetMappedMemoryLimit() { 116 size_t GLInProcessContextImpl::GetMappedMemoryLimit() {
115 return mem_limits_.mapped_memory_reclaim_limit; 117 return mem_limits_.mapped_memory_reclaim_limit;
116 } 118 }
117 119
120 void GLInProcessContextImpl::SetLock(base::Lock* lock) {
121 command_buffer_->SetLock(lock);
122 lock_ = lock;
123 }
124
118 void GLInProcessContextImpl::SetContextLostCallback( 125 void GLInProcessContextImpl::SetContextLostCallback(
119 const base::Closure& callback) { 126 const base::Closure& callback) {
120 context_lost_callback_ = callback; 127 context_lost_callback_ = callback;
121 } 128 }
122 129
123 void GLInProcessContextImpl::OnContextLost() { 130 void GLInProcessContextImpl::OnContextLost() {
131 scoped_ptr<base::AutoLock> lock;
132 if (lock_)
133 lock.reset(new base::AutoLock(*lock_));
124 context_lost_ = true; 134 context_lost_ = true;
125 if (!context_lost_callback_.is_null()) { 135 if (!context_lost_callback_.is_null()) {
126 context_lost_callback_.Run(); 136 context_lost_callback_.Run();
127 } 137 }
128 } 138 }
129 139
130 bool GLInProcessContextImpl::Initialize( 140 bool GLInProcessContextImpl::Initialize(
131 scoped_refptr<gfx::GLSurface> surface, 141 scoped_refptr<gfx::GLSurface> surface,
132 bool is_offscreen, 142 bool is_offscreen,
133 bool use_global_share_group, 143 bool use_global_share_group,
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 gpu_preference, 310 gpu_preference,
301 service, 311 service,
302 gpu_memory_buffer_manager, 312 gpu_memory_buffer_manager,
303 image_factory)) 313 image_factory))
304 return NULL; 314 return NULL;
305 315
306 return context.release(); 316 return context.release();
307 } 317 }
308 318
309 } // namespace gpu 319 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gl_in_process_context.h ('k') | gpu/command_buffer/client/gles2_c_lib_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698