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

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 reviewers' comments Created 6 years, 5 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 "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "cc/output/gl_renderer.h" 9 #include "cc/output/gl_renderer.h"
10 #include "cc/resources/resource_provider.h" 10 #include "cc/resources/resource_provider.h"
11 #include "gpu/GLES2/gl2extchromium.h" 11 #include "gpu/GLES2/gl2extchromium.h"
12 #include "gpu/command_buffer/client/gles2_interface.h" 12 #include "gpu/command_buffer/client/gles2_interface.h"
13 #include "media/base/video_frame.h" 13 #include "media/base/video_frame.h"
14 #include "media/filters/skcanvas_video_renderer.h" 14 #include "media/filters/skcanvas_video_renderer.h"
15 #include "third_party/khronos/GLES2/gl2.h" 15 #include "third_party/khronos/GLES2/gl2.h"
16 #include "third_party/khronos/GLES2/gl2ext.h" 16 #include "third_party/khronos/GLES2/gl2ext.h"
17 #include "ui/gfx/size_conversions.h" 17 #include "ui/gfx/size_conversions.h"
18 18
19 namespace cc { 19 namespace cc {
20 20
21 namespace {
22
21 const ResourceFormat kYUVResourceFormat = LUMINANCE_8; 23 const ResourceFormat kYUVResourceFormat = LUMINANCE_8;
22 const ResourceFormat kRGBResourceFormat = RGBA_8888; 24 const ResourceFormat kRGBResourceFormat = RGBA_8888;
23 25
26 class SyncPointClientImpl : public media::VideoFrame::SyncPointClient {
27 public:
28 explicit SyncPointClientImpl(gpu::gles2::GLES2Interface* gl) : gl_(gl) {}
29 virtual ~SyncPointClientImpl() {}
30 virtual uint32 InsertSyncPoint() OVERRIDE {
31 return GLC(gl_, gl_->InsertSyncPointCHROMIUM());
32 }
33 virtual void WaitSyncPoint(uint32 sync_point) OVERRIDE {
34 GLC(gl_, gl_->WaitSyncPointCHROMIUM(sync_point));
35 }
36
37 private:
38 gpu::gles2::GLES2Interface* gl_;
39 };
40
41 } // namespace
42
24 VideoFrameExternalResources::VideoFrameExternalResources() : type(NONE) {} 43 VideoFrameExternalResources::VideoFrameExternalResources() : type(NONE) {}
25 44
26 VideoFrameExternalResources::~VideoFrameExternalResources() {} 45 VideoFrameExternalResources::~VideoFrameExternalResources() {}
27 46
28 VideoResourceUpdater::VideoResourceUpdater(ContextProvider* context_provider, 47 VideoResourceUpdater::VideoResourceUpdater(ContextProvider* context_provider,
29 ResourceProvider* resource_provider) 48 ResourceProvider* resource_provider)
30 : context_provider_(context_provider), 49 : context_provider_(context_provider),
31 resource_provider_(resource_provider) { 50 resource_provider_(resource_provider) {
32 } 51 }
33 52
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 external_resources.mailboxes.push_back( 297 external_resources.mailboxes.push_back(
279 TextureMailbox(plane_resources[i].mailbox, GL_TEXTURE_2D, 0)); 298 TextureMailbox(plane_resources[i].mailbox, GL_TEXTURE_2D, 0));
280 external_resources.release_callbacks.push_back( 299 external_resources.release_callbacks.push_back(
281 base::Bind(&RecycleResource, AsWeakPtr(), recycle_data)); 300 base::Bind(&RecycleResource, AsWeakPtr(), recycle_data));
282 } 301 }
283 302
284 external_resources.type = VideoFrameExternalResources::YUV_RESOURCE; 303 external_resources.type = VideoFrameExternalResources::YUV_RESOURCE;
285 return external_resources; 304 return external_resources;
286 } 305 }
287 306
288 static void ReturnTexture(const scoped_refptr<media::VideoFrame>& frame, 307 // static
289 uint32 sync_point, 308 void VideoResourceUpdater::ReturnTexture(
290 bool lost_resource) { 309 base::WeakPtr<VideoResourceUpdater> updater,
291 frame->AppendReleaseSyncPoint(sync_point); 310 const scoped_refptr<media::VideoFrame>& video_frame,
311 uint32 sync_point,
312 bool lost_resource) {
313 // TODO(dshwang) this case should be forwarded to the decoder as lost
314 // resource.
dshwang 2014/07/10 21:44:25 danakj@, use WeakPtr<VideoResourceUpdater> and add
315 if (lost_resource || !updater.get())
316 return;
317 // VideoFrame::UpdateReleaseSyncPoint() creates new sync point using the same
318 // GL context which created the given |sync_point|, so discard the
319 // |sync_point|.
320 SyncPointClientImpl client(updater->context_provider_->ContextGL());
321 video_frame->UpdateReleaseSyncPoint(&client);
292 } 322 }
293 323
294 VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( 324 VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes(
295 const scoped_refptr<media::VideoFrame>& video_frame) { 325 const scoped_refptr<media::VideoFrame>& video_frame) {
296 TRACE_EVENT0("cc", "VideoResourceUpdater::CreateForHardwarePlanes"); 326 TRACE_EVENT0("cc", "VideoResourceUpdater::CreateForHardwarePlanes");
297 media::VideoFrame::Format frame_format = video_frame->format(); 327 media::VideoFrame::Format frame_format = video_frame->format();
298 328
299 DCHECK_EQ(frame_format, media::VideoFrame::NATIVE_TEXTURE); 329 DCHECK_EQ(frame_format, media::VideoFrame::NATIVE_TEXTURE);
300 if (frame_format != media::VideoFrame::NATIVE_TEXTURE) 330 if (frame_format != media::VideoFrame::NATIVE_TEXTURE)
301 return VideoFrameExternalResources(); 331 return VideoFrameExternalResources();
(...skipping 17 matching lines...) Expand all
319 default: 349 default:
320 NOTREACHED(); 350 NOTREACHED();
321 return VideoFrameExternalResources(); 351 return VideoFrameExternalResources();
322 } 352 }
323 353
324 external_resources.mailboxes.push_back( 354 external_resources.mailboxes.push_back(
325 TextureMailbox(mailbox_holder->mailbox, 355 TextureMailbox(mailbox_holder->mailbox,
326 mailbox_holder->texture_target, 356 mailbox_holder->texture_target,
327 mailbox_holder->sync_point)); 357 mailbox_holder->sync_point));
328 external_resources.release_callbacks.push_back( 358 external_resources.release_callbacks.push_back(
329 base::Bind(&ReturnTexture, video_frame)); 359 base::Bind(&ReturnTexture, AsWeakPtr(), video_frame));
330 return external_resources; 360 return external_resources;
331 } 361 }
332 362
333 // static 363 // static
334 void VideoResourceUpdater::RecycleResource( 364 void VideoResourceUpdater::RecycleResource(
335 base::WeakPtr<VideoResourceUpdater> updater, 365 base::WeakPtr<VideoResourceUpdater> updater,
336 RecycleResourceData data, 366 RecycleResourceData data,
337 uint32 sync_point, 367 uint32 sync_point,
338 bool lost_resource) { 368 bool lost_resource) {
339 if (!updater.get()) { 369 if (!updater.get()) {
(...skipping 21 matching lines...) Expand all
361 } 391 }
362 392
363 PlaneResource recycled_resource(data.resource_id, 393 PlaneResource recycled_resource(data.resource_id,
364 data.resource_size, 394 data.resource_size,
365 data.resource_format, 395 data.resource_format,
366 data.mailbox); 396 data.mailbox);
367 updater->recycled_resources_.push_back(recycled_resource); 397 updater->recycled_resources_.push_back(recycled_resource);
368 } 398 }
369 399
370 } // namespace cc 400 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698