diff options
Diffstat (limited to 'content')
-rw-r--r-- | content/common/gpu/gpu_command_buffer_stub.cc | 158 | ||||
-rw-r--r-- | content/common/gpu/gpu_command_buffer_stub.h | 8 | ||||
-rw-r--r-- | content/renderer/gpu/command_buffer_proxy.cc | 16 | ||||
-rw-r--r-- | content/renderer/gpu/command_buffer_proxy.h | 7 | ||||
-rw-r--r-- | content/renderer/gpu/renderer_gl_context.cc | 18 | ||||
-rw-r--r-- | content/renderer/gpu/renderer_gl_context.h | 15 | ||||
-rw-r--r-- | content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc | 12 | ||||
-rw-r--r-- | content/renderer/render_widget_fullscreen_pepper.cc | 4 |
8 files changed, 72 insertions, 166 deletions
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc index 047cfa7..6076eba 100644 --- a/content/common/gpu/gpu_command_buffer_stub.cc +++ b/content/common/gpu/gpu_command_buffer_stub.cc @@ -99,11 +99,6 @@ bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { OnCreateVideoDecoder) IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyVideoDecoder, OnDestroyVideoDecoder) - IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ResizeOffscreenFrameBuffer, - OnResizeOffscreenFrameBuffer); -#if defined(OS_MACOSX) - IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetWindowSize, OnSetWindowSize); -#endif // defined(OS_MACOSX) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -200,38 +195,18 @@ void GpuCommandBufferStub::OnInitialize( &gpu::GpuScheduler::PutChanged)); command_buffer_->SetParseErrorCallback( NewCallback(this, &GpuCommandBufferStub::OnParseError)); - scheduler_->SetSwapBuffersCallback( - NewCallback(this, &GpuCommandBufferStub::OnSwapBuffers)); scheduler_->SetScheduledCallback( NewCallback(channel_, &GpuChannel::OnScheduled)); + scheduler_->SetSwapBuffersCallback( + NewCallback(this, &GpuCommandBufferStub::OnSwapBuffers)); + if (handle_ != gfx::kNullPluginWindow) { + scheduler_->SetResizeCallback( + NewCallback(this, &GpuCommandBufferStub::OnResize)); + } if (watchdog_) scheduler_->SetCommandProcessedCallback( NewCallback(this, &GpuCommandBufferStub::OnCommandProcessed)); -#if defined(OS_MACOSX) - if (handle_) { - // This context conceptually puts its output directly on the - // screen, rendered by the accelerated plugin layer in - // RenderWidgetHostViewMac. Set up a pathway to notify the - // browser process when its contents change. - scheduler_->SetSwapBuffersCallback( - NewCallback(this, - &GpuCommandBufferStub::SwapBuffersCallback)); - } -#endif // defined(OS_MACOSX) - - // Set up a pathway for resizing the output window or framebuffer at the - // right time relative to other GL commands. -#if defined(TOUCH_UI) - if (handle_ == gfx::kNullPluginWindow) { - scheduler_->SetResizeCallback( - NewCallback(this, &GpuCommandBufferStub::ResizeCallback)); - } -#else - scheduler_->SetResizeCallback( - NewCallback(this, &GpuCommandBufferStub::ResizeCallback)); -#endif - if (parent_stub_for_initialization_) { scheduler_->SetParent(parent_stub_for_initialization_->scheduler_.get(), parent_texture_for_initialization_); @@ -427,99 +402,106 @@ void GpuCommandBufferStub::OnGetTransferBuffer( Send(reply_message); } -void GpuCommandBufferStub::OnResizeOffscreenFrameBuffer(const gfx::Size& size) { - scheduler_->ResizeOffscreenFrameBuffer(size); -} - void GpuCommandBufferStub::OnSwapBuffers() { TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnSwapBuffers"); ReportState(); - Send(new GpuCommandBufferMsg_SwapBuffers(route_id_)); -} - -void GpuCommandBufferStub::OnCommandProcessed() { - if (watchdog_) - watchdog_->CheckArmed(); -} #if defined(OS_MACOSX) -void GpuCommandBufferStub::OnSetWindowSize(const gfx::Size& size) { - GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); - // Try using the IOSurface version first. - uint64 new_backing_store = scheduler_->SetWindowSizeForIOSurface(size); - if (new_backing_store) { - GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params params; + if (handle_) { + // To swap on OSX, we have to send a message to the browser to get the + // context put onscreen. + GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); + GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; params.renderer_id = renderer_id_; params.render_view_id = render_view_id_; params.window = handle_; - params.width = size.width(); - params.height = size.height(); - params.identifier = new_backing_store; + params.surface_id = scheduler_->GetSurfaceId(); + params.route_id = route_id(); + params.swap_buffers_count = scheduler_->swap_buffers_count(); gpu_channel_manager->Send( - new GpuHostMsg_AcceleratedSurfaceSetIOSurface(params)); - } else { - // TODO(kbr): figure out what to do here. It wouldn't be difficult - // to support the compositor on 10.5, but the performance would be - // questionable. - NOTREACHED(); + new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); + scheduler_->SetScheduled(false); } +#else + // Notify the upstream commandbuffer that the swapbuffers has completed. + Send(new GpuCommandBufferMsg_SwapBuffers(route_id_)); +#endif } -void GpuCommandBufferStub::SwapBuffersCallback() { - TRACE_EVENT0("gpu", "GpuCommandBufferStub::SwapBuffersCallback"); - GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); - GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; - params.renderer_id = renderer_id_; - params.render_view_id = render_view_id_; - params.window = handle_; - params.surface_id = scheduler_->GetSurfaceId(); - params.route_id = route_id(); - params.swap_buffers_count = scheduler_->swap_buffers_count(); - gpu_channel_manager->Send( - new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); - - scheduler_->SetScheduled(false); +void GpuCommandBufferStub::OnCommandProcessed() { + if (watchdog_) + watchdog_->CheckArmed(); } +#if defined(OS_MACOSX) void GpuCommandBufferStub::AcceleratedSurfaceBuffersSwapped( uint64 swap_buffers_count) { TRACE_EVENT1("gpu", "GpuCommandBufferStub::AcceleratedSurfaceBuffersSwapped", "frame", swap_buffers_count); + DCHECK(handle_ != gfx::kNullPluginWindow); // Multiple swapbuffers may get consolidated together into a single - // AcceleratedSurfaceBuffersSwapped call. Since OnSwapBuffers expects to be - // called one time for every swap, make up the difference here. + // AcceleratedSurfaceBuffersSwapped call. Upstream code listening to the + // GpuCommandBufferMsg_SwapBuffers expects to be called one time for every + // swap. So, send one SwapBuffers message for every outstanding swap. uint64 delta = swap_buffers_count - scheduler_->acknowledged_swap_buffers_count(); scheduler_->set_acknowledged_swap_buffers_count(swap_buffers_count); for(uint64 i = 0; i < delta; i++) { - OnSwapBuffers(); + // Notify the upstream commandbuffer that the swapbuffers has completed. + Send(new GpuCommandBufferMsg_SwapBuffers(route_id_)); + // Wake up the GpuScheduler to start doing work again. scheduler_->SetScheduled(true); } } #endif // defined(OS_MACOSX) -void GpuCommandBufferStub::ResizeCallback(gfx::Size size) { - if (handle_ == gfx::kNullPluginWindow) { - scheduler_->decoder()->ResizeOffscreenFrameBuffer(size); - scheduler_->decoder()->UpdateOffscreenFrameBufferSize(); - } else { -#if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN) - GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); - gpu_channel_manager->Send( - new GpuHostMsg_ResizeView(renderer_id_, - render_view_id_, - route_id_, - size)); +void GpuCommandBufferStub::OnResize(gfx::Size size) { + if (handle_ == gfx::kNullPluginWindow) + return; - scheduler_->SetScheduled(false); -#endif + GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); + +#if defined(OS_MACOSX) + // On Mac, we need to tell the browser about the new IOSurface handle, + // asynchronously. + uint64 new_backing_store = scheduler_->SetWindowSizeForIOSurface(size); + if (new_backing_store) { + GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params params; + params.renderer_id = renderer_id_; + params.render_view_id = render_view_id_; + params.window = handle_; + params.width = size.width(); + params.height = size.height(); + params.identifier = new_backing_store; + gpu_channel_manager->Send( + new GpuHostMsg_AcceleratedSurfaceSetIOSurface(params)); + } else { + // TODO(kbr): figure out what to do here. It wouldn't be difficult + // to support the compositor on 10.5, but the performance would be + // questionable. + NOTREACHED(); } +#elif defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN) + // On Windows, Linux, we need to coordinate resizing of onscreen + // contexts with the resizing of the actual OS-level window. We do this by + // sending a resize message to the browser process and descheduling the + // context until the ViewResized message comes back in reply. + // Send the resize message if needed + gpu_channel_manager->Send( + new GpuHostMsg_ResizeView(renderer_id_, + render_view_id_, + route_id_, + size)); + + scheduler_->SetScheduled(false); +#endif // defined(OS_MACOSX) } + void GpuCommandBufferStub::ViewResized() { #if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN) DCHECK(handle_ != gfx::kNullPluginWindow); diff --git a/content/common/gpu/gpu_command_buffer_stub.h b/content/common/gpu/gpu_command_buffer_stub.h index 9ea9bdb..ef2dabb 100644 --- a/content/common/gpu/gpu_command_buffer_stub.h +++ b/content/common/gpu/gpu_command_buffer_stub.h @@ -112,7 +112,6 @@ class GpuCommandBufferStub IPC::Message* reply_message); void OnDestroyTransferBuffer(int32 id, IPC::Message* reply_message); void OnGetTransferBuffer(int32 id, IPC::Message* reply_message); - void OnResizeOffscreenFrameBuffer(const gfx::Size& size); void OnCreateVideoDecoder(const std::vector<int32>& configs, IPC::Message* reply_message); @@ -122,12 +121,7 @@ class GpuCommandBufferStub void OnCommandProcessed(); void OnParseError(); -#if defined(OS_MACOSX) - void OnSetWindowSize(const gfx::Size& size); - void SwapBuffersCallback(); -#endif // defined(OS_MACOSX) - - void ResizeCallback(gfx::Size size); + void OnResize(gfx::Size size); void ReportState(); // The lifetime of objects of this class is managed by a GpuChannel. The diff --git a/content/renderer/gpu/command_buffer_proxy.cc b/content/renderer/gpu/command_buffer_proxy.cc index caa1de5..1caeb5a 100644 --- a/content/renderer/gpu/command_buffer_proxy.cc +++ b/content/renderer/gpu/command_buffer_proxy.cc @@ -380,13 +380,6 @@ void CommandBufferProxy::SetSwapBuffersCallback(Callback0::Type* callback) { swap_buffers_callback_.reset(callback); } -void CommandBufferProxy::ResizeOffscreenFrameBuffer(const gfx::Size& size) { - if (last_state_.error != gpu::error::kNoError) - return; - - Send(new GpuCommandBufferMsg_ResizeOffscreenFrameBuffer(route_id_, size)); -} - void CommandBufferProxy::SetNotifyRepaintTask(Task* task) { notify_repaint_task_.reset(task); } @@ -413,15 +406,6 @@ CommandBufferProxy::CreateVideoDecoder( return decoder_host; } -#if defined(OS_MACOSX) -void CommandBufferProxy::SetWindowSize(const gfx::Size& size) { - if (last_state_.error != gpu::error::kNoError) - return; - - Send(new GpuCommandBufferMsg_SetWindowSize(route_id_, size)); -} -#endif - bool CommandBufferProxy::Send(IPC::Message* msg) { // Caller should not intentionally send a message if the context is lost. DCHECK(last_state_.error == gpu::error::kNoError); diff --git a/content/renderer/gpu/command_buffer_proxy.h b/content/renderer/gpu/command_buffer_proxy.h index 2a2e25b..8c62508 100644 --- a/content/renderer/gpu/command_buffer_proxy.h +++ b/content/renderer/gpu/command_buffer_proxy.h @@ -77,9 +77,6 @@ class CommandBufferProxy : public gpu::CommandBuffer, void SetSwapBuffersCallback(Callback0::Type* callback); void SetChannelErrorCallback(Callback0::Type* callback); - // Asynchronously resizes an offscreen frame buffer. - void ResizeOffscreenFrameBuffer(const gfx::Size& size); - // Set a task that will be invoked the next time the window becomes invalid // and needs to be repainted. Takes ownership of task. void SetNotifyRepaintTask(Task* task); @@ -94,10 +91,6 @@ class CommandBufferProxy : public gpu::CommandBuffer, const std::vector<int32>& configs, media::VideoDecodeAccelerator::Client* client); -#if defined(OS_MACOSX) - virtual void SetWindowSize(const gfx::Size& size); -#endif - private: // Send an IPC message over the GPU channel. This is private to fully diff --git a/content/renderer/gpu/renderer_gl_context.cc b/content/renderer/gpu/renderer_gl_context.cc index 426386e..53baa9b 100644 --- a/content/renderer/gpu/renderer_gl_context.cc +++ b/content/renderer/gpu/renderer_gl_context.cc @@ -107,14 +107,6 @@ RendererGLContext* RendererGLContext::CreateViewContext( #endif } -#if defined(OS_MACOSX) -void RendererGLContext::ResizeOnscreen(const gfx::Size& size) { - DCHECK(size.width() > 0 && size.height() > 0); - size_ = size; - command_buffer_->SetWindowSize(size); -} -#endif - RendererGLContext* RendererGLContext::CreateOffscreenContext( GpuChannelHost* channel, const gfx::Size& size, @@ -191,14 +183,6 @@ bool RendererGLContext::SetParent(RendererGLContext* new_parent) { return true; } -void RendererGLContext::ResizeOffscreen(const gfx::Size& size) { - DCHECK(size.width() > 0 && size.height() > 0); - if (size_ != size) { - command_buffer_->ResizeOffscreenFrameBuffer(size); - size_ = size; - } -} - uint32 RendererGLContext::GetParentTextureId() { return parent_texture_id_; } @@ -426,8 +410,6 @@ bool RendererGLContext::Initialize(bool onscreen, share_resources, bind_generates_resource); - size_ = size; - return true; } diff --git a/content/renderer/gpu/renderer_gl_context.h b/content/renderer/gpu/renderer_gl_context.h index a9f9580..5013dc9 100644 --- a/content/renderer/gpu/renderer_gl_context.h +++ b/content/renderer/gpu/renderer_gl_context.h @@ -106,13 +106,6 @@ class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext> { const int32* attrib_list, const GURL& active_arl); -#if defined(OS_MACOSX) - // On Mac OS X only, view RendererGLContexts actually behave like offscreen - // RendererGLContexts, and require an explicit resize operation which is - // slightly different from that of offscreen RendererGLContexts. - void ResizeOnscreen(const gfx::Size& size); -#endif - // Create a RendererGLContext that renders to an offscreen frame buffer. If // parent is not NULL, that RendererGLContext can access a copy of the created // RendererGLContext's frame buffer that is updated every time SwapBuffers is @@ -134,13 +127,6 @@ class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext> { // another parent, it is important to delete them before changing the parent. bool SetParent(RendererGLContext* parent); - // 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 - // SwapBuffers will be lost. A lost RendererGLContext will be reported if the - // resize fails. - void ResizeOffscreen(const gfx::Size& size); - // For an offscreen frame buffer RendererGLContext, return the texture ID with // respect to the parent RendererGLContext. Returns zero if RendererGLContext // does not have a parent. @@ -213,7 +199,6 @@ class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext> { gpu::gles2::GLES2CmdHelper* gles2_helper_; int32 transfer_buffer_id_; gpu::gles2::GLES2Implementation* gles2_implementation_; - gfx::Size size_; Error last_error_; int frame_number_; diff --git a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc index 7c721df..0366725 100644 --- a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc +++ b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc @@ -241,17 +241,7 @@ void WebGraphicsContext3DCommandBufferImpl::reshape(int width, int height) { cached_width_ = width; cached_height_ = height; - if (render_directly_to_web_view_) { -#if defined(OS_MACOSX) - context_->ResizeOnscreen(gfx::Size(width, height)); -#else - gl_->ResizeCHROMIUM(width, height); -#endif - } else { - context_->ResizeOffscreen(gfx::Size(width, height)); - // Force a SwapBuffers to get the framebuffer to resize. - context_->SwapBuffers(); - } + gl_->ResizeCHROMIUM(width, height); #ifdef FLIP_FRAMEBUFFER_VERTICALLY scanline_.reset(new uint8[width * 4]); diff --git a/content/renderer/render_widget_fullscreen_pepper.cc b/content/renderer/render_widget_fullscreen_pepper.cc index 1ccd917..0d5480b 100644 --- a/content/renderer/render_widget_fullscreen_pepper.cc +++ b/content/renderer/render_widget_fullscreen_pepper.cc @@ -316,11 +316,7 @@ void RenderWidgetFullscreenPepper::OnResize(const gfx::Size& size, const gfx::Rect& resizer_rect) { if (context_) { gpu::gles2::GLES2Implementation* gl = context_->GetImplementation(); -#if defined(OS_MACOSX) - context_->ResizeOnscreen(size); -#else gl->ResizeCHROMIUM(size.width(), size.height()); -#endif gl->Viewport(0, 0, size.width(), size.height()); } RenderWidget::OnResize(size, resizer_rect); |