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

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: Addressed comments from kmarshall, except swap 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/in_memory_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 std::unique_ptr<BlobCacheImageMetadata> parsed_metadata(
vmpstr 2016/04/15 18:18:54 Since this seems to be only used locally, can you
nyquist 2016/04/16 00:25:29 Done.
17 data->size()}; 19 new BlobCacheImageMetadata);
18 WebPDemuxState demuxState(WEBP_DEMUX_PARSING_HEADER); 20 int signed_size = base::checked_cast<int>(data->size());
19 WebPDemuxer* demux = WebPDemuxPartial(&inputData, &demuxState); 21 if (!parsed_metadata->ParseFromArray(data->data(), signed_size)) {
22 // Failed to parse proto, so will fail to decode later as well. Inform
23 // Skia by giving back an empty SkImageInfo.
24 return new DecodingImageGenerator(SkImageInfo::MakeN32Premul(0, 0),
25 data->data(), data->size());
26 }
20 27
21 uint32_t width = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH); 28 return new DecodingImageGenerator(
22 uint32_t height = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT); 29 SkImageInfo::MakeN32Premul(parsed_metadata->width(),
23 30 parsed_metadata->height()),
24 const SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); 31 data->data(), data->size());
25 return new DecodingImageGenerator(info, data->data(), data->size());
26 } 32 }
27 33
28 DecodingImageGenerator::DecodingImageGenerator(const SkImageInfo info, 34 DecodingImageGenerator::DecodingImageGenerator(const SkImageInfo info,
29 const void* data, 35 const void* data,
30 size_t size) 36 size_t size)
31 : SkImageGenerator(info) { 37 : SkImageGenerator(info) {
32 WebPDecoder(data, size, &decoded_bitmap_); 38 WebPDecoder(data, size, &decoded_bitmap_);
33 } 39 }
34 40
35 DecodingImageGenerator::~DecodingImageGenerator() {} 41 DecodingImageGenerator::~DecodingImageGenerator() {}
(...skipping 16 matching lines...) Expand all
52 return false; 58 return false;
53 } 59 }
54 60
55 bool DecodingImageGenerator::onGetYUV8Planes(const SkYUVSizeInfo& sizeInfo, 61 bool DecodingImageGenerator::onGetYUV8Planes(const SkYUVSizeInfo& sizeInfo,
56 void* planes[3]) { 62 void* planes[3]) {
57 return false; 63 return false;
58 } 64 }
59 65
60 } // namespace client 66 } // namespace client
61 } // namespace blimp 67 } // namespace blimp
OLDNEW
« no previous file with comments | « no previous file | blimp/common/BUILD.gn » ('j') | blimp/common/blob_cache/in_memory_blob_cache.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698