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) { |
18 // Check if this is a cache identifier instead of a WebP image. | |
Kevin M
2016/04/13 23:29:52
Can you add a prefix byte instead of trying to par
nyquist
2016/04/14 19:33:22
Moved all of this to a proto instead.
| |
19 std::unique_ptr<BlobCacheImageIdentifier> deserialized( | |
20 new BlobCacheImageIdentifier); | |
21 int signed_size = base::checked_cast<int>(data->size()); | |
22 if (deserialized->ParseFromArray(data->data(), signed_size)) { | |
23 const SkImageInfo info = SkImageInfo::MakeN32Premul(deserialized->width(), | |
24 deserialized->height()); | |
25 return new DecodingImageGenerator(info, data->data(), data->size()); | |
26 } | |
27 | |
16 WebPData inputData = {reinterpret_cast<const uint8_t*>(data->data()), | 28 WebPData inputData = {reinterpret_cast<const uint8_t*>(data->data()), |
17 data->size()}; | 29 data->size()}; |
18 WebPDemuxState demuxState(WEBP_DEMUX_PARSING_HEADER); | 30 WebPDemuxState demuxState(WEBP_DEMUX_PARSING_HEADER); |
19 WebPDemuxer* demux = WebPDemuxPartial(&inputData, &demuxState); | 31 WebPDemuxer* demux = WebPDemuxPartial(&inputData, &demuxState); |
20 | 32 |
21 uint32_t width = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH); | 33 uint32_t width = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH); |
22 uint32_t height = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT); | 34 uint32_t height = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT); |
23 | 35 |
24 const SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); | 36 const SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); |
25 return new DecodingImageGenerator(info, data->data(), data->size()); | 37 return new DecodingImageGenerator(info, data->data(), data->size()); |
(...skipping 26 matching lines...) Expand all Loading... | |
52 return false; | 64 return false; |
53 } | 65 } |
54 | 66 |
55 bool DecodingImageGenerator::onGetYUV8Planes(const SkYUVSizeInfo& sizeInfo, | 67 bool DecodingImageGenerator::onGetYUV8Planes(const SkYUVSizeInfo& sizeInfo, |
56 void* planes[3]) { | 68 void* planes[3]) { |
57 return false; | 69 return false; |
58 } | 70 } |
59 | 71 |
60 } // namespace client | 72 } // namespace client |
61 } // namespace blimp | 73 } // namespace blimp |
OLD | NEW |