Index: content/common/gpu/image_transport_surface.cc |
=================================================================== |
--- content/common/gpu/image_transport_surface.cc (revision 108480) |
+++ content/common/gpu/image_transport_surface.cc (working copy) |
@@ -13,6 +13,12 @@ |
#include "content/common/gpu/gpu_messages.h" |
#include "gpu/command_buffer/service/gpu_scheduler.h" |
+ImageTransportSurface::ImageTransportSurface() { |
+} |
+ |
+ImageTransportSurface::~ImageTransportSurface() { |
+} |
+ |
ImageTransportHelper::ImageTransportHelper(ImageTransportSurface* surface, |
GpuChannelManager* manager, |
int32 render_view_id, |
@@ -55,6 +61,7 @@ |
OnBuffersSwappedACK) |
IPC_MESSAGE_HANDLER(AcceleratedSurfaceMsg_NewACK, |
OnNewSurfaceACK) |
+ IPC_MESSAGE_HANDLER(AcceleratedSurfaceMsg_ResizeViewACK, OnResizeViewACK); |
IPC_MESSAGE_UNHANDLED(handled = false) |
IPC_END_MESSAGE_MAP() |
return handled; |
@@ -90,6 +97,13 @@ |
manager_->Send(new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); |
} |
+void ImageTransportHelper::SendResizeView(const gfx::Size& size) { |
+ manager_->Send(new GpuHostMsg_ResizeView(renderer_id_, |
+ render_view_id_, |
+ route_id_, |
+ size)); |
+} |
+ |
void ImageTransportHelper::SetScheduled(bool is_scheduled) { |
gpu::GpuScheduler* scheduler = Scheduler(); |
if (!scheduler) |
@@ -98,6 +112,13 @@ |
scheduler->SetScheduled(is_scheduled); |
} |
+void ImageTransportHelper::DeferToFence(base::Closure task) { |
+ gpu::GpuScheduler* scheduler = Scheduler(); |
+ DCHECK(scheduler); |
+ |
+ scheduler->DeferToFence(task); |
+} |
+ |
void ImageTransportHelper::OnBuffersSwappedACK() { |
surface_->OnBuffersSwappedACK(); |
} |
@@ -108,10 +129,40 @@ |
surface_->OnNewSurfaceACK(surface_id, shm_handle); |
} |
+void ImageTransportHelper::OnResizeViewACK() { |
+ surface_->OnResizeViewACK(); |
+} |
+ |
void ImageTransportHelper::Resize(gfx::Size size) { |
+ // On windows, the surface is recreated and, in case the newly allocated |
+ // surface happens to have the same address, it should be invalidated on the |
+ // decoder so that future calls to MakeCurrent do not early out on the |
+ // assumption that neither the context or surface have actually changed. |
+#if defined(OS_WIN) |
+ Decoder()->ReleaseCurrent(); |
+#endif |
+ |
surface_->OnResize(size); |
+ |
+#if defined(OS_WIN) |
+ Decoder()->MakeCurrent(); |
+ SetSwapInterval(); |
+#endif |
} |
+void ImageTransportHelper::SetSwapInterval() { |
+ GpuChannel* channel = manager_->LookupChannel(renderer_id_); |
+ if (!channel) |
+ return; |
+ |
+ GpuCommandBufferStub* stub = |
+ channel->LookupCommandBuffer(command_buffer_id_); |
+ if (!stub) |
+ return; |
+ |
+ stub->SetSwapInterval(); |
+} |
+ |
bool ImageTransportHelper::MakeCurrent() { |
gpu::gles2::GLES2Decoder* decoder = Decoder(); |
if (!decoder) |
@@ -145,4 +196,47 @@ |
return stub->decoder(); |
} |
+PassThroughImageTransportSurface::PassThroughImageTransportSurface( |
+ GpuChannelManager* manager, |
+ int32 render_view_id, |
+ int32 renderer_id, |
+ int32 command_buffer_id, |
+ gfx::GLSurface* surface) : GLSurfaceAdapter(surface) { |
+ helper_.reset(new ImageTransportHelper(this, |
+ manager, |
+ render_view_id, |
+ renderer_id, |
+ command_buffer_id, |
+ gfx::kNullPluginWindow)); |
+} |
+ |
+PassThroughImageTransportSurface::~PassThroughImageTransportSurface() { |
+} |
+ |
+bool PassThroughImageTransportSurface::Initialize() { |
+ // The surface is assumed to have already been initialized. |
+ return helper_->Initialize(); |
+} |
+ |
+void PassThroughImageTransportSurface::Destroy() { |
+ helper_->Destroy(); |
+ GLSurfaceAdapter::Destroy(); |
+} |
+ |
+void PassThroughImageTransportSurface::OnNewSurfaceACK( |
+ uint64 surface_id, TransportDIB::Handle surface_handle) { |
+} |
+ |
+void PassThroughImageTransportSurface::OnBuffersSwappedACK() { |
+} |
+ |
+void PassThroughImageTransportSurface::OnResizeViewACK() { |
+ helper_->SetScheduled(true); |
+} |
+ |
+void PassThroughImageTransportSurface::OnResize(gfx::Size size) { |
+ helper_->SendResizeView(size); |
+ helper_->SetScheduled(false); |
+} |
+ |
#endif // defined(ENABLE_GPU) |