Skip to content

Commit

Permalink
Reland "EGLImage transport for TOUCH_UI".
Browse files Browse the repository at this point in the history
The issue with r90511 was that we need EGL header files for touchui=1 builds. The solution was to pull them in from third_party/angle for touchui=1 only.

BUG=none
TEST=by hand on Linux (w/ and w/o TOUCH_UI), Windows, and Mac
TBR=sky@chromium.org,apatrick@chromium.org

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90513 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
backer@chromium.org committed Jun 25, 2011
1 parent 1cf99aa commit ae80234
Show file tree
Hide file tree
Showing 28 changed files with 615 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "accelerated_surface_container_touch.h"

#include "third_party/angle/include/EGL/egl.h"
#include "third_party/angle/include/EGL/eglext.h"
#include "ui/gfx/gl/gl_bindings.h"
#include "ui/gfx/gl/gl_surface_egl.h"

AcceleratedSurfaceContainerTouch::AcceleratedSurfaceContainerTouch(
uint64 surface_handle)
: image_(NULL),
texture_(0) {
image_ = eglCreateImageKHR(
gfx::GLSurfaceEGL::GetDisplay(), EGL_NO_CONTEXT,
EGL_NATIVE_PIXMAP_KHR, (void*) surface_handle, NULL);

glGenTextures(1, &texture_);

glBindTexture(GL_TEXTURE_2D, texture_);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image_);
}

AcceleratedSurfaceContainerTouch::~AcceleratedSurfaceContainerTouch() {
glDeleteTextures(1, &texture_);
eglDestroyImageKHR(gfx::GLSurfaceEGL::GetDisplay(), image_);
}
31 changes: 31 additions & 0 deletions chrome/browser/renderer_host/accelerated_surface_container_touch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_RENDERER_HOST_ACCELERATED_SURFACE_CONTAINER_TOUCH_H_
#define CHROME_BROWSER_RENDERER_HOST_ACCELERATED_SURFACE_CONTAINER_TOUCH_H_
#pragma once

#include "base/basictypes.h"
#include "base/memory/ref_counted.h"

// Helper class for storing image data from the GPU process renderered
// on behalf of the RWHVV. It assumes that GL context that will display
// the image data is current when an instance of this object is created
// or destroyed.
class AcceleratedSurfaceContainerTouch
: public base::RefCounted<AcceleratedSurfaceContainerTouch> {
public:
explicit AcceleratedSurfaceContainerTouch(uint64 surface_handle);
uint32 texture() const { return texture_; }
private:
friend class base::RefCounted<AcceleratedSurfaceContainerTouch>;

~AcceleratedSurfaceContainerTouch();

void* image_;
uint32 texture_;
DISALLOW_COPY_AND_ASSIGN(AcceleratedSurfaceContainerTouch);
};

#endif // CHROME_BROWSER_RENDERER_HOST_ACCELERATED_SURFACE_CONTAINER_TOUCH_H_
11 changes: 5 additions & 6 deletions chrome/browser/renderer_host/render_widget_host_view_views.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
#include "views/ime/input_method.h"
#include "views/widget/widget.h"

#if defined(TOUCH_UI)
#include "chrome/browser/renderer_host/accelerated_surface_container_touch.h"
#endif

static const int kMaxWindowWidth = 4000;
static const int kMaxWindowHeight = 4000;

Expand Down Expand Up @@ -566,7 +570,7 @@ views::View* RenderWidgetHostViewViews::GetOwnerViewOfTextInputClient() {
}

void RenderWidgetHostViewViews::OnPaint(gfx::Canvas* canvas) {
if (is_hidden_ || !host_)
if (is_hidden_ || !host_ || host_->is_accelerated_compositing_active())
return;

// Paint a "hole" in the canvas so that the render of the web page is on
Expand All @@ -576,11 +580,6 @@ void RenderWidgetHostViewViews::OnPaint(gfx::Canvas* canvas) {
bounds().width(), bounds().height(),
SkXfermode::kClear_Mode);

// Don't do any painting if the GPU process is rendering directly
// into the View.
if (host_->is_accelerated_compositing_active())
return;

#if defined(TOOLKIT_USES_GTK)
GdkWindow* window = GetInnerNativeView()->window;
#endif
Expand Down
15 changes: 14 additions & 1 deletion chrome/browser/renderer_host/render_widget_host_view_views.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <string>
#include <vector>

#include "base/memory/scoped_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/time.h"
#include "content/browser/renderer_host/render_widget_host_view.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
Expand All @@ -25,6 +25,7 @@
namespace ui {
enum TouchStatus;
}
class AcceleratedSurfaceContainerTouch;
#endif

class RenderWidgetHost;
Expand Down Expand Up @@ -143,6 +144,13 @@ class RenderWidgetHostViewViews : public RenderWidgetHostView,
base::i18n::TextDirection direction) OVERRIDE;
virtual views::View* GetOwnerViewOfTextInputClient() OVERRIDE;

#if defined(TOUCH_UI)
virtual void AcceleratedSurfaceSetIOSurface(
int32 width, int32 height, uint64 surface_id) OVERRIDE;
virtual void AcceleratedSurfaceBuffersSwapped(uint64 surface_id) OVERRIDE;
virtual void AcceleratedSurfaceRelease(uint64 surface_id) OVERRIDE;
#endif

protected:
// Overridden from RenderWidgetHostView / views::View.
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
Expand Down Expand Up @@ -227,6 +235,11 @@ class RenderWidgetHostViewViews : public RenderWidgetHostView,
// Indicates if there is onging composition text.
bool has_composition_text_;

#if defined(TOUCH_UI)
std::map<uint64, scoped_refptr<AcceleratedSurfaceContainerTouch> >
accelerated_surface_containers_;
#endif

DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewViews);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "chrome/browser/renderer_host/render_widget_host_view_views.h"

#include "base/logging.h"
#include "chrome/browser/renderer_host/accelerated_surface_container_touch.h"
#include "content/browser/renderer_host/render_widget_host.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/gtk/WebInputEventFactory.h"

Expand Down Expand Up @@ -187,3 +188,26 @@ RenderWidgetHostView*
return reinterpret_cast<RenderWidgetHostView*>(user_data);
}

void RenderWidgetHostViewViews::AcceleratedSurfaceSetIOSurface(
int32 width, int32 height, uint64 surface_id) {
// TODO(backer): Currently NO-OPed. Should eventually be something like:

// context_->MakeCurrent(surface_.get());
// accelerated_surface_containers_[surface_id] =
// new AcceleratedSurfaceContainer(surface_id);
// glFlush();
}

void RenderWidgetHostViewViews::AcceleratedSurfaceBuffersSwapped(
uint64 surface_id) {
// TODO(backer): Currently NO-OPed. Will eventually tie into the
// browser compositor.
}

void RenderWidgetHostViewViews::AcceleratedSurfaceRelease(uint64 surface_id) {
// TODO(backer): Currently NO-OPed. Should eventually be something like:

// context_->MakeCurrent(surface_.get());
// accelerated_surface_containers_.erase(surface_id);
// glFlush();
}
11 changes: 11 additions & 0 deletions chrome/chrome_browser.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -1761,6 +1761,8 @@
'browser/remove_rows_table_model.h',
'browser/renderer_host/accelerated_plugin_view_mac.h',
'browser/renderer_host/accelerated_plugin_view_mac.mm',
'browser/renderer_host/accelerated_surface_container_touch.cc',
'browser/renderer_host/accelerated_surface_container_touch.h',
'browser/renderer_host/chrome_render_message_filter.cc',
'browser/renderer_host/chrome_render_message_filter.h',
'browser/renderer_host/chrome_render_view_host_observer.cc',
Expand Down Expand Up @@ -3697,6 +3699,9 @@
['exclude', '^browser/chromeos/login/touch_*'],
['exclude', '^browser/extensions/extension_input_ui_api.cc'],
['exclude', '^browser/extensions/extension_input_ui_api.h'],
['exclude', '^browser/renderer_host/accelerated_surface_container_touch.cc'],
['exclude', '^browser/renderer_host/accelerated_surface_container_touch.h'],
['exclude', '^browser/renderer_host/render_widget_host_view_views_touch.cc'],
['exclude', '^browser/renderer_host/render_widget_host_view_views_touch.cc'],
['exclude', '^browser/ui/touch/*'],
['exclude', '^browser/ui/views/tab_contents/tab_contents_container_views.cc'],
Expand All @@ -3706,6 +3711,9 @@
],
}],
['touchui==1', {
'dependencies': [
'../ui/gfx/gl/gl.gyp:gl',
],
'sources/': [
['include', '^browser/ui/touch/*'],
['exclude', '^browser/chromeos/frame/browser_non_client_frame_view_factory_chromeos.cc'],
Expand All @@ -3720,6 +3728,9 @@
['exclude', '^browser/chromeos/input_method/candidate_window.cc'],
['exclude', '^browser/chromeos/input_method/candidate_window.h'],
],
'include_dirs': [
'../third_party/angle/include',
],
}],
['toolkit_uses_gtk == 1', {
'dependencies': [
Expand Down
45 changes: 43 additions & 2 deletions content/browser/gpu/gpu_process_host_ui_shim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,19 @@ bool GpuProcessHostUIShim::OnControlMessageReceived(
OnLogMessage)
#if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN)
IPC_MESSAGE_HANDLER(GpuHostMsg_ResizeView, OnResizeView)
#elif defined(OS_MACOSX)
#endif

#if defined(OS_MACOSX) || defined(TOUCH_UI)
IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSetIOSurface,
OnAcceleratedSurfaceSetIOSurface)
IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped,
OnAcceleratedSurfaceBuffersSwapped)
#endif

#if defined(TOUCH_UI)
IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceRelease,
OnAcceleratedSurfaceRelease)
#endif
IPC_MESSAGE_UNHANDLED_ERROR()
IPC_END_MESSAGE_MAP()

Expand Down Expand Up @@ -215,7 +222,9 @@ void GpuProcessHostUIShim::OnResizeView(int32 renderer_id,
Send(new GpuMsg_ResizeViewACK(renderer_id, command_buffer_route_id));
}

#elif defined(OS_MACOSX)
#endif

#if defined(OS_MACOSX) || defined(TOUCH_UI)

void GpuProcessHostUIShim::OnAcceleratedSurfaceSetIOSurface(
const GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params& params) {
Expand All @@ -226,10 +235,17 @@ void GpuProcessHostUIShim::OnAcceleratedSurfaceSetIOSurface(
RenderWidgetHostView* view = host->view();
if (!view)
return;
#if defined(OS_MACOSX)
view->AcceleratedSurfaceSetIOSurface(params.window,
params.width,
params.height,
params.identifier);
#elif defined(TOUCH_UI)
view->AcceleratedSurfaceSetIOSurface(
params.width, params.height, params.identifier);
Send(new GpuMsg_AcceleratedSurfaceSetIOSurfaceACK(
params.renderer_id, params.route_id, params.identifier));
#endif
}

void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped(
Expand All @@ -243,6 +259,7 @@ void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped(
RenderWidgetHostView* view = host->view();
if (!view)
return;
#if defined (OS_MACOSX)
view->AcceleratedSurfaceBuffersSwapped(
// Parameters needed to swap the IOSurface.
params.window,
Expand All @@ -252,6 +269,30 @@ void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped(
params.route_id,
host_id_,
params.swap_buffers_count);
#elif defined(TOUCH_UI)
view->AcceleratedSurfaceBuffersSwapped(params.surface_id);
Send(new GpuMsg_AcceleratedSurfaceBuffersSwappedACK(
params.renderer_id, params.route_id, params.swap_buffers_count));
#endif
}

#endif

#if defined(TOUCH_UI)

void GpuProcessHostUIShim::OnAcceleratedSurfaceRelease(
const GpuHostMsg_AcceleratedSurfaceRelease_Params& params) {
RenderViewHost* host = RenderViewHost::FromID(params.renderer_id,
params.render_view_id);
if (!host)
return;
RenderWidgetHostView* view = host->view();
if (!view)
return;
view->AcceleratedSurfaceRelease(params.identifier);

Send(new GpuMsg_AcceleratedSurfaceReleaseACK(
params.renderer_id, params.route_id, params.identifier));
}

#endif
10 changes: 9 additions & 1 deletion content/browser/gpu/gpu_process_host_ui_shim.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Size;
}

struct GPUCreateCommandBufferConfig;
struct GpuHostMsg_AcceleratedSurfaceRelease_Params;
struct GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params;
struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params;

Expand Down Expand Up @@ -97,13 +98,20 @@ class GpuProcessHostUIShim
int32 render_view_id,
int32 command_buffer_route_id,
gfx::Size size);
#elif defined(OS_MACOSX)
#endif

#if defined(OS_MACOSX) || defined(TOUCH_UI)
void OnAcceleratedSurfaceSetIOSurface(
const GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params& params);
void OnAcceleratedSurfaceBuffersSwapped(
const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params);
#endif

#if defined(TOUCH_UI)
void OnAcceleratedSurfaceRelease(
const GpuHostMsg_AcceleratedSurfaceRelease_Params& params);
#endif

// The serial number of the GpuProcessHost / GpuProcessHostUIShim pair.
int host_id_;
};
Expand Down
7 changes: 7 additions & 0 deletions content/browser/renderer_host/render_widget_host_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,13 @@ class RenderWidgetHostView {
virtual void GpuRenderingStateDidChange() = 0;
#endif

#if defined(TOUCH_UI)
virtual void AcceleratedSurfaceSetIOSurface(
int32 width, int32 height, uint64 surface_id) = 0;
virtual void AcceleratedSurfaceBuffersSwapped(uint64 surface_id) = 0;
virtual void AcceleratedSurfaceRelease(uint64 surface_id) = 0;
#endif

#if defined(TOOLKIT_USES_GTK)
virtual void CreatePluginContainer(gfx::PluginWindowHandle id) = 0;
virtual void DestroyPluginContainer(gfx::PluginWindowHandle id) = 0;
Expand Down
7 changes: 7 additions & 0 deletions content/browser/renderer_host/test_render_view_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ class TestRenderWidgetHostView : public RenderWidgetHostView {
#endif
virtual void SetVisuallyDeemphasized(const SkColor* color, bool animate) { }

#if defined(TOUCH_UI)
virtual void AcceleratedSurfaceSetIOSurface(
int32 width, int32 height, uint64 surface_id) { }
virtual void AcceleratedSurfaceBuffersSwapped(uint64 surface_id) { }
virtual void AcceleratedSurfaceRelease(uint64 surface_id) { }
#endif

#if defined(TOOLKIT_USES_GTK)
virtual void CreatePluginContainer(gfx::PluginWindowHandle id) { }
virtual void DestroyPluginContainer(gfx::PluginWindowHandle id) { }
Expand Down
22 changes: 21 additions & 1 deletion content/common/gpu/gpu_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,35 @@ GpuCommandBufferStub* GpuChannel::LookupCommandBuffer(int32 route_id) {
return stubs_.Lookup(route_id);
}

#if defined(OS_MACOSX)
#if defined(TOUCH_UI)
void GpuChannel::AcceleratedSurfaceIOSurfaceSet(
int32 route_id, uint64 surface_id) {
GpuCommandBufferStub* stub = stubs_.Lookup(route_id);
if (stub == NULL)
return;
stub->AcceleratedSurfaceIOSurfaceSet(surface_id);
}

void GpuChannel::AcceleratedSurfaceReleased(
int32 route_id, uint64 surface_id) {
GpuCommandBufferStub* stub = stubs_.Lookup(route_id);
if (stub == NULL)
return;
stub->AcceleratedSurfaceReleased(surface_id);
}
#endif

#if defined(OS_MACOSX) || defined(TOUCH_UI)
void GpuChannel::AcceleratedSurfaceBuffersSwapped(
int32 route_id, uint64 swap_buffers_count) {
GpuCommandBufferStub* stub = stubs_.Lookup(route_id);
if (stub == NULL)
return;
stub->AcceleratedSurfaceBuffersSwapped(swap_buffers_count);
}
#endif

#if defined(OS_MACOSX)
void GpuChannel::DestroyCommandBufferByViewId(int32 render_view_id) {
// This responds to a message from the browser process to destroy the command
// buffer when the window with a GpuScheduler is closed (see
Expand Down
Loading

0 comments on commit ae80234

Please sign in to comment.