Chromium Code Reviews| 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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 | 309 |
| 310 int bits_per_channel = video_frame->BitsPerChannel(input_frame_format); | 310 int bits_per_channel = video_frame->BitsPerChannel(input_frame_format); |
| 311 | 311 |
| 312 // Only YUV and Y16 software video frames are supported. | 312 // Only YUV and Y16 software video frames are supported. |
| 313 DCHECK(media::IsYuvPlanar(input_frame_format) || | 313 DCHECK(media::IsYuvPlanar(input_frame_format) || |
| 314 input_frame_format == media::PIXEL_FORMAT_Y16); | 314 input_frame_format == media::PIXEL_FORMAT_Y16); |
| 315 | 315 |
| 316 const bool software_compositor = context_provider_ == NULL; | 316 const bool software_compositor = context_provider_ == NULL; |
| 317 | 317 |
| 318 ResourceFormat output_resource_format; | 318 ResourceFormat output_resource_format; |
| 319 gfx::ColorSpace output_color_space = video_frame->ColorSpace(); | |
| 319 if (input_frame_format == media::PIXEL_FORMAT_Y16) { | 320 if (input_frame_format == media::PIXEL_FORMAT_Y16) { |
| 320 // Unable to display directly as yuv planes so convert it to RGBA for | 321 // Unable to display directly as yuv planes so convert it to RGBA for |
| 321 // compositing. | 322 // compositing. |
| 322 output_resource_format = RGBA_8888; | 323 output_resource_format = RGBA_8888; |
| 324 output_color_space = output_color_space.GetAsFullRangeRGB(); | |
| 323 } else { | 325 } else { |
| 324 // Can be composited directly from yuv planes. | 326 // Can be composited directly from yuv planes. |
| 325 output_resource_format = | 327 output_resource_format = |
| 326 resource_provider_->YuvResourceFormat(bits_per_channel); | 328 resource_provider_->YuvResourceFormat(bits_per_channel); |
| 327 } | 329 } |
| 328 gfx::ColorSpace output_color_space = video_frame->ColorSpace(); | |
| 329 | 330 |
| 330 // If GPU compositing is enabled, but the output resource format | 331 // If GPU compositing is enabled, but the output resource format |
| 331 // returned by the resource provider is RGBA_8888, then a GPU driver | 332 // returned by the resource provider is RGBA_8888, then a GPU driver |
| 332 // bug workaround requires that YUV frames must be converted to RGB | 333 // bug workaround requires that YUV frames must be converted to RGB |
| 333 // before texture upload. | 334 // before texture upload. |
| 334 bool texture_needs_rgb_conversion = | 335 bool texture_needs_rgb_conversion = |
| 335 !software_compositor && | 336 !software_compositor && |
| 336 output_resource_format == ResourceFormat::RGBA_8888; | 337 output_resource_format == ResourceFormat::RGBA_8888; |
| 337 size_t output_plane_count = media::VideoFrame::NumPlanes(input_frame_format); | 338 size_t output_plane_count = media::VideoFrame::NumPlanes(input_frame_format); |
| 338 | 339 |
| 339 // TODO(skaslev): If we're in software compositing mode, we do the YUV -> RGB | 340 // TODO(skaslev): If we're in software compositing mode, we do the YUV -> RGB |
| 340 // conversion here. That involves an extra copy of each frame to a bitmap. | 341 // conversion here. That involves an extra copy of each frame to a bitmap. |
| 341 // Obviously, this is suboptimal and should be addressed once ubercompositor | 342 // Obviously, this is suboptimal and should be addressed once ubercompositor |
| 342 // starts shaping up. | 343 // starts shaping up. |
| 343 if (software_compositor || texture_needs_rgb_conversion) { | 344 if (software_compositor || texture_needs_rgb_conversion) { |
| 344 output_color_space = output_color_space.GetAsFullRangeRGB(); | |
| 345 output_resource_format = kRGBResourceFormat; | 345 output_resource_format = kRGBResourceFormat; |
| 346 output_plane_count = 1; | 346 output_plane_count = 1; |
| 347 bits_per_channel = 8; | 347 bits_per_channel = 8; |
| 348 } | 348 } |
| 349 | 349 |
| 350 // Drop recycled resources that are the wrong format. | 350 // Drop recycled resources that are the wrong format. |
| 351 for (auto it = all_resources_.begin(); it != all_resources_.end();) { | 351 for (auto it = all_resources_.begin(); it != all_resources_.end();) { |
| 352 if (!it->has_refs() && it->resource_format() != output_resource_format) | 352 if (!it->has_refs() && it->resource_format() != output_resource_format) |
| 353 DeleteResource(it++); | 353 DeleteResource(it++); |
| 354 else | 354 else |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 628 external_resources.read_lock_fences_enabled = true; | 628 external_resources.read_lock_fences_enabled = true; |
| 629 } | 629 } |
| 630 gfx::ColorSpace resource_color_space = video_frame->ColorSpace(); | 630 gfx::ColorSpace resource_color_space = video_frame->ColorSpace(); |
| 631 | 631 |
| 632 external_resources.type = | 632 external_resources.type = |
| 633 ResourceTypeForVideoFrame(video_frame.get(), use_stream_video_draw_quad_); | 633 ResourceTypeForVideoFrame(video_frame.get(), use_stream_video_draw_quad_); |
| 634 if (external_resources.type == VideoFrameExternalResources::NONE) { | 634 if (external_resources.type == VideoFrameExternalResources::NONE) { |
| 635 DLOG(ERROR) << "Unsupported Texture format" | 635 DLOG(ERROR) << "Unsupported Texture format" |
| 636 << media::VideoPixelFormatToString(video_frame->format()); | 636 << media::VideoPixelFormatToString(video_frame->format()); |
| 637 return external_resources; | 637 return external_resources; |
| 638 } | 638 } |
|
ccameron
2017/04/07 00:04:01
This is the root of the bug.
I don't see how this
hubbe
2017/04/07 00:19:31
Acknowledged.
| |
| 639 if (external_resources.type == VideoFrameExternalResources::YUV_RESOURCE) | 639 if (external_resources.type == VideoFrameExternalResources::RGB_RESOURCE) |
| 640 resource_color_space = resource_color_space.GetAsFullRangeRGB(); | 640 resource_color_space = resource_color_space.GetAsFullRangeRGB(); |
| 641 | 641 |
| 642 const size_t num_planes = media::VideoFrame::NumPlanes(video_frame->format()); | 642 const size_t num_planes = media::VideoFrame::NumPlanes(video_frame->format()); |
| 643 for (size_t i = 0; i < num_planes; ++i) { | 643 for (size_t i = 0; i < num_planes; ++i) { |
| 644 const gpu::MailboxHolder& mailbox_holder = video_frame->mailbox_holder(i); | 644 const gpu::MailboxHolder& mailbox_holder = video_frame->mailbox_holder(i); |
| 645 if (mailbox_holder.mailbox.IsZero()) | 645 if (mailbox_holder.mailbox.IsZero()) |
| 646 break; | 646 break; |
| 647 | 647 |
| 648 if (video_frame->metadata()->IsTrue( | 648 if (video_frame->metadata()->IsTrue( |
| 649 media::VideoFrameMetadata::COPY_REQUIRED)) { | 649 media::VideoFrameMetadata::COPY_REQUIRED)) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 699 if (lost_resource) { | 699 if (lost_resource) { |
| 700 resource_it->clear_refs(); | 700 resource_it->clear_refs(); |
| 701 updater->DeleteResource(resource_it); | 701 updater->DeleteResource(resource_it); |
| 702 return; | 702 return; |
| 703 } | 703 } |
| 704 | 704 |
| 705 resource_it->remove_ref(); | 705 resource_it->remove_ref(); |
| 706 } | 706 } |
| 707 | 707 |
| 708 } // namespace cc | 708 } // namespace cc |
| OLD | NEW |