1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_ANDROID_IN_PROCESS_SURFACE_TEXTURE_MANAGER_H_
6 #define CONTENT_BROWSER_ANDROID_IN_PROCESS_SURFACE_TEXTURE_MANAGER_H_
8 #include "content/common/android/surface_texture_manager.h"
10 #include "base/containers/scoped_ptr_hash_map.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/singleton.h"
13 #include "base/synchronization/lock.h"
14 #include "content/common/android/surface_texture_peer.h"
15 #include "content/common/content_export.h"
16 #include "ui/gl/android/scoped_java_surface.h"
20 class CONTENT_EXPORT InProcessSurfaceTextureManager
21 : public SurfaceTextureManager
,
22 public SurfaceTexturePeer
{
24 static InProcessSurfaceTextureManager
* GetInstance();
26 // Overridden from SurfaceTextureManager:
27 void RegisterSurfaceTexture(int surface_texture_id
,
29 gfx::SurfaceTexture
* surface_texture
) override
;
30 void UnregisterSurfaceTexture(int surface_texture_id
, int client_id
) override
;
31 gfx::AcceleratedWidget
AcquireNativeWidgetForSurfaceTexture(
32 int surface_texture_id
) override
;
34 // Overridden from SurfaceTexturePeer:
35 void EstablishSurfaceTexturePeer(
36 base::ProcessHandle render_process_handle
,
37 scoped_refptr
<gfx::SurfaceTexture
> surface_texture
,
39 int player_id
) override
;
42 friend struct base::DefaultSingletonTraits
<InProcessSurfaceTextureManager
>;
44 InProcessSurfaceTextureManager();
45 ~InProcessSurfaceTextureManager() override
;
47 using SurfaceTextureMap
=
48 base::ScopedPtrHashMap
<int, scoped_ptr
<gfx::ScopedJavaSurface
>>;
49 SurfaceTextureMap surface_textures_
;
52 DISALLOW_COPY_AND_ASSIGN(InProcessSurfaceTextureManager
);
55 } // namespace content
57 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SURFACE_TEXTURE_MANAGER_H_