Commit b8e15ca8 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[image_decode_bench] Remove use of SharedBuffer::Data()

SharedBuffer::Data() is deprecated, and was being used to consolidate
the buffer into one contiguous piece of memory. This is now redundant
since the ShardBuffer is created in ReadFile() by adopting the Vector
of image data (which is a contiguous piece of memory under the hood).

Remove the SharedBuffer::Data() call, move the related error handling
for ReadFile() back into that routine.

Bug: 601198
Change-Id: Ic0eab97ead78a967180d1ee6bdcb708e3cc3a4e5
Reviewed-on: https://chromium-review.googlesource.com/956644Reviewed-by: default avatarLeon Scroggins <scroggo@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542102}
parent 2ebefc34
...@@ -40,11 +40,13 @@ scoped_refptr<SharedBuffer> ReadFile(const char* name) { ...@@ -40,11 +40,13 @@ scoped_refptr<SharedBuffer> ReadFile(const char* name) {
} }
file.seekg(0, std::ios::end); file.seekg(0, std::ios::end);
size_t file_size = file.tellg(); int file_size = file.tellg();
file.seekg(0, std::ios::beg); file.seekg(0, std::ios::beg);
if (!file || !file_size) if (!file || file_size <= 0) {
return SharedBuffer::Create(); fprintf(stderr, "Error seeking file %s\n", name);
exit(2);
}
Vector<char> buffer(file_size); Vector<char> buffer(file_size);
if (!file.read(buffer.data(), file_size)) { if (!file.read(buffer.data(), file_size)) {
...@@ -126,21 +128,11 @@ int ImageDecodeBenchMain(int argc, char* argv[]) { ...@@ -126,21 +128,11 @@ int ImageDecodeBenchMain(int argc, char* argv[]) {
class WebPlatform : public Platform {}; class WebPlatform : public Platform {};
Platform::Initialize(new WebPlatform()); Platform::Initialize(new WebPlatform());
// Read entire file content to data, and consolidate the SharedBuffer data // Read entire file content into |data| (a contiguous block of memory) then
// segments into one, contiguous block of memory. // decode it to verify the image and record its ImageMeta data.
ImageMeta image = {argv[1], 0, 0, 0, 0};
scoped_refptr<SharedBuffer> data = ReadFile(argv[1]); scoped_refptr<SharedBuffer> data = ReadFile(argv[1]);
if (!data.get() || !data->size()) {
fprintf(stderr, "Error reading image %s\n", argv[1]);
exit(2);
}
data->Data();
// Warm-up: throw out the first iteration for more consistent results.
ImageMeta image;
image.name = argv[1];
DecodeImageData(data.get(), &image); DecodeImageData(data.get(), &image);
// Image decode bench for decode_iterations. // Image decode bench for decode_iterations.
......
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