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

Side by Side Diff: cc/resources/video_resource_updater.cc

Issue 312803002: Android media: VideoFrame should not store so many sync points. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address danakj@'s concern Created 6 years, 6 months 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 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 #include "cc/resources/video_resource_updater.h" 5 #include "cc/resources/video_resource_updater.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "cc/output/gl_renderer.h" 8 #include "cc/output/gl_renderer.h"
9 #include "cc/resources/resource_provider.h" 9 #include "cc/resources/resource_provider.h"
10 #include "gpu/GLES2/gl2extchromium.h" 10 #include "gpu/GLES2/gl2extchromium.h"
11 #include "gpu/command_buffer/client/gles2_interface.h" 11 #include "gpu/command_buffer/client/gles2_interface.h"
12 #include "media/base/video_frame.h" 12 #include "media/base/video_frame.h"
13 #include "media/filters/skcanvas_video_renderer.h" 13 #include "media/filters/skcanvas_video_renderer.h"
14 #include "third_party/khronos/GLES2/gl2.h" 14 #include "third_party/khronos/GLES2/gl2.h"
15 #include "third_party/khronos/GLES2/gl2ext.h" 15 #include "third_party/khronos/GLES2/gl2ext.h"
16 #include "ui/gfx/size_conversions.h" 16 #include "ui/gfx/size_conversions.h"
17 17
18 namespace cc { 18 namespace cc {
19 19
20 namespace {
21
20 const ResourceFormat kYUVResourceFormat = LUMINANCE_8; 22 const ResourceFormat kYUVResourceFormat = LUMINANCE_8;
21 const ResourceFormat kRGBResourceFormat = RGBA_8888; 23 const ResourceFormat kRGBResourceFormat = RGBA_8888;
22 24
25 class SyncPointProviderImpl : public media::VideoFrame::SyncPointProvider {
26 public:
27 explicit SyncPointProviderImpl(gpu::gles2::GLES2Interface* gl) : gl_(gl) {}
28 virtual ~SyncPointProviderImpl();
29 virtual uint32 InsertSyncPoint();
30 virtual void WaitSyncPoint(uint32 sync_point);
31
32 private:
33 gpu::gles2::GLES2Interface* gl_;
34 };
35
36 SyncPointProviderImpl::~SyncPointProviderImpl() {
37 }
38
39 uint32 SyncPointProviderImpl::InsertSyncPoint() {
40 return GLC(gl_, gl_->InsertSyncPointCHROMIUM());
41 }
42
43 void SyncPointProviderImpl::WaitSyncPoint(uint32 sync_point) {
44 GLC(gl_, gl_->WaitSyncPointCHROMIUM(sync_point));
45 }
46
47 } // namespace
48
23 VideoFrameExternalResources::VideoFrameExternalResources() : type(NONE) {} 49 VideoFrameExternalResources::VideoFrameExternalResources() : type(NONE) {}
24 50
25 VideoFrameExternalResources::~VideoFrameExternalResources() {} 51 VideoFrameExternalResources::~VideoFrameExternalResources() {}
26 52
27 VideoResourceUpdater::VideoResourceUpdater(ContextProvider* context_provider, 53 VideoResourceUpdater::VideoResourceUpdater(ContextProvider* context_provider,
28 ResourceProvider* resource_provider) 54 ResourceProvider* resource_provider)
29 : context_provider_(context_provider), 55 : context_provider_(context_provider),
30 resource_provider_(resource_provider) { 56 resource_provider_(resource_provider) {
31 } 57 }
32 58
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 external_resources.mailboxes.push_back( 302 external_resources.mailboxes.push_back(
277 TextureMailbox(plane_resources[i].mailbox, GL_TEXTURE_2D, 0)); 303 TextureMailbox(plane_resources[i].mailbox, GL_TEXTURE_2D, 0));
278 external_resources.release_callbacks.push_back( 304 external_resources.release_callbacks.push_back(
279 base::Bind(&RecycleResource, AsWeakPtr(), recycle_data)); 305 base::Bind(&RecycleResource, AsWeakPtr(), recycle_data));
280 } 306 }
281 307
282 external_resources.type = VideoFrameExternalResources::YUV_RESOURCE; 308 external_resources.type = VideoFrameExternalResources::YUV_RESOURCE;
283 return external_resources; 309 return external_resources;
284 } 310 }
285 311
286 static void ReturnTexture(const scoped_refptr<media::VideoFrame>& frame, 312 static void ReturnTexture(
287 uint32 sync_point, 313 const scoped_refptr<media::VideoFrame>& video_frame,
288 bool lost_resource) { 314 const scoped_refptr<ContextProvider>& context_provider,
danakj 2014/06/19 15:56:26 Can we pass a WeakPtr to the VRUpdater instead so
dshwang 2014/06/23 18:33:20 Yes, I use WeakPtr in new patch set.
289 frame->AppendReleaseSyncPoint(sync_point); 315 uint32 sync_point,
316 bool lost_resource) {
317 SyncPointProviderImpl provider(context_provider->ContextGL());
318 provider.WaitSyncPoint(sync_point);
danakj 2014/06/19 15:56:26 why waiting on the sync point here? this same cont
319 video_frame->UpdateReleaseSyncPoint(provider);
290 } 320 }
291 321
292 VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( 322 VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes(
293 const scoped_refptr<media::VideoFrame>& video_frame) { 323 const scoped_refptr<media::VideoFrame>& video_frame) {
294 media::VideoFrame::Format frame_format = video_frame->format(); 324 media::VideoFrame::Format frame_format = video_frame->format();
295 325
296 DCHECK_EQ(frame_format, media::VideoFrame::NATIVE_TEXTURE); 326 DCHECK_EQ(frame_format, media::VideoFrame::NATIVE_TEXTURE);
297 if (frame_format != media::VideoFrame::NATIVE_TEXTURE) 327 if (frame_format != media::VideoFrame::NATIVE_TEXTURE)
298 return VideoFrameExternalResources(); 328 return VideoFrameExternalResources();
299 329
(...skipping 15 matching lines...) Expand all
315 break; 345 break;
316 default: 346 default:
317 NOTREACHED(); 347 NOTREACHED();
318 return VideoFrameExternalResources(); 348 return VideoFrameExternalResources();
319 } 349 }
320 350
321 external_resources.mailboxes.push_back( 351 external_resources.mailboxes.push_back(
322 TextureMailbox(mailbox_holder->mailbox, 352 TextureMailbox(mailbox_holder->mailbox,
323 mailbox_holder->texture_target, 353 mailbox_holder->texture_target,
324 mailbox_holder->sync_point)); 354 mailbox_holder->sync_point));
325 external_resources.release_callbacks.push_back( 355 external_resources.release_callbacks.push_back(base::Bind(
326 base::Bind(&ReturnTexture, video_frame)); 356 &ReturnTexture, video_frame, make_scoped_refptr(context_provider_)));
danakj 2014/06/19 15:56:26 make_scoped_refptr() is not needed
327 return external_resources; 357 return external_resources;
328 } 358 }
329 359
330 // static 360 // static
331 void VideoResourceUpdater::RecycleResource( 361 void VideoResourceUpdater::RecycleResource(
332 base::WeakPtr<VideoResourceUpdater> updater, 362 base::WeakPtr<VideoResourceUpdater> updater,
333 RecycleResourceData data, 363 RecycleResourceData data,
334 uint32 sync_point, 364 uint32 sync_point,
335 bool lost_resource) { 365 bool lost_resource) {
336 if (!updater.get()) { 366 if (!updater.get()) {
(...skipping 21 matching lines...) Expand all
358 } 388 }
359 389
360 PlaneResource recycled_resource(data.resource_id, 390 PlaneResource recycled_resource(data.resource_id,
361 data.resource_size, 391 data.resource_size,
362 data.resource_format, 392 data.resource_format,
363 data.mailbox); 393 data.mailbox);
364 updater->recycled_resources_.push_back(recycled_resource); 394 updater->recycled_resources_.push_back(recycled_resource);
365 } 395 }
366 396
367 } // namespace cc 397 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698