Commit 2949cca9 authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[graphics][cleanup] Avoid use of ArrayBufferContents::DataHandle

It seems to me that the additional step of first creating a DataHandle
was used to handle the case where allocation fails. However, this is
also possible by creating an ArrayBufferContents directly.

Bug: chromium:1008840
Change-Id: If2dde91b411157721dacc8257f9ab2a08bf48048
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1865159Reviewed-by: default avatarFlorin Malita <fmalita@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706454}
parent a88c5fe6
......@@ -97,12 +97,14 @@ bool StaticBitmapImage::ConvertToArrayBufferContents(
int alloc_size_in_bytes = data_size.ValueOrDie();
if (!src_image) {
auto data = WTF::ArrayBufferContents::CreateDataHandle(
alloc_size_in_bytes, WTF::ArrayBufferContents::kZeroInitialize);
if (!data)
WTF::ArrayBufferContents result(alloc_size_in_bytes, 1,
WTF::ArrayBufferContents::kNotShared,
WTF::ArrayBufferContents::kZeroInitialize);
// Check if the ArrayBuffer backing store was allocated correctly.
if (result.DataLength() != static_cast<size_t>(alloc_size_in_bytes)) {
return false;
WTF::ArrayBufferContents result(std::move(data),
WTF::ArrayBufferContents::kNotShared);
}
result.Transfer(dest_contents);
return true;
}
......@@ -115,12 +117,14 @@ bool StaticBitmapImage::ConvertToArrayBufferContents(
WTF::ArrayBufferContents::InitializationPolicy initialization_policy =
may_have_stray_area ? WTF::ArrayBufferContents::kZeroInitialize
: WTF::ArrayBufferContents::kDontInitialize;
auto data = WTF::ArrayBufferContents::CreateDataHandle(alloc_size_in_bytes,
initialization_policy);
if (!data)
WTF::ArrayBufferContents result(alloc_size_in_bytes, 1,
WTF::ArrayBufferContents::kNotShared,
initialization_policy);
// Check if the ArrayBuffer backing store was allocated correctly.
if (result.DataLength() != static_cast<size_t>(alloc_size_in_bytes)) {
return false;
WTF::ArrayBufferContents result(std::move(data),
WTF::ArrayBufferContents::kNotShared);
}
SkColorType color_type =
(color_params.GetSkColorType() == kRGBA_F16_SkColorType)
......
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