Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Side by Side Diff: content/renderer/media/android/stream_texture_wrapper_impl.h

Issue 2480523006: Enable texture copy for webiew (Closed)
Patch Set: Addressed comments. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/renderer/media/android/stream_texture_wrapper_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 24 matching lines...) Expand all
35 // - We create a StreamTextureProxy in the Renderer process which listens for 35 // - We create a StreamTextureProxy in the Renderer process which listens for
36 // the IPC fired by the StreamTexture's OnFrameAvailable() callback. 36 // the IPC fired by the StreamTexture's OnFrameAvailable() callback.
37 // - We bind the StreamTextureProxy's lifetime to the |compositor_task_runner_|. 37 // - We bind the StreamTextureProxy's lifetime to the |compositor_task_runner_|.
38 // - We wrap the client texture into a VideoFrame. 38 // - We wrap the client texture into a VideoFrame.
39 // - When the SurfaceTexture's OnFrameAvailable() callback is fired (and routed 39 // - When the SurfaceTexture's OnFrameAvailable() callback is fired (and routed
40 // to the StreamTextureProxy living on the compositor thread), we notify 40 // to the StreamTextureProxy living on the compositor thread), we notify
41 // |client_| that a new frame is available, via the DidReceiveFrame() callback. 41 // |client_| that a new frame is available, via the DidReceiveFrame() callback.
42 class CONTENT_EXPORT StreamTextureWrapperImpl 42 class CONTENT_EXPORT StreamTextureWrapperImpl
43 : public media::StreamTextureWrapper { 43 : public media::StreamTextureWrapper {
44 public: 44 public:
45 // |enable_texture_copy| controls the VideoFrameMetadata::COPY_REQUIRED flag,
46 // making sure it is correctly set on |current_frame_|, for webview scenarios.
45 static media::ScopedStreamTextureWrapper Create( 47 static media::ScopedStreamTextureWrapper Create(
48 bool enable_texture_copy,
46 scoped_refptr<StreamTextureFactory> factory, 49 scoped_refptr<StreamTextureFactory> factory,
47 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); 50 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner);
48 51
49 // Creates the underlying StreamTexture, and binds |stream_texture_proxy_| to 52 // Creates the underlying StreamTexture, and binds |stream_texture_proxy_| to
50 // |compositor_task_runner|. 53 // |compositor_task_runner|.
51 // 54 //
52 // Additional threading considerations: 55 // Additional threading considerations:
53 // - Can be called from any thread. 56 // - Can be called from any thread.
54 // - Initialization will be posted to |main_task_runner_|. 57 // - Initialization will be posted to |main_task_runner_|.
55 // - |init_cb| will be run on the calling thread. 58 // - |init_cb| will be run on the calling thread.
(...skipping 17 matching lines...) Expand all
73 76
74 // Sends the StreamTexture to the browser process, to fulfill the request 77 // Sends the StreamTexture to the browser process, to fulfill the request
75 // identified by |request_token|. 78 // identified by |request_token|.
76 // Uses the gpu::ScopedSurfaceRequestConduit to forward the underlying 79 // Uses the gpu::ScopedSurfaceRequestConduit to forward the underlying
77 // SurfaceTexture to the ScopedSurfaceRequestManager. 80 // SurfaceTexture to the ScopedSurfaceRequestManager.
78 void ForwardStreamTextureForSurfaceRequest( 81 void ForwardStreamTextureForSurfaceRequest(
79 const base::UnguessableToken& request_token) override; 82 const base::UnguessableToken& request_token) override;
80 83
81 private: 84 private:
82 StreamTextureWrapperImpl( 85 StreamTextureWrapperImpl(
86 bool enable_texture_copy,
83 scoped_refptr<StreamTextureFactory> factory, 87 scoped_refptr<StreamTextureFactory> factory,
84 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); 88 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner);
85 ~StreamTextureWrapperImpl() override; 89 ~StreamTextureWrapperImpl() override;
86 90
87 // Destroys |this| safely on |main_task_runner_|. 91 // Destroys |this| safely on |main_task_runner_|.
88 void Destroy() override; 92 void Destroy() override;
89 93
90 void InitializeOnMainThread(const base::Closure& received_frame_cb, 94 void InitializeOnMainThread(const base::Closure& received_frame_cb,
91 const base::Closure& init_cb); 95 const base::Closure& init_cb);
92 96
93 void ReallocateVideoFrame(const gfx::Size& natural_size); 97 void ReallocateVideoFrame(const gfx::Size& natural_size);
94 98
95 void SetCurrentFrameInternal( 99 void SetCurrentFrameInternal(
96 const scoped_refptr<media::VideoFrame>& video_frame); 100 const scoped_refptr<media::VideoFrame>& video_frame);
97 101
102 bool enable_texture_copy_;
103
98 // Client GL texture ID allocated to the StreamTexture. 104 // Client GL texture ID allocated to the StreamTexture.
99 unsigned texture_id_; 105 unsigned texture_id_;
100 106
101 // GL texture mailbox for |texture_id_|. 107 // GL texture mailbox for |texture_id_|.
102 gpu::Mailbox texture_mailbox_; 108 gpu::Mailbox texture_mailbox_;
103 109
104 // Object for calling back the compositor thread to repaint the video when a 110 // Object for calling back the compositor thread to repaint the video when a
105 // frame is available. It should be bound to |compositor_task_runner_|. 111 // frame is available. It should be bound to |compositor_task_runner_|.
106 ScopedStreamTextureProxy stream_texture_proxy_; 112 ScopedStreamTextureProxy stream_texture_proxy_;
107 113
108 // Size of the video frames. 114 // Size of the video frames.
109 gfx::Size natural_size_; 115 gfx::Size natural_size_;
110 116
111 scoped_refptr<StreamTextureFactory> factory_; 117 scoped_refptr<StreamTextureFactory> factory_;
112 118
113 base::Lock current_frame_lock_; 119 base::Lock current_frame_lock_;
114 scoped_refptr<media::VideoFrame> current_frame_; 120 scoped_refptr<media::VideoFrame> current_frame_;
115 121
116 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; 122 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
117 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; 123 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
118 124
119 base::WeakPtrFactory<StreamTextureWrapperImpl> weak_factory_; 125 base::WeakPtrFactory<StreamTextureWrapperImpl> weak_factory_;
120 126
121 DISALLOW_COPY_AND_ASSIGN(StreamTextureWrapperImpl); 127 DISALLOW_COPY_AND_ASSIGN(StreamTextureWrapperImpl);
122 }; 128 };
123 129
124 } // namespace media 130 } // namespace media
125 131
126 #endif // CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_WRAPPER_IMPL_H_ 132 #endif // CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_WRAPPER_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/android/stream_texture_wrapper_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698