diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-29 22:31:45 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-29 22:31:45 +0000 |
commit | 80cf42e4ec43bbbf6846eca720fe5bc348358d1f (patch) | |
tree | 8a04fb54f8ae09c4531bb8cbdfee85a3d1d8cf4e /webkit/gpu | |
parent | d271e216f18485d8e1dc0615b15c98ce04817fb1 (diff) | |
download | chromium_src-80cf42e4ec43bbbf6846eca720fe5bc348358d1f.zip chromium_src-80cf42e4ec43bbbf6846eca720fe5bc348358d1f.tar.gz chromium_src-80cf42e4ec43bbbf6846eca720fe5bc348358d1f.tar.bz2 |
Implemented MapExternalResource for DumpRenderTree.
This will allow me to delete GL_copy_texture_to_parent_texture from the GPU process.
Review URL: http://codereview.chromium.org/7518005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94775 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/gpu')
-rw-r--r-- | webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc index c046bc3..937fdb7 100644 --- a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc +++ b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc @@ -122,6 +122,34 @@ class GLInProcessContext : public base::SupportsWeakPtr<GLInProcessContext> { const int32* attrib_list, const GURL& active_url); + // Map a resource from an external context into this context. The source + // context need not be in the same share group from the client's point of + // view, allowing safe sharing between an "untrusted" context, like Pepper + // and a compositor context. + // + // Currently only texture resources are supported. TODO(apatrick): generalize + // this as appropriate. + // + // To unmap a previously mapped external resource, delete it in the + // destination context group. This will not delete the underlying texture + // object, just disassociate it with the id in the destination context group. + // + // The lifetime of the external resource is managed by the context group it + // was originally created in. When the last context in that group is destroyed + // the resource becomes invalid in all other context groups it is mapped into. + bool MapExternalResource(::gpu::resource_type::ResourceType resource_type, + uint32 resource_source_id, + GLInProcessContext* source_context, + uint32 resource_dest_id); + + // TODO(apatrick): this is a workaround until the parent / child relationship + // between contexts is removed. MapExternalResource has no such restrictions + // on the relationship between contexts. Use it instead. + bool MapExternalResourceToParent( + ::gpu::resource_type::ResourceType resource_type, + uint32 resource_source_id, + uint32 resource_dest_id); + // Resize an offscreen frame buffer. The resize occurs on the next call to // SwapBuffers. This is to avoid waiting until all pending GL calls have been // executed by the GPU process. Everything rendered up to the call to @@ -286,6 +314,38 @@ GLInProcessContext* GLInProcessContext::CreateOffscreenContext( #endif } +bool GLInProcessContext::MapExternalResource( + ::gpu::resource_type::ResourceType resource_type, + uint32 resource_source_id, + GLInProcessContext* source_context, + uint32 resource_dest_id) { + if (!command_buffer_.get()) + return false; + + return gpu_scheduler_->MapExternalResource( + resource_type, + resource_source_id, + source_context->gpu_scheduler_, + resource_dest_id); +} + +bool GLInProcessContext::MapExternalResourceToParent( + ::gpu::resource_type::ResourceType resource_type, + uint32 resource_source_id, + uint32 resource_dest_id) { + if (!command_buffer_.get()) + return false; + + if (!parent_.get()) + return false; + + return parent_->MapExternalResource( + resource_type, + resource_source_id, + this, + resource_dest_id); +} + void GLInProcessContext::ResizeOffscreen(const gfx::Size& size) { DCHECK(size.width() > 0 && size.height() > 0); if (size_ != size) { @@ -1597,8 +1657,10 @@ void WebGraphicsContext3DInProcessCommandBufferImpl::copyTextureToCompositor( WebGLId texture, WebGLId parentTexture) { // TODO(gmam): See if we can comment this in. // ClearContext(); - gl_->CopyTextureToParentTextureCHROMIUM(texture, parentTexture); gl_->Flush(); + context_->MapExternalResourceToParent(::gpu::resource_type::kTexture, + texture, + parentTexture); } void WebGraphicsContext3DInProcessCommandBufferImpl::OnSwapBuffersComplete() { |