| Index: cc/resources/video_resource_updater.cc
|
| diff --git a/cc/resources/video_resource_updater.cc b/cc/resources/video_resource_updater.cc
|
| index 2ea3f4691eaeee32cbf94f12bde5951088415aeb..e713c5d5857f90112eacee81246a6fb5427e9996 100644
|
| --- a/cc/resources/video_resource_updater.cc
|
| +++ b/cc/resources/video_resource_updater.cc
|
| @@ -379,6 +379,32 @@ VideoResourceUpdater::NewHalfFloatMaker(int bits_per_channel) {
|
| }
|
| }
|
|
|
| +ResourceFormat VideoResourceUpdater::YuvResourceFormat(
|
| + int bits,
|
| + media::VideoPixelFormat format) const {
|
| + if (!context_provider_)
|
| + return RGBA_8888;
|
| +
|
| + if (format == media::PIXEL_FORMAT_Y16) {
|
| + // Unable to display directly as yuv planes so convert it to RGBA for
|
| + // compositing.
|
| + return RGBA_8888;
|
| + }
|
| +
|
| + const auto caps = context_provider_->ContextCapabilities();
|
| + if (caps.disable_one_component_textures)
|
| + return RGBA_8888;
|
| +
|
| + ResourceFormat yuv_resource_format = caps.texture_rg ? RED_8 : LUMINANCE_8;
|
| + if (bits <= 8)
|
| + return yuv_resource_format;
|
| +
|
| + if (caps.texture_half_float_linear)
|
| + return LUMINANCE_F16;
|
| +
|
| + return yuv_resource_format;
|
| +}
|
| +
|
| VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes(
|
| scoped_refptr<media::VideoFrame> video_frame) {
|
| TRACE_EVENT0("cc", "VideoResourceUpdater::CreateForSoftwarePlanes");
|
| @@ -432,26 +458,23 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes(
|
| DCHECK(media::IsYuvPlanar(input_frame_format) ||
|
| input_frame_format == media::PIXEL_FORMAT_Y16);
|
|
|
| - const bool software_compositor = context_provider_ == NULL;
|
| -
|
| - ResourceFormat output_resource_format;
|
| - if (input_frame_format == media::PIXEL_FORMAT_Y16) {
|
| - // Unable to display directly as yuv planes so convert it to RGBA for
|
| - // compositing.
|
| - output_resource_format = RGBA_8888;
|
| - } else {
|
| - // Can be composited directly from yuv planes.
|
| - output_resource_format =
|
| - resource_provider_->YuvResourceFormat(bits_per_channel);
|
| + const bool software_compositor = context_provider_ == nullptr;
|
| + bool disable_one_component_textures = true;
|
| + if (!software_compositor) {
|
| + const auto caps = context_provider_->ContextCapabilities();
|
| + disable_one_component_textures = caps.disable_one_component_textures;
|
| }
|
|
|
| + ResourceFormat output_resource_format =
|
| + YuvResourceFormat(bits_per_channel, input_frame_format);
|
| +
|
| // If GPU compositing is enabled, but the output resource format
|
| // returned by the resource provider is RGBA_8888, then a GPU driver
|
| // bug workaround requires that YUV frames must be converted to RGB
|
| // before texture upload.
|
| bool texture_needs_rgb_conversion =
|
| - !software_compositor &&
|
| - output_resource_format == ResourceFormat::RGBA_8888;
|
| + (!software_compositor && disable_one_component_textures) ||
|
| + input_frame_format == media::PIXEL_FORMAT_Y16;
|
| size_t output_plane_count = media::VideoFrame::NumPlanes(input_frame_format);
|
|
|
| // TODO(skaslev): If we're in software compositing mode, we do the YUV -> RGB
|
| @@ -459,7 +482,7 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes(
|
| // Obviously, this is suboptimal and should be addressed once ubercompositor
|
| // starts shaping up.
|
| if (software_compositor || texture_needs_rgb_conversion) {
|
| - output_resource_format = kRGBResourceFormat;
|
| + DCHECK_EQ(output_resource_format, kRGBResourceFormat);
|
| output_plane_count = 1;
|
| bits_per_channel = 8;
|
| }
|
| @@ -527,7 +550,9 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes(
|
| upload_pixels_.resize(needed_size);
|
|
|
| media::SkCanvasVideoRenderer::ConvertVideoFrameToRGBPixels(
|
| - video_frame.get(), &upload_pixels_[0], bytes_per_row);
|
| + video_frame.get(),
|
| + media::SkCanvasVideoRenderer::ConvertingSize::CODED,
|
| + &upload_pixels_[0], bytes_per_row);
|
|
|
| resource_provider_->CopyToResource(plane_resource.resource_id(),
|
| &upload_pixels_[0],
|
| @@ -547,7 +572,8 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes(
|
| // a sync token is not required.
|
| TextureMailbox mailbox(plane_resource.mailbox(), gpu::SyncToken(),
|
| resource_provider_->GetResourceTextureTarget(
|
| - plane_resource.resource_id()));
|
| + plane_resource.resource_id()),
|
| + plane_resource.resource_size(), false, false);
|
| mailbox.set_color_space(video_frame->ColorSpace());
|
| external_resources.mailboxes.push_back(mailbox);
|
| external_resources.release_callbacks.push_back(base::Bind(
|
| @@ -558,7 +584,7 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes(
|
| }
|
|
|
| std::unique_ptr<HalfFloatMaker> half_float_maker;
|
| - if (resource_provider_->YuvResourceFormat(bits_per_channel) ==
|
| + if (YuvResourceFormat(bits_per_channel, input_frame_format) ==
|
| LUMINANCE_F16) {
|
| half_float_maker = NewHalfFloatMaker(bits_per_channel);
|
| external_resources.offset = half_float_maker->Offset();
|
| @@ -569,7 +595,7 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes(
|
| PlaneResource& plane_resource = *plane_resources[i];
|
| // Update each plane's resource id with its content.
|
| DCHECK_EQ(plane_resource.resource_format(),
|
| - resource_provider_->YuvResourceFormat(bits_per_channel));
|
| + YuvResourceFormat(bits_per_channel, input_frame_format));
|
|
|
| if (!plane_resource.Matches(video_frame->unique_id(), i)) {
|
| // TODO(hubbe): Move all conversion (and upload?) code to media/.
|
|
|