Commit 1ef0d20c authored by jchen10's avatar jchen10 Committed by Chromium LUCI CQ

WEBGL_webcodecs_video_frame: Support software video frame

This uses GpuMemoryBufferVideoFramePool to import software video
frames.

Bug: 1142754
Change-Id: Ic1a7849ca7a833ecf255892ba962ce2207b57546
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2603036Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
Cr-Commit-Position: refs/heads/master@{#841423}
parent 2149a931
......@@ -963,11 +963,18 @@ RendererBlinkPlatformImpl::GetGpuFactories() {
return render_thread->GetGpuFactories();
}
media::DecoderFactory* RendererBlinkPlatformImpl::GetMediaDecoderFactory() {
scoped_refptr<base::SingleThreadTaskRunner>
RendererBlinkPlatformImpl::MediaThreadTaskRunner() {
auto* render_thread = RenderThreadImpl::current();
if (!render_thread)
return nullptr;
return render_thread->GetMediaThreadTaskRunner();
}
media::DecoderFactory* RendererBlinkPlatformImpl::GetMediaDecoderFactory() {
auto* render_thread = RenderThreadImpl::current();
DCHECK(!!render_thread);
return render_thread->GetMediaDecoderFactory();
}
......
......@@ -210,6 +210,7 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
blink::MediaInspectorContext* inspector_context,
scoped_refptr<base::SingleThreadTaskRunner> owner_task_runner) override;
media::GpuVideoAcceleratorFactories* GetGpuFactories() override;
scoped_refptr<base::SingleThreadTaskRunner> MediaThreadTaskRunner() override;
media::DecoderFactory* GetMediaDecoderFactory() override;
void SetRenderingColorSpace(const gfx::ColorSpace& color_space) override;
void SetActiveURL(const blink::WebURL& url,
......
......@@ -387,6 +387,12 @@ class BLINK_PLATFORM_EXPORT Platform {
// once CreateAndSetCompositorThread() is called.
scoped_refptr<base::SingleThreadTaskRunner> CompositorThreadTaskRunner();
// Returns the task runner of the media thread.
// This method should only be called on the main thread, or it crashes.
virtual scoped_refptr<base::SingleThreadTaskRunner> MediaThreadTaskRunner() {
return nullptr;
}
// This is called after the compositor thread is created, so the embedder
// can initiate an IPC to change its thread priority (on Linux we can't
// increase the nice value, so we need to ask the browser process). This
......
......@@ -6,7 +6,7 @@
enum ColorSpacePrimaryID {
"BT709",
"BT407M",
"BT470M",
"BT470BG",
"SMPTE170M",
"SMPTE240M",
......
......@@ -8,6 +8,7 @@ include_rules = [
"+gpu/config/gpu_feature_info.h",
"+media/base/video_frame.h",
"+media/base/wait_and_replace_sync_token_client.h",
"+media/video/gpu_memory_buffer_video_frame_pool.h",
"+skia/ext",
"+third_party/blink/renderer/modules/webcodecs",
"+ui/gl/gpu_preference.h",
......
......@@ -10,6 +10,10 @@
#include "third_party/blink/renderer/modules/webcodecs/video_frame.h"
#include "third_party/blink/renderer/modules/webgl/webgl_extension.h"
namespace media {
class GpuMemoryBufferVideoFramePool;
} // namespace media
namespace blink {
class WebGLWebCodecsVideoFrameHandle;
......@@ -18,6 +22,8 @@ class WebGLWebCodecsVideoFrame final : public WebGLExtension {
DEFINE_WRAPPERTYPEINFO();
public:
~WebGLWebCodecsVideoFrame() override;
static bool Supported(WebGLRenderingContextBase*);
static const char* ExtensionName();
......@@ -36,9 +42,13 @@ class WebGLWebCodecsVideoFrame final : public WebGLExtension {
ExceptionState&);
private:
void OnHardwareVideoFrameCreated(
base::WaitableEvent* waitable_event,
scoped_refptr<media::VideoFrame> video_frame);
void InitializeGpuMemoryBufferPool();
std::bitset<media::PIXEL_FORMAT_MAX + 1> formats_supported;
std::string sampler_type_;
std::string sampler_func_;
std::array<std::array<std::string, media::VideoFrame::kMaxPlanes>,
media::PIXEL_FORMAT_MAX + 1>
format_to_components_map_;
......@@ -47,6 +57,11 @@ class WebGLWebCodecsVideoFrame final : public WebGLExtension {
// This holds the reference for all video frames being imported, but not
// yet released.
VideoFrameHandleMap tex0_to_video_frame_map_;
std::unique_ptr<media::GpuMemoryBufferVideoFramePool> gpu_memory_buffer_pool_;
scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
scoped_refptr<media::VideoFrame> hardware_video_frame_;
};
} // namespace blink
......
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