Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / content / renderer / media / android / stream_texture_factory_synchronous_impl.h
blob1e2db8a539cc6bb0906052071fb3f8cbf75b595b
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"
13 namespace gfx {
14 class SurfaceTexture;
17 namespace gpu {
18 namespace gles2 {
19 class GLES2Interface;
20 } // namespace gles2
21 } // namespace gpu
23 namespace content {
25 // Factory for when using synchronous compositor in Android WebView.
26 class StreamTextureFactorySynchronousImpl : public StreamTextureFactory {
27 public:
28 class ContextProvider : public base::RefCountedThreadSafe<ContextProvider> {
29 public:
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;
38 protected:
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,
48 int frame_id);
50 StreamTextureProxy* CreateProxy() override;
51 void EstablishPeer(int32 stream_id, int player_id) override;
52 unsigned CreateStreamTexture(unsigned texture_target,
53 unsigned* texture_id,
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;
60 private:
61 friend class base::RefCounted<StreamTextureFactorySynchronousImpl>;
62 StreamTextureFactorySynchronousImpl(
63 const CreateContextProviderCallback& try_create_callback,
64 int frame_id);
65 ~StreamTextureFactorySynchronousImpl() override;
67 CreateContextProviderCallback create_context_provider_callback_;
68 scoped_refptr<ContextProvider> context_provider_;
69 int frame_id_;
70 StreamTextureFactoryContextObserver* observer_;
72 DISALLOW_IMPLICIT_CONSTRUCTORS(StreamTextureFactorySynchronousImpl);
75 } // namespace content
77 #endif // CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_SYNCHRONOUS_IMPL_H_