Commit 1b9b03f7 authored by Reza.Zakerinasab's avatar Reza.Zakerinasab Committed by Commit Bot

Fix memory allocation issue in DecodingImageGenerator

This change fixes a memory allocation issue that apparently
has caused a memory usage regression in video_VideoDecodeMemoryUsage

Bug: 900455
Change-Id: Idc614a5c5171f3a12585ebd3c8384eddc5be7474
Reviewed-on: https://chromium-review.googlesource.com/c/1312627Reviewed-by: default avatarFernando Serboncini <fserb@chromium.org>
Commit-Queue: Mohammad Reza Zakerinasab <zakerinasab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604600}
parent 51eb7a02
......@@ -130,7 +130,7 @@ bool DecodingImageGenerator::GetPixels(const SkImageInfo& dst_info,
// the requested color type from N32.
SkImageInfo target_info = dst_info;
char* memory = static_cast<char*>(pixels);
std::unique_ptr<char*> memory_ref_ptr;
std::unique_ptr<char[]> memory_ref_ptr;
size_t adjusted_row_bytes = row_bytes;
if ((target_info.colorType() != kN32_SkColorType) &&
(target_info.colorType() != kRGBA_F16_SkColorType)) {
......@@ -141,8 +141,8 @@ bool DecodingImageGenerator::GetPixels(const SkImageInfo& dst_info,
DCHECK_EQ(0ul, row_bytes % dst_info.bytesPerPixel());
adjusted_row_bytes =
target_info.bytesPerPixel() * (row_bytes / dst_info.bytesPerPixel());
memory = new char[target_info.computeMinByteSize()];
memory_ref_ptr = std::make_unique<char*>(memory);
memory_ref_ptr.reset(new char[target_info.computeMinByteSize()]);
memory = memory_ref_ptr.get();
}
// Skip the check for alphaType. blink::ImageFrame may have changed the
......
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