diff options
author | fsamuel <fsamuel@chromium.org> | 2016-03-09 14:12:36 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-09 22:47:37 +0000 |
commit | de3cdcdce42f1a807fab41190f96273ec62c704d (patch) | |
tree | f709cd16b189d02ebedb8f04976dc1f1f90b0d8a | |
parent | aaab4d14f3b0266d774592136a1f097cd75c923c (diff) | |
download | chromium_src-de3cdcdce42f1a807fab41190f96273ec62c704d.zip chromium_src-de3cdcdce42f1a807fab41190f96273ec62c704d.tar.gz chromium_src-de3cdcdce42f1a807fab41190f96273ec62c704d.tar.bz2 |
mustash: SurfaceTexture* => gpu/ipc/common
As part of the effort to move content/common/gpu => gpu/ipc
to allow code reuse in Mus, I'm moving some android specific
code: SurfaceTextureManager and SurfaceTexturePeer to
gpu/ipc/common.
BUG=586371
CQ_INCLUDE_TRYBOTS=tryserver.chromium.win:win_optional_gpu_tests_rel;tryserver.chromium.mac:mac_optional_gpu_tests_rel
Review URL: https://codereview.chromium.org/1770073002
Cr-Commit-Position: refs/heads/master@{#380240}
21 files changed, 76 insertions, 63 deletions
diff --git a/content/app/android/child_process_service.cc b/content/app/android/child_process_service.cc index 3627eba..0e2bfc2 100644 --- a/content/app/android/child_process_service.cc +++ b/content/app/android/child_process_service.cc @@ -14,10 +14,10 @@ #include "base/macros.h" #include "base/posix/global_descriptors.h" #include "content/child/child_thread_impl.h" -#include "content/common/android/surface_texture_manager.h" -#include "content/common/android/surface_texture_peer.h" #include "content/common/gpu/gpu_surface_lookup.h" #include "content/public/common/content_descriptors.h" +#include "gpu/ipc/common/android/surface_texture_manager.h" +#include "gpu/ipc/common/android/surface_texture_peer.h" #include "ipc/ipc_descriptors.h" #include "jni/ChildProcessService_jni.h" #include "ui/gl/android/scoped_java_surface.h" @@ -32,8 +32,8 @@ namespace { // TODO(sievers): Use two different implementations of this depending on if // we're in a renderer or gpu process. -class SurfaceTextureManagerImpl : public SurfaceTextureManager, - public SurfaceTexturePeer, +class SurfaceTextureManagerImpl : public gpu::SurfaceTextureManager, + public gpu::SurfaceTexturePeer, public GpuSurfaceLookup { public: // |service| is the instance of @@ -146,7 +146,8 @@ void InternalInitChildProcess(JNIEnv* env, jlong cpu_features) { // Set the CPU properties. android_setCpu(cpu_count, cpu_features); - SurfaceTextureManager::SetInstance(new SurfaceTextureManagerImpl(service)); + gpu::SurfaceTextureManager::SetInstance( + new SurfaceTextureManagerImpl(service)); base::android::MemoryPressureListenerAndroid::RegisterSystemCallback(env); } diff --git a/content/browser/android/browser_surface_texture_manager.h b/content/browser/android/browser_surface_texture_manager.h index f9fb74c..639ce28 100644 --- a/content/browser/android/browser_surface_texture_manager.h +++ b/content/browser/android/browser_surface_texture_manager.h @@ -5,18 +5,18 @@ #ifndef CONTENT_BROWSER_ANDROID_BROWSER_SURFACE_TEXTURE_MANAGER_H_ #define CONTENT_BROWSER_ANDROID_BROWSER_SURFACE_TEXTURE_MANAGER_H_ -#include "content/common/android/surface_texture_manager.h" +#include "gpu/ipc/common/android/surface_texture_manager.h" #include "base/macros.h" #include "base/memory/singleton.h" -#include "content/common/android/surface_texture_peer.h" #include "content/common/content_export.h" +#include "gpu/ipc/common/android/surface_texture_peer.h" namespace content { class CONTENT_EXPORT BrowserSurfaceTextureManager - : public SurfaceTextureManager, - public SurfaceTexturePeer { + : public gpu::SurfaceTextureManager, + public gpu::SurfaceTexturePeer { public: static BrowserSurfaceTextureManager* GetInstance(); diff --git a/content/browser/android/in_process_surface_texture_manager.h b/content/browser/android/in_process_surface_texture_manager.h index 24e951c..8cf4d2ee 100644 --- a/content/browser/android/in_process_surface_texture_manager.h +++ b/content/browser/android/in_process_surface_texture_manager.h @@ -5,22 +5,22 @@ #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 "gpu/ipc/common/android/surface_texture_manager.h" #include "base/containers/scoped_ptr_hash_map.h" #include "base/macros.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 "gpu/ipc/common/android/surface_texture_peer.h" #include "ui/gl/android/scoped_java_surface.h" namespace content { class CONTENT_EXPORT InProcessSurfaceTextureManager - : public SurfaceTextureManager, - public SurfaceTexturePeer { + : public gpu::SurfaceTextureManager, + public gpu::SurfaceTexturePeer { public: static InProcessSurfaceTextureManager* GetInstance(); diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc index 2b1664f..162f026 100644 --- a/content/browser/browser_main_loop.cc +++ b/content/browser/browser_main_loop.cc @@ -638,10 +638,10 @@ void BrowserMainLoop::PostMainMessageLoopStart() { { TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:SurfaceTextureManager"); if (parsed_command_line_.HasSwitch(switches::kSingleProcess)) { - SurfaceTextureManager::SetInstance( + gpu::SurfaceTextureManager::SetInstance( InProcessSurfaceTextureManager::GetInstance()); } else { - SurfaceTextureManager::SetInstance( + gpu::SurfaceTextureManager::SetInstance( BrowserSurfaceTextureManager::GetInstance()); } } diff --git a/content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.cc b/content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.cc index 64de624..5e48a9e 100644 --- a/content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.cc +++ b/content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.cc @@ -6,8 +6,8 @@ #include "base/logging.h" #include "base/trace_event/trace_event.h" -#include "content/common/android/surface_texture_manager.h" #include "content/common/gpu/gpu_memory_buffer_factory_surface_texture.h" +#include "gpu/ipc/common/android/surface_texture_manager.h" #include "ui/gfx/buffer_format_util.h" #include "ui/gl/android/surface_texture.h" #include "ui/gl/gl_bindings.h" @@ -43,7 +43,7 @@ int WindowFormat(gfx::BufferFormat format) { void FreeSurfaceTextureForTesting( scoped_refptr<gfx::SurfaceTexture> surface_texture, gfx::GpuMemoryBufferId id) { - SurfaceTextureManager::GetInstance()->UnregisterSurfaceTexture(id.id, 0); + gpu::SurfaceTextureManager::GetInstance()->UnregisterSurfaceTexture(id.id, 0); } } // namespace @@ -70,7 +70,7 @@ GpuMemoryBufferImplSurfaceTexture::CreateFromHandle( gfx::BufferUsage usage, const DestructionCallback& callback) { ANativeWindow* native_window = - SurfaceTextureManager::GetInstance() + gpu::SurfaceTextureManager::GetInstance() ->AcquireNativeWidgetForSurfaceTexture(handle.id.id); if (!native_window) return nullptr; @@ -100,7 +100,7 @@ base::Closure GpuMemoryBufferImplSurfaceTexture::AllocateForTesting( gfx::SurfaceTexture::Create(0); DCHECK(surface_texture); const gfx::GpuMemoryBufferId kBufferId(1); - SurfaceTextureManager::GetInstance()->RegisterSurfaceTexture( + gpu::SurfaceTextureManager::GetInstance()->RegisterSurfaceTexture( kBufferId.id, 0, surface_texture.get()); handle->type = gfx::SURFACE_TEXTURE_BUFFER; handle->id = kBufferId; diff --git a/content/common/gpu/gpu_memory_buffer_factory_surface_texture.cc b/content/common/gpu/gpu_memory_buffer_factory_surface_texture.cc index a4cf15e..d9fd7d5 100644 --- a/content/common/gpu/gpu_memory_buffer_factory_surface_texture.cc +++ b/content/common/gpu/gpu_memory_buffer_factory_surface_texture.cc @@ -4,7 +4,7 @@ #include "content/common/gpu/gpu_memory_buffer_factory_surface_texture.h" -#include "content/common/android/surface_texture_manager.h" +#include "gpu/ipc/common/android/surface_texture_manager.h" #include "ui/gl/android/surface_texture.h" #include "ui/gl/gl_image_surface_texture.h" @@ -50,7 +50,7 @@ GpuMemoryBufferFactorySurfaceTexture::CreateGpuMemoryBuffer( if (!surface_texture.get()) return gfx::GpuMemoryBufferHandle(); - SurfaceTextureManager::GetInstance()->RegisterSurfaceTexture( + gpu::SurfaceTextureManager::GetInstance()->RegisterSurfaceTexture( id.id, client_id, surface_texture.get()); { @@ -89,8 +89,8 @@ void GpuMemoryBufferFactorySurfaceTexture::DestroyGpuMemoryBuffer( surface_textures_.erase(key); } - SurfaceTextureManager::GetInstance()->UnregisterSurfaceTexture(id.id, - client_id); + gpu::SurfaceTextureManager::GetInstance()->UnregisterSurfaceTexture( + id.id, client_id); } gpu::ImageFactory* GpuMemoryBufferFactorySurfaceTexture::AsImageFactory() { diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h index fcf885d..47cf56b6 100644 --- a/content/common/gpu/gpu_messages.h +++ b/content/common/gpu/gpu_messages.h @@ -38,7 +38,7 @@ #include "url/ipc/url_param_traits.h" #if defined(OS_ANDROID) -#include "content/common/android/surface_texture_peer.h" +#include "gpu/ipc/common/android/surface_texture_peer.h" #elif defined(OS_MACOSX) #include "ui/base/cocoa/remote_layer_api.h" #include "ui/gfx/mac/io_surface.h" diff --git a/content/common/gpu/stream_texture_android.cc b/content/common/gpu/stream_texture_android.cc index 857bd16..2ee40a7 100644 --- a/content/common/gpu/stream_texture_android.cc +++ b/content/common/gpu/stream_texture_android.cc @@ -8,13 +8,13 @@ #include "base/bind.h" #include "base/strings/stringize_macros.h" -#include "content/common/android/surface_texture_peer.h" #include "content/common/gpu/gpu_channel.h" #include "content/common/gpu/gpu_messages.h" #include "gpu/command_buffer/service/context_group.h" #include "gpu/command_buffer/service/context_state.h" #include "gpu/command_buffer/service/gles2_cmd_decoder.h" #include "gpu/command_buffer/service/texture_manager.h" +#include "gpu/ipc/common/android/surface_texture_peer.h" #include "ui/gfx/geometry/size.h" #include "ui/gl/gl_context.h" #include "ui/gl/gl_helper.h" @@ -254,7 +254,7 @@ void StreamTexture::OnEstablishPeer(int32_t primary_id, int32_t secondary_id) { base::ProcessHandle process = owner_stub_->channel()->GetClientPID(); - SurfaceTexturePeer::GetInstance()->EstablishSurfaceTexturePeer( + gpu::SurfaceTexturePeer::GetInstance()->EstablishSurfaceTexturePeer( process, surface_texture_, primary_id, secondary_id); } diff --git a/content/content_app.gypi b/content/content_app.gypi index cca9124..e25a00c 100644 --- a/content/content_app.gypi +++ b/content/content_app.gypi @@ -50,6 +50,7 @@ 'dependencies': [ 'content.gyp:content_jni_headers', '../build/android/ndk.gyp:cpu_features', + '../gpu/gpu.gyp:gpu_ipc_common', '../skia/skia.gyp:skia', '../ui/android/ui_android.gyp:ui_android', ], diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 5d5e591..4096ef2 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -21,6 +21,7 @@ '../gin/gin.gyp:gin', '../google_apis/google_apis.gyp:google_apis', '../gpu/gpu.gyp:gpu', + '../gpu/gpu.gyp:gpu_ipc_common', '../mojo/mojo_base.gyp:mojo_application_base', '../mojo/mojo_base.gyp:mojo_geometry_lib', '../mojo/mojo_base.gyp:mojo_url_type_converters', diff --git a/content/content_common.gypi b/content/content_common.gypi index 215ca90..0215d04 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -234,10 +234,6 @@ 'common/android/gin_java_bridge_value.h', 'common/android/hash_set.cc', 'common/android/hash_set.h', - 'common/android/surface_texture_manager.cc', - 'common/android/surface_texture_manager.h', - 'common/android/surface_texture_peer.cc', - 'common/android/surface_texture_peer.h', 'common/android/sync_compositor_messages.cc', 'common/android/sync_compositor_messages.h', 'common/appcache_interfaces.cc', diff --git a/content/content_tests.gypi b/content/content_tests.gypi index 53b52ca..a6c21b5 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi @@ -842,6 +842,7 @@ 'target_name': 'test_support_content', 'type': 'static_library', 'dependencies': [ + '../gpu/gpu.gyp:gpu_ipc_common', '../mojo/mojo_base.gyp:mojo_application_base', '../mojo/mojo_edk.gyp:mojo_system_impl', '../mojo/mojo_public.gyp:mojo_cpp_bindings', diff --git a/content/renderer/gpu/stream_texture_host_android.h b/content/renderer/gpu/stream_texture_host_android.h index 998cff5..8d5da74 100644 --- a/content/renderer/gpu/stream_texture_host_android.h +++ b/content/renderer/gpu/stream_texture_host_android.h @@ -9,7 +9,7 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" -#include "content/common/android/surface_texture_peer.h" +#include "gpu/ipc/common/android/surface_texture_peer.h" #include "ipc/ipc_listener.h" #include "ipc/ipc_message.h" diff --git a/content/renderer/media/android/stream_texture_factory_synchronous_impl.cc b/content/renderer/media/android/stream_texture_factory_synchronous_impl.cc index 137dc98..86a0e37 100644 --- a/content/renderer/media/android/stream_texture_factory_synchronous_impl.cc +++ b/content/renderer/media/android/stream_texture_factory_synchronous_impl.cc @@ -15,9 +15,9 @@ #include "base/single_thread_task_runner.h" #include "base/synchronization/lock.h" #include "cc/output/context_provider.h" -#include "content/common/android/surface_texture_peer.h" #include "content/renderer/render_thread_impl.h" #include "gpu/command_buffer/client/gles2_interface.h" +#include "gpu/ipc/common/android/surface_texture_peer.h" #include "ui/gl/android/surface_texture.h" using gpu::gles2::GLES2Interface; @@ -183,11 +183,8 @@ void StreamTextureFactorySynchronousImpl::EstablishPeer(int32_t stream_id, scoped_refptr<gfx::SurfaceTexture> surface_texture = context_provider_->GetSurfaceTexture(stream_id); if (surface_texture.get()) { - SurfaceTexturePeer::GetInstance()->EstablishSurfaceTexturePeer( - base::GetCurrentProcessHandle(), - surface_texture, - frame_id, - player_id); + gpu::SurfaceTexturePeer::GetInstance()->EstablishSurfaceTexturePeer( + base::GetCurrentProcessHandle(), surface_texture, frame_id, player_id); } } diff --git a/content/test/content_test_suite.cc b/content/test/content_test_suite.cc index 701f59c..318e34e 100644 --- a/content/test/content_test_suite.cc +++ b/content/test/content_test_suite.cc @@ -111,7 +111,7 @@ void ContentTestSuite::Initialize() { testing::UnitTest::GetInstance()->listeners(); listeners.Append(new TestInitializationListener); #if defined(OS_ANDROID) - SurfaceTextureManager::SetInstance( + gpu::SurfaceTextureManager::SetInstance( InProcessSurfaceTextureManager::GetInstance()); #endif #if defined(USE_OZONE) diff --git a/gpu/gpu_ipc_common.gypi b/gpu/gpu_ipc_common.gypi index 9cbe65a..a986b28 100644 --- a/gpu/gpu_ipc_common.gypi +++ b/gpu/gpu_ipc_common.gypi @@ -28,5 +28,13 @@ '../ipc/ipc.gyp:ipc', ], }], + ['OS=="android"', { + 'sources': [ + 'ipc/common/android/surface_texture_manager.cc', + 'ipc/common/android/surface_texture_manager.h', + 'ipc/common/android/surface_texture_peer.cc', + 'ipc/common/android/surface_texture_peer.h', + ] + }] ], } diff --git a/gpu/ipc/common/BUILD.gn b/gpu/ipc/common/BUILD.gn index 5d4cb18..67c4d8b 100644 --- a/gpu/ipc/common/BUILD.gn +++ b/gpu/ipc/common/BUILD.gn @@ -25,6 +25,15 @@ source_set("ipc_common_sources") { "memory_stats.h", ] + if (is_android) { + sources += [ + "android/surface_texture_manager.cc", + "android/surface_texture_manager.h", + "android/surface_texture_peer.cc", + "android/surface_texture_peer.h", + ] + } + configs += [ "//gpu:gpu_implementation", "//third_party/khronos:khronos_headers", diff --git a/content/common/android/surface_texture_manager.cc b/gpu/ipc/common/android/surface_texture_manager.cc index c2cb6ee..22b27d0 100644 --- a/content/common/android/surface_texture_manager.cc +++ b/gpu/ipc/common/android/surface_texture_manager.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/common/android/surface_texture_manager.h" +#include "gpu/ipc/common/android/surface_texture_manager.h" #include "base/logging.h" -namespace content { +namespace gpu { namespace { -SurfaceTextureManager* g_instance = NULL; +SurfaceTextureManager* g_instance = nullptr; } // namespace @@ -25,4 +25,4 @@ void SurfaceTextureManager::SetInstance(SurfaceTextureManager* instance) { g_instance = instance; } -} // namespace content +} // namespace gpu diff --git a/content/common/android/surface_texture_manager.h b/gpu/ipc/common/android/surface_texture_manager.h index 30a17dc..3179d4a 100644 --- a/content/common/android/surface_texture_manager.h +++ b/gpu/ipc/common/android/surface_texture_manager.h @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_COMMON_ANDROID_SURFACE_TEXTURE_MANAGER_H_ -#define CONTENT_COMMON_ANDROID_SURFACE_TEXTURE_MANAGER_H_ +#ifndef GPU_IPC_COMMON_ANDROID_SURFACE_TEXTURE_MANAGER_H_ +#define GPU_IPC_COMMON_ANDROID_SURFACE_TEXTURE_MANAGER_H_ -#include "content/common/content_export.h" +#include "gpu/gpu_export.h" #include "ui/gfx/native_widget_types.h" namespace gfx { class SurfaceTexture; } -namespace content { +namespace gpu { -class CONTENT_EXPORT SurfaceTextureManager { +class GPU_EXPORT SurfaceTextureManager { public: static SurfaceTextureManager* GetInstance(); static void SetInstance(SurfaceTextureManager* instance); @@ -37,6 +37,6 @@ class CONTENT_EXPORT SurfaceTextureManager { virtual ~SurfaceTextureManager() {} }; -} // namespace content +} // namespace gpu -#endif // CONTENT_COMMON_ANDROID_SURFACE_TEXTURE_MANAGER_H_ +#endif // GPU_IPC_COMMON_ANDROID_SURFACE_TEXTURE_MANAGER_H_ diff --git a/content/common/android/surface_texture_peer.cc b/gpu/ipc/common/android/surface_texture_peer.cc index a6fade4..397c5ba 100644 --- a/content/common/android/surface_texture_peer.cc +++ b/gpu/ipc/common/android/surface_texture_peer.cc @@ -2,21 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/common/android/surface_texture_peer.h" +#include "gpu/ipc/common/android/surface_texture_peer.h" #include "base/logging.h" -namespace content { +namespace gpu { namespace { -SurfaceTexturePeer* g_instance_ = NULL; +SurfaceTexturePeer* g_instance_ = nullptr; } // namespace -SurfaceTexturePeer::SurfaceTexturePeer() { -} +SurfaceTexturePeer::SurfaceTexturePeer() {} -SurfaceTexturePeer::~SurfaceTexturePeer() { -} +SurfaceTexturePeer::~SurfaceTexturePeer() {} // static SurfaceTexturePeer* SurfaceTexturePeer::GetInstance() { @@ -30,4 +28,4 @@ void SurfaceTexturePeer::InitInstance(SurfaceTexturePeer* instance) { g_instance_ = instance; } -} // namespace content +} // namespace gpu diff --git a/content/common/android/surface_texture_peer.h b/gpu/ipc/common/android/surface_texture_peer.h index 0afe3ef..06bfd94 100644 --- a/content/common/android/surface_texture_peer.h +++ b/gpu/ipc/common/android/surface_texture_peer.h @@ -2,16 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_COMMON_ANDROID_SURFACE_TEXTURE_PEER_H_ -#define CONTENT_COMMON_ANDROID_SURFACE_TEXTURE_PEER_H_ +#ifndef GPU_IPC_COMMON_ANDROID_SURFACE_TEXTURE_PEER_H_ +#define GPU_IPC_COMMON_ANDROID_SURFACE_TEXTURE_PEER_H_ #include "base/macros.h" #include "base/process/process.h" +#include "gpu/gpu_export.h" #include "ui/gl/android/surface_texture.h" -namespace content { +namespace gpu { -class SurfaceTexturePeer { +class GPU_EXPORT SurfaceTexturePeer { public: static SurfaceTexturePeer* GetInstance(); @@ -33,6 +34,6 @@ class SurfaceTexturePeer { DISALLOW_COPY_AND_ASSIGN(SurfaceTexturePeer); }; -} // namespace content +} // namespace gpu -#endif // CONTENT_COMMON_ANDROID_SURFACE_TEXTURE_PEER_H_ +#endif // GPU_IPC_COMMON_ANDROID_SURFACE_TEXTURE_PEER_H_ |