| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_SYNCHRONOUS_IMPL_H
_ | |
| 6 #define CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_SYNCHRONOUS_IMPL_H
_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <set> | |
| 11 | |
| 12 #include "base/callback.h" | |
| 13 #include "base/macros.h" | |
| 14 #include "base/memory/ref_counted.h" | |
| 15 #include "base/observer_list.h" | |
| 16 #include "content/renderer/media/android/stream_texture_factory.h" | |
| 17 | |
| 18 namespace gfx { | |
| 19 class SurfaceTexture; | |
| 20 } | |
| 21 | |
| 22 namespace gpu { | |
| 23 namespace gles2 { | |
| 24 class GLES2Interface; | |
| 25 } // namespace gles2 | |
| 26 } // namespace gpu | |
| 27 | |
| 28 namespace content { | |
| 29 | |
| 30 // Factory for when using synchronous compositor in Android WebView. | |
| 31 class StreamTextureFactorySynchronousImpl : public StreamTextureFactory { | |
| 32 public: | |
| 33 class ContextProvider : public base::RefCountedThreadSafe<ContextProvider> { | |
| 34 public: | |
| 35 virtual scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture( | |
| 36 uint32_t stream_id) = 0; | |
| 37 | |
| 38 virtual uint32_t CreateStreamTexture(uint32_t texture_id) = 0; | |
| 39 | |
| 40 virtual gpu::gles2::GLES2Interface* ContextGL() = 0; | |
| 41 | |
| 42 virtual void AddObserver(StreamTextureFactoryContextObserver* obs) = 0; | |
| 43 virtual void RemoveObserver(StreamTextureFactoryContextObserver* obs) = 0; | |
| 44 | |
| 45 protected: | |
| 46 friend class base::RefCountedThreadSafe<ContextProvider>; | |
| 47 virtual ~ContextProvider() {} | |
| 48 }; | |
| 49 | |
| 50 typedef base::Callback<scoped_refptr<ContextProvider>(void)> | |
| 51 CreateContextProviderCallback; | |
| 52 | |
| 53 static scoped_refptr<StreamTextureFactorySynchronousImpl> Create( | |
| 54 const CreateContextProviderCallback& try_create_callback); | |
| 55 | |
| 56 StreamTextureProxy* CreateProxy() override; | |
| 57 void EstablishPeer(int32_t stream_id, int player_id, int frame_id) override; | |
| 58 unsigned CreateStreamTexture(unsigned texture_target, | |
| 59 unsigned* texture_id, | |
| 60 gpu::Mailbox* texture_mailbox) override; | |
| 61 void SetStreamTextureSize(int32_t stream_id, const gfx::Size& size) override; | |
| 62 gpu::gles2::GLES2Interface* ContextGL() override; | |
| 63 void AddObserver(StreamTextureFactoryContextObserver* obs) override; | |
| 64 void RemoveObserver(StreamTextureFactoryContextObserver* obs) override; | |
| 65 | |
| 66 private: | |
| 67 friend class base::RefCounted<StreamTextureFactorySynchronousImpl>; | |
| 68 StreamTextureFactorySynchronousImpl( | |
| 69 const CreateContextProviderCallback& try_create_callback); | |
| 70 ~StreamTextureFactorySynchronousImpl() override; | |
| 71 | |
| 72 CreateContextProviderCallback create_context_provider_callback_; | |
| 73 scoped_refptr<ContextProvider> context_provider_; | |
| 74 std::set<StreamTextureFactoryContextObserver*> observers_; | |
| 75 | |
| 76 DISALLOW_IMPLICIT_CONSTRUCTORS(StreamTextureFactorySynchronousImpl); | |
| 77 }; | |
| 78 | |
| 79 } // namespace content | |
| 80 | |
| 81 #endif // CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_SYNCHRONOUS_IMP
L_H_ | |
| OLD | NEW |