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

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

Issue 1864723003: Make lost context and error message callbacks on GpuControl go to client (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: errorcallback: blimp2 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 GLInProcessContext* share_context, 60 GLInProcessContext* share_context,
61 gfx::AcceleratedWidget window, 61 gfx::AcceleratedWidget window,
62 const gfx::Size& size, 62 const gfx::Size& size,
63 const gpu::gles2::ContextCreationAttribHelper& attribs, 63 const gpu::gles2::ContextCreationAttribHelper& attribs,
64 gfx::GpuPreference gpu_preference, 64 gfx::GpuPreference gpu_preference,
65 const scoped_refptr<InProcessCommandBuffer::Service>& service, 65 const scoped_refptr<InProcessCommandBuffer::Service>& service,
66 GpuMemoryBufferManager* gpu_memory_buffer_manager, 66 GpuMemoryBufferManager* gpu_memory_buffer_manager,
67 ImageFactory* image_factory); 67 ImageFactory* image_factory);
68 68
69 // GLInProcessContext implementation: 69 // GLInProcessContext implementation:
70 void SetContextLostCallback(const base::Closure& callback) override;
71 gles2::GLES2Implementation* GetImplementation() override; 70 gles2::GLES2Implementation* GetImplementation() override;
72 size_t GetMappedMemoryLimit() override; 71 size_t GetMappedMemoryLimit() override;
73 void SetLock(base::Lock* lock) override; 72 void SetLock(base::Lock* lock) override;
74 73
75 #if defined(OS_ANDROID) 74 #if defined(OS_ANDROID)
76 scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture( 75 scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture(
77 uint32_t stream_id) override; 76 uint32_t stream_id) override;
78 uint32_t CreateStreamTexture(uint32_t texture_id) override; 77 uint32_t CreateStreamTexture(uint32_t texture_id) override;
79 #endif 78 #endif
80 79
81 private: 80 private:
82 void Destroy(); 81 void Destroy();
83 void OnContextLost();
84 void OnSignalSyncPoint(const base::Closure& callback); 82 void OnSignalSyncPoint(const base::Closure& callback);
85 83
86 scoped_ptr<gles2::GLES2CmdHelper> gles2_helper_; 84 scoped_ptr<gles2::GLES2CmdHelper> gles2_helper_;
87 scoped_ptr<TransferBuffer> transfer_buffer_; 85 scoped_ptr<TransferBuffer> transfer_buffer_;
88 scoped_ptr<gles2::GLES2Implementation> gles2_implementation_; 86 scoped_ptr<gles2::GLES2Implementation> gles2_implementation_;
89 scoped_ptr<InProcessCommandBuffer> command_buffer_; 87 scoped_ptr<InProcessCommandBuffer> command_buffer_;
90 88
91 const GLInProcessContextSharedMemoryLimits mem_limits_; 89 const GLInProcessContextSharedMemoryLimits mem_limits_;
92 base::Closure context_lost_callback_;
93 90
94 DISALLOW_COPY_AND_ASSIGN(GLInProcessContextImpl); 91 DISALLOW_COPY_AND_ASSIGN(GLInProcessContextImpl);
95 }; 92 };
96 93
97 GLInProcessContextImpl::GLInProcessContextImpl( 94 GLInProcessContextImpl::GLInProcessContextImpl(
98 const GLInProcessContextSharedMemoryLimits& mem_limits) 95 const GLInProcessContextSharedMemoryLimits& mem_limits)
99 : mem_limits_(mem_limits) {} 96 : mem_limits_(mem_limits) {}
100 97
101 GLInProcessContextImpl::~GLInProcessContextImpl() { 98 GLInProcessContextImpl::~GLInProcessContextImpl() {
102 Destroy(); 99 Destroy();
103 } 100 }
104 101
105 gles2::GLES2Implementation* GLInProcessContextImpl::GetImplementation() { 102 gles2::GLES2Implementation* GLInProcessContextImpl::GetImplementation() {
106 return gles2_implementation_.get(); 103 return gles2_implementation_.get();
107 } 104 }
108 105
109 size_t GLInProcessContextImpl::GetMappedMemoryLimit() { 106 size_t GLInProcessContextImpl::GetMappedMemoryLimit() {
110 return mem_limits_.mapped_memory_reclaim_limit; 107 return mem_limits_.mapped_memory_reclaim_limit;
111 } 108 }
112 109
113 void GLInProcessContextImpl::SetLock(base::Lock* lock) { 110 void GLInProcessContextImpl::SetLock(base::Lock* lock) {
114 NOTREACHED(); 111 NOTREACHED();
115 } 112 }
116 113
117 void GLInProcessContextImpl::SetContextLostCallback(
118 const base::Closure& callback) {
119 context_lost_callback_ = callback;
120 }
121
122 void GLInProcessContextImpl::OnContextLost() {
123 if (!context_lost_callback_.is_null())
124 context_lost_callback_.Run();
125 }
126
127 bool GLInProcessContextImpl::Initialize( 114 bool GLInProcessContextImpl::Initialize(
128 scoped_refptr<gfx::GLSurface> surface, 115 scoped_refptr<gfx::GLSurface> surface,
129 bool is_offscreen, 116 bool is_offscreen,
130 GLInProcessContext* share_context, 117 GLInProcessContext* share_context,
131 gfx::AcceleratedWidget window, 118 gfx::AcceleratedWidget window,
132 const gfx::Size& size, 119 const gfx::Size& size,
133 const gles2::ContextCreationAttribHelper& attribs, 120 const gles2::ContextCreationAttribHelper& attribs,
134 gfx::GpuPreference gpu_preference, 121 gfx::GpuPreference gpu_preference,
135 const scoped_refptr<InProcessCommandBuffer::Service>& service, 122 const scoped_refptr<InProcessCommandBuffer::Service>& service,
136 GpuMemoryBufferManager* gpu_memory_buffer_manager, 123 GpuMemoryBufferManager* gpu_memory_buffer_manager,
137 ImageFactory* image_factory) { 124 ImageFactory* image_factory) {
138 DCHECK(size.width() >= 0 && size.height() >= 0); 125 DCHECK(size.width() >= 0 && size.height() >= 0);
139 126
140 std::vector<int32_t> attrib_vector; 127 std::vector<int32_t> attrib_vector;
141 attribs.Serialize(&attrib_vector); 128 attribs.Serialize(&attrib_vector);
142 129
143 base::Closure wrapped_callback =
144 base::Bind(&GLInProcessContextImpl::OnContextLost, AsWeakPtr());
145 command_buffer_.reset(new InProcessCommandBuffer(service)); 130 command_buffer_.reset(new InProcessCommandBuffer(service));
146 131
147 scoped_refptr<gles2::ShareGroup> share_group; 132 scoped_refptr<gles2::ShareGroup> share_group;
148 InProcessCommandBuffer* share_command_buffer = nullptr; 133 InProcessCommandBuffer* share_command_buffer = nullptr;
149 if (share_context) { 134 if (share_context) {
150 GLInProcessContextImpl* impl = 135 GLInProcessContextImpl* impl =
151 static_cast<GLInProcessContextImpl*>(share_context); 136 static_cast<GLInProcessContextImpl*>(share_context);
152 share_group = impl->gles2_implementation_->share_group(); 137 share_group = impl->gles2_implementation_->share_group();
153 share_command_buffer = impl->command_buffer_.get(); 138 share_command_buffer = impl->command_buffer_.get();
154 DCHECK(share_group); 139 DCHECK(share_group);
155 DCHECK(share_command_buffer); 140 DCHECK(share_command_buffer);
156 } 141 }
157 142
158 if (!command_buffer_->Initialize(surface, 143 if (!command_buffer_->Initialize(surface,
159 is_offscreen, 144 is_offscreen,
160 window, 145 window,
161 size, 146 size,
162 attrib_vector, 147 attrib_vector,
163 gpu_preference, 148 gpu_preference,
164 wrapped_callback,
165 share_command_buffer, 149 share_command_buffer,
166 gpu_memory_buffer_manager, 150 gpu_memory_buffer_manager,
167 image_factory)) { 151 image_factory)) {
168 DLOG(ERROR) << "Failed to initialize InProcessCommmandBuffer"; 152 DLOG(ERROR) << "Failed to initialize InProcessCommmandBuffer";
169 return false; 153 return false;
170 } 154 }
171 155
172 // Create the GLES2 helper, which writes the command buffer protocol. 156 // Create the GLES2 helper, which writes the command buffer protocol.
173 gles2_helper_.reset(new gles2::GLES2CmdHelper(command_buffer_.get())); 157 gles2_helper_.reset(new gles2::GLES2CmdHelper(command_buffer_.get()));
174 if (!gles2_helper_->Initialize(mem_limits_.command_buffer_size)) { 158 if (!gles2_helper_->Initialize(mem_limits_.command_buffer_size)) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 gpu_preference, 258 gpu_preference,
275 service, 259 service,
276 gpu_memory_buffer_manager, 260 gpu_memory_buffer_manager,
277 image_factory)) 261 image_factory))
278 return NULL; 262 return NULL;
279 263
280 return context.release(); 264 return context.release();
281 } 265 }
282 266
283 } // namespace gpu 267 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698