OLD | NEW |
---|---|
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<BlobCacheImage> deserialized(new BlobCacheImage); |
Kevin M
2016/04/14 20:08:30
"parsed_metadata"?
nyquist
2016/04/15 01:27:12
Done.
| |
17 data->size()}; | 19 int signed_size = base::checked_cast<int>(data->size()); |
18 WebPDemuxState demuxState(WEBP_DEMUX_PARSING_HEADER); | 20 if (!deserialized->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 const SkImageInfo info = SkImageInfo::MakeN32Premul(0, 0); | |
24 return new DecodingImageGenerator(info, data->data(), data->size()); | |
25 } | |
20 | 26 |
21 uint32_t width = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH); | 27 const SkImageInfo info = |
22 uint32_t height = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT); | 28 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.
| |
23 | |
24 const SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); | |
25 return new DecodingImageGenerator(info, data->data(), data->size()); | 29 return new DecodingImageGenerator(info, data->data(), data->size()); |
26 } | 30 } |
27 | 31 |
28 DecodingImageGenerator::DecodingImageGenerator(const SkImageInfo info, | 32 DecodingImageGenerator::DecodingImageGenerator(const SkImageInfo info, |
29 const void* data, | 33 const void* data, |
30 size_t size) | 34 size_t size) |
31 : SkImageGenerator(info) { | 35 : SkImageGenerator(info) { |
32 WebPDecoder(data, size, &decoded_bitmap_); | 36 WebPDecoder(data, size, &decoded_bitmap_); |
33 } | 37 } |
34 | 38 |
(...skipping 17 matching lines...) Expand all Loading... | |
52 return false; | 56 return false; |
53 } | 57 } |
54 | 58 |
55 bool DecodingImageGenerator::onGetYUV8Planes(const SkYUVSizeInfo& sizeInfo, | 59 bool DecodingImageGenerator::onGetYUV8Planes(const SkYUVSizeInfo& sizeInfo, |
56 void* planes[3]) { | 60 void* planes[3]) { |
57 return false; | 61 return false; |
58 } | 62 } |
59 | 63 |
60 } // namespace client | 64 } // namespace client |
61 } // namespace blimp | 65 } // namespace blimp |
OLD | NEW |