Index: cc/resources/video_resource_updater.cc |
diff --git a/cc/resources/video_resource_updater.cc b/cc/resources/video_resource_updater.cc |
index 1d93aebe3cce20f763da7349490d0f2a3f0d177b..57aadd68c2bbb9bb4d021d08ea569e5400b26824 100644 |
--- a/cc/resources/video_resource_updater.cc |
+++ b/cc/resources/video_resource_updater.cc |
@@ -17,9 +17,28 @@ |
namespace cc { |
+namespace { |
+ |
const ResourceFormat kYUVResourceFormat = LUMINANCE_8; |
const ResourceFormat kRGBResourceFormat = RGBA_8888; |
+class SyncPointClientImpl : public media::VideoFrame::SyncPointClient { |
+ public: |
+ explicit SyncPointClientImpl(gpu::gles2::GLES2Interface* gl) : gl_(gl) {} |
+ virtual ~SyncPointClientImpl() {} |
+ virtual uint32 InsertSyncPoint() { |
+ return GLC(gl_, gl_->InsertSyncPointCHROMIUM()); |
+ } |
+ virtual void WaitSyncPoint(uint32 sync_point) { |
+ GLC(gl_, gl_->WaitSyncPointCHROMIUM(sync_point)); |
+ } |
+ |
+ private: |
+ gpu::gles2::GLES2Interface* gl_; |
+}; |
+ |
+} // namespace |
+ |
VideoFrameExternalResources::VideoFrameExternalResources() : type(NONE) {} |
VideoFrameExternalResources::~VideoFrameExternalResources() {} |
@@ -283,10 +302,18 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes( |
return external_resources; |
} |
-static void ReturnTexture(const scoped_refptr<media::VideoFrame>& frame, |
- uint32 sync_point, |
+static void ReturnTexture(const scoped_refptr<media::VideoFrame>& video_frame, |
+ base::WeakPtr<ContextProvider> context_provider, |
+ uint32 /* sync_point */, |
bool lost_resource) { |
- frame->AppendReleaseSyncPoint(sync_point); |
+ DCHECK(context_provider.get() || lost_resource); |
dshwang
2014/06/23 18:33:20
This callback is called from ResourceProvider, whi
|
+ if (lost_resource) |
+ return; |
+ // VideoFrame::UpdateReleaseSyncPoint() creates new sync point using the same |
+ // GL context which created the given |sync_point|, so discard the |
+ // |sync_point|. |
+ SyncPointClientImpl client(context_provider->ContextGL()); |
+ video_frame->UpdateReleaseSyncPoint(&client); |
} |
VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( |
@@ -323,7 +350,7 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( |
mailbox_holder->texture_target, |
mailbox_holder->sync_point)); |
external_resources.release_callbacks.push_back( |
- base::Bind(&ReturnTexture, video_frame)); |
+ base::Bind(&ReturnTexture, video_frame, context_provider_->AsWeakPtr())); |
return external_resources; |
} |