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 /content | |
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}
Diffstat (limited to 'content')
19 files changed, 35 insertions, 179 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/android/surface_texture_manager.cc b/content/common/android/surface_texture_manager.cc deleted file mode 100644 index c2cb6ee..0000000 --- a/content/common/android/surface_texture_manager.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 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/android/surface_texture_manager.h" - -#include "base/logging.h" - -namespace content { -namespace { - -SurfaceTextureManager* g_instance = NULL; - -} // namespace - -// static -SurfaceTextureManager* SurfaceTextureManager::GetInstance() { - DCHECK(g_instance); - return g_instance; -} - -// static -void SurfaceTextureManager::SetInstance(SurfaceTextureManager* instance) { - DCHECK(!g_instance || !instance); - g_instance = instance; -} - -} // namespace content diff --git a/content/common/android/surface_texture_manager.h b/content/common/android/surface_texture_manager.h deleted file mode 100644 index 30a17dc..0000000 --- a/content/common/android/surface_texture_manager.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2014 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_ANDROID_SURFACE_TEXTURE_MANAGER_H_ -#define CONTENT_COMMON_ANDROID_SURFACE_TEXTURE_MANAGER_H_ - -#include "content/common/content_export.h" -#include "ui/gfx/native_widget_types.h" - -namespace gfx { -class SurfaceTexture; -} - -namespace content { - -class CONTENT_EXPORT SurfaceTextureManager { - public: - static SurfaceTextureManager* GetInstance(); - static void SetInstance(SurfaceTextureManager* instance); - - // Register a surface texture for use in another process. - virtual void RegisterSurfaceTexture(int surface_texture_id, - int client_id, - gfx::SurfaceTexture* surface_texture) = 0; - - // Unregister a surface texture previously registered for use in another - // process. - virtual void UnregisterSurfaceTexture(int surface_texture_id, - int client_id) = 0; - - // Acquire native widget for a registered surface texture. - virtual gfx::AcceleratedWidget AcquireNativeWidgetForSurfaceTexture( - int surface_texture_id) = 0; - - protected: - virtual ~SurfaceTextureManager() {} -}; - -} // namespace content - -#endif // CONTENT_COMMON_ANDROID_SURFACE_TEXTURE_MANAGER_H_ diff --git a/content/common/android/surface_texture_peer.cc b/content/common/android/surface_texture_peer.cc deleted file mode 100644 index a6fade4..0000000 --- a/content/common/android/surface_texture_peer.cc +++ /dev/null @@ -1,33 +0,0 @@ -// 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/android/surface_texture_peer.h" - -#include "base/logging.h" - -namespace content { - -namespace { -SurfaceTexturePeer* g_instance_ = NULL; -} // namespace - -SurfaceTexturePeer::SurfaceTexturePeer() { -} - -SurfaceTexturePeer::~SurfaceTexturePeer() { -} - -// static -SurfaceTexturePeer* SurfaceTexturePeer::GetInstance() { - DCHECK(g_instance_); - return g_instance_; -} - -// static -void SurfaceTexturePeer::InitInstance(SurfaceTexturePeer* instance) { - DCHECK(!g_instance_); - g_instance_ = instance; -} - -} // namespace content diff --git a/content/common/android/surface_texture_peer.h b/content/common/android/surface_texture_peer.h deleted file mode 100644 index 0afe3ef..0000000 --- a/content/common/android/surface_texture_peer.h +++ /dev/null @@ -1,38 +0,0 @@ -// 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_ANDROID_SURFACE_TEXTURE_PEER_H_ -#define CONTENT_COMMON_ANDROID_SURFACE_TEXTURE_PEER_H_ - -#include "base/macros.h" -#include "base/process/process.h" -#include "ui/gl/android/surface_texture.h" - -namespace content { - -class SurfaceTexturePeer { - public: - static SurfaceTexturePeer* GetInstance(); - - static void InitInstance(SurfaceTexturePeer* instance); - - // Establish the producer end for the given surface texture in another - // process. - virtual void EstablishSurfaceTexturePeer( - base::ProcessHandle pid, - scoped_refptr<gfx::SurfaceTexture> surface_texture, - int primary_id, - int secondary_id) = 0; - - protected: - SurfaceTexturePeer(); - virtual ~SurfaceTexturePeer(); - - private: - DISALLOW_COPY_AND_ASSIGN(SurfaceTexturePeer); -}; - -} // namespace content - -#endif // CONTENT_COMMON_ANDROID_SURFACE_TEXTURE_PEER_H_ 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) |