diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-07 22:29:23 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-07 22:29:23 +0000 |
commit | a770f2a9d10b62be15bd6538baa4d140be6a3a44 (patch) | |
tree | 4371feaa96fc3e157ed13524e8741a80287419c9 | |
parent | 3c2f21e1612cca5e45ec9e2bf3e9c5cd49c4da1c (diff) | |
download | chromium_src-a770f2a9d10b62be15bd6538baa4d140be6a3a44.zip chromium_src-a770f2a9d10b62be15bd6538baa4d140be6a3a44.tar.gz chromium_src-a770f2a9d10b62be15bd6538baa4d140be6a3a44.tar.bz2 |
Remove unneeded WebGraphicsContext3D refs from content
This is mostly mechanical, the only difference is that in places that rely
on the content context support the code now downcasts the cc::ContextProvider
pointer instead of downcasing the blink::WebGraphicsContext3D pointer.
BUG=181120
Review URL: https://codereview.chromium.org/120043005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243410 0039d316-1c4b-4281-b951-d872f2087c98
9 files changed, 91 insertions, 78 deletions
diff --git a/content/browser/android/in_process/synchronous_compositor_output_surface.cc b/content/browser/android/in_process/synchronous_compositor_output_surface.cc index 2d37659..b7c150f 100644 --- a/content/browser/android/in_process/synchronous_compositor_output_surface.cc +++ b/content/browser/android/in_process/synchronous_compositor_output_surface.cc @@ -14,6 +14,7 @@ #include "content/browser/android/in_process/synchronous_compositor_impl.h" #include "content/public/browser/browser_thread.h" #include "gpu/command_buffer/client/gl_in_process_context.h" +#include "gpu/command_buffer/client/gles2_interface.h" #include "gpu/command_buffer/common/gpu_memory_allocation.h" #include "third_party/skia/include/core/SkBitmapDevice.h" #include "third_party/skia/include/core/SkCanvas.h" @@ -174,7 +175,7 @@ void SynchronousCompositorOutputSurface::SwapBuffers( DCHECK(CalledOnValidThread()); if (!ForcedDrawToSoftwareDevice()) { DCHECK(context_provider_); - context_provider_->Context3d()->shallowFlushCHROMIUM(); + context_provider_->ContextGL()->ShallowFlushCHROMIUM(); } SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); if (delegate) diff --git a/content/browser/aura/gpu_browser_compositor_output_surface.cc b/content/browser/aura/gpu_browser_compositor_output_surface.cc index 8e3c30c..8c37780 100644 --- a/content/browser/aura/gpu_browser_compositor_output_surface.cc +++ b/content/browser/aura/gpu_browser_compositor_output_surface.cc @@ -6,7 +6,8 @@ #include "cc/output/compositor_frame.h" #include "content/browser/aura/reflector_impl.h" -#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" +#include "content/common/gpu/client/context_provider_command_buffer.h" +#include "gpu/command_buffer/client/gles2_interface.h" namespace content { @@ -28,13 +29,12 @@ void GpuBrowserCompositorOutputSurface::SwapBuffers( cc::CompositorFrame* frame) { DCHECK(frame->gl_frame_data); - WebGraphicsContext3DCommandBufferImpl* command_buffer_context = - static_cast<WebGraphicsContext3DCommandBufferImpl*>( - context_provider_->Context3d()); + ContextProviderCommandBuffer* provider_command_buffer = + static_cast<ContextProviderCommandBuffer*>(context_provider_.get()); CommandBufferProxyImpl* command_buffer_proxy = - command_buffer_context->GetCommandBufferProxy(); + provider_command_buffer->GetCommandBufferProxy(); DCHECK(command_buffer_proxy); - context_provider_->Context3d()->shallowFlushCHROMIUM(); + context_provider_->ContextGL()->ShallowFlushCHROMIUM(); command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info); if (reflector_.get()) { diff --git a/content/browser/aura/gpu_process_transport_factory.cc b/content/browser/aura/gpu_process_transport_factory.cc index 38dc904..75896d3d 100644 --- a/content/browser/aura/gpu_process_transport_factory.cc +++ b/content/browser/aura/gpu_process_transport_factory.cc @@ -293,11 +293,11 @@ gfx::GLSurfaceHandle GpuProcessTransportFactory::CreateSharedSurfaceHandle() { SharedMainThreadContextProvider(); if (!provider.get()) return gfx::GLSurfaceHandle(); - typedef WebGraphicsContext3DCommandBufferImpl WGC3DCBI; - WGC3DCBI* context = static_cast<WGC3DCBI*>(provider->Context3d()); + ContextProviderCommandBuffer* provider_command_buffer = + static_cast<ContextProviderCommandBuffer*>(provider.get()); gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle( gfx::kNullPluginWindow, gfx::TEXTURE_TRANSPORT); - handle.parent_gpu_process_id = context->GetGPUProcessID(); + handle.parent_gpu_process_id = provider_command_buffer->GetGPUProcessID(); handle.parent_client_id = BrowserGpuChannelHostFactory::instance()->GetGpuChannelId(); return handle; @@ -349,7 +349,7 @@ uint32 GpuProcessTransportFactory::InsertSyncPoint() { SharedMainThreadContextProvider(); if (!provider.get()) return 0; - return provider->Context3d()->insertSyncPoint(); + return provider->ContextGL()->InsertSyncPointCHROMIUM(); } void GpuProcessTransportFactory::WaitSyncPoint(uint32 sync_point) { @@ -357,7 +357,7 @@ void GpuProcessTransportFactory::WaitSyncPoint(uint32 sync_point) { SharedMainThreadContextProvider(); if (!provider.get()) return; - provider->Context3d()->waitSyncPoint(sync_point); + provider->ContextGL()->WaitSyncPointCHROMIUM(sync_point); } void GpuProcessTransportFactory::AddObserver( diff --git a/content/browser/aura/no_transport_image_transport_factory.cc b/content/browser/aura/no_transport_image_transport_factory.cc index 7f68e02..ecb6571 100644 --- a/content/browser/aura/no_transport_image_transport_factory.cc +++ b/content/browser/aura/no_transport_image_transport_factory.cc @@ -6,7 +6,7 @@ #include "cc/output/context_provider.h" #include "content/common/gpu/client/gl_helper.h" -#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" +#include "gpu/command_buffer/client/gles2_interface.h" #include "ui/compositor/compositor.h" namespace content { @@ -19,7 +19,9 @@ class FakeTexture : public ui::Texture { float device_scale_factor) : ui::Texture(false, gfx::Size(), device_scale_factor), context_provider_(context_provider), - texture_(context_provider_->Context3d()->createTexture()) {} + texture_(0u) { + context_provider_->ContextGL()->GenTextures(1, &texture_); + } virtual unsigned int PrepareTexture() OVERRIDE { return texture_; } @@ -30,7 +32,7 @@ class FakeTexture : public ui::Texture { private: virtual ~FakeTexture() { - context_provider_->Context3d()->deleteTexture(texture_); + context_provider_->ContextGL()->DeleteTextures(1, &texture_); } scoped_refptr<cc::ContextProvider> context_provider_; diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc index 78b2398..7722ba1 100644 --- a/content/browser/renderer_host/compositor_impl_android.cc +++ b/content/browser/renderer_host/compositor_impl_android.cc @@ -35,6 +35,7 @@ #include "content/common/gpu/gpu_process_launch_causes.h" #include "content/public/browser/android/compositor_client.h" #include "content/public/common/content_switches.h" +#include "gpu/command_buffer/client/gles2_interface.h" #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" #include "third_party/khronos/GLES2/gl2.h" #include "third_party/khronos/GLES2/gl2ext.h" @@ -64,26 +65,25 @@ class DirectOutputSurface : public cc::OutputSurface { surface_size_ = size; } virtual void SwapBuffers(cc::CompositorFrame*) OVERRIDE { - context_provider_->Context3d()->shallowFlushCHROMIUM(); + context_provider_->ContextGL()->ShallowFlushCHROMIUM(); } }; // Used to override capabilities_.adjust_deadline_for_parent to false class OutputSurfaceWithoutParent : public cc::OutputSurface { public: - OutputSurfaceWithoutParent( - const scoped_refptr< - content::ContextProviderCommandBuffer>& context_provider) + OutputSurfaceWithoutParent(const scoped_refptr< + content::ContextProviderCommandBuffer>& context_provider) : cc::OutputSurface(context_provider) { capabilities_.adjust_deadline_for_parent = false; } virtual void SwapBuffers(cc::CompositorFrame* frame) OVERRIDE { - content::WebGraphicsContext3DCommandBufferImpl* command_buffer_context = - static_cast<content::WebGraphicsContext3DCommandBufferImpl*>( - context_provider_->Context3d()); + content::ContextProviderCommandBuffer* provider_command_buffer = + static_cast<content::ContextProviderCommandBuffer*>( + context_provider_.get()); content::CommandBufferProxyImpl* command_buffer_proxy = - command_buffer_context->GetCommandBufferProxy(); + provider_command_buffer->GetCommandBufferProxy(); DCHECK(command_buffer_proxy); command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info); diff --git a/content/common/gpu/client/context_provider_command_buffer.cc b/content/common/gpu/client/context_provider_command_buffer.cc index 359ba4d..d5e82a3 100644 --- a/content/common/gpu/client/context_provider_command_buffer.cc +++ b/content/common/gpu/client/context_provider_command_buffer.cc @@ -78,6 +78,15 @@ ContextProviderCommandBuffer::~ContextProviderCommandBuffer() { } } + +CommandBufferProxyImpl* ContextProviderCommandBuffer::GetCommandBufferProxy() { + return context3d_->GetCommandBufferProxy(); +} + +int ContextProviderCommandBuffer::GetGPUProcessID() { + return context3d_->GetGPUProcessID(); +} + bool ContextProviderCommandBuffer::BindToCurrentThread() { // This is called on the thread the context will be used. DCHECK(context_thread_checker_.CalledOnValidThread()); diff --git a/content/common/gpu/client/context_provider_command_buffer.h b/content/common/gpu/client/context_provider_command_buffer.h index 2f8e4f2..d61e05c 100644 --- a/content/common/gpu/client/context_provider_command_buffer.h +++ b/content/common/gpu/client/context_provider_command_buffer.h @@ -30,6 +30,15 @@ class CONTENT_EXPORT ContextProviderCommandBuffer scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, const std::string& debug_name); + CommandBufferProxyImpl* GetCommandBufferProxy(); + int GetGPUProcessID(); + + void set_leak_on_destroy() { + base::AutoLock lock(main_thread_lock_); + leak_on_destroy_ = true; + } + + // cc::ContextProvider implementation. virtual bool BindToCurrentThread() OVERRIDE; virtual WebGraphicsContext3DCommandBufferImpl* Context3d() OVERRIDE; virtual gpu::gles2::GLES2Interface* ContextGL() OVERRIDE; @@ -46,11 +55,6 @@ class CONTENT_EXPORT ContextProviderCommandBuffer const MemoryPolicyChangedCallback& memory_policy_changed_callback) OVERRIDE; - void set_leak_on_destroy() { - base::AutoLock lock(main_thread_lock_); - leak_on_destroy_ = true; - } - protected: ContextProviderCommandBuffer( scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, diff --git a/content/renderer/gpu/compositor_output_surface.cc b/content/renderer/gpu/compositor_output_surface.cc index 3889f46..d44bf6e 100644 --- a/content/renderer/gpu/compositor_output_surface.cc +++ b/content/renderer/gpu/compositor_output_surface.cc @@ -16,6 +16,7 @@ #include "content/common/view_messages.h" #include "content/public/common/content_switches.h" #include "content/renderer/render_thread_impl.h" +#include "gpu/command_buffer/client/gles2_interface.h" #include "ipc/ipc_forwarding_message_filter.h" #include "ipc/ipc_sync_channel.h" @@ -120,13 +121,12 @@ void CompositorOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { } if (frame->gl_frame_data) { - WebGraphicsContext3DCommandBufferImpl* command_buffer_context = - static_cast<WebGraphicsContext3DCommandBufferImpl*>( - context_provider_->Context3d()); + ContextProviderCommandBuffer* provider_command_buffer = + static_cast<ContextProviderCommandBuffer*>(context_provider_.get()); CommandBufferProxyImpl* command_buffer_proxy = - command_buffer_context->GetCommandBufferProxy(); + provider_command_buffer->GetCommandBufferProxy(); DCHECK(command_buffer_proxy); - context_provider_->Context3d()->shallowFlushCHROMIUM(); + context_provider_->ContextGL()->ShallowFlushCHROMIUM(); command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info); } diff --git a/content/renderer/gpu/mailbox_output_surface.cc b/content/renderer/gpu/mailbox_output_surface.cc index 09e1ec0..7031be6 100644 --- a/content/renderer/gpu/mailbox_output_surface.cc +++ b/content/renderer/gpu/mailbox_output_surface.cc @@ -9,7 +9,7 @@ #include "cc/output/compositor_frame_ack.h" #include "cc/output/gl_frame_data.h" #include "cc/resources/resource_provider.h" -#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" +#include "gpu/command_buffer/client/gles2_interface.h" #include "third_party/khronos/GLES2/gl2.h" #include "third_party/khronos/GLES2/gl2ext.h" @@ -17,6 +17,7 @@ using cc::CompositorFrame; using cc::GLFrameData; using cc::ResourceProvider; using gpu::Mailbox; +using gpu::gles2::GLES2Interface; namespace content { @@ -43,8 +44,8 @@ MailboxOutputSurface::~MailboxOutputSurface() { DiscardBackbuffer(); while (!pending_textures_.empty()) { if (pending_textures_.front().texture_id) { - context_provider_->Context3d()->deleteTexture( - pending_textures_.front().texture_id); + context_provider_->ContextGL()->DeleteTextures( + 1, &pending_textures_.front().texture_id); } pending_textures_.pop_front(); } @@ -53,7 +54,7 @@ MailboxOutputSurface::~MailboxOutputSurface() { void MailboxOutputSurface::EnsureBackbuffer() { is_backbuffer_discarded_ = false; - blink::WebGraphicsContext3D* context3d = context_provider_->Context3d(); + GLES2Interface* gl = context_provider_->ContextGL(); if (!current_backing_.texture_id) { // Find a texture of matching size to recycle. @@ -62,40 +63,34 @@ void MailboxOutputSurface::EnsureBackbuffer() { if (texture.size == surface_size_) { current_backing_ = texture; if (current_backing_.sync_point) - context3d->waitSyncPoint(current_backing_.sync_point); + gl->WaitSyncPointCHROMIUM(current_backing_.sync_point); returned_textures_.pop(); break; } - context3d->deleteTexture(texture.texture_id); + gl->DeleteTextures(1, &texture.texture_id); returned_textures_.pop(); } if (!current_backing_.texture_id) { - current_backing_.texture_id = context3d->createTexture(); + gl->GenTextures(1, ¤t_backing_.texture_id); current_backing_.size = surface_size_; - context3d->bindTexture(GL_TEXTURE_2D, current_backing_.texture_id); - context3d->texParameteri( - GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - context3d->texParameteri( - GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - context3d->texParameteri( - GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - context3d->texParameteri( - GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - context3d->texImage2D( - GL_TEXTURE_2D, - 0, - GLInternalFormat(format_), - surface_size_.width(), - surface_size_.height(), - 0, - GLDataFormat(format_), - GLDataType(format_), - NULL); - context3d->genMailboxCHROMIUM(current_backing_.mailbox.name); - context3d->produceTextureCHROMIUM( - GL_TEXTURE_2D, current_backing_.mailbox.name); + gl->BindTexture(GL_TEXTURE_2D, current_backing_.texture_id); + gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + gl->TexImage2D(GL_TEXTURE_2D, + 0, + GLInternalFormat(format_), + surface_size_.width(), + surface_size_.height(), + 0, + GLDataFormat(format_), + GLDataType(format_), + NULL); + gl->GenMailboxCHROMIUM(current_backing_.mailbox.name); + gl->ProduceTextureCHROMIUM(GL_TEXTURE_2D, current_backing_.mailbox.name); } } } @@ -103,22 +98,22 @@ void MailboxOutputSurface::EnsureBackbuffer() { void MailboxOutputSurface::DiscardBackbuffer() { is_backbuffer_discarded_ = true; - blink::WebGraphicsContext3D* context3d = context_provider_->Context3d(); + GLES2Interface* gl = context_provider_->ContextGL(); if (current_backing_.texture_id) { - context3d->deleteTexture(current_backing_.texture_id); + gl->DeleteTextures(1, ¤t_backing_.texture_id); current_backing_ = TransferableFrame(); } while (!returned_textures_.empty()) { const TransferableFrame& frame = returned_textures_.front(); - context3d->deleteTexture(frame.texture_id); + gl->DeleteTextures(1, &frame.texture_id); returned_textures_.pop(); } if (fbo_) { - context3d->bindFramebuffer(GL_FRAMEBUFFER, fbo_); - context3d->deleteFramebuffer(fbo_); + gl->BindFramebuffer(GL_FRAMEBUFFER, fbo_); + gl->DeleteFramebuffers(1, &fbo_); fbo_ = 0; } } @@ -137,14 +132,16 @@ void MailboxOutputSurface::BindFramebuffer() { EnsureBackbuffer(); DCHECK(current_backing_.texture_id); - blink::WebGraphicsContext3D* context3d = context_provider_->Context3d(); + GLES2Interface* gl = context_provider_->ContextGL(); if (!fbo_) - fbo_ = context3d->createFramebuffer(); - context3d->bindFramebuffer(GL_FRAMEBUFFER, fbo_); - context3d->framebufferTexture2D( - GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, - current_backing_.texture_id, 0); + gl->GenFramebuffers(1, &fbo_); + gl->BindFramebuffer(GL_FRAMEBUFFER, fbo_); + gl->FramebufferTexture2D(GL_FRAMEBUFFER, + GL_COLOR_ATTACHMENT0, + GL_TEXTURE_2D, + current_backing_.texture_id, + 0); } void MailboxOutputSurface::OnSwapAck(uint32 output_surface_id, @@ -175,7 +172,7 @@ void MailboxOutputSurface::OnSwapAck(uint32 output_surface_id, if (!is_backbuffer_discarded_) { returned_textures_.push(*it); } else { - context_provider_->Context3d()->deleteTexture(it->texture_id); + context_provider_->ContextGL()->DeleteTextures(1, &it->texture_id); } pending_textures_.erase(it); @@ -186,7 +183,7 @@ void MailboxOutputSurface::OnSwapAck(uint32 output_surface_id, // the oldest texture we sent. uint32 texture_id = pending_textures_.front().texture_id; if (texture_id) - context_provider_->Context3d()->deleteTexture(texture_id); + context_provider_->ContextGL()->DeleteTextures(1, &texture_id); pending_textures_.pop_front(); } CompositorOutputSurface::OnSwapAck(output_surface_id, ack); @@ -198,12 +195,12 @@ void MailboxOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { DCHECK(surface_size_ == current_backing_.size); DCHECK(frame->gl_frame_data->size == current_backing_.size); DCHECK(!current_backing_.mailbox.IsZero() || - context_provider_->Context3d()->isContextLost()); + context_provider_->IsContextLost()); frame->gl_frame_data->mailbox = current_backing_.mailbox; - context_provider_->Context3d()->flush(); + context_provider_->ContextGL()->Flush(); frame->gl_frame_data->sync_point = - context_provider_->Context3d()->insertSyncPoint(); + context_provider_->ContextGL()->InsertSyncPointCHROMIUM(); CompositorOutputSurface::SwapBuffers(frame); pending_textures_.push_back(current_backing_); |