Commit ea793710 authored by Gil Dekel's avatar Gil Dekel Committed by Commit Bot

gpu/ipc: Adjust IDAProxy to filter simple WebPs

This CL modifies ImageDecodeAcceleratorProxy::IsImageSupported() to
allow simple WebPs decoding. For now, it just verifies that WebP image's
dimensions are within the supported decoding size.

Bug: 877694
Test: TBD
Change-Id: Idcb72d913a369815219401621cc7e45c09f6c430
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1707172
Commit-Queue: Gil Dekel <gildekel@chromium.org>
Reviewed-by: default avatarSunny Sachanandani <sunnyps@chromium.org>
Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Reviewed-by: default avatarAndres Calderon Jaramillo <andrescj@chromium.org>
Reviewed-by: default avatarMiguel Casas <mcasas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680206}
parent f7e301bb
......@@ -12,6 +12,7 @@ specific_include_rules = {
],
"image_decode_accelerator_proxy.cc": [
"+media/parsers/jpeg_parser.h",
"+media/parsers/vp8_parser.h",
"+media/parsers/webp_parser.h",
],
"raster_in_process_context_tests.cc": [
......
......@@ -7,6 +7,7 @@
#include <string.h>
#include <algorithm>
#include <memory>
#include <utility>
#include <vector>
......@@ -18,6 +19,7 @@
#include "gpu/ipc/common/command_buffer_id.h"
#include "gpu/ipc/common/gpu_messages.h"
#include "media/parsers/jpeg_parser.h"
#include "media/parsers/vp8_parser.h"
#include "media/parsers/webp_parser.h"
#include "ui/gfx/color_space.h"
#include "ui/gfx/geometry/size.h"
......@@ -127,6 +129,27 @@ bool IsSupportedJpegImage(
return true;
}
bool IsSupportedWebPImage(
base::span<const uint8_t> encoded_data,
const ImageDecodeAcceleratorSupportedProfile& supported_profile) {
DCHECK(media::IsLossyWebPImage(encoded_data));
DCHECK_EQ(ImageDecodeAcceleratorType::kWebP, supported_profile.image_type);
const std::unique_ptr<media::Vp8FrameHeader> parse_result =
media::ParseWebPImage(encoded_data);
if (!parse_result)
return false;
// TODO(crbug.com/984971): we may need to compute the coded size instead and
// check that against the supported dimensions.
const int width = base::strict_cast<int>(parse_result->width);
const int height = base::strict_cast<int>(parse_result->height);
return width >= supported_profile.min_encoded_dimensions.width() &&
height >= supported_profile.min_encoded_dimensions.height() &&
width <= supported_profile.max_encoded_dimensions.width() &&
height <= supported_profile.max_encoded_dimensions.height();
}
} // namespace
ImageDecodeAcceleratorProxy::ImageDecodeAcceleratorProxy(GpuChannelHost* host,
......@@ -156,10 +179,15 @@ bool ImageDecodeAcceleratorProxy::IsImageSupported(
return false;
// Validate the image according to that profile.
if (image_type == ImageDecodeAcceleratorType::kJpeg)
return IsSupportedJpegImage(encoded_data, *profile_it);
NOTREACHED();
switch (image_type) {
case ImageDecodeAcceleratorType::kJpeg:
return IsSupportedJpegImage(encoded_data, *profile_it);
case ImageDecodeAcceleratorType::kWebP:
return IsSupportedWebPImage(encoded_data, *profile_it);
case ImageDecodeAcceleratorType::kUnknown:
// No Op. Should not reach due to a check above.
break;
}
return false;
}
......
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