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

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

Issue 1088903002: cc: VideoResourceUpdater: don't dismiss the sync_point given by the compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass compositor sync_point with no previous sync point in media::VideoFrame Created 5 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
11 #include "cc/base/util.h" 11 #include "cc/base/util.h"
12 #include "cc/output/gl_renderer.h" 12 #include "cc/output/gl_renderer.h"
13 #include "cc/resources/resource_provider.h" 13 #include "cc/resources/resource_provider.h"
14 #include "gpu/GLES2/gl2extchromium.h" 14 #include "gpu/GLES2/gl2extchromium.h"
15 #include "gpu/command_buffer/client/gles2_interface.h" 15 #include "gpu/command_buffer/client/gles2_interface.h"
16 #include "media/base/video_frame.h" 16 #include "media/base/video_frame.h"
17 #include "media/blink/skcanvas_video_renderer.h" 17 #include "media/blink/skcanvas_video_renderer.h"
18 #include "third_party/khronos/GLES2/gl2.h" 18 #include "third_party/khronos/GLES2/gl2.h"
19 #include "third_party/khronos/GLES2/gl2ext.h" 19 #include "third_party/khronos/GLES2/gl2ext.h"
20 #include "ui/gfx/geometry/size_conversions.h" 20 #include "ui/gfx/geometry/size_conversions.h"
21 21
22 namespace cc { 22 namespace cc {
23 23
24 namespace { 24 namespace {
25 25
26 const ResourceFormat kRGBResourceFormat = RGBA_8888; 26 const ResourceFormat kRGBResourceFormat = RGBA_8888;
27 27
28 class SyncPointClientImpl : public media::VideoFrame::SyncPointClient { 28 class SyncPointClientImpl : public media::VideoFrame::SyncPointClient {
29 public: 29 public:
30 explicit SyncPointClientImpl(gpu::gles2::GLES2Interface* gl) : gl_(gl) {} 30 explicit SyncPointClientImpl(gpu::gles2::GLES2Interface* gl,
31 uint32 sync_point)
32 : gl_(gl), sync_point_(sync_point) {}
31 ~SyncPointClientImpl() override {} 33 ~SyncPointClientImpl() override {}
32 uint32 InsertSyncPoint() override { return gl_->InsertSyncPointCHROMIUM(); } 34 uint32 InsertSyncPoint() override {
35 if (sync_point_)
36 return sync_point_;
37 return gl_->InsertSyncPointCHROMIUM();
38 }
33 void WaitSyncPoint(uint32 sync_point) override { 39 void WaitSyncPoint(uint32 sync_point) override {
40 if (!sync_point)
41 return;
34 gl_->WaitSyncPointCHROMIUM(sync_point); 42 gl_->WaitSyncPointCHROMIUM(sync_point);
43 if (sync_point_) {
44 gl_->WaitSyncPointCHROMIUM(sync_point_);
45 sync_point_ = 0;
46 }
35 } 47 }
36 48
37 private: 49 private:
38 gpu::gles2::GLES2Interface* gl_; 50 gpu::gles2::GLES2Interface* gl_;
51 uint32 sync_point_;
39 }; 52 };
40 53
41 } // namespace 54 } // namespace
42 55
43 VideoResourceUpdater::PlaneResource::PlaneResource( 56 VideoResourceUpdater::PlaneResource::PlaneResource(
44 unsigned int resource_id, 57 unsigned int resource_id,
45 const gfx::Size& resource_size, 58 const gfx::Size& resource_size,
46 ResourceFormat resource_format, 59 ResourceFormat resource_format,
47 gpu::Mailbox mailbox) 60 gpu::Mailbox mailbox)
48 : resource_id(resource_id), 61 : resource_id(resource_id),
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 void VideoResourceUpdater::ReturnTexture( 381 void VideoResourceUpdater::ReturnTexture(
369 base::WeakPtr<VideoResourceUpdater> updater, 382 base::WeakPtr<VideoResourceUpdater> updater,
370 const scoped_refptr<media::VideoFrame>& video_frame, 383 const scoped_refptr<media::VideoFrame>& video_frame,
371 uint32 sync_point, 384 uint32 sync_point,
372 bool lost_resource, 385 bool lost_resource,
373 BlockingTaskRunner* main_thread_task_runner) { 386 BlockingTaskRunner* main_thread_task_runner) {
374 // TODO(dshwang) this case should be forwarded to the decoder as lost 387 // TODO(dshwang) this case should be forwarded to the decoder as lost
375 // resource. 388 // resource.
376 if (lost_resource || !updater.get()) 389 if (lost_resource || !updater.get())
377 return; 390 return;
378 // VideoFrame::UpdateReleaseSyncPoint() creates new sync point using the same 391 // Update the release sync point in |video_frame| with |sync_point|
379 // GL context which created the given |sync_point|, so discard the 392 // returned by the compositor and emit a WaitSyncPointCHROMIUM on
380 // |sync_point|. 393 // |video_frame|'s previous sync point using the current GL context.
381 SyncPointClientImpl client(updater->context_provider_->ContextGL()); 394 SyncPointClientImpl client(updater->context_provider_->ContextGL(),
395 sync_point);
382 video_frame->UpdateReleaseSyncPoint(&client); 396 video_frame->UpdateReleaseSyncPoint(&client);
383 } 397 }
384 398
385 VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( 399 VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes(
386 const scoped_refptr<media::VideoFrame>& video_frame) { 400 const scoped_refptr<media::VideoFrame>& video_frame) {
387 TRACE_EVENT0("cc", "VideoResourceUpdater::CreateForHardwarePlanes"); 401 TRACE_EVENT0("cc", "VideoResourceUpdater::CreateForHardwarePlanes");
388 media::VideoFrame::Format frame_format = video_frame->format(); 402 media::VideoFrame::Format frame_format = video_frame->format();
389 403
390 DCHECK_EQ(frame_format, media::VideoFrame::NATIVE_TEXTURE); 404 DCHECK_EQ(frame_format, media::VideoFrame::NATIVE_TEXTURE);
391 if (frame_format != media::VideoFrame::NATIVE_TEXTURE) 405 if (frame_format != media::VideoFrame::NATIVE_TEXTURE)
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 resource_it->ref_count = 0; 466 resource_it->ref_count = 0;
453 updater->DeleteResource(resource_it); 467 updater->DeleteResource(resource_it);
454 return; 468 return;
455 } 469 }
456 470
457 --resource_it->ref_count; 471 --resource_it->ref_count;
458 DCHECK_GE(resource_it->ref_count, 0); 472 DCHECK_GE(resource_it->ref_count, 0);
459 } 473 }
460 474
461 } // namespace cc 475 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698