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

Side by Side Diff: content/renderer/gpu/renderer_gl_context.cc

Issue 7518016: Revert 94743 - Allow the renderer process to map textures from one context into another. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/renderer/gpu/renderer_gl_context.h" 5 #include "content/renderer/gpu/renderer_gl_context.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 attrib_list, 127 attrib_list,
128 active_url)) 128 active_url))
129 return NULL; 129 return NULL;
130 130
131 return context.release(); 131 return context.release();
132 #else 132 #else
133 return NULL; 133 return NULL;
134 #endif 134 #endif
135 } 135 }
136 136
137 bool RendererGLContext::MapExternalResource(
138 gpu::resource_type::ResourceType resource_type,
139 uint32 resource_source_id,
140 RendererGLContext* source_context,
141 uint32 resource_dest_id) {
142 if (!command_buffer_)
143 return false;
144
145 return command_buffer_->MapExternalResource(
146 resource_type,
147 resource_source_id,
148 source_context ? source_context->command_buffer_ : NULL,
149 resource_dest_id);
150 }
151
152 bool RendererGLContext::MapExternalResourceToParent(
153 gpu::resource_type::ResourceType resource_type,
154 uint32 resource_source_id,
155 uint32 resource_dest_id) {
156 if (!command_buffer_)
157 return false;
158
159 if (!parent_.get())
160 return false;
161
162 return parent_->MapExternalResource(
163 resource_type,
164 resource_source_id,
165 this,
166 resource_dest_id);
167 }
168
169 bool RendererGLContext::SetParent(RendererGLContext* new_parent) { 137 bool RendererGLContext::SetParent(RendererGLContext* new_parent) {
170 if (parent_.get() == new_parent) 138 if (parent_.get() == new_parent)
171 return true; 139 return true;
172 140
173 // Allocate a texture ID with respect to the parent and change the parent. 141 // Allocate a texture ID with respect to the parent and change the parent.
174 uint32 new_parent_texture_id = 0; 142 uint32 new_parent_texture_id = 0;
175 if (command_buffer_) { 143 if (command_buffer_) {
176 if (new_parent) { 144 if (new_parent) {
177 TRACE_EVENT0("gpu", "RendererGLContext::SetParent::flushParent"); 145 TRACE_EVENT0("gpu", "RendererGLContext::SetParent::flushParent");
178 // Flush any remaining commands in the parent context to make sure the 146 // Flush any remaining commands in the parent context to make sure the
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 command_buffer_->ResizeOffscreenFrameBuffer(size); 188 command_buffer_->ResizeOffscreenFrameBuffer(size);
221 size_ = size; 189 size_ = size;
222 } 190 }
223 } 191 }
224 192
225 uint32 RendererGLContext::GetParentTextureId() { 193 uint32 RendererGLContext::GetParentTextureId() {
226 return parent_texture_id_; 194 return parent_texture_id_;
227 } 195 }
228 196
229 uint32 RendererGLContext::CreateParentTexture(const gfx::Size& size) { 197 uint32 RendererGLContext::CreateParentTexture(const gfx::Size& size) {
198 // Allocate a texture ID with respect to the parent.
230 if (parent_.get()) { 199 if (parent_.get()) {
231 // Reserve a parent texture ID on the client side. 200 if (!MakeCurrent(parent_.get()))
232 uint32 parent_texture_id = 0; 201 return 0;
233 parent_->gles2_implementation_->GenTextures(1, &parent_texture_id); 202 uint32 texture_id = parent_->gles2_implementation_->MakeTextureId();
234 return parent_texture_id; 203 parent_->gles2_implementation_->BindTexture(GL_TEXTURE_2D, texture_id);
204 parent_->gles2_implementation_->TexParameteri(
205 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
206 parent_->gles2_implementation_->TexParameteri(
207 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
208 parent_->gles2_implementation_->TexParameteri(
209 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
210 parent_->gles2_implementation_->TexParameteri(
211 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
212
213 parent_->gles2_implementation_->TexImage2D(GL_TEXTURE_2D,
214 0, // mip level
215 GL_RGBA,
216 size.width(),
217 size.height(),
218 0, // border
219 GL_RGBA,
220 GL_UNSIGNED_BYTE,
221 NULL);
222 // Make sure that the parent texture's storage is allocated before we let
223 // the caller attempt to use it.
224 int32 token = parent_->gles2_helper_->InsertToken();
225 parent_->gles2_helper_->WaitForToken(token);
226 return texture_id;
235 } 227 }
236 return 0; 228 return 0;
237 } 229 }
238 230
239 void RendererGLContext::DeleteParentTexture(uint32 texture) { 231 void RendererGLContext::DeleteParentTexture(uint32 texture) {
240 if (parent_.get()) 232 if (parent_.get()) {
233 if (!MakeCurrent(parent_.get()))
234 return;
241 parent_->gles2_implementation_->DeleteTextures(1, &texture); 235 parent_->gles2_implementation_->DeleteTextures(1, &texture);
236 }
242 } 237 }
243 238
244 void RendererGLContext::SetSwapBuffersCallback(Callback0::Type* callback) { 239 void RendererGLContext::SetSwapBuffersCallback(Callback0::Type* callback) {
245 swap_buffers_callback_.reset(callback); 240 swap_buffers_callback_.reset(callback);
246 } 241 }
247 242
248 void RendererGLContext::SetContextLostCallback( 243 void RendererGLContext::SetContextLostCallback(
249 Callback1<ContextLostReason>::Type* callback) { 244 Callback1<ContextLostReason>::Type* callback) {
250 context_lost_callback_.reset(callback); 245 context_lost_callback_.reset(callback);
251 } 246 }
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 void RendererGLContext::OnContextLost() { 479 void RendererGLContext::OnContextLost() {
485 if (context_lost_callback_.get()) { 480 if (context_lost_callback_.get()) {
486 RendererGLContext::ContextLostReason reason = kUnknown; 481 RendererGLContext::ContextLostReason reason = kUnknown;
487 if (command_buffer_) { 482 if (command_buffer_) {
488 reason = ConvertReason( 483 reason = ConvertReason(
489 command_buffer_->GetLastState().context_lost_reason); 484 command_buffer_->GetLastState().context_lost_reason);
490 } 485 }
491 context_lost_callback_->Run(reason); 486 context_lost_callback_->Run(reason);
492 } 487 }
493 } 488 }
OLDNEW
« no previous file with comments | « content/renderer/gpu/renderer_gl_context.h ('k') | content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698