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

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 7529015: Allow the renderer process to map textures from one context into another. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/gles2_cmd_decoder.cc
===================================================================
--- gpu/command_buffer/service/gles2_cmd_decoder.cc (revision 94701)
+++ gpu/command_buffer/service/gles2_cmd_decoder.cc (working copy)
@@ -465,6 +465,10 @@
const char* allowed_extensions,
const std::vector<int32>& attribs);
virtual void Destroy();
+ virtual bool MapExternalResource(resource_type::ResourceType resource_type,
+ uint32 resource_source_id,
+ GLES2Decoder* source_decoder,
+ uint32 resource_dest_id);
virtual bool SetParent(GLES2Decoder* parent_decoder,
uint32 parent_texture_id);
virtual void ResizeOffscreenFrameBuffer(const gfx::Size& size);
@@ -588,6 +592,11 @@
return (info && !info->IsDeleted()) ? info : NULL;
}
+ // Adds the texture info for the given texture.
+ void AddTextureInfo(GLuint client_id, TextureManager::TextureInfo* info) {
+ texture_manager()->AddTextureInfo(feature_info_, client_id, info);
+ }
+
// Deletes the texture info for the given texture.
void RemoveTextureInfo(GLuint client_id) {
texture_manager()->RemoveTextureInfo(feature_info_, client_id);
@@ -2089,8 +2098,10 @@
if (info->IsAttachedToFramebuffer()) {
state_dirty_ = true;
}
- GLuint service_id = info->service_id();
- glDeleteTextures(1, &service_id);
+ if (info->owner() == group_->texture_manager()) {
+ GLuint service_id = info->service_id();
+ glDeleteTextures(1, &service_id);
+ }
RemoveTextureInfo(client_ids[ii]);
}
}
@@ -2470,6 +2481,37 @@
offscreen_saved_color_texture_.reset();
}
+bool GLES2DecoderImpl::MapExternalResource(
+ resource_type::ResourceType resource_type,
+ uint32 resource_source_id,
+ GLES2Decoder* source_decoder,
+ uint32 resource_dest_id) {
+ GLES2DecoderImpl* source_decoder_impl = static_cast<GLES2DecoderImpl*>(
+ source_decoder);
+
+ if (resource_type != resource_type::kTexture)
+ return false;
+
+ if (!source_decoder)
+ return false;
+
+ // The client should already have created the texture in the source context
+ // group and flushed.
+ TextureManager::TextureInfo* source_info =
+ source_decoder_impl->GetTextureInfo(resource_source_id);
+ if (!source_info)
+ return false;
+
+ // Delete or unmap any existing texture with this ID.
+ DeleteTexturesHelper(1, &resource_dest_id);
+
+ // Add the source texture info to this group's manager with the
+ // requested id.
+ AddTextureInfo(resource_dest_id, source_info);
+
+ return true;
+}
+
bool GLES2DecoderImpl::SetParent(GLES2Decoder* new_parent,
uint32 new_parent_texture_id) {
if (!offscreen_saved_color_texture_.get())
@@ -2502,8 +2544,8 @@
feature_info_, new_parent_texture_id);
TextureManager::TextureInfo* info =
- new_parent_impl->CreateTextureInfo(new_parent_texture_id, service_id);
- info->SetNotOwned();
+ new TextureManager::TextureInfo(service_id);
+ new_parent_impl->AddTextureInfo(new_parent_texture_id, info);
new_parent_impl->texture_manager()->SetInfoTarget(info, GL_TEXTURE_2D);
parent_ = new_parent_impl->AsWeakPtr();

Powered by Google App Engine
This is Rietveld 408576698