Commit ab083380 authored by Yan, Shaobo's avatar Yan, Shaobo Committed by Chromium LUCI CQ

WebGL: Combine video uploading path by using SkSurface

This CL replace SkImage::MakeFromYUVATexturesCopyToExternal with
Sksurface. This will combine all of the uploading path to the
same logic and remove duplicated codes.

This CL also change the incorrect condition to try direct uploading
path on Windows.

BUG=1108154

Change-Id: Iaa44d23e984b192f4c3b38aa52c7d22dea879748
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2559649Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Reviewed-by: default avatarBrian Salomon <bsalomon@google.com>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
Cr-Commit-Position: refs/heads/master@{#833551}
parent 762e8d3b
......@@ -1369,8 +1369,13 @@ bool PaintCanvasVideoRenderer::CopyVideoFrameTexturesToGLTexture(
// TODO(crbug.com/1108154): Expand this uploading path to macOS, linux
// chromeOS after collecting perf data and resolve failure cases.
#if defined(OS_WIN)
// Try direct uploading path
if (premultiply_alpha && level == 0) {
// Since skia always produces premultiply alpha outputs,
// trying direct uploading path when video format is opaque or premultiply
// alpha been requested. And dst texture mipLevel must be 0.
// TODO(crbug.com/1155003): Figure out whether premultiply options here are
// accurate.
if ((media::IsOpaque(video_frame->format()) || premultiply_alpha) &&
level == 0) {
if (UploadVideoFrameToGLTexture(raster_context_provider, destination_gl,
video_frame, target, texture,
internal_format, format, type, flip_y)) {
......@@ -1483,7 +1488,7 @@ bool PaintCanvasVideoRenderer::UploadVideoFrameToGLTexture(
destination_gl->GenUnverifiedSyncTokenCHROMIUM(
mailbox_holder.sync_token.GetData());
if (!VideoFrameYUVConverter::ConvertYUVVideoFrameWithSkSurfaceNoCaching(
if (!VideoFrameYUVConverter::ConvertYUVVideoFrameToDstTextureNoCaching(
video_frame.get(), raster_context_provider, mailbox_holder,
internal_format, type, flip_y, true /* use visible_rect */)) {
return false;
......
......@@ -7,6 +7,7 @@
#include <array>
#include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/common/mailbox_holder.h"
#include "media/base/media_export.h"
#include "ui/gfx/color_space.h"
......@@ -34,7 +35,7 @@ class MEDIA_EXPORT VideoFrameYUVConverter {
public:
static bool IsVideoFrameFormatSupported(const VideoFrame& video_frame);
static void ConvertYUVVideoFrameNoCaching(
static bool ConvertYUVVideoFrameNoCaching(
const VideoFrame* video_frame,
viz::RasterContextProvider* raster_context_provider,
const gpu::MailboxHolder& dest_mailbox_holder);
......@@ -42,7 +43,7 @@ class MEDIA_EXPORT VideoFrameYUVConverter {
// TODO(crbug.com/1108154): Will merge this uploading path
// with ConvertYUVVideoFrameYUVWithGrContext after solving
// issue 1120911, 1120912
static bool ConvertYUVVideoFrameWithSkSurfaceNoCaching(
static bool ConvertYUVVideoFrameToDstTextureNoCaching(
const VideoFrame* video_frame,
viz::RasterContextProvider* raster_context_provider,
const gpu::MailboxHolder& dest_mailbox_holder,
......@@ -54,25 +55,29 @@ class MEDIA_EXPORT VideoFrameYUVConverter {
VideoFrameYUVConverter();
~VideoFrameYUVConverter();
void ConvertYUVVideoFrame(const VideoFrame* video_frame,
bool ConvertYUVVideoFrame(const VideoFrame* video_frame,
viz::RasterContextProvider* raster_context_provider,
const gpu::MailboxHolder& dest_mailbox_holder);
const gpu::MailboxHolder& dest_mailbox_holder,
unsigned int internal_format = GL_RGBA,
unsigned int type = GL_UNSIGNED_BYTE,
bool flip_y = false,
bool use_visible_rect = false);
void ReleaseCachedData();
private:
void ConvertFromVideoFrameYUVWithGrContext(
bool ConvertFromVideoFrameYUVWithGrContext(
const VideoFrame* video_frame,
viz::RasterContextProvider* raster_context_provider,
const gpu::MailboxHolder& dest_mailbox_holder);
void ConvertFromVideoFrameYUVSkia(
const gpu::MailboxHolder& dest_mailbox_holder,
unsigned int internal_format,
unsigned int type,
bool flip_y,
bool use_visible_rect);
bool ConvertFromVideoFrameYUVSkia(
const VideoFrame* video_frame,
viz::RasterContextProvider* raster_context_provider,
unsigned int texture_target,
unsigned int texture_id);
bool ConvertYUVVideoFrameWithSkSurface(
const VideoFrame* video_frame,
viz::RasterContextProvider* raster_context_provider,
const gpu::MailboxHolder& dest_mailbox_holder,
unsigned int texture_id,
unsigned int internal_format,
unsigned int type,
bool flip_y,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment