OLD | NEW |
---|---|
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 { return sync_point_; } |
33 void WaitSyncPoint(uint32 sync_point) override { | 35 void WaitSyncPoint(uint32 sync_point) override { |
34 gl_->WaitSyncPointCHROMIUM(sync_point); | 36 gl_->WaitSyncPointCHROMIUM(sync_point); |
35 } | 37 } |
36 | 38 |
37 private: | 39 private: |
38 gpu::gles2::GLES2Interface* gl_; | 40 gpu::gles2::GLES2Interface* gl_; |
41 uint32 sync_point_; | |
39 }; | 42 }; |
40 | 43 |
41 } // namespace | 44 } // namespace |
42 | 45 |
43 VideoResourceUpdater::PlaneResource::PlaneResource( | 46 VideoResourceUpdater::PlaneResource::PlaneResource( |
44 unsigned int resource_id, | 47 unsigned int resource_id, |
45 const gfx::Size& resource_size, | 48 const gfx::Size& resource_size, |
46 ResourceFormat resource_format, | 49 ResourceFormat resource_format, |
47 gpu::Mailbox mailbox) | 50 gpu::Mailbox mailbox) |
48 : resource_id(resource_id), | 51 : resource_id(resource_id), |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 void VideoResourceUpdater::ReturnTexture( | 371 void VideoResourceUpdater::ReturnTexture( |
369 base::WeakPtr<VideoResourceUpdater> updater, | 372 base::WeakPtr<VideoResourceUpdater> updater, |
370 const scoped_refptr<media::VideoFrame>& video_frame, | 373 const scoped_refptr<media::VideoFrame>& video_frame, |
371 uint32 sync_point, | 374 uint32 sync_point, |
372 bool lost_resource, | 375 bool lost_resource, |
373 BlockingTaskRunner* main_thread_task_runner) { | 376 BlockingTaskRunner* main_thread_task_runner) { |
374 // TODO(dshwang) this case should be forwarded to the decoder as lost | 377 // TODO(dshwang) this case should be forwarded to the decoder as lost |
375 // resource. | 378 // resource. |
376 if (lost_resource || !updater.get()) | 379 if (lost_resource || !updater.get()) |
377 return; | 380 return; |
378 // VideoFrame::UpdateReleaseSyncPoint() creates new sync point using the same | 381 // VideoFrame::UpdateReleaseSyncPoint() creates new sync point using the same |
danakj
2015/04/14 15:56:27
What about this comment? Why is it wrong?
llandwerlin-old
2015/04/14 16:21:54
Thanks, I will update the comment.
It's wrong bec
| |
379 // GL context which created the given |sync_point|, so discard the | 382 // GL context which created the given |sync_point|, so discard the |
380 // |sync_point|. | 383 // |sync_point|. |
381 SyncPointClientImpl client(updater->context_provider_->ContextGL()); | 384 SyncPointClientImpl client(updater->context_provider_->ContextGL(), |
385 sync_point); | |
382 video_frame->UpdateReleaseSyncPoint(&client); | 386 video_frame->UpdateReleaseSyncPoint(&client); |
383 } | 387 } |
384 | 388 |
385 VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( | 389 VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( |
386 const scoped_refptr<media::VideoFrame>& video_frame) { | 390 const scoped_refptr<media::VideoFrame>& video_frame) { |
387 TRACE_EVENT0("cc", "VideoResourceUpdater::CreateForHardwarePlanes"); | 391 TRACE_EVENT0("cc", "VideoResourceUpdater::CreateForHardwarePlanes"); |
388 media::VideoFrame::Format frame_format = video_frame->format(); | 392 media::VideoFrame::Format frame_format = video_frame->format(); |
389 | 393 |
390 DCHECK_EQ(frame_format, media::VideoFrame::NATIVE_TEXTURE); | 394 DCHECK_EQ(frame_format, media::VideoFrame::NATIVE_TEXTURE); |
391 if (frame_format != media::VideoFrame::NATIVE_TEXTURE) | 395 if (frame_format != media::VideoFrame::NATIVE_TEXTURE) |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
452 resource_it->ref_count = 0; | 456 resource_it->ref_count = 0; |
453 updater->DeleteResource(resource_it); | 457 updater->DeleteResource(resource_it); |
454 return; | 458 return; |
455 } | 459 } |
456 | 460 |
457 --resource_it->ref_count; | 461 --resource_it->ref_count; |
458 DCHECK_GE(resource_it->ref_count, 0); | 462 DCHECK_GE(resource_it->ref_count, 0); |
459 } | 463 } |
460 | 464 |
461 } // namespace cc | 465 } // namespace cc |
OLD | NEW |