Commit 4d0ac15c authored by kjellander's avatar kjellander Committed by Commit bot

Revert of content: Single process support for native GpuMemoryBuffers....

Revert of content: Single process support for native GpuMemoryBuffers. (patchset #8 id:140001 of https://codereview.chromium.org/1120873002/)

Reason for revert:
Breaks Mac10.6 Tests: https://build.chromium.org/p/chromium.mac/builders/Mac10.6%20Tests/builds/3331

Original issue's description:
> content: Single process support for native GpuMemoryBuffers.
>
> This adds single process support for IOSurface and
> SurfaceTexture backed GpuMemoryBuffers.
>
> Also makes the SurfaceTexture code more consistent
> with IOSurface code by using a singleton instead of
> leaking a raw pointer.
>
> BUG=497559
> TEST=content_browsertests --gtest_filter=ChildThreadImplGpuMemoryBufferBrowserTests/*
>
> Committed: https://crrev.com/d5395d05e7f006ef9d1efaf8ec84030d24fb9fef
> Cr-Commit-Position: refs/heads/master@{#333625}

TBR=avi@chromium.org,dcastagna@chromium.org,reveman@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=497559

Review URL: https://codereview.chromium.org/1171293005

Cr-Commit-Position: refs/heads/master@{#333696}
parent 7199a8d9
...@@ -73,10 +73,12 @@ static void SetSurfacePeer(scoped_refptr<gfx::SurfaceTexture> surface_texture, ...@@ -73,10 +73,12 @@ static void SetSurfacePeer(scoped_refptr<gfx::SurfaceTexture> surface_texture,
} // namespace } // namespace
// static BrowserSurfaceTextureManager::BrowserSurfaceTextureManager() {
BrowserSurfaceTextureManager* BrowserSurfaceTextureManager::GetInstance() { SurfaceTexturePeer::InitInstance(this);
return Singleton<BrowserSurfaceTextureManager, }
LeakySingletonTraits<BrowserSurfaceTextureManager>>::get();
BrowserSurfaceTextureManager::~BrowserSurfaceTextureManager() {
SurfaceTexturePeer::InitInstance(NULL);
} }
void BrowserSurfaceTextureManager::RegisterSurfaceTexture( void BrowserSurfaceTextureManager::RegisterSurfaceTexture(
...@@ -131,12 +133,4 @@ void BrowserSurfaceTextureManager::EstablishSurfaceTexturePeer( ...@@ -131,12 +133,4 @@ void BrowserSurfaceTextureManager::EstablishSurfaceTexturePeer(
player_id)); player_id));
} }
BrowserSurfaceTextureManager::BrowserSurfaceTextureManager() {
SurfaceTexturePeer::InitInstance(this);
}
BrowserSurfaceTextureManager::~BrowserSurfaceTextureManager() {
SurfaceTexturePeer::InitInstance(nullptr);
}
} // namespace content } // namespace content
...@@ -7,17 +7,15 @@ ...@@ -7,17 +7,15 @@
#include "content/common/android/surface_texture_manager.h" #include "content/common/android/surface_texture_manager.h"
#include "base/memory/singleton.h"
#include "content/common/android/surface_texture_peer.h" #include "content/common/android/surface_texture_peer.h"
#include "content/common/content_export.h"
namespace content { namespace content {
class CONTENT_EXPORT BrowserSurfaceTextureManager class BrowserSurfaceTextureManager : public SurfaceTextureManager,
: public SurfaceTextureManager, public SurfaceTexturePeer {
public SurfaceTexturePeer {
public: public:
static BrowserSurfaceTextureManager* GetInstance(); BrowserSurfaceTextureManager();
~BrowserSurfaceTextureManager() override;
// Overridden from SurfaceTextureManager: // Overridden from SurfaceTextureManager:
void RegisterSurfaceTexture(int surface_texture_id, void RegisterSurfaceTexture(int surface_texture_id,
...@@ -35,11 +33,6 @@ class CONTENT_EXPORT BrowserSurfaceTextureManager ...@@ -35,11 +33,6 @@ class CONTENT_EXPORT BrowserSurfaceTextureManager
int player_id) override; int player_id) override;
private: private:
friend struct DefaultSingletonTraits<BrowserSurfaceTextureManager>;
BrowserSurfaceTextureManager();
~BrowserSurfaceTextureManager() override;
DISALLOW_COPY_AND_ASSIGN(BrowserSurfaceTextureManager); DISALLOW_COPY_AND_ASSIGN(BrowserSurfaceTextureManager);
}; };
......
// Copyright 2015 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/browser/android/in_process_surface_texture_manager.h"
#include <android/native_window.h>
#include <android/native_window_jni.h>
#include "base/android/jni_android.h"
#include "base/containers/scoped_ptr_hash_map.h"
#include "base/logging.h"
namespace content {
// static
InProcessSurfaceTextureManager* InProcessSurfaceTextureManager::GetInstance() {
return Singleton<InProcessSurfaceTextureManager,
LeakySingletonTraits<InProcessSurfaceTextureManager>>::get();
}
void InProcessSurfaceTextureManager::RegisterSurfaceTexture(
int surface_texture_id,
int client_id,
gfx::SurfaceTexture* surface_texture) {
base::AutoLock lock(lock_);
DCHECK(surface_textures_.find(surface_texture_id) == surface_textures_.end());
surface_textures_.add(
surface_texture_id,
make_scoped_ptr(new gfx::ScopedJavaSurface(surface_texture)));
}
void InProcessSurfaceTextureManager::UnregisterSurfaceTexture(
int surface_texture_id,
int client_id) {
base::AutoLock lock(lock_);
DCHECK(surface_textures_.find(surface_texture_id) != surface_textures_.end());
surface_textures_.erase(surface_texture_id);
}
gfx::AcceleratedWidget
InProcessSurfaceTextureManager::AcquireNativeWidgetForSurfaceTexture(
int surface_texture_id) {
base::AutoLock lock(lock_);
DCHECK(surface_textures_.find(surface_texture_id) != surface_textures_.end());
JNIEnv* env = base::android::AttachCurrentThread();
return ANativeWindow_fromSurface(
env, surface_textures_.get(surface_texture_id)->j_surface().obj());
}
void InProcessSurfaceTextureManager::EstablishSurfaceTexturePeer(
base::ProcessHandle render_process_handle,
scoped_refptr<gfx::SurfaceTexture> surface_texture,
int render_frame_id,
int player_id) {
NOTIMPLEMENTED();
}
InProcessSurfaceTextureManager::InProcessSurfaceTextureManager() {
SurfaceTexturePeer::InitInstance(this);
}
InProcessSurfaceTextureManager::~InProcessSurfaceTextureManager() {
SurfaceTexturePeer::InitInstance(nullptr);
}
} // namespace content
// Copyright 2015 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_BROWSER_ANDROID_IN_PROCESS_SURFACE_TEXTURE_MANAGER_H_
#define CONTENT_BROWSER_ANDROID_IN_PROCESS_SURFACE_TEXTURE_MANAGER_H_
#include "content/common/android/surface_texture_manager.h"
#include "base/containers/scoped_ptr_hash_map.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "base/synchronization/lock.h"
#include "content/common/android/surface_texture_peer.h"
#include "content/common/content_export.h"
#include "ui/gl/android/scoped_java_surface.h"
namespace content {
class CONTENT_EXPORT InProcessSurfaceTextureManager
: public SurfaceTextureManager,
public SurfaceTexturePeer {
public:
static InProcessSurfaceTextureManager* GetInstance();
// Overridden from SurfaceTextureManager:
void RegisterSurfaceTexture(int surface_texture_id,
int client_id,
gfx::SurfaceTexture* surface_texture) override;
void UnregisterSurfaceTexture(int surface_texture_id, int client_id) override;
gfx::AcceleratedWidget AcquireNativeWidgetForSurfaceTexture(
int surface_texture_id) override;
// Overridden from SurfaceTexturePeer:
void EstablishSurfaceTexturePeer(
base::ProcessHandle render_process_handle,
scoped_refptr<gfx::SurfaceTexture> surface_texture,
int render_frame_id,
int player_id) override;
private:
friend struct DefaultSingletonTraits<InProcessSurfaceTextureManager>;
InProcessSurfaceTextureManager();
~InProcessSurfaceTextureManager() override;
using SurfaceTextureMap =
base::ScopedPtrHashMap<int, scoped_ptr<gfx::ScopedJavaSurface>>;
SurfaceTextureMap surface_textures_;
base::Lock lock_;
DISALLOW_COPY_AND_ASSIGN(InProcessSurfaceTextureManager);
};
} // namespace content
#endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SURFACE_TEXTURE_MANAGER_H_
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "content/common/content_export.h"
#include "content/common/mac/io_surface_manager.h" #include "content/common/mac/io_surface_manager.h"
#include "content/common/mac/io_surface_manager_messages.h" #include "content/common/mac/io_surface_manager_messages.h"
#include "content/common/mac/io_surface_manager_token.h" #include "content/common/mac/io_surface_manager_token.h"
......
...@@ -86,7 +86,6 @@ ...@@ -86,7 +86,6 @@
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
#include "content/browser/android/browser_startup_controller.h" #include "content/browser/android/browser_startup_controller.h"
#include "content/browser/android/browser_surface_texture_manager.h" #include "content/browser/android/browser_surface_texture_manager.h"
#include "content/browser/android/in_process_surface_texture_manager.h"
#include "content/browser/android/tracing_controller_android.h" #include "content/browser/android/tracing_controller_android.h"
#include "content/browser/screen_orientation/screen_orientation_delegate_android.h" #include "content/browser/screen_orientation/screen_orientation_delegate_android.h"
#include "content/public/browser/screen_orientation_provider.h" #include "content/public/browser/screen_orientation_provider.h"
...@@ -103,7 +102,6 @@ ...@@ -103,7 +102,6 @@
#include "content/browser/browser_io_surface_manager_mac.h" #include "content/browser/browser_io_surface_manager_mac.h"
#include "content/browser/cocoa/system_hotkey_helper_mac.h" #include "content/browser/cocoa/system_hotkey_helper_mac.h"
#include "content/browser/compositor/browser_compositor_view_mac.h" #include "content/browser/compositor/browser_compositor_view_mac.h"
#include "content/browser/in_process_io_surface_manager_mac.h"
#include "content/browser/theme_helper_mac.h" #include "content/browser/theme_helper_mac.h"
#endif #endif
...@@ -591,13 +589,7 @@ void BrowserMainLoop::PostMainMessageLoopStart() { ...@@ -591,13 +589,7 @@ void BrowserMainLoop::PostMainMessageLoopStart() {
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
{ {
TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:SurfaceTextureManager"); TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:SurfaceTextureManager");
if (parsed_command_line_.HasSwitch(switches::kSingleProcess)) { SurfaceTextureManager::SetInstance(new BrowserSurfaceTextureManager);
SurfaceTextureManager::SetInstance(
InProcessSurfaceTextureManager::GetInstance());
} else {
SurfaceTextureManager::SetInstance(
BrowserSurfaceTextureManager::GetInstance());
}
} }
if (!parsed_command_line_.HasSwitch( if (!parsed_command_line_.HasSwitch(
...@@ -613,11 +605,7 @@ void BrowserMainLoop::PostMainMessageLoopStart() { ...@@ -613,11 +605,7 @@ void BrowserMainLoop::PostMainMessageLoopStart() {
#if defined(OS_MACOSX) && !defined(OS_IOS) #if defined(OS_MACOSX) && !defined(OS_IOS)
{ {
TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:IOSurfaceManager"); TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:IOSurfaceManager");
if (parsed_command_line_.HasSwitch(switches::kSingleProcess)) { IOSurfaceManager::SetInstance(BrowserIOSurfaceManager::GetInstance());
IOSurfaceManager::SetInstance(InProcessIOSurfaceManager::GetInstance());
} else {
IOSurfaceManager::SetInstance(BrowserIOSurfaceManager::GetInstance());
}
} }
#endif #endif
......
// Copyright 2015 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/browser/in_process_io_surface_manager_mac.h"
#include "base/logging.h"
namespace content {
// static
InProcessIOSurfaceManager* InProcessIOSurfaceManager::GetInstance() {
return Singleton<InProcessIOSurfaceManager,
LeakySingletonTraits<InProcessIOSurfaceManager>>::get();
}
bool InProcessIOSurfaceManager::RegisterIOSurface(int io_surface_id,
int client_id,
IOSurfaceRef io_surface) {
base::AutoLock lock(lock_);
DCHECK(io_surfaces_.find(io_surface_id) == io_surfaces_.end());
io_surfaces_.add(io_surface_id,
make_scoped_ptr(new base::mac::ScopedMachSendRight(
IOSurfaceCreateMachPort(io_surface))));
return true;
}
void InProcessIOSurfaceManager::UnregisterIOSurface(int io_surface_id,
int client_id) {
base::AutoLock lock(lock_);
DCHECK(io_surfaces_.find(io_surface_id) != io_surfaces_.end());
io_surfaces_.erase(io_surface_id);
}
IOSurfaceRef InProcessIOSurfaceManager::AcquireIOSurface(int io_surface_id) {
base::AutoLock lock(lock_);
DCHECK(io_surfaces_.find(io_surface_id) != io_surfaces_.end());
return IOSurfaceLookupFromMachPort(io_surfaces_.get(io_surface_id)->get());
}
InProcessIOSurfaceManager::InProcessIOSurfaceManager() {
}
InProcessIOSurfaceManager::~InProcessIOSurfaceManager() {
}
} // namespace content
// Copyright 2015 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_BROWSER_IN_PROCESS_IO_SURFACE_MANAGER_MAC_H_
#define CONTENT_BROWSER_IN_PROCESS_IO_SURFACE_MANAGER_MAC_H_
#include "base/containers/scoped_ptr_hash_map.h"
#include "base/mac/scoped_mach_port.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "base/synchronization/lock.h"
#include "content/common/content_export.h"
#include "content/common/mac/io_surface_manager.h"
namespace content {
class CONTENT_EXPORT InProcessIOSurfaceManager : public IOSurfaceManager {
public:
static InProcessIOSurfaceManager* GetInstance();
// Overridden from IOSurfaceManager:
bool RegisterIOSurface(int io_surface_id,
int client_id,
IOSurfaceRef io_surface) override;
void UnregisterIOSurface(int io_surface_id, int client_id) override;
IOSurfaceRef AcquireIOSurface(int io_surface_id) override;
private:
friend struct DefaultSingletonTraits<InProcessIOSurfaceManager>;
InProcessIOSurfaceManager();
~InProcessIOSurfaceManager() override;
using IOSurfaceMap =
base::ScopedPtrHashMap<int, scoped_ptr<base::mac::ScopedMachSendRight>>;
IOSurfaceMap io_surfaces_;
base::Lock lock_;
DISALLOW_COPY_AND_ASSIGN(InProcessIOSurfaceManager);
};
} // namespace content
#endif // CONTENT_BROWSER_IN_PROCESS_IO_SURFACE_MANAGER_MAC_H_
...@@ -8,9 +8,7 @@ ...@@ -8,9 +8,7 @@
#include "base/memory/scoped_vector.h" #include "base/memory/scoped_vector.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "content/child/child_discardable_shared_memory_manager.h" #include "content/child/child_discardable_shared_memory_manager.h"
#include "content/child/child_gpu_memory_buffer_manager.h"
#include "content/child/child_thread_impl.h" #include "content/child/child_thread_impl.h"
#include "content/common/gpu/client/gpu_memory_buffer_impl.h"
#include "content/common/host_discardable_shared_memory_manager.h" #include "content/common/host_discardable_shared_memory_manager.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "content/public/test/content_browser_test.h" #include "content/public/test/content_browser_test.h"
...@@ -19,13 +17,11 @@ ...@@ -19,13 +17,11 @@
#include "url/gurl.h" #include "url/gurl.h"
namespace content { namespace content {
namespace {
class ChildThreadImplBrowserTest : public ContentBrowserTest { class ChildThreadImplBrowserTest : public ContentBrowserTest {
public: public:
ChildThreadImplBrowserTest() ChildThreadImplBrowserTest()
: child_gpu_memory_buffer_manager_(nullptr), : child_discardable_shared_memory_manager_(nullptr) {}
child_discardable_shared_memory_manager_(nullptr) {}
// Overridden from BrowserTestBase: // Overridden from BrowserTestBase:
void SetUpCommandLine(base::CommandLine* command_line) override { void SetUpCommandLine(base::CommandLine* command_line) override {
...@@ -37,10 +33,6 @@ class ChildThreadImplBrowserTest : public ContentBrowserTest { ...@@ -37,10 +33,6 @@ class ChildThreadImplBrowserTest : public ContentBrowserTest {
base::Bind(&ChildThreadImplBrowserTest::SetUpOnChildThread, this)); base::Bind(&ChildThreadImplBrowserTest::SetUpOnChildThread, this));
} }
ChildGpuMemoryBufferManager* child_gpu_memory_buffer_manager() {
return child_gpu_memory_buffer_manager_;
}
ChildDiscardableSharedMemoryManager* ChildDiscardableSharedMemoryManager*
child_discardable_shared_memory_manager() { child_discardable_shared_memory_manager() {
return child_discardable_shared_memory_manager_; return child_discardable_shared_memory_manager_;
...@@ -48,13 +40,10 @@ class ChildThreadImplBrowserTest : public ContentBrowserTest { ...@@ -48,13 +40,10 @@ class ChildThreadImplBrowserTest : public ContentBrowserTest {
private: private:
void SetUpOnChildThread() { void SetUpOnChildThread() {
child_gpu_memory_buffer_manager_ =
ChildThreadImpl::current()->gpu_memory_buffer_manager();
child_discardable_shared_memory_manager_ = child_discardable_shared_memory_manager_ =
ChildThreadImpl::current()->discardable_shared_memory_manager(); ChildThreadImpl::current()->discardable_shared_memory_manager();
} }
ChildGpuMemoryBufferManager* child_gpu_memory_buffer_manager_;
ChildDiscardableSharedMemoryManager* child_discardable_shared_memory_manager_; ChildDiscardableSharedMemoryManager* child_discardable_shared_memory_manager_;
}; };
...@@ -124,85 +113,4 @@ IN_PROC_BROWSER_TEST_F(ChildThreadImplBrowserTest, ...@@ -124,85 +113,4 @@ IN_PROC_BROWSER_TEST_F(ChildThreadImplBrowserTest,
EXPECT_LT(base::TimeTicks::Now(), end); EXPECT_LT(base::TimeTicks::Now(), end);
} }
enum NativeBufferFlag { kDisableNativeBuffers, kEnableNativeBuffers }; } // content
class ChildThreadImplGpuMemoryBufferBrowserTest
: public ChildThreadImplBrowserTest,
public testing::WithParamInterface<
::testing::tuple<NativeBufferFlag, gfx::GpuMemoryBuffer::Format>> {
public:
// Overridden from BrowserTestBase:
void SetUpCommandLine(base::CommandLine* command_line) override {
ChildThreadImplBrowserTest::SetUpCommandLine(command_line);
NativeBufferFlag native_buffer_flag = ::testing::get<0>(GetParam());
switch (native_buffer_flag) {
case kEnableNativeBuffers:
command_line->AppendSwitch(switches::kEnableNativeGpuMemoryBuffers);
break;
case kDisableNativeBuffers:
break;
}
}
};
IN_PROC_BROWSER_TEST_P(ChildThreadImplGpuMemoryBufferBrowserTest, Map) {
gfx::GpuMemoryBuffer::Format format = ::testing::get<1>(GetParam());
gfx::Size buffer_size(4, 4);
scoped_ptr<gfx::GpuMemoryBuffer> buffer =
child_gpu_memory_buffer_manager()->AllocateGpuMemoryBuffer(
buffer_size, format, gfx::GpuMemoryBuffer::MAP);
ASSERT_TRUE(buffer);
EXPECT_EQ(format, buffer->GetFormat());
size_t num_planes =
GpuMemoryBufferImpl::NumberOfPlanesForGpuMemoryBufferFormat(format);
// Map buffer planes.
scoped_ptr<void* []> planes(new void* [num_planes]);
bool rv = buffer->Map(planes.get());
ASSERT_TRUE(rv);
EXPECT_TRUE(buffer->IsMapped());
// Get strides.
scoped_ptr<int[]> strides(new int[num_planes]);
buffer->GetStride(strides.get());
// Write to buffer and check result.
for (size_t plane = 0; plane < num_planes; ++plane) {
size_t row_size_in_bytes = 0;
EXPECT_TRUE(GpuMemoryBufferImpl::RowSizeInBytes(buffer_size.width(), format,
plane, &row_size_in_bytes));
scoped_ptr<char[]> data(new char[row_size_in_bytes]);
memset(data.get(), 0x2a + plane, row_size_in_bytes);
size_t height = buffer_size.height() /
GpuMemoryBufferImpl::SubsamplingFactor(format, plane);
for (size_t y = 0; y < height; ++y) {
// Copy |data| to row |y| of |plane| and verify result.
memcpy(static_cast<char*>(planes[plane]) + y * strides[plane], data.get(),
row_size_in_bytes);
EXPECT_EQ(memcmp(static_cast<char*>(planes[plane]) + y * strides[plane],
data.get(), row_size_in_bytes),
0);
}
}
buffer->Unmap();
EXPECT_FALSE(buffer->IsMapped());
}
INSTANTIATE_TEST_CASE_P(
ChildThreadImplGpuMemoryBufferBrowserTests,
ChildThreadImplGpuMemoryBufferBrowserTest,
::testing::Combine(::testing::Values(kDisableNativeBuffers,
kEnableNativeBuffers),
// These formats are guaranteed to work on all platforms.
::testing::Values(gfx::GpuMemoryBuffer::R_8,
gfx::GpuMemoryBuffer::RGBA_4444,
gfx::GpuMemoryBuffer::RGBA_8888,
gfx::GpuMemoryBuffer::BGRA_8888,
gfx::GpuMemoryBuffer::YUV_420)));
} // namespace
} // namespace content
...@@ -382,8 +382,6 @@ ...@@ -382,8 +382,6 @@
'browser/android/in_process/synchronous_compositor_registry.h', 'browser/android/in_process/synchronous_compositor_registry.h',
'browser/android/in_process/synchronous_input_event_filter.cc', 'browser/android/in_process/synchronous_input_event_filter.cc',
'browser/android/in_process/synchronous_input_event_filter.h', 'browser/android/in_process/synchronous_input_event_filter.h',
'browser/android/in_process_surface_texture_manager.cc',
'browser/android/in_process_surface_texture_manager.h',
'browser/android/interstitial_page_delegate_android.cc', 'browser/android/interstitial_page_delegate_android.cc',
'browser/android/interstitial_page_delegate_android.h', 'browser/android/interstitial_page_delegate_android.h',
'browser/android/load_url_params.cc', 'browser/android/load_url_params.cc',
...@@ -863,8 +861,6 @@ ...@@ -863,8 +861,6 @@
'browser/host_zoom_level_context.h', 'browser/host_zoom_level_context.h',
'browser/host_zoom_map_impl.cc', 'browser/host_zoom_map_impl.cc',
'browser/host_zoom_map_impl.h', 'browser/host_zoom_map_impl.h',
'browser/in_process_io_surface_manager_mac.cc',
'browser/in_process_io_surface_manager_mac.h',
'browser/indexed_db/indexed_db.h', 'browser/indexed_db/indexed_db.h',
'browser/indexed_db/indexed_db_active_blob_registry.cc', 'browser/indexed_db/indexed_db_active_blob_registry.cc',
'browser/indexed_db/indexed_db_active_blob_registry.h', 'browser/indexed_db/indexed_db_active_blob_registry.h',
......
...@@ -4,6 +4,11 @@ ...@@ -4,6 +4,11 @@
#include "content/test/content_test_suite.h" #include "content/test/content_test_suite.h"
#if defined(OS_ANDROID)
#include <android/native_window.h>
#include <android/native_window_jni.h>
#endif
#include "base/base_paths.h" #include "base/base_paths.h"
#include "base/logging.h" #include "base/logging.h"
#include "content/public/common/content_client.h" #include "content/public/common/content_client.h"
...@@ -19,8 +24,11 @@ ...@@ -19,8 +24,11 @@
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
#include "base/mac/scoped_nsautorelease_pool.h" #include "base/mac/scoped_nsautorelease_pool.h"
#if !defined(OS_IOS) #if !defined(OS_IOS)
#include "base/containers/scoped_ptr_hash_map.h"
#include "base/mac/scoped_mach_port.h"
#include "base/memory/scoped_ptr.h"
#include "base/test/mock_chrome_application_mac.h" #include "base/test/mock_chrome_application_mac.h"
#include "content/browser/in_process_io_surface_manager_mac.h" #include "content/common/mac/io_surface_manager.h"
#endif #endif
#endif #endif
...@@ -32,7 +40,12 @@ ...@@ -32,7 +40,12 @@
#endif #endif
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "content/browser/android/in_process_surface_texture_manager.h" #include "base/android/jni_android.h"
#include "base/containers/scoped_ptr_hash_map.h"
#include "base/memory/scoped_ptr.h"
#include "content/common/android/surface_texture_manager.h"
#include "ui/gl/android/scoped_java_surface.h"
#include "ui/gl/android/surface_texture.h"
#endif #endif
namespace content { namespace content {
...@@ -58,6 +71,60 @@ class TestInitializationListener : public testing::EmptyTestEventListener { ...@@ -58,6 +71,60 @@ class TestInitializationListener : public testing::EmptyTestEventListener {
DISALLOW_COPY_AND_ASSIGN(TestInitializationListener); DISALLOW_COPY_AND_ASSIGN(TestInitializationListener);
}; };
#if defined(OS_ANDROID)
class TestSurfaceTextureManager : public SurfaceTextureManager {
public:
// Overridden from SurfaceTextureManager:
void RegisterSurfaceTexture(int surface_texture_id,
int client_id,
gfx::SurfaceTexture* surface_texture) override {
surfaces_.add(surface_texture_id,
make_scoped_ptr(new gfx::ScopedJavaSurface(surface_texture)));
}
void UnregisterSurfaceTexture(int surface_texture_id,
int client_id) override {
surfaces_.erase(surface_texture_id);
}
gfx::AcceleratedWidget AcquireNativeWidgetForSurfaceTexture(
int surface_texture_id) override {
JNIEnv* env = base::android::AttachCurrentThread();
return ANativeWindow_fromSurface(
env, surfaces_.get(surface_texture_id)->j_surface().obj());
}
private:
using SurfaceMap =
base::ScopedPtrHashMap<int, scoped_ptr<gfx::ScopedJavaSurface>>;
SurfaceMap surfaces_;
};
#endif
#if defined(OS_MACOSX) && !defined(OS_IOS)
class TestIOSurfaceManager : public IOSurfaceManager {
public:
// Overridden from IOSurfaceManager:
bool RegisterIOSurface(int io_surface_id,
int client_id,
IOSurfaceRef io_surface) override {
io_surfaces_.add(io_surface_id,
make_scoped_ptr(new base::mac::ScopedMachSendRight(
IOSurfaceCreateMachPort(io_surface))));
return true;
}
void UnregisterIOSurface(int io_surface_id, int client_id) override {
io_surfaces_.erase(io_surface_id);
}
IOSurfaceRef AcquireIOSurface(int io_surface_id) override {
return IOSurfaceLookupFromMachPort(io_surfaces_.get(io_surface_id)->get());
}
private:
using IOSurfaceMap =
base::ScopedPtrHashMap<int, scoped_ptr<base::mac::ScopedMachSendRight>>;
IOSurfaceMap io_surfaces_;
};
#endif
} // namespace } // namespace
ContentTestSuite::ContentTestSuite(int argc, char** argv) ContentTestSuite::ContentTestSuite(int argc, char** argv)
...@@ -99,11 +166,10 @@ void ContentTestSuite::Initialize() { ...@@ -99,11 +166,10 @@ void ContentTestSuite::Initialize() {
testing::UnitTest::GetInstance()->listeners(); testing::UnitTest::GetInstance()->listeners();
listeners.Append(new TestInitializationListener); listeners.Append(new TestInitializationListener);
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
SurfaceTextureManager::SetInstance( SurfaceTextureManager::SetInstance(new TestSurfaceTextureManager);
InProcessSurfaceTextureManager::GetInstance());
#endif #endif
#if defined(OS_MACOSX) && !defined(OS_IOS) #if defined(OS_MACOSX) && !defined(OS_IOS)
IOSurfaceManager::SetInstance(InProcessIOSurfaceManager::GetInstance()); IOSurfaceManager::SetInstance(new TestIOSurfaceManager);
#endif #endif
} }
......
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