Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_WRAPPER_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_WRAPPER_IMPL_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_WRAPPER_IMPL_H_ | 6 #define CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_WRAPPER_IMPL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 bool enable_texture_copy, | 48 bool enable_texture_copy, |
| 49 scoped_refptr<StreamTextureFactory> factory, | 49 scoped_refptr<StreamTextureFactory> factory, |
| 50 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); | 50 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); |
| 51 | 51 |
| 52 // Creates the underlying StreamTexture, and binds |stream_texture_proxy_| to | 52 // Creates the underlying StreamTexture, and binds |stream_texture_proxy_| to |
| 53 // |compositor_task_runner|. | 53 // |compositor_task_runner|. |
| 54 // | 54 // |
| 55 // Additional threading considerations: | 55 // Additional threading considerations: |
| 56 // - Can be called from any thread. | 56 // - Can be called from any thread. |
| 57 // - Initialization will be posted to |main_task_runner_|. | 57 // - Initialization will be posted to |main_task_runner_|. |
| 58 // - |init_cb| will be run on the calling thread. | 58 // - |init_cb| will be run on the calling thread, and will passed a bool |
|
watk
2016/12/07 01:48:11
"will be"
tguilbert
2016/12/07 19:23:55
Done.
| |
| 59 // indicating whether the initialization was successful. | |
| 59 // - New frames will be signaled on |compositor_task_runner| via |client|'s | 60 // - New frames will be signaled on |compositor_task_runner| via |client|'s |
| 60 // DidReceiveFrame() method. | 61 // DidReceiveFrame() method. |
| 61 void Initialize( | 62 void Initialize( |
| 62 const base::Closure& received_frame_cb, | 63 const base::Closure& received_frame_cb, |
| 63 const gfx::Size& natural_size, | 64 const gfx::Size& natural_size, |
| 64 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner, | 65 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner, |
| 65 const base::Closure& init_cb) override; | 66 const StreamTextureWrapperInitCB& init_cb) override; |
| 66 | 67 |
| 67 // Should be called when the Video size changes. | 68 // Should be called when the Video size changes. |
| 68 // Can be called from any thread, but runs on |main_task_runner_|. | 69 // Can be called from any thread, but runs on |main_task_runner_|. |
| 69 void UpdateTextureSize(const gfx::Size& natural_size) override; | 70 void UpdateTextureSize(const gfx::Size& natural_size) override; |
| 70 | 71 |
| 71 // Returns the latest frame. | 72 // Returns the latest frame. |
| 72 // N.B: We create a single VideoFrame at initialization time (and update it | 73 // N.B: We create a single VideoFrame at initialization time (and update it |
| 73 // in UpdateTextureSize()), and repeatedly return it here. The underlying | 74 // in UpdateTextureSize()), and repeatedly return it here. The underlying |
| 74 // texture's changes are signalled via |client|'s DidReceiveFrame() callback. | 75 // texture's changes are signalled via |client|'s DidReceiveFrame() callback. |
| 75 scoped_refptr<media::VideoFrame> GetCurrentFrame() override; | 76 scoped_refptr<media::VideoFrame> GetCurrentFrame() override; |
| 76 | 77 |
| 77 // Sends the StreamTexture to the browser process, to fulfill the request | 78 // Sends the StreamTexture to the browser process, to fulfill the request |
| 78 // identified by |request_token|. | 79 // identified by |request_token|. |
| 79 // Uses the gpu::ScopedSurfaceRequestConduit to forward the underlying | 80 // Uses the gpu::ScopedSurfaceRequestConduit to forward the underlying |
| 80 // SurfaceTexture to the ScopedSurfaceRequestManager. | 81 // SurfaceTexture to the ScopedSurfaceRequestManager. |
| 81 void ForwardStreamTextureForSurfaceRequest( | 82 void ForwardStreamTextureForSurfaceRequest( |
| 82 const base::UnguessableToken& request_token) override; | 83 const base::UnguessableToken& request_token) override; |
| 83 | 84 |
| 84 private: | 85 private: |
| 85 StreamTextureWrapperImpl( | 86 StreamTextureWrapperImpl( |
| 86 bool enable_texture_copy, | 87 bool enable_texture_copy, |
| 87 scoped_refptr<StreamTextureFactory> factory, | 88 scoped_refptr<StreamTextureFactory> factory, |
| 88 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); | 89 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); |
| 89 ~StreamTextureWrapperImpl() override; | 90 ~StreamTextureWrapperImpl() override; |
| 90 | 91 |
| 91 // Destroys |this| safely on |main_task_runner_|. | 92 // Destroys |this| safely on |main_task_runner_|. |
| 92 void Destroy() override; | 93 void Destroy() override; |
| 93 | 94 |
| 94 void InitializeOnMainThread(const base::Closure& received_frame_cb, | 95 void InitializeOnMainThread(const base::Closure& received_frame_cb, |
| 95 const base::Closure& init_cb); | 96 const StreamTextureWrapperInitCB& init_cb); |
| 96 | 97 |
| 97 void ReallocateVideoFrame(const gfx::Size& natural_size); | 98 void ReallocateVideoFrame(const gfx::Size& natural_size); |
| 98 | 99 |
| 99 void SetCurrentFrameInternal( | 100 void SetCurrentFrameInternal( |
| 100 const scoped_refptr<media::VideoFrame>& video_frame); | 101 const scoped_refptr<media::VideoFrame>& video_frame); |
| 101 | 102 |
| 102 bool enable_texture_copy_; | 103 bool enable_texture_copy_; |
| 103 | 104 |
| 104 // Client GL texture ID allocated to the StreamTexture. | 105 // Client GL texture ID allocated to the StreamTexture. |
| 105 unsigned texture_id_; | 106 unsigned texture_id_; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 123 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; | 124 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; |
| 124 | 125 |
| 125 base::WeakPtrFactory<StreamTextureWrapperImpl> weak_factory_; | 126 base::WeakPtrFactory<StreamTextureWrapperImpl> weak_factory_; |
| 126 | 127 |
| 127 DISALLOW_COPY_AND_ASSIGN(StreamTextureWrapperImpl); | 128 DISALLOW_COPY_AND_ASSIGN(StreamTextureWrapperImpl); |
| 128 }; | 129 }; |
| 129 | 130 |
| 130 } // namespace media | 131 } // namespace media |
| 131 | 132 |
| 132 #endif // CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_WRAPPER_IMPL_H_ | 133 #endif // CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_WRAPPER_IMPL_H_ |
| OLD | NEW |