1 // Copyright 2014 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_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_SYNCHRONOUS_IMPL_H_
6 #define CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_SYNCHRONOUS_IMPL_H_
8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/observer_list.h"
11 #include "content/renderer/media/android/stream_texture_factory.h"
25 // Factory for when using synchronous compositor in Android WebView.
26 class StreamTextureFactorySynchronousImpl
: public StreamTextureFactory
{
28 class ContextProvider
: public base::RefCountedThreadSafe
<ContextProvider
> {
30 virtual scoped_refptr
<gfx::SurfaceTexture
> GetSurfaceTexture(
31 uint32 stream_id
) = 0;
33 virtual gpu::gles2::GLES2Interface
* ContextGL() = 0;
35 virtual void AddObserver(StreamTextureFactoryContextObserver
* obs
) = 0;
36 virtual void RemoveObserver(StreamTextureFactoryContextObserver
* obs
) = 0;
39 friend class base::RefCountedThreadSafe
<ContextProvider
>;
40 virtual ~ContextProvider() {}
43 typedef base::Callback
<scoped_refptr
<ContextProvider
>(void)>
44 CreateContextProviderCallback
;
46 static scoped_refptr
<StreamTextureFactorySynchronousImpl
> Create(
47 const CreateContextProviderCallback
& try_create_callback
,
50 StreamTextureProxy
* CreateProxy() override
;
51 void EstablishPeer(int32 stream_id
, int player_id
) override
;
52 unsigned CreateStreamTexture(unsigned texture_target
,
54 gpu::Mailbox
* texture_mailbox
) override
;
55 void SetStreamTextureSize(int32 stream_id
, const gfx::Size
& size
) override
;
56 gpu::gles2::GLES2Interface
* ContextGL() override
;
57 void AddObserver(StreamTextureFactoryContextObserver
* obs
) override
;
58 void RemoveObserver(StreamTextureFactoryContextObserver
* obs
) override
;
61 friend class base::RefCounted
<StreamTextureFactorySynchronousImpl
>;
62 StreamTextureFactorySynchronousImpl(
63 const CreateContextProviderCallback
& try_create_callback
,
65 ~StreamTextureFactorySynchronousImpl() override
;
67 CreateContextProviderCallback create_context_provider_callback_
;
68 scoped_refptr
<ContextProvider
> context_provider_
;
70 StreamTextureFactoryContextObserver
* observer_
;
72 DISALLOW_IMPLICIT_CONSTRUCTORS(StreamTextureFactorySynchronousImpl
);
75 } // namespace content
77 #endif // CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_SYNCHRONOUS_IMPL_H_