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

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

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

Powered by Google App Engine
This is Rietveld 408576698