| Index: chrome/browser/renderer_host/render_widget_host_view_views.cc
|
| diff --git a/chrome/browser/renderer_host/render_widget_host_view_views.cc b/chrome/browser/renderer_host/render_widget_host_view_views.cc
|
| index 4ad443c5e0890c1020d080600d3db53d6903dd8a..1a48a3781890a200f4b0a3feb1adb441fce969bf 100644
|
| --- a/chrome/browser/renderer_host/render_widget_host_view_views.cc
|
| +++ b/chrome/browser/renderer_host/render_widget_host_view_views.cc
|
| @@ -37,6 +37,14 @@
|
| #include "views/widget/tooltip_manager.h"
|
| #include "views/widget/widget.h"
|
|
|
| +#if defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
|
| +#include "base/bind.h"
|
| +#include "chrome/browser/renderer_host/accelerated_surface_container_touch.h"
|
| +#include "content/browser/gpu/gpu_process_host_ui_shim.h"
|
| +#include "content/common/gpu/gpu_messages.h"
|
| +#include "ui/gfx/gl/gl_bindings.h"
|
| +#endif
|
| +
|
| #if defined(TOOLKIT_USES_GTK)
|
| #include <gtk/gtk.h>
|
| #include <gtk/gtkwindow.h>
|
| @@ -45,10 +53,6 @@
|
| #include "views/widget/native_widget_gtk.h"
|
| #endif
|
|
|
| -#if defined(TOUCH_UI)
|
| -#include "chrome/browser/renderer_host/accelerated_surface_container_touch.h"
|
| -#endif
|
| -
|
| #if defined(OS_POSIX)
|
| #include "content/browser/renderer_host/gtk_window_utils.h"
|
| #endif
|
| @@ -94,6 +98,15 @@ void InitializeWebMouseEventFromViewsEvent(const views::LocatedEvent& event,
|
| wmevent->globalY = wmevent->y + origin.y();
|
| }
|
|
|
| +#if defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
|
| +void AcknowledgeSwapBuffers(int32 route_id, int gpu_host_id) {
|
| + // It's possible that gpu_host_id is no longer valid at this point (like if
|
| + // gpu process was restarted after a crash). SendToGpuHost handles this.
|
| + GpuProcessHostUIShim::SendToGpuHost(gpu_host_id,
|
| + new AcceleratedSurfaceMsg_BuffersSwappedACK(route_id));
|
| +}
|
| +#endif
|
| +
|
| } // namespace
|
|
|
| RenderWidgetHostViewViews::RenderWidgetHostViewViews(RenderWidgetHost* host)
|
| @@ -1067,7 +1080,7 @@ gfx::Rect RenderWidgetHostViewViews::GetRootWindowBounds() {
|
| }
|
| #endif
|
|
|
| -#if !defined(TOUCH_UI) && !defined(OS_WIN)
|
| +#if !defined(OS_WIN) && !defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
|
| gfx::PluginWindowHandle RenderWidgetHostViewViews::GetCompositingSurface() {
|
| // TODO(oshima): The original implementation was broken as
|
| // GtkNativeViewManager doesn't know about NativeWidgetGtk. Figure
|
| @@ -1077,3 +1090,64 @@ gfx::PluginWindowHandle RenderWidgetHostViewViews::GetCompositingSurface() {
|
| return gfx::kNullPluginWindow;
|
| }
|
| #endif
|
| +
|
| +#if defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
|
| +gfx::PluginWindowHandle RenderWidgetHostViewViews::GetCompositingSurface() {
|
| + // On TOUCH_UI builds, the GPU process renders to an offscreen surface
|
| + // (created by the GPU process), which is later displayed by the browser.
|
| + // As the GPU process creates this surface, we can return any non-zero value.
|
| + return 1;
|
| +}
|
| +
|
| +void RenderWidgetHostViewViews::AcceleratedSurfaceNew(
|
| + int32 width,
|
| + int32 height,
|
| + uint64* surface_id,
|
| + TransportDIB::Handle* surface_handle) {
|
| + scoped_ptr<AcceleratedSurfaceContainerTouch> surface(
|
| + AcceleratedSurfaceContainerTouch::CreateAcceleratedSurfaceContainer(
|
| + gfx::Size(width, height)));
|
| + if (!surface->Initialize(surface_id)) {
|
| + LOG(ERROR) << "Failed to create AcceleratedSurfaceContainer";
|
| + return;
|
| + }
|
| + *surface_handle = surface->Handle();
|
| +
|
| + accelerated_surface_containers_[*surface_id] = surface.release();
|
| +}
|
| +
|
| +void RenderWidgetHostViewViews::AcceleratedSurfaceRelease(uint64 surface_id) {
|
| + accelerated_surface_containers_.erase(surface_id);
|
| +}
|
| +
|
| +void RenderWidgetHostViewViews::AcceleratedSurfaceBuffersSwapped(
|
| + uint64 surface_id,
|
| + int32 route_id,
|
| + int gpu_host_id) {
|
| + SetExternalTexture(accelerated_surface_containers_[surface_id].get());
|
| + glFlush();
|
| +
|
| + if (!GetWidget() || !GetWidget()->GetCompositor()) {
|
| + // We have no compositor, so we have no way to display the surface
|
| + AcknowledgeSwapBuffers(route_id, gpu_host_id); // Must still send the ACK
|
| + } else {
|
| + // Add sending an ACK to the list of things to do OnCompositingEnded
|
| + on_compositing_ended_callbacks_.push_back(
|
| + base::Bind(AcknowledgeSwapBuffers, route_id, gpu_host_id));
|
| + ui::Compositor *compositor = GetWidget()->GetCompositor();
|
| + if (!compositor->HasObserver(this))
|
| + compositor->AddObserver(this);
|
| + }
|
| +}
|
| +
|
| +void RenderWidgetHostViewViews::OnCompositingEnded(ui::Compositor* compositor) {
|
| + for (std::vector< base::Callback<void(void)> >::const_iterator
|
| + it = on_compositing_ended_callbacks_.begin();
|
| + it != on_compositing_ended_callbacks_.end(); ++it) {
|
| + it->Run();
|
| + }
|
| + on_compositing_ended_callbacks_.clear();
|
| + compositor->RemoveObserver(this);
|
| +}
|
| +
|
| +#endif
|
|
|