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

Unified Diff: cc/resources/video_resource_updater.cc

Issue 2418173002: Fix HTML5 video blurry (Closed)
Patch Set: add pixeltests Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: cc/resources/video_resource_updater.cc
diff --git a/cc/resources/video_resource_updater.cc b/cc/resources/video_resource_updater.cc
index 9fe434f3837211b63d4ded74b8b39ced0a398b20..fcdd1c1c484c1706b48e2924de31008dcc0e479d 100644
--- a/cc/resources/video_resource_updater.cc
+++ b/cc/resources/video_resource_updater.cc
@@ -309,6 +309,24 @@ void VideoResourceUpdater::MakeHalfFloats(const uint16_t* src,
libyuv::HalfFloatPlane(src, stride, dst, stride, 1.0f / max_value, num, rows);
}
+ResourceFormat VideoResourceUpdater::YuvResourceFormat(int bits) const {
dshwang 2016/10/18 19:14:36 Move this logic from ResourceProvider because 1. t
+ if (!context_provider_)
+ return LUMINANCE_8;
+
+ 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");
@@ -367,18 +385,21 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes(
return VideoFrameExternalResources();
}
- const bool software_compositor = context_provider_ == NULL;
+ 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 =
- resource_provider_->YuvResourceFormat(bits_per_channel);
+ ResourceFormat output_resource_format = YuvResourceFormat(bits_per_channel);
// 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;
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
@@ -454,7 +475,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],
@@ -474,7 +497,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);
dshwang 2016/10/18 19:14:36 This hidden bug is covered by VideoGLRendererPixel
mailbox.set_color_space(video_frame->ColorSpace());
external_resources.mailboxes.push_back(mailbox);
external_resources.release_callbacks.push_back(base::Bind(
@@ -488,7 +512,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));
if (!plane_resource.Matches(video_frame->unique_id(), i)) {
// TODO(hubbe): Move all conversion (and upload?) code to media/.

Powered by Google App Engine
This is Rietveld 408576698