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

Side by Side 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: Changed to use BlobId and BlobData 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 unified diff | Download patch
« no previous file with comments | « no previous file | blimp/common/BUILD.gn » ('j') | blimp/common/blob_cache/blob_cache.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "blimp/client/feature/compositor/decoding_image_generator.h" 5 #include "blimp/client/feature/compositor/decoding_image_generator.h"
6 6
7 #include "base/numerics/safe_conversions.h"
7 #include "blimp/common/compositor/webp_decoder.h" 8 #include "blimp/common/compositor/webp_decoder.h"
9 #include "blimp/common/proto/blob_cache.pb.h"
8 #include "third_party/libwebp/webp/decode.h" 10 #include "third_party/libwebp/webp/decode.h"
9 #include "third_party/libwebp/webp/demux.h" 11 #include "third_party/libwebp/webp/demux.h"
10 #include "third_party/skia/include/core/SkData.h" 12 #include "third_party/skia/include/core/SkData.h"
11 13
12 namespace blimp { 14 namespace blimp {
13 namespace client { 15 namespace client {
14 16
15 SkImageGenerator* DecodingImageGenerator::create(SkData* data) { 17 SkImageGenerator* DecodingImageGenerator::create(SkData* data) {
16 WebPData inputData = {reinterpret_cast<const uint8_t*>(data->data()), 18 BlobCacheImageMetadata parsed_metadata;
17 data->size()}; 19 int signed_size = base::checked_cast<int>(data->size());
18 WebPDemuxState demuxState(WEBP_DEMUX_PARSING_HEADER); 20 if (!parsed_metadata.ParseFromArray(data->data(), signed_size)) {
19 WebPDemuxer* demux = WebPDemuxPartial(&inputData, &demuxState); 21 // Failed to parse proto, so will fail to decode later as well. Inform
22 // Skia by giving back an empty SkImageInfo.
23 return new DecodingImageGenerator(SkImageInfo::MakeN32Premul(0, 0),
24 data->data(), data->size());
25 }
20 26
21 uint32_t width = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH); 27 return new DecodingImageGenerator(
22 uint32_t height = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT); 28 SkImageInfo::MakeN32Premul(parsed_metadata.width(),
23 29 parsed_metadata.height()),
24 const SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); 30 data->data(), data->size());
25 return new DecodingImageGenerator(info, data->data(), data->size());
26 } 31 }
27 32
28 DecodingImageGenerator::DecodingImageGenerator(const SkImageInfo info, 33 DecodingImageGenerator::DecodingImageGenerator(const SkImageInfo info,
29 const void* data, 34 const void* data,
30 size_t size) 35 size_t size)
31 : SkImageGenerator(info) { 36 : SkImageGenerator(info) {
32 WebPDecoder(data, size, &decoded_bitmap_); 37 WebPDecoder(data, size, &decoded_bitmap_);
33 } 38 }
34 39
35 DecodingImageGenerator::~DecodingImageGenerator() {} 40 DecodingImageGenerator::~DecodingImageGenerator() {}
(...skipping 16 matching lines...) Expand all
52 return false; 57 return false;
53 } 58 }
54 59
55 bool DecodingImageGenerator::onGetYUV8Planes(const SkYUVSizeInfo& sizeInfo, 60 bool DecodingImageGenerator::onGetYUV8Planes(const SkYUVSizeInfo& sizeInfo,
56 void* planes[3]) { 61 void* planes[3]) {
57 return false; 62 return false;
58 } 63 }
59 64
60 } // namespace client 65 } // namespace client
61 } // namespace blimp 66 } // namespace blimp
OLDNEW
« no previous file with comments | « no previous file | blimp/common/BUILD.gn » ('j') | blimp/common/blob_cache/blob_cache.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698