| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 void VideoResourceUpdater::PlaneResource::SetUniqueId(int unique_frame_id, | 152 void VideoResourceUpdater::PlaneResource::SetUniqueId(int unique_frame_id, |
| 153 size_t plane_index) { | 153 size_t plane_index) { |
| 154 DCHECK_EQ(ref_count_, 1); | 154 DCHECK_EQ(ref_count_, 1); |
| 155 plane_index_ = plane_index; | 155 plane_index_ = plane_index; |
| 156 unique_frame_id_ = unique_frame_id; | 156 unique_frame_id_ = unique_frame_id; |
| 157 has_unique_frame_id_and_plane_index_ = true; | 157 has_unique_frame_id_and_plane_index_ = true; |
| 158 } | 158 } |
| 159 | 159 |
| 160 VideoFrameExternalResources::VideoFrameExternalResources() | 160 VideoFrameExternalResources::VideoFrameExternalResources() |
| 161 : type(NONE), | 161 : type(NONE), |
| 162 pixel_format(media::PIXEL_FORMAT_UNKNOWN), |
| 162 read_lock_fences_enabled(false), | 163 read_lock_fences_enabled(false), |
| 163 offset(0.0f), | 164 offset(0.0f), |
| 164 multiplier(1.0f), | 165 multiplier(1.0f), |
| 165 bits_per_channel(8) {} | 166 bits_per_channel(8) {} |
| 166 | 167 |
| 167 VideoFrameExternalResources::VideoFrameExternalResources( | 168 VideoFrameExternalResources::VideoFrameExternalResources( |
| 168 const VideoFrameExternalResources& other) = default; | 169 const VideoFrameExternalResources& other) = default; |
| 169 | 170 |
| 170 VideoFrameExternalResources::~VideoFrameExternalResources() {} | 171 VideoFrameExternalResources::~VideoFrameExternalResources() {} |
| 171 | 172 |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 output_plane_resource_size, output_resource_format, | 495 output_plane_resource_size, output_resource_format, |
| 495 video_frame->ColorSpace(), software_compositor, is_immutable, | 496 video_frame->ColorSpace(), software_compositor, is_immutable, |
| 496 video_frame->unique_id(), i); | 497 video_frame->unique_id(), i); |
| 497 | 498 |
| 498 resource_it->add_ref(); | 499 resource_it->add_ref(); |
| 499 plane_resources.push_back(resource_it); | 500 plane_resources.push_back(resource_it); |
| 500 } | 501 } |
| 501 | 502 |
| 502 VideoFrameExternalResources external_resources; | 503 VideoFrameExternalResources external_resources; |
| 503 | 504 |
| 505 external_resources.pixel_format = video_frame->format(); |
| 504 external_resources.bits_per_channel = bits_per_channel; | 506 external_resources.bits_per_channel = bits_per_channel; |
| 505 | 507 |
| 506 if (software_compositor || texture_needs_rgb_conversion) { | 508 if (software_compositor || texture_needs_rgb_conversion) { |
| 507 DCHECK_EQ(plane_resources.size(), 1u); | 509 DCHECK_EQ(plane_resources.size(), 1u); |
| 508 PlaneResource& plane_resource = *plane_resources[0]; | 510 PlaneResource& plane_resource = *plane_resources[0]; |
| 509 DCHECK_EQ(plane_resource.resource_format(), kRGBResourceFormat); | 511 DCHECK_EQ(plane_resource.resource_format(), kRGBResourceFormat); |
| 510 DCHECK_EQ(software_compositor, plane_resource.mailbox().IsZero()); | 512 DCHECK_EQ(software_compositor, plane_resource.mailbox().IsZero()); |
| 511 | 513 |
| 512 if (!plane_resource.Matches(video_frame->unique_id(), 0)) { | 514 if (!plane_resource.Matches(video_frame->unique_id(), 0)) { |
| 513 // We need to transfer data from |video_frame| to the plane resource. | 515 // We need to transfer data from |video_frame| to the plane resource. |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 } | 736 } |
| 735 | 737 |
| 736 VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( | 738 VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( |
| 737 scoped_refptr<media::VideoFrame> video_frame) { | 739 scoped_refptr<media::VideoFrame> video_frame) { |
| 738 TRACE_EVENT0("cc", "VideoResourceUpdater::CreateForHardwarePlanes"); | 740 TRACE_EVENT0("cc", "VideoResourceUpdater::CreateForHardwarePlanes"); |
| 739 DCHECK(video_frame->HasTextures()); | 741 DCHECK(video_frame->HasTextures()); |
| 740 if (!context_provider_) | 742 if (!context_provider_) |
| 741 return VideoFrameExternalResources(); | 743 return VideoFrameExternalResources(); |
| 742 | 744 |
| 743 VideoFrameExternalResources external_resources; | 745 VideoFrameExternalResources external_resources; |
| 746 external_resources.pixel_format = video_frame->format(); |
| 744 if (video_frame->metadata()->IsTrue( | 747 if (video_frame->metadata()->IsTrue( |
| 745 media::VideoFrameMetadata::READ_LOCK_FENCES_ENABLED)) { | 748 media::VideoFrameMetadata::READ_LOCK_FENCES_ENABLED)) { |
| 746 external_resources.read_lock_fences_enabled = true; | 749 external_resources.read_lock_fences_enabled = true; |
| 747 } | 750 } |
| 748 | 751 |
| 749 external_resources.type = ResourceTypeForVideoFrame(video_frame.get()); | 752 external_resources.type = ResourceTypeForVideoFrame(video_frame.get()); |
| 750 if (external_resources.type == VideoFrameExternalResources::NONE) { | 753 if (external_resources.type == VideoFrameExternalResources::NONE) { |
| 751 DLOG(ERROR) << "Unsupported Texture format" | 754 DLOG(ERROR) << "Unsupported Texture format" |
| 752 << media::VideoPixelFormatToString(video_frame->format()); | 755 << media::VideoPixelFormatToString(video_frame->format()); |
| 753 return external_resources; | 756 return external_resources; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 if (lost_resource) { | 815 if (lost_resource) { |
| 813 resource_it->clear_refs(); | 816 resource_it->clear_refs(); |
| 814 updater->DeleteResource(resource_it); | 817 updater->DeleteResource(resource_it); |
| 815 return; | 818 return; |
| 816 } | 819 } |
| 817 | 820 |
| 818 resource_it->remove_ref(); | 821 resource_it->remove_ref(); |
| 819 } | 822 } |
| 820 | 823 |
| 821 } // namespace cc | 824 } // namespace cc |
| OLD | NEW |