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

Side by Side Diff: blimp/client/feature/compositor/decoding_image_generator.cc

Issue 1680333004: Add support for encoding/decoding WebP images. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@serialize-deserialize-images-framework
Patch Set: address minor last comments Created 4 years, 10 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 | « blimp/client/feature/compositor/decoding_image_generator.h ('k') | blimp/common/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "blimp/client/feature/compositor/decoding_image_generator.h"
6
7 #include "blimp/common/compositor/webp_decoder.h"
8 #include "third_party/libwebp/webp/decode.h"
9 #include "third_party/libwebp/webp/demux.h"
10 #include "third_party/skia/include/core/SkData.h"
11
12 namespace blimp {
13 namespace client {
14
15 SkImageGenerator* DecodingImageGenerator::create(SkData* data) {
16 WebPData inputData = {reinterpret_cast<const uint8_t*>(data->data()),
17 data->size()};
18 WebPDemuxState demuxState(WEBP_DEMUX_PARSING_HEADER);
19 WebPDemuxer* demux = WebPDemuxPartial(&inputData, &demuxState);
20
21 uint32_t width = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH);
22 uint32_t height = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT);
23
24 const SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
25 return new DecodingImageGenerator(info, data->data(), data->size());
26 }
27
28 DecodingImageGenerator::DecodingImageGenerator(const SkImageInfo info,
29 const void* data,
30 size_t size)
31 : SkImageGenerator(info) {
32 WebPDecoder(data, size, &decoded_bitmap_);
33 }
34
35 DecodingImageGenerator::~DecodingImageGenerator() {}
36
37 bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info,
38 void* pixels,
39 size_t rowBytes,
40 SkPMColor table[],
41 int* tableCount) {
42 SkAutoLockPixels bitmapLock(decoded_bitmap_);
43 if (decoded_bitmap_.getPixels() != pixels) {
44 return decoded_bitmap_.copyPixelsTo(pixels, rowBytes * info.height(),
45 rowBytes);
46 }
47 return true;
48 }
49
50 bool DecodingImageGenerator::onGetYUV8Planes(SkISize sizes[3],
51 void* planes[3],
52 size_t rowBytes[3],
53 SkYUVColorSpace*) {
54 return false;
55 }
56
57 } // namespace client
58 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/feature/compositor/decoding_image_generator.h ('k') | blimp/common/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698