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

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

Issue 2480523006: Enable texture copy for webiew (Closed)
Patch Set: 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
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 #include "content/renderer/media/android/stream_texture_wrapper_impl.h" 5 #include "content/renderer/media/android/stream_texture_wrapper_impl.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "cc/layers/video_frame_provider.h" 8 #include "cc/layers/video_frame_provider.h"
9 #include "gpu/GLES2/gl2extchromium.h" 9 #include "gpu/GLES2/gl2extchromium.h"
10 #include "gpu/command_buffer/client/gles2_interface.h" 10 #include "gpu/command_buffer/client/gles2_interface.h"
(...skipping 12 matching lines...) Expand all
23 gl->WaitSyncTokenCHROMIUM(sync_token.GetConstData()); 23 gl->WaitSyncTokenCHROMIUM(sync_token.GetConstData());
24 gl->DeleteTextures(1, &texture_id); 24 gl->DeleteTextures(1, &texture_id);
25 // Flush to ensure that the stream texture gets deleted in a timely fashion. 25 // Flush to ensure that the stream texture gets deleted in a timely fashion.
26 gl->ShallowFlushCHROMIUM(); 26 gl->ShallowFlushCHROMIUM();
27 } 27 }
28 } 28 }
29 29
30 namespace content { 30 namespace content {
31 31
32 StreamTextureWrapperImpl::StreamTextureWrapperImpl( 32 StreamTextureWrapperImpl::StreamTextureWrapperImpl(
33 bool enable_texture_copy,
33 scoped_refptr<StreamTextureFactory> factory, 34 scoped_refptr<StreamTextureFactory> factory,
34 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) 35 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner)
35 : texture_id_(0), 36 : enable_texture_copy_(enable_texture_copy),
37 texture_id_(0),
36 factory_(factory), 38 factory_(factory),
37 main_task_runner_(main_task_runner), 39 main_task_runner_(main_task_runner),
38 weak_factory_(this) {} 40 weak_factory_(this) {}
39 41
40 StreamTextureWrapperImpl::~StreamTextureWrapperImpl() { 42 StreamTextureWrapperImpl::~StreamTextureWrapperImpl() {
41 DCHECK(main_task_runner_->BelongsToCurrentThread()); 43 DCHECK(main_task_runner_->BelongsToCurrentThread());
42 44
43 if (texture_id_) { 45 if (texture_id_) {
44 GLES2Interface* gl = factory_->ContextGL(); 46 GLES2Interface* gl = factory_->ContextGL();
45 gl->DeleteTextures(1, &texture_id_); 47 gl->DeleteTextures(1, &texture_id_);
46 // Flush to ensure that the stream texture gets deleted in a timely fashion. 48 // Flush to ensure that the stream texture gets deleted in a timely fashion.
47 gl->ShallowFlushCHROMIUM(); 49 gl->ShallowFlushCHROMIUM();
48 } 50 }
49 51
50 SetCurrentFrameInternal(nullptr); 52 SetCurrentFrameInternal(nullptr);
51 } 53 }
52 54
53 media::ScopedStreamTextureWrapper StreamTextureWrapperImpl::Create( 55 media::ScopedStreamTextureWrapper StreamTextureWrapperImpl::Create(
56 bool enable_texture_copy,
54 scoped_refptr<StreamTextureFactory> factory, 57 scoped_refptr<StreamTextureFactory> factory,
55 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) { 58 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) {
56 return media::ScopedStreamTextureWrapper( 59 return media::ScopedStreamTextureWrapper(new StreamTextureWrapperImpl(
57 new StreamTextureWrapperImpl(factory, main_task_runner)); 60 enable_texture_copy, factory, main_task_runner));
58 } 61 }
59 62
60 scoped_refptr<media::VideoFrame> StreamTextureWrapperImpl::GetCurrentFrame() { 63 scoped_refptr<media::VideoFrame> StreamTextureWrapperImpl::GetCurrentFrame() {
61 base::AutoLock auto_lock(current_frame_lock_); 64 base::AutoLock auto_lock(current_frame_lock_);
62 return current_frame_; 65 return current_frame_;
63 } 66 }
64 67
65 void StreamTextureWrapperImpl::ReallocateVideoFrame( 68 void StreamTextureWrapperImpl::ReallocateVideoFrame(
66 const gfx::Size& natural_size) { 69 const gfx::Size& natural_size) {
67 DVLOG(2) << __FUNCTION__; 70 DVLOG(2) << __FUNCTION__;
(...skipping 22 matching lines...) Expand all
90 texture_target)}; 93 texture_target)};
91 94
92 scoped_refptr<media::VideoFrame> new_frame = 95 scoped_refptr<media::VideoFrame> new_frame =
93 media::VideoFrame::WrapNativeTextures( 96 media::VideoFrame::WrapNativeTextures(
94 media::PIXEL_FORMAT_ARGB, holders, 97 media::PIXEL_FORMAT_ARGB, holders,
95 media::BindToCurrentLoop( 98 media::BindToCurrentLoop(
96 base::Bind(&OnReleaseTexture, factory_, texture_id_ref)), 99 base::Bind(&OnReleaseTexture, factory_, texture_id_ref)),
97 natural_size, gfx::Rect(natural_size), natural_size, 100 natural_size, gfx::Rect(natural_size), natural_size,
98 base::TimeDelta()); 101 base::TimeDelta());
99 102
100 // TODO(tguilbert): Create and pipe the enable_texture_copy_ flag for Webview 103 if (enable_texture_copy_)
DaleCurtis 2016/11/07 22:37:50 multiline if needs {}
tguilbert 2016/11/07 23:25:01 Oops, yes :) Done.
101 // scenarios. See crbug.com/628066. 104 new_frame->metadata()->SetBoolean(media::VideoFrameMetadata::COPY_REQUIRED,
105 true);
102 106
103 SetCurrentFrameInternal(new_frame); 107 SetCurrentFrameInternal(new_frame);
104 } 108 }
105 109
106 void StreamTextureWrapperImpl::ForwardStreamTextureForSurfaceRequest( 110 void StreamTextureWrapperImpl::ForwardStreamTextureForSurfaceRequest(
107 const base::UnguessableToken& request_token) { 111 const base::UnguessableToken& request_token) {
108 stream_texture_proxy_->ForwardStreamTextureForSurfaceRequest(request_token); 112 stream_texture_proxy_->ForwardStreamTextureForSurfaceRequest(request_token);
109 } 113 }
110 114
111 void StreamTextureWrapperImpl::SetCurrentFrameInternal( 115 void StreamTextureWrapperImpl::SetCurrentFrameInternal(
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 main_task_runner_->PostTask( 186 main_task_runner_->PostTask(
183 FROM_HERE, 187 FROM_HERE,
184 base::Bind(&StreamTextureWrapperImpl::Destroy, base::Unretained(this))); 188 base::Bind(&StreamTextureWrapperImpl::Destroy, base::Unretained(this)));
185 return; 189 return;
186 } 190 }
187 191
188 delete this; 192 delete this;
189 } 193 }
190 194
191 } // namespace content 195 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698