Commit 13fc6ba7 authored by sievers@chromium.org's avatar sievers@chromium.org

Add GL surface creation for Android.

  
This creates either a texture transport surface (for compositor use) or a native window surface.
    
Also add a way to look up a surface handle that cannot be serialized over IPC. We simply get it from the tracker as we are running the GPU thread in the browser process.

BUG=136923

Review URL: https://chromiumcodereview.appspot.com/10795058

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148715 0039d316-1c4b-4281-b951-d872f2087c98
parent 43e58451
...@@ -8,9 +8,11 @@ ...@@ -8,9 +8,11 @@
GpuSurfaceTracker::GpuSurfaceTracker() GpuSurfaceTracker::GpuSurfaceTracker()
: next_surface_id_(1) { : next_surface_id_(1) {
GpuSurfaceLookup::InitInstance(this);
} }
GpuSurfaceTracker::~GpuSurfaceTracker() { GpuSurfaceTracker::~GpuSurfaceTracker() {
GpuSurfaceLookup::InitInstance(NULL);
} }
GpuSurfaceTracker* GpuSurfaceTracker::GetInstance() { GpuSurfaceTracker* GpuSurfaceTracker::GetInstance() {
...@@ -94,3 +96,11 @@ gfx::PluginWindowHandle GpuSurfaceTracker::GetSurfaceWindowHandle( ...@@ -94,3 +96,11 @@ gfx::PluginWindowHandle GpuSurfaceTracker::GetSurfaceWindowHandle(
return gfx::kNullPluginWindow; return gfx::kNullPluginWindow;
return it->second.handle.handle; return it->second.handle.handle;
} }
gfx::AcceleratedWidget GpuSurfaceTracker::GetNativeWidget(int surface_id) {
base::AutoLock lock(lock_);
SurfaceMap::iterator it = surface_map_.find(surface_id);
if (it == surface_map_.end())
return gfx::kNullAcceleratedWidget;
return it->second.native_widget;
}
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "content/common/gpu/gpu_surface_lookup.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#include "ui/gfx/size.h" #include "ui/gfx/size.h"
...@@ -22,8 +23,12 @@ ...@@ -22,8 +23,12 @@
// Note: The ID can exist before the actual native handle for the surface is // Note: The ID can exist before the actual native handle for the surface is
// created, for example to allow giving a reference to it to a renderer, so that // created, for example to allow giving a reference to it to a renderer, so that
// it is unamibiguously identified. // it is unamibiguously identified.
class GpuSurfaceTracker { class GpuSurfaceTracker : public GpuSurfaceLookup {
public: public:
// GpuSurfaceLookup implementation:
// Returns the native widget associated with a given surface_id.
virtual gfx::AcceleratedWidget GetNativeWidget(int surface_id) OVERRIDE;
// Gets the global instance of the surface tracker. // Gets the global instance of the surface tracker.
static GpuSurfaceTracker* Get() { return GetInstance(); } static GpuSurfaceTracker* Get() { return GetInstance(); }
...@@ -78,7 +83,7 @@ class GpuSurfaceTracker { ...@@ -78,7 +83,7 @@ class GpuSurfaceTracker {
friend struct DefaultSingletonTraits<GpuSurfaceTracker>; friend struct DefaultSingletonTraits<GpuSurfaceTracker>;
GpuSurfaceTracker(); GpuSurfaceTracker();
~GpuSurfaceTracker(); virtual ~GpuSurfaceTracker();
base::Lock lock_; base::Lock lock_;
SurfaceMap surface_map_; SurfaceMap surface_map_;
......
// Copyright (c) 2012 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 "content/common/gpu/gpu_surface_lookup.h"
#include "base/logging.h"
namespace {
GpuSurfaceLookup* g_instance = NULL;
} // anonymous namespace
// static
GpuSurfaceLookup* GpuSurfaceLookup::GetInstance() {
DCHECK(g_instance);
return g_instance;
}
// static
void GpuSurfaceLookup::InitInstance(GpuSurfaceLookup* lookup) {
DCHECK(!g_instance || !lookup);
g_instance = lookup;
}
// Copyright (c) 2012 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 CONTENT_COMMON_GPU_GPU_SURFACE_LOOKUP_H_
#define CONTENT_COMMON_GPU_GPU_SURFACE_LOOKUP_H_
#include "ui/gfx/native_widget_types.h"
// This class provides an interface to look up window surface handles
// that cannot be sent through the IPC channel.
class GpuSurfaceLookup {
public:
GpuSurfaceLookup() { }
virtual ~GpuSurfaceLookup() { }
static GpuSurfaceLookup* GetInstance();
static void InitInstance(GpuSurfaceLookup* lookup);
virtual gfx::AcceleratedWidget GetNativeWidget(int surface_id) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(GpuSurfaceLookup);
};
#endif // CONTENT_COMMON_GPU_GPU_SURFACE_LOOKUP_H_
...@@ -2,14 +2,42 @@ ...@@ -2,14 +2,42 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "base/logging.h"
#include "content/common/gpu/image_transport_surface.h" #include "content/common/gpu/image_transport_surface.h"
#include "base/logging.h"
#include "content/common/gpu/gpu_surface_lookup.h"
#include "content/common/gpu/texture_image_transport_surface.h"
#include "ui/gl/gl_surface_egl.h"
// static // static
scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface(
GpuChannelManager* manager, GpuChannelManager* manager,
GpuCommandBufferStub* stub, GpuCommandBufferStub* stub,
const gfx::GLSurfaceHandle& handle) { const gfx::GLSurfaceHandle& handle) {
NOTIMPLEMENTED(); scoped_refptr<gfx::GLSurface> surface;
return NULL; if (!handle.handle && handle.transport) {
DCHECK(handle.parent_client_id);
surface = new TextureImageTransportSurface(manager, stub, handle);
} else if (handle.handle == gfx::kDummyPluginWindow && !handle.transport) {
DCHECK(GpuSurfaceLookup::GetInstance());
ANativeWindow* window = GpuSurfaceLookup::GetInstance()->GetNativeWidget(
stub->surface_id());
DCHECK(window);
surface = new gfx::NativeViewGLSurfaceEGL(false, window);
if (!surface.get() || !surface->Initialize())
return NULL;
surface = new PassThroughImageTransportSurface(
manager, stub, surface.get(), handle.transport);
} else {
NOTIMPLEMENTED();
return NULL;
}
if (surface->Initialize())
return surface;
else {
LOG(ERROR) << "Failed to initialize ImageTransportSurface";
return NULL;
}
} }
...@@ -208,6 +208,8 @@ ...@@ -208,6 +208,8 @@
'common/gpu/gpu_memory_manager.h', 'common/gpu/gpu_memory_manager.h',
'common/gpu/gpu_messages.h', 'common/gpu/gpu_messages.h',
'common/gpu/gpu_process_launch_causes.h', 'common/gpu/gpu_process_launch_causes.h',
'common/gpu/gpu_surface_lookup.h',
'common/gpu/gpu_surface_lookup.cc',
'common/gpu/stream_texture_manager_android.cc', 'common/gpu/stream_texture_manager_android.cc',
'common/gpu/stream_texture_manager_android.h', 'common/gpu/stream_texture_manager_android.h',
'common/gpu/gpu_watchdog.h', 'common/gpu/gpu_watchdog.h',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment