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

Side by Side Diff: cc/resources/video_resource_updater.cc

Issue 2683763003: cc: make resource keep video buffer format for hardware overlay.
Patch Set: make Resource keep video buffer format Created 3 years, 8 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 void VideoResourceUpdater::PlaneResource::SetUniqueId(int unique_frame_id, 154 void VideoResourceUpdater::PlaneResource::SetUniqueId(int unique_frame_id,
155 size_t plane_index) { 155 size_t plane_index) {
156 DCHECK_EQ(ref_count_, 1); 156 DCHECK_EQ(ref_count_, 1);
157 plane_index_ = plane_index; 157 plane_index_ = plane_index;
158 unique_frame_id_ = unique_frame_id; 158 unique_frame_id_ = unique_frame_id;
159 has_unique_frame_id_and_plane_index_ = true; 159 has_unique_frame_id_and_plane_index_ = true;
160 } 160 }
161 161
162 VideoFrameExternalResources::VideoFrameExternalResources() 162 VideoFrameExternalResources::VideoFrameExternalResources()
163 : type(NONE), 163 : type(NONE),
164 pixel_format(media::PIXEL_FORMAT_UNKNOWN),
164 read_lock_fences_enabled(false), 165 read_lock_fences_enabled(false),
165 offset(0.0f), 166 offset(0.0f),
166 multiplier(1.0f), 167 multiplier(1.0f),
167 bits_per_channel(8) {} 168 bits_per_channel(8) {}
168 169
169 VideoFrameExternalResources::VideoFrameExternalResources( 170 VideoFrameExternalResources::VideoFrameExternalResources(
170 const VideoFrameExternalResources& other) = default; 171 const VideoFrameExternalResources& other) = default;
171 172
172 VideoFrameExternalResources::~VideoFrameExternalResources() {} 173 VideoFrameExternalResources::~VideoFrameExternalResources() {}
173 174
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 ResourceList::iterator resource_it = RecycleOrAllocateResource( 372 ResourceList::iterator resource_it = RecycleOrAllocateResource(
372 output_plane_resource_size, output_resource_format, output_color_space, 373 output_plane_resource_size, output_resource_format, output_color_space,
373 software_compositor, is_immutable, video_frame->unique_id(), i); 374 software_compositor, is_immutable, video_frame->unique_id(), i);
374 375
375 resource_it->add_ref(); 376 resource_it->add_ref();
376 plane_resources.push_back(resource_it); 377 plane_resources.push_back(resource_it);
377 } 378 }
378 379
379 VideoFrameExternalResources external_resources; 380 VideoFrameExternalResources external_resources;
380 381
382 external_resources.pixel_format = video_frame->format();
381 external_resources.bits_per_channel = bits_per_channel; 383 external_resources.bits_per_channel = bits_per_channel;
382 384
383 if (software_compositor || texture_needs_rgb_conversion) { 385 if (software_compositor || texture_needs_rgb_conversion) {
384 DCHECK_EQ(plane_resources.size(), 1u); 386 DCHECK_EQ(plane_resources.size(), 1u);
385 PlaneResource& plane_resource = *plane_resources[0]; 387 PlaneResource& plane_resource = *plane_resources[0];
386 DCHECK_EQ(plane_resource.resource_format(), kRGBResourceFormat); 388 DCHECK_EQ(plane_resource.resource_format(), kRGBResourceFormat);
387 DCHECK_EQ(software_compositor, plane_resource.mailbox().IsZero()); 389 DCHECK_EQ(software_compositor, plane_resource.mailbox().IsZero());
388 390
389 if (!plane_resource.Matches(video_frame->unique_id(), 0)) { 391 if (!plane_resource.Matches(video_frame->unique_id(), 0)) {
390 // We need to transfer data from |video_frame| to the plane resource. 392 // We need to transfer data from |video_frame| to the plane resource.
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 } 615 }
614 616
615 VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( 617 VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes(
616 scoped_refptr<media::VideoFrame> video_frame) { 618 scoped_refptr<media::VideoFrame> video_frame) {
617 TRACE_EVENT0("cc", "VideoResourceUpdater::CreateForHardwarePlanes"); 619 TRACE_EVENT0("cc", "VideoResourceUpdater::CreateForHardwarePlanes");
618 DCHECK(video_frame->HasTextures()); 620 DCHECK(video_frame->HasTextures());
619 if (!context_provider_) 621 if (!context_provider_)
620 return VideoFrameExternalResources(); 622 return VideoFrameExternalResources();
621 623
622 VideoFrameExternalResources external_resources; 624 VideoFrameExternalResources external_resources;
625 external_resources.pixel_format = video_frame->format();
623 if (video_frame->metadata()->IsTrue( 626 if (video_frame->metadata()->IsTrue(
624 media::VideoFrameMetadata::READ_LOCK_FENCES_ENABLED)) { 627 media::VideoFrameMetadata::READ_LOCK_FENCES_ENABLED)) {
625 external_resources.read_lock_fences_enabled = true; 628 external_resources.read_lock_fences_enabled = true;
626 } 629 }
627 gfx::ColorSpace resource_color_space = video_frame->ColorSpace(); 630 gfx::ColorSpace resource_color_space = video_frame->ColorSpace();
628 631
629 external_resources.type = ResourceTypeForVideoFrame(video_frame.get()); 632 external_resources.type = ResourceTypeForVideoFrame(video_frame.get());
630 if (external_resources.type == VideoFrameExternalResources::NONE) { 633 if (external_resources.type == VideoFrameExternalResources::NONE) {
631 DLOG(ERROR) << "Unsupported Texture format" 634 DLOG(ERROR) << "Unsupported Texture format"
632 << media::VideoPixelFormatToString(video_frame->format()); 635 << media::VideoPixelFormatToString(video_frame->format());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 if (lost_resource) { 698 if (lost_resource) {
696 resource_it->clear_refs(); 699 resource_it->clear_refs();
697 updater->DeleteResource(resource_it); 700 updater->DeleteResource(resource_it);
698 return; 701 return;
699 } 702 }
700 703
701 resource_it->remove_ref(); 704 resource_it->remove_ref();
702 } 705 }
703 706
704 } // namespace cc 707 } // namespace cc
OLDNEW
« cc/output/overlay_candidate.cc ('K') | « cc/resources/video_resource_updater.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698