Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(790)

Unified Diff: blimp/client/feature/compositor/decoding_image_generator.cc

Issue 1867653002: Initial version of Blimp BlobCache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed all comments. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | blimp/common/BUILD.gn » ('j') | blimp/common/blob_cache/infinite_blob_cache.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: blimp/client/feature/compositor/decoding_image_generator.cc
diff --git a/blimp/client/feature/compositor/decoding_image_generator.cc b/blimp/client/feature/compositor/decoding_image_generator.cc
index 692dd373c4df152e1de69054ca0deef64b44f5bd..c76a98326bd4d76b12cd45febf39bc59d0a569cc 100644
--- a/blimp/client/feature/compositor/decoding_image_generator.cc
+++ b/blimp/client/feature/compositor/decoding_image_generator.cc
@@ -4,7 +4,9 @@
#include "blimp/client/feature/compositor/decoding_image_generator.h"
+#include "base/numerics/safe_conversions.h"
#include "blimp/common/compositor/webp_decoder.h"
+#include "blimp/common/proto/blob_cache.pb.h"
#include "third_party/libwebp/webp/decode.h"
#include "third_party/libwebp/webp/demux.h"
#include "third_party/skia/include/core/SkData.h"
@@ -13,15 +15,17 @@ namespace blimp {
namespace client {
SkImageGenerator* DecodingImageGenerator::create(SkData* data) {
- WebPData inputData = {reinterpret_cast<const uint8_t*>(data->data()),
- data->size()};
- WebPDemuxState demuxState(WEBP_DEMUX_PARSING_HEADER);
- WebPDemuxer* demux = WebPDemuxPartial(&inputData, &demuxState);
-
- uint32_t width = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH);
- uint32_t height = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT);
+ std::unique_ptr<BlobCacheImage> deserialized(new BlobCacheImage);
Kevin M 2016/04/14 20:08:30 "parsed_metadata"?
nyquist 2016/04/15 01:27:12 Done.
+ int signed_size = base::checked_cast<int>(data->size());
+ if (!deserialized->ParseFromArray(data->data(), signed_size)) {
+ // Failed to parse proto, so will fail to decode later as well. Inform
+ // Skia by giving back an empty SkImageInfo.
+ const SkImageInfo info = SkImageInfo::MakeN32Premul(0, 0);
+ return new DecodingImageGenerator(info, data->data(), data->size());
+ }
- const SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
+ const SkImageInfo info =
+ SkImageInfo::MakeN32Premul(deserialized->width(), deserialized->height());
Kevin M 2016/04/14 20:08:30 Inline this in the DecodingImageGenerator ctor cal
nyquist 2016/04/15 01:27:12 Done. Also did above.
return new DecodingImageGenerator(info, data->data(), data->size());
}
« no previous file with comments | « no previous file | blimp/common/BUILD.gn » ('j') | blimp/common/blob_cache/infinite_blob_cache.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698