Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_ANDROID_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_ANDROID_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_ANDROID_H_ | 6 #define CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_ANDROID_H_ |
| 7 | 7 |
| 8 // TODO(boliu): move headers | |
|
joth
2013/08/10 01:43:44
don't understand comment? ah, to common or somethi
boliu
2013/08/10 04:17:04
Meant moving to the impl.h header. Done in PS2.
| |
| 9 | |
| 8 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 9 #include "cc/layers/video_frame_provider.h" | 11 #include "cc/layers/video_frame_provider.h" |
| 10 #include "content/renderer/gpu/stream_texture_host_android.h" | |
| 11 #include "gpu/command_buffer/common/mailbox.h" | 12 #include "gpu/command_buffer/common/mailbox.h" |
| 13 #include "ui/gfx/size.h" | |
| 12 | 14 |
| 13 namespace WebKit { | 15 namespace WebKit { |
| 14 class WebGraphicsContext3D; | 16 class WebGraphicsContext3D; |
| 15 } | 17 } |
| 16 | 18 |
| 17 namespace content { | 19 namespace content { |
| 18 | 20 |
| 19 // The proxy class for the gpu thread to notify the compositor thread | 21 // The proxy class for the gpu thread to notify the compositor thread |
| 20 // when a new video frame is available. | 22 // when a new video frame is available. |
| 21 class StreamTextureProxy : public StreamTextureHost::Listener { | 23 class StreamTextureProxy { |
| 22 public: | 24 public: |
| 23 explicit StreamTextureProxy(StreamTextureHost* host); | 25 virtual ~StreamTextureProxy() {} |
|
joth
2013/08/10 01:43:44
gives a clang warning? Or not if it's pure interfa
boliu
2013/08/10 04:17:04
This is allowed by chromium style guide for inlini
| |
| 24 virtual ~StreamTextureProxy(); | |
| 25 | 26 |
| 26 // Initialize and bind to the current thread, which becomes the thread that | 27 // Initialize and bind to the current thread, which becomes the thread that |
| 27 // a connected client will receive callbacks on. | 28 // a connected client will receive callbacks on. |
| 28 void BindToCurrentThread(int32 stream_id); | 29 virtual void BindToCurrentThread(int32 stream_id) = 0; |
| 29 | 30 |
| 30 bool IsBoundToThread() { return loop_.get() != NULL; } | 31 virtual bool IsBoundToThread() = 0; |
| 31 | 32 |
| 32 // Setting the target for callback when a frame is available. This function | 33 // Setting the target for callback when a frame is available. This function |
| 33 // could be called on both the main thread and the compositor thread. | 34 // could be called on both the main thread and the compositor thread. |
| 34 void SetClient(cc::VideoFrameProvider::Client* client); | 35 virtual void SetClient(cc::VideoFrameProvider::Client* client) = 0; |
| 35 | |
| 36 // StreamTextureHost::Listener implementation: | |
| 37 virtual void OnFrameAvailable() OVERRIDE; | |
| 38 virtual void OnMatrixChanged(const float matrix[16]) OVERRIDE; | |
| 39 | 36 |
| 40 struct Deleter { | 37 struct Deleter { |
| 41 inline void operator()(StreamTextureProxy* ptr) const { ptr->Release(); } | 38 inline void operator()(StreamTextureProxy* ptr) const { ptr->Release(); } |
| 42 }; | 39 }; |
| 43 | 40 |
| 44 private: | 41 private: |
| 45 // Causes this instance to be deleted on the thread it is bound to. | 42 // Causes this instance to be deleted on the thread it is bound to. |
| 46 void Release(); | 43 virtual void Release() = 0; |
| 47 | |
| 48 scoped_ptr<StreamTextureHost> host_; | |
| 49 scoped_refptr<base::MessageLoopProxy> loop_; | |
| 50 | |
| 51 base::Lock client_lock_; | |
| 52 cc::VideoFrameProvider::Client* client_; | |
| 53 | |
| 54 DISALLOW_IMPLICIT_CONSTRUCTORS(StreamTextureProxy); | |
| 55 }; | 44 }; |
| 56 | 45 |
| 57 typedef scoped_ptr<StreamTextureProxy, StreamTextureProxy::Deleter> | 46 typedef scoped_ptr<StreamTextureProxy, StreamTextureProxy::Deleter> |
| 58 ScopedStreamTextureProxy; | 47 ScopedStreamTextureProxy; |
| 59 | 48 |
| 60 // Factory class for managing stream textures. | 49 // Factory class for managing stream textures. |
| 61 class StreamTextureFactory { | 50 class StreamTextureFactory { |
| 62 public: | 51 public: |
| 63 StreamTextureFactory(WebKit::WebGraphicsContext3D* context, | 52 virtual ~StreamTextureFactory() {} |
|
qinmin
2013/08/10 02:45:43
nit: move to cc file
boliu
2013/08/10 04:17:04
Again, this is allowed by the style guide: http://
| |
| 64 GpuChannelHost* channel, | |
| 65 int view_id); | |
| 66 ~StreamTextureFactory(); | |
| 67 | 53 |
| 68 // Create the StreamTextureProxy object. | 54 // Create the StreamTextureProxy object. |
| 69 StreamTextureProxy* CreateProxy(); | 55 virtual StreamTextureProxy* CreateProxy() = 0; |
| 70 | 56 |
| 71 // Send an IPC message to the browser process to request a java surface | 57 // Send an IPC message to the browser process to request a java surface |
| 72 // object for the given stream_id. After the the surface is created, | 58 // object for the given stream_id. After the the surface is created, |
| 73 // it will be passed back to the WebMediaPlayerAndroid object identified by | 59 // it will be passed back to the WebMediaPlayerAndroid object identified by |
| 74 // the player_id. | 60 // the player_id. |
| 75 void EstablishPeer(int32 stream_id, int player_id); | 61 virtual void EstablishPeer(int32 stream_id, int player_id) = 0; |
| 76 | 62 |
| 77 // Create the streamTexture and return the stream Id and create a client-side | 63 // Create the streamTexture and return the stream Id and create a client-side |
| 78 // texture id to refer to the streamTexture. The texture id is produced into | 64 // texture id to refer to the streamTexture. The texture id is produced into |
| 79 // a mailbox so it can be used to ship in a VideoFrame, with a sync point for | 65 // a mailbox so it can be used to ship in a VideoFrame, with a sync point for |
| 80 // when the mailbox can be accessed. | 66 // when the mailbox can be accessed. |
| 81 unsigned CreateStreamTexture( | 67 virtual unsigned CreateStreamTexture( |
| 82 unsigned texture_target, | 68 unsigned texture_target, |
| 83 unsigned* texture_id, | 69 unsigned* texture_id, |
| 84 gpu::Mailbox* texture_mailbox, | 70 gpu::Mailbox* texture_mailbox, |
| 85 unsigned* texture_mailbox_sync_point); | 71 unsigned* texture_mailbox_sync_point) = 0; |
| 86 | 72 |
| 87 // Destroy the streamTexture for the given texture id, as well as the | 73 // Destroy the streamTexture for the given texture id, as well as the |
| 88 // client side texture. | 74 // client side texture. |
| 89 void DestroyStreamTexture(unsigned texture_id); | 75 virtual void DestroyStreamTexture(unsigned texture_id) = 0; |
| 90 | 76 |
| 91 // Set the streamTexture size for the given stream Id. | 77 // Set the streamTexture size for the given stream Id. |
| 92 void SetStreamTextureSize(int32 texture_id, const gfx::Size& size); | 78 virtual void SetStreamTextureSize(int32 texture_id, |
| 93 | 79 const gfx::Size& size) = 0; |
| 94 private: | |
| 95 WebKit::WebGraphicsContext3D* context_; | |
| 96 scoped_refptr<GpuChannelHost> channel_; | |
| 97 int view_id_; | |
| 98 | |
| 99 DISALLOW_IMPLICIT_CONSTRUCTORS(StreamTextureFactory); | |
| 100 }; | 80 }; |
| 101 | 81 |
| 102 } // namespace content | 82 } // namespace content |
| 103 | 83 |
| 104 #endif // CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_ANDROID_H_ | 84 #endif // CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_ANDROID_H_ |
| OLD | NEW |