| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 // | 507 // |
| 508 // PLEASE NOTE: This doesn't work if bits_per_channel is > 10. | 508 // PLEASE NOTE: This doesn't work if bits_per_channel is > 10. |
| 509 // PLEASE NOTE: All planes are assumed to use the same multiplier/offset. | 509 // PLEASE NOTE: All planes are assumed to use the same multiplier/offset. |
| 510 external_resources.offset = 0.5f; | 510 external_resources.offset = 0.5f; |
| 511 // Max value from input data. | 511 // Max value from input data. |
| 512 int max_input_value = (1 << bits_per_channel) - 1; | 512 int max_input_value = (1 << bits_per_channel) - 1; |
| 513 // 2 << 11 = 2048 would be 1.0 with our exponent. | 513 // 2 << 11 = 2048 would be 1.0 with our exponent. |
| 514 external_resources.multiplier = 2048.0 / max_input_value; | 514 external_resources.multiplier = 2048.0 / max_input_value; |
| 515 } | 515 } |
| 516 | 516 |
| 517 external_resources.mailboxes.push_back( | 517 TextureMailbox mailbox(plane_resource.mailbox(), gpu::SyncToken(), |
| 518 TextureMailbox(plane_resource.mailbox(), gpu::SyncToken(), | 518 resource_provider_->GetResourceTextureTarget( |
| 519 resource_provider_->GetResourceTextureTarget( | 519 plane_resource.resource_id())); |
| 520 plane_resource.resource_id()))); | 520 mailbox.set_color_space(video_frame->ColorSpace()); |
| 521 external_resources.mailboxes.push_back(mailbox); |
| 521 external_resources.release_callbacks.push_back(base::Bind( | 522 external_resources.release_callbacks.push_back(base::Bind( |
| 522 &RecycleResource, AsWeakPtr(), plane_resource.resource_id())); | 523 &RecycleResource, AsWeakPtr(), plane_resource.resource_id())); |
| 523 } | 524 } |
| 524 | 525 |
| 525 external_resources.type = VideoFrameExternalResources::YUV_RESOURCE; | 526 external_resources.type = VideoFrameExternalResources::YUV_RESOURCE; |
| 526 return external_resources; | 527 return external_resources; |
| 527 } | 528 } |
| 528 | 529 |
| 529 // static | 530 // static |
| 530 void VideoResourceUpdater::ReturnTexture( | 531 void VideoResourceUpdater::ReturnTexture( |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 | 602 |
| 602 // Sync point for use of frame copy. | 603 // Sync point for use of frame copy. |
| 603 gpu::SyncToken sync_token; | 604 gpu::SyncToken sync_token; |
| 604 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); | 605 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); |
| 605 gl->ShallowFlushCHROMIUM(); | 606 gl->ShallowFlushCHROMIUM(); |
| 606 gl->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 607 gl->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
| 607 | 608 |
| 608 // Done with the source video frame texture at this point. | 609 // Done with the source video frame texture at this point. |
| 609 video_frame->UpdateReleaseSyncToken(&client); | 610 video_frame->UpdateReleaseSyncToken(&client); |
| 610 | 611 |
| 611 external_resources->mailboxes.push_back( | 612 TextureMailbox mailbox(resource->mailbox(), sync_token, GL_TEXTURE_2D, |
| 612 TextureMailbox(resource->mailbox(), sync_token, GL_TEXTURE_2D, | 613 video_frame->coded_size(), false, false); |
| 613 video_frame->coded_size(), false, false)); | 614 mailbox.set_color_space(video_frame->ColorSpace()); |
| 615 external_resources->mailboxes.push_back(mailbox); |
| 614 | 616 |
| 615 external_resources->release_callbacks.push_back( | 617 external_resources->release_callbacks.push_back( |
| 616 base::Bind(&RecycleResource, AsWeakPtr(), resource->resource_id())); | 618 base::Bind(&RecycleResource, AsWeakPtr(), resource->resource_id())); |
| 617 } | 619 } |
| 618 | 620 |
| 619 VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( | 621 VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( |
| 620 scoped_refptr<media::VideoFrame> video_frame) { | 622 scoped_refptr<media::VideoFrame> video_frame) { |
| 621 TRACE_EVENT0("cc", "VideoResourceUpdater::CreateForHardwarePlanes"); | 623 TRACE_EVENT0("cc", "VideoResourceUpdater::CreateForHardwarePlanes"); |
| 622 DCHECK(video_frame->HasTextures()); | 624 DCHECK(video_frame->HasTextures()); |
| 623 if (!context_provider_) | 625 if (!context_provider_) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 639 const size_t num_planes = media::VideoFrame::NumPlanes(video_frame->format()); | 641 const size_t num_planes = media::VideoFrame::NumPlanes(video_frame->format()); |
| 640 for (size_t i = 0; i < num_planes; ++i) { | 642 for (size_t i = 0; i < num_planes; ++i) { |
| 641 const gpu::MailboxHolder& mailbox_holder = video_frame->mailbox_holder(i); | 643 const gpu::MailboxHolder& mailbox_holder = video_frame->mailbox_holder(i); |
| 642 if (mailbox_holder.mailbox.IsZero()) | 644 if (mailbox_holder.mailbox.IsZero()) |
| 643 break; | 645 break; |
| 644 | 646 |
| 645 if (video_frame->metadata()->IsTrue( | 647 if (video_frame->metadata()->IsTrue( |
| 646 media::VideoFrameMetadata::COPY_REQUIRED)) { | 648 media::VideoFrameMetadata::COPY_REQUIRED)) { |
| 647 CopyPlaneTexture(video_frame.get(), mailbox_holder, &external_resources); | 649 CopyPlaneTexture(video_frame.get(), mailbox_holder, &external_resources); |
| 648 } else { | 650 } else { |
| 649 external_resources.mailboxes.push_back(TextureMailbox( | 651 TextureMailbox mailbox(mailbox_holder.mailbox, mailbox_holder.sync_token, |
| 650 mailbox_holder.mailbox, mailbox_holder.sync_token, | 652 mailbox_holder.texture_target, |
| 651 mailbox_holder.texture_target, video_frame->coded_size(), | 653 video_frame->coded_size(), |
| 652 video_frame->metadata()->IsTrue( | 654 video_frame->metadata()->IsTrue( |
| 653 media::VideoFrameMetadata::ALLOW_OVERLAY), | 655 media::VideoFrameMetadata::ALLOW_OVERLAY), |
| 654 false)); | 656 false); |
| 655 | 657 mailbox.set_color_space(video_frame->ColorSpace()); |
| 658 external_resources.mailboxes.push_back(mailbox); |
| 656 external_resources.release_callbacks.push_back( | 659 external_resources.release_callbacks.push_back( |
| 657 base::Bind(&ReturnTexture, AsWeakPtr(), video_frame)); | 660 base::Bind(&ReturnTexture, AsWeakPtr(), video_frame)); |
| 658 } | 661 } |
| 659 } | 662 } |
| 660 return external_resources; | 663 return external_resources; |
| 661 } | 664 } |
| 662 | 665 |
| 663 // static | 666 // static |
| 664 void VideoResourceUpdater::RecycleResource( | 667 void VideoResourceUpdater::RecycleResource( |
| 665 base::WeakPtr<VideoResourceUpdater> updater, | 668 base::WeakPtr<VideoResourceUpdater> updater, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 689 if (lost_resource) { | 692 if (lost_resource) { |
| 690 resource_it->clear_refs(); | 693 resource_it->clear_refs(); |
| 691 updater->DeleteResource(resource_it); | 694 updater->DeleteResource(resource_it); |
| 692 return; | 695 return; |
| 693 } | 696 } |
| 694 | 697 |
| 695 resource_it->remove_ref(); | 698 resource_it->remove_ref(); |
| 696 } | 699 } |
| 697 | 700 |
| 698 } // namespace cc | 701 } // namespace cc |
| OLD | NEW |