Commit 8477ed3e authored by Dale Curtis's avatar Dale Curtis Committed by Commit Bot

Enable support for I420A VideoFrame objects.

This always uses the unaccelerated path right now, if we find these
cases are common, we will need to improve VideoFrameYUVConverter so the
hardware based conversion process works.

Note: This inlines the preferAcceleratedImageBitmap() function to make
it more clear when the accelerated path is preferred.

R=sandersd

Bug: 1148800
Change-Id: I8f669ade90d9f4133ffe15a63c8c47d22a1dc286
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2542671
Auto-Submit: Dale Curtis <dalecurtis@chromium.org>
Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828025}
parent 5f965480
...@@ -379,12 +379,6 @@ IntSize VideoFrame::BitmapSourceSize() const { ...@@ -379,12 +379,6 @@ IntSize VideoFrame::BitmapSourceSize() const {
return IntSize(cropWidth(), cropHeight()); return IntSize(cropWidth(), cropHeight());
} }
bool VideoFrame::preferAcceleratedImageBitmap() const {
auto local_frame = frame();
return BitmapSourceSize().Area() > kCpuEfficientFrameSize ||
(local_frame && local_frame->HasTextures());
}
ScriptPromise VideoFrame::CreateImageBitmap(ScriptState* script_state, ScriptPromise VideoFrame::CreateImageBitmap(ScriptState* script_state,
base::Optional<IntRect> crop_rect, base::Optional<IntRect> crop_rect,
const ImageBitmapOptions* options, const ImageBitmapOptions* options,
...@@ -399,7 +393,8 @@ ScriptPromise VideoFrame::CreateImageBitmap(ScriptState* script_state, ...@@ -399,7 +393,8 @@ ScriptPromise VideoFrame::CreateImageBitmap(ScriptState* script_state,
} }
if ((local_frame->IsMappable() && if ((local_frame->IsMappable() &&
(local_frame->format() == media::PIXEL_FORMAT_I420)) || (local_frame->format() == media::PIXEL_FORMAT_I420 ||
local_frame->format() == media::PIXEL_FORMAT_I420A)) ||
(local_frame->HasTextures() && (local_frame->HasTextures() &&
(local_frame->format() == media::PIXEL_FORMAT_I420 || (local_frame->format() == media::PIXEL_FORMAT_I420 ||
local_frame->format() == media::PIXEL_FORMAT_NV12 || local_frame->format() == media::PIXEL_FORMAT_NV12 ||
...@@ -414,7 +409,12 @@ ScriptPromise VideoFrame::CreateImageBitmap(ScriptState* script_state, ...@@ -414,7 +409,12 @@ ScriptPromise VideoFrame::CreateImageBitmap(ScriptState* script_state,
sk_color_space = SkColorSpace::MakeSRGB(); sk_color_space = SkColorSpace::MakeSRGB();
} }
if (!preferAcceleratedImageBitmap()) { const bool prefer_accelerated_image_bitmap =
local_frame->format() != media::PIXEL_FORMAT_I420A &&
(BitmapSourceSize().Area() > kCpuEfficientFrameSize ||
local_frame->HasTextures());
if (!prefer_accelerated_image_bitmap) {
size_t bytes_per_row = sizeof(SkColor) * cropWidth(); size_t bytes_per_row = sizeof(SkColor) * cropWidth();
size_t image_pixels_size = bytes_per_row * cropHeight(); size_t image_pixels_size = bytes_per_row * cropHeight();
......
...@@ -87,7 +87,6 @@ class MODULES_EXPORT VideoFrame final : public ScriptWrappable, ...@@ -87,7 +87,6 @@ class MODULES_EXPORT VideoFrame final : public ScriptWrappable,
// ImageBitmapSource implementation // ImageBitmapSource implementation
static constexpr uint64_t kCpuEfficientFrameSize = 320u * 240u; static constexpr uint64_t kCpuEfficientFrameSize = 320u * 240u;
IntSize BitmapSourceSize() const override; IntSize BitmapSourceSize() const override;
bool preferAcceleratedImageBitmap() const;
ScriptPromise CreateImageBitmap(ScriptState*, ScriptPromise CreateImageBitmap(ScriptState*,
base::Optional<IntRect> crop_rect, base::Optional<IntRect> crop_rect,
const ImageBitmapOptions*, const ImageBitmapOptions*,
......
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