scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
Hal Canary | c640d0d | 2018-06-13 09:59:02 -0400 | [diff] [blame] | 8 | #include "SkWebpCodec.h" |
| 9 | |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 10 | #include "SkBitmap.h" |
| 11 | #include "SkCanvas.h" |
Leon Scroggins III | 33deb7e | 2017-06-07 12:31:51 -0400 | [diff] [blame] | 12 | #include "SkCodecAnimation.h" |
| 13 | #include "SkCodecAnimationPriv.h" |
scroggo | cc2feb1 | 2015-08-14 08:32:46 -0700 | [diff] [blame] | 14 | #include "SkCodecPriv.h" |
Mike Reed | ede7bac | 2017-07-23 15:30:02 -0400 | [diff] [blame] | 15 | #include "SkMakeUnique.h" |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 16 | #include "SkRasterPipeline.h" |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 17 | #include "SkSampler.h" |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 18 | #include "SkStreamPriv.h" |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 19 | #include "SkTemplates.h" |
Hal Canary | c640d0d | 2018-06-13 09:59:02 -0400 | [diff] [blame] | 20 | #include "SkTo.h" |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 21 | |
| 22 | // A WebP decoder on top of (subset of) libwebp |
| 23 | // For more information on WebP image format, and libwebp library, see: |
| 24 | // https://code.google.com/speed/webp/ |
| 25 | // http://www.webmproject.org/code/#libwebp-webp-image-library |
| 26 | // https://chromium.googlesource.com/webm/libwebp |
| 27 | |
| 28 | // If moving libwebp out of skia source tree, path for webp headers must be |
| 29 | // updated accordingly. Here, we enforce using local copy in webp sub-directory. |
| 30 | #include "webp/decode.h" |
msarett | 9d15dab | 2016-08-24 07:36:06 -0700 | [diff] [blame] | 31 | #include "webp/demux.h" |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 32 | #include "webp/encode.h" |
| 33 | |
scroggo | db30be2 | 2015-12-08 18:54:13 -0800 | [diff] [blame] | 34 | bool SkWebpCodec::IsWebp(const void* buf, size_t bytesRead) { |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 35 | // WEBP starts with the following: |
| 36 | // RIFFXXXXWEBPVP |
| 37 | // Where XXXX is unspecified. |
scroggo | db30be2 | 2015-12-08 18:54:13 -0800 | [diff] [blame] | 38 | const char* bytes = static_cast<const char*>(buf); |
| 39 | return bytesRead >= 14 && !memcmp(bytes, "RIFF", 4) && !memcmp(&bytes[8], "WEBPVP", 6); |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 40 | } |
| 41 | |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 42 | // Parse headers of RIFF container, and check for valid Webp (VP8) content. |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 43 | // Returns an SkWebpCodec on success |
Mike Reed | ede7bac | 2017-07-23 15:30:02 -0400 | [diff] [blame] | 44 | std::unique_ptr<SkCodec> SkWebpCodec::MakeFromStream(std::unique_ptr<SkStream> stream, |
| 45 | Result* result) { |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 46 | // Webp demux needs a contiguous data buffer. |
| 47 | sk_sp<SkData> data = nullptr; |
| 48 | if (stream->getMemoryBase()) { |
| 49 | // It is safe to make without copy because we'll hold onto the stream. |
| 50 | data = SkData::MakeWithoutCopy(stream->getMemoryBase(), stream->getLength()); |
| 51 | } else { |
Mike Reed | ede7bac | 2017-07-23 15:30:02 -0400 | [diff] [blame] | 52 | data = SkCopyStreamToData(stream.get()); |
scroggo | db30be2 | 2015-12-08 18:54:13 -0800 | [diff] [blame] | 53 | |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 54 | // If we are forced to copy the stream to a data, we can go ahead and delete the stream. |
Mike Reed | ede7bac | 2017-07-23 15:30:02 -0400 | [diff] [blame] | 55 | stream.reset(nullptr); |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | // It's a little strange that the |demux| will outlive |webpData|, though it needs the |
| 59 | // pointer in |webpData| to remain valid. This works because the pointer remains valid |
| 60 | // until the SkData is freed. |
| 61 | WebPData webpData = { data->bytes(), data->size() }; |
Leon Scroggins III | 588fb04 | 2017-07-14 16:32:31 -0400 | [diff] [blame] | 62 | WebPDemuxState state; |
| 63 | SkAutoTCallVProc<WebPDemuxer, WebPDemuxDelete> demux(WebPDemuxPartial(&webpData, &state)); |
| 64 | switch (state) { |
| 65 | case WEBP_DEMUX_PARSE_ERROR: |
| 66 | *result = kInvalidInput; |
| 67 | return nullptr; |
| 68 | case WEBP_DEMUX_PARSING_HEADER: |
| 69 | *result = kIncompleteInput; |
| 70 | return nullptr; |
| 71 | case WEBP_DEMUX_PARSED_HEADER: |
| 72 | case WEBP_DEMUX_DONE: |
| 73 | SkASSERT(demux); |
| 74 | break; |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 75 | } |
| 76 | |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 77 | const int width = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH); |
| 78 | const int height = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT); |
| 79 | |
| 80 | // Sanity check for image size that's about to be decoded. |
| 81 | { |
| 82 | const int64_t size = sk_64_mul(width, height); |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 83 | // now check that if we are 4-bytes per pixel, we also don't overflow |
Herb Derby | c402b77 | 2017-09-20 11:56:00 -0400 | [diff] [blame] | 84 | if (!SkTFitsIn<int32_t>(size) || SkTo<int32_t>(size) > (0x7FFFFFFF >> 2)) { |
Leon Scroggins III | 588fb04 | 2017-07-14 16:32:31 -0400 | [diff] [blame] | 85 | *result = kInvalidInput; |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 86 | return nullptr; |
| 87 | } |
| 88 | } |
| 89 | |
Leon Scroggins III | 36f7e32 | 2018-08-27 11:55:46 -0400 | [diff] [blame] | 90 | std::unique_ptr<SkEncodedInfo::ICCProfile> profile = nullptr; |
Leon Scroggins III | da3e9ad | 2018-01-26 15:48:26 -0500 | [diff] [blame] | 91 | { |
| 92 | WebPChunkIterator chunkIterator; |
| 93 | SkAutoTCallVProc<WebPChunkIterator, WebPDemuxReleaseChunkIterator> autoCI(&chunkIterator); |
| 94 | if (WebPDemuxGetChunk(demux, "ICCP", 1, &chunkIterator)) { |
Leon Scroggins III | 36f7e32 | 2018-08-27 11:55:46 -0400 | [diff] [blame] | 95 | // FIXME: I think this could be MakeWithoutCopy |
| 96 | auto chunk = SkData::MakeWithCopy(chunkIterator.chunk.bytes, chunkIterator.chunk.size); |
| 97 | profile = SkEncodedInfo::ICCProfile::Make(std::move(chunk)); |
Leon Scroggins III | da3e9ad | 2018-01-26 15:48:26 -0500 | [diff] [blame] | 98 | } |
Leon Scroggins III | 5dd47e4 | 2018-09-27 15:26:48 -0400 | [diff] [blame] | 99 | if (profile && profile->profile()->data_color_space != skcms_Signature_RGB) { |
| 100 | profile = nullptr; |
Leon Scroggins III | da3e9ad | 2018-01-26 15:48:26 -0500 | [diff] [blame] | 101 | } |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 102 | } |
Leon Scroggins III | da3e9ad | 2018-01-26 15:48:26 -0500 | [diff] [blame] | 103 | |
| 104 | SkEncodedOrigin origin = kDefault_SkEncodedOrigin; |
| 105 | { |
| 106 | WebPChunkIterator chunkIterator; |
| 107 | SkAutoTCallVProc<WebPChunkIterator, WebPDemuxReleaseChunkIterator> autoCI(&chunkIterator); |
| 108 | if (WebPDemuxGetChunk(demux, "EXIF", 1, &chunkIterator)) { |
| 109 | is_orientation_marker(chunkIterator.chunk.bytes, chunkIterator.chunk.size, &origin); |
| 110 | } |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 111 | } |
| 112 | |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 113 | // Get the first frame and its "features" to determine the color and alpha types. |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 114 | WebPIterator frame; |
| 115 | SkAutoTCallVProc<WebPIterator, WebPDemuxReleaseIterator> autoFrame(&frame); |
| 116 | if (!WebPDemuxGetFrame(demux, 1, &frame)) { |
Leon Scroggins III | 588fb04 | 2017-07-14 16:32:31 -0400 | [diff] [blame] | 117 | *result = kIncompleteInput; |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 118 | return nullptr; |
| 119 | } |
| 120 | |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 121 | WebPBitstreamFeatures features; |
Leon Scroggins III | 588fb04 | 2017-07-14 16:32:31 -0400 | [diff] [blame] | 122 | switch (WebPGetFeatures(frame.fragment.bytes, frame.fragment.size, &features)) { |
| 123 | case VP8_STATUS_OK: |
| 124 | break; |
| 125 | case VP8_STATUS_SUSPENDED: |
| 126 | case VP8_STATUS_NOT_ENOUGH_DATA: |
| 127 | *result = kIncompleteInput; |
| 128 | return nullptr; |
| 129 | default: |
| 130 | *result = kInvalidInput; |
| 131 | return nullptr; |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 132 | } |
| 133 | |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 134 | const bool hasAlpha = SkToBool(frame.has_alpha) |
| 135 | || frame.width != width || frame.height != height; |
msarett | ac6c750 | 2016-04-25 09:30:24 -0700 | [diff] [blame] | 136 | SkEncodedInfo::Color color; |
| 137 | SkEncodedInfo::Alpha alpha; |
| 138 | switch (features.format) { |
| 139 | case 0: |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 140 | // This indicates a "mixed" format. We could see this for |
| 141 | // animated webps (multiple fragments). |
msarett | ac6c750 | 2016-04-25 09:30:24 -0700 | [diff] [blame] | 142 | // We could also guess kYUV here, but I think it makes more |
| 143 | // sense to guess kBGRA which is likely closer to the final |
| 144 | // output. Otherwise, we might end up converting |
| 145 | // BGRA->YUVA->BGRA. |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 146 | // Fallthrough: |
| 147 | case 2: |
| 148 | // This is the lossless format (BGRA). |
| 149 | if (hasAlpha) { |
| 150 | color = SkEncodedInfo::kBGRA_Color; |
| 151 | alpha = SkEncodedInfo::kUnpremul_Alpha; |
| 152 | } else { |
| 153 | color = SkEncodedInfo::kBGRX_Color; |
| 154 | alpha = SkEncodedInfo::kOpaque_Alpha; |
| 155 | } |
msarett | ac6c750 | 2016-04-25 09:30:24 -0700 | [diff] [blame] | 156 | break; |
| 157 | case 1: |
| 158 | // This is the lossy format (YUV). |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 159 | if (hasAlpha) { |
msarett | ac6c750 | 2016-04-25 09:30:24 -0700 | [diff] [blame] | 160 | color = SkEncodedInfo::kYUVA_Color; |
msarett | c30c418 | 2016-04-20 11:53:35 -0700 | [diff] [blame] | 161 | alpha = SkEncodedInfo::kUnpremul_Alpha; |
msarett | ac6c750 | 2016-04-25 09:30:24 -0700 | [diff] [blame] | 162 | } else { |
| 163 | color = SkEncodedInfo::kYUV_Color; |
| 164 | alpha = SkEncodedInfo::kOpaque_Alpha; |
| 165 | } |
| 166 | break; |
msarett | ac6c750 | 2016-04-25 09:30:24 -0700 | [diff] [blame] | 167 | default: |
Leon Scroggins III | 588fb04 | 2017-07-14 16:32:31 -0400 | [diff] [blame] | 168 | *result = kInvalidInput; |
msarett | ac6c750 | 2016-04-25 09:30:24 -0700 | [diff] [blame] | 169 | return nullptr; |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 170 | } |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 171 | |
Leon Scroggins III | da3e9ad | 2018-01-26 15:48:26 -0500 | [diff] [blame] | 172 | |
Leon Scroggins III | 588fb04 | 2017-07-14 16:32:31 -0400 | [diff] [blame] | 173 | *result = kSuccess; |
Leon Scroggins III | 36f7e32 | 2018-08-27 11:55:46 -0400 | [diff] [blame] | 174 | SkEncodedInfo info = SkEncodedInfo::Make(width, height, color, alpha, 8, std::move(profile)); |
| 175 | return std::unique_ptr<SkCodec>(new SkWebpCodec(std::move(info), std::move(stream), |
| 176 | demux.release(), std::move(data), origin)); |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 177 | } |
| 178 | |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 179 | SkISize SkWebpCodec::onGetScaledDimensions(float desiredScale) const { |
Leon Scroggins III | 712476e | 2018-10-03 15:47:00 -0400 | [diff] [blame] | 180 | SkISize dim = this->dimensions(); |
msarett | a0c414d | 2015-06-19 07:34:30 -0700 | [diff] [blame] | 181 | // SkCodec treats zero dimensional images as errors, so the minimum size |
| 182 | // that we will recommend is 1x1. |
| 183 | dim.fWidth = SkTMax(1, SkScalarRoundToInt(desiredScale * dim.fWidth)); |
| 184 | dim.fHeight = SkTMax(1, SkScalarRoundToInt(desiredScale * dim.fHeight)); |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 185 | return dim; |
| 186 | } |
| 187 | |
scroggo | e7fc14b | 2015-10-02 13:14:46 -0700 | [diff] [blame] | 188 | bool SkWebpCodec::onDimensionsSupported(const SkISize& dim) { |
Leon Scroggins III | 712476e | 2018-10-03 15:47:00 -0400 | [diff] [blame] | 189 | const SkEncodedInfo& info = this->getEncodedInfo(); |
scroggo | e7fc14b | 2015-10-02 13:14:46 -0700 | [diff] [blame] | 190 | return dim.width() >= 1 && dim.width() <= info.width() |
| 191 | && dim.height() >= 1 && dim.height() <= info.height(); |
| 192 | } |
| 193 | |
Leon Scroggins III | 0358841 | 2017-11-17 08:07:32 -0500 | [diff] [blame] | 194 | static WEBP_CSP_MODE webp_decode_mode(SkColorType dstCT, bool premultiply) { |
| 195 | switch (dstCT) { |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 196 | case kBGRA_8888_SkColorType: |
| 197 | return premultiply ? MODE_bgrA : MODE_BGRA; |
| 198 | case kRGBA_8888_SkColorType: |
| 199 | return premultiply ? MODE_rgbA : MODE_RGBA; |
scroggo | 74992b5 | 2015-08-06 13:50:15 -0700 | [diff] [blame] | 200 | case kRGB_565_SkColorType: |
| 201 | return MODE_RGB_565; |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 202 | default: |
| 203 | return MODE_LAST; |
| 204 | } |
| 205 | } |
| 206 | |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 207 | SkWebpCodec::Frame* SkWebpCodec::FrameHolder::appendNewFrame(bool hasAlpha) { |
| 208 | const int i = this->size(); |
Leon Scroggins III | c8037dc | 2017-12-05 13:55:24 -0500 | [diff] [blame] | 209 | fFrames.emplace_back(i, hasAlpha ? SkEncodedInfo::kUnpremul_Alpha |
| 210 | : SkEncodedInfo::kOpaque_Alpha); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 211 | return &fFrames[i]; |
| 212 | } |
| 213 | |
scroggo | b636b45 | 2015-07-22 07:16:20 -0700 | [diff] [blame] | 214 | bool SkWebpCodec::onGetValidSubset(SkIRect* desiredSubset) const { |
| 215 | if (!desiredSubset) { |
| 216 | return false; |
| 217 | } |
| 218 | |
Leon Scroggins III | 712476e | 2018-10-03 15:47:00 -0400 | [diff] [blame] | 219 | if (!this->bounds().contains(*desiredSubset)) { |
scroggo | b636b45 | 2015-07-22 07:16:20 -0700 | [diff] [blame] | 220 | return false; |
| 221 | } |
| 222 | |
| 223 | // As stated below, libwebp snaps to even left and top. Make sure top and left are even, so we |
| 224 | // decode this exact subset. |
| 225 | // Leave right and bottom unmodified, so we suggest a slightly larger subset than requested. |
| 226 | desiredSubset->fLeft = (desiredSubset->fLeft >> 1) << 1; |
| 227 | desiredSubset->fTop = (desiredSubset->fTop >> 1) << 1; |
| 228 | return true; |
| 229 | } |
| 230 | |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 231 | int SkWebpCodec::onGetRepetitionCount() { |
| 232 | auto flags = WebPDemuxGetI(fDemux.get(), WEBP_FF_FORMAT_FLAGS); |
| 233 | if (!(flags & ANIMATION_FLAG)) { |
| 234 | return 0; |
| 235 | } |
| 236 | |
| 237 | const int repCount = WebPDemuxGetI(fDemux.get(), WEBP_FF_LOOP_COUNT); |
| 238 | if (0 == repCount) { |
| 239 | return kRepetitionCountInfinite; |
| 240 | } |
| 241 | |
| 242 | return repCount; |
| 243 | } |
| 244 | |
| 245 | int SkWebpCodec::onGetFrameCount() { |
| 246 | auto flags = WebPDemuxGetI(fDemux.get(), WEBP_FF_FORMAT_FLAGS); |
| 247 | if (!(flags & ANIMATION_FLAG)) { |
| 248 | return 1; |
| 249 | } |
| 250 | |
| 251 | const uint32_t oldFrameCount = fFrameHolder.size(); |
| 252 | if (fFailed) { |
| 253 | return oldFrameCount; |
| 254 | } |
| 255 | |
| 256 | const uint32_t frameCount = WebPDemuxGetI(fDemux, WEBP_FF_FRAME_COUNT); |
| 257 | if (oldFrameCount == frameCount) { |
| 258 | // We have already parsed this. |
| 259 | return frameCount; |
| 260 | } |
| 261 | |
| 262 | fFrameHolder.reserve(frameCount); |
| 263 | |
| 264 | for (uint32_t i = oldFrameCount; i < frameCount; i++) { |
| 265 | WebPIterator iter; |
| 266 | SkAutoTCallVProc<WebPIterator, WebPDemuxReleaseIterator> autoIter(&iter); |
| 267 | |
| 268 | if (!WebPDemuxGetFrame(fDemux.get(), i + 1, &iter)) { |
| 269 | fFailed = true; |
| 270 | break; |
| 271 | } |
| 272 | |
| 273 | // libwebp only reports complete frames of an animated image. |
| 274 | SkASSERT(iter.complete); |
| 275 | |
| 276 | Frame* frame = fFrameHolder.appendNewFrame(iter.has_alpha); |
| 277 | frame->setXYWH(iter.x_offset, iter.y_offset, iter.width, iter.height); |
| 278 | frame->setDisposalMethod(iter.dispose_method == WEBP_MUX_DISPOSE_BACKGROUND ? |
Leon Scroggins III | 33deb7e | 2017-06-07 12:31:51 -0400 | [diff] [blame] | 279 | SkCodecAnimation::DisposalMethod::kRestoreBGColor : |
| 280 | SkCodecAnimation::DisposalMethod::kKeep); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 281 | frame->setDuration(iter.duration); |
| 282 | if (WEBP_MUX_BLEND != iter.blend_method) { |
| 283 | frame->setBlend(SkCodecAnimation::Blend::kBG); |
| 284 | } |
| 285 | fFrameHolder.setAlphaAndRequiredFrame(frame); |
| 286 | } |
| 287 | |
| 288 | return fFrameHolder.size(); |
| 289 | |
| 290 | } |
| 291 | |
| 292 | const SkFrame* SkWebpCodec::FrameHolder::onGetFrame(int i) const { |
| 293 | return static_cast<const SkFrame*>(this->frame(i)); |
| 294 | } |
| 295 | |
| 296 | const SkWebpCodec::Frame* SkWebpCodec::FrameHolder::frame(int i) const { |
| 297 | SkASSERT(i >= 0 && i < this->size()); |
| 298 | return &fFrames[i]; |
| 299 | } |
| 300 | |
| 301 | bool SkWebpCodec::onGetFrameInfo(int i, FrameInfo* frameInfo) const { |
| 302 | if (i >= fFrameHolder.size()) { |
| 303 | return false; |
| 304 | } |
| 305 | |
| 306 | const Frame* frame = fFrameHolder.frame(i); |
| 307 | if (!frame) { |
| 308 | return false; |
| 309 | } |
| 310 | |
| 311 | if (frameInfo) { |
| 312 | frameInfo->fRequiredFrame = frame->getRequiredFrame(); |
| 313 | frameInfo->fDuration = frame->getDuration(); |
| 314 | // libwebp only reports fully received frames for an |
| 315 | // animated image. |
| 316 | frameInfo->fFullyReceived = true; |
Leon Scroggins III | c8037dc | 2017-12-05 13:55:24 -0500 | [diff] [blame] | 317 | frameInfo->fAlphaType = frame->hasAlpha() ? kUnpremul_SkAlphaType |
| 318 | : kOpaque_SkAlphaType; |
Leon Scroggins III | 33deb7e | 2017-06-07 12:31:51 -0400 | [diff] [blame] | 319 | frameInfo->fDisposalMethod = frame->getDisposalMethod(); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | return true; |
| 323 | } |
| 324 | |
| 325 | static bool is_8888(SkColorType colorType) { |
| 326 | switch (colorType) { |
| 327 | case kRGBA_8888_SkColorType: |
| 328 | case kBGRA_8888_SkColorType: |
| 329 | return true; |
| 330 | default: |
| 331 | return false; |
| 332 | } |
| 333 | } |
| 334 | |
Leon Scroggins III | 0358841 | 2017-11-17 08:07:32 -0500 | [diff] [blame] | 335 | // Requires that the src input be unpremultiplied (or opaque). |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 336 | static void blend_line(SkColorType dstCT, void* dst, |
Mike Klein | 45c16fa | 2017-07-18 18:15:13 -0400 | [diff] [blame] | 337 | SkColorType srcCT, const void* src, |
Leon Scroggins III | 0358841 | 2017-11-17 08:07:32 -0500 | [diff] [blame] | 338 | SkAlphaType dstAt, |
| 339 | bool srcHasAlpha, |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 340 | int width) { |
Mike Klein | b11ab57 | 2018-10-24 06:42:14 -0400 | [diff] [blame] | 341 | SkRasterPipeline_MemoryCtx dst_ctx = { (void*)dst, 0 }, |
| 342 | src_ctx = { (void*)src, 0 }; |
Mike Klein | 45c16fa | 2017-07-18 18:15:13 -0400 | [diff] [blame] | 343 | |
Mike Klein | b24704d | 2017-05-24 07:53:00 -0400 | [diff] [blame] | 344 | SkRasterPipeline_<256> p; |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 345 | |
Mike Klein | 1a3eb52 | 2018-10-18 10:11:00 -0400 | [diff] [blame] | 346 | p.append_load_dst(dstCT, &dst_ctx); |
Leon Scroggins III | 0358841 | 2017-11-17 08:07:32 -0500 | [diff] [blame] | 347 | if (kUnpremul_SkAlphaType == dstAt) { |
Mike Klein | 1a3eb52 | 2018-10-18 10:11:00 -0400 | [diff] [blame] | 348 | p.append(SkRasterPipeline::premul_dst); |
Leon Scroggins III | 0358841 | 2017-11-17 08:07:32 -0500 | [diff] [blame] | 349 | } |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 350 | |
Mike Klein | 1a3eb52 | 2018-10-18 10:11:00 -0400 | [diff] [blame] | 351 | p.append_load(srcCT, &src_ctx); |
Leon Scroggins III | 0358841 | 2017-11-17 08:07:32 -0500 | [diff] [blame] | 352 | if (srcHasAlpha) { |
| 353 | p.append(SkRasterPipeline::premul); |
| 354 | } |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 355 | |
| 356 | p.append(SkRasterPipeline::srcover); |
| 357 | |
Leon Scroggins III | 0358841 | 2017-11-17 08:07:32 -0500 | [diff] [blame] | 358 | if (kUnpremul_SkAlphaType == dstAt) { |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 359 | p.append(SkRasterPipeline::unpremul); |
| 360 | } |
Mike Klein | 1a3eb52 | 2018-10-18 10:11:00 -0400 | [diff] [blame] | 361 | p.append_store(dstCT, &dst_ctx); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 362 | |
Mike Klein | 45c16fa | 2017-07-18 18:15:13 -0400 | [diff] [blame] | 363 | p.run(0,0, width,1); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 364 | } |
| 365 | |
scroggo | eb602a5 | 2015-07-09 08:16:03 -0700 | [diff] [blame] | 366 | SkCodec::Result SkWebpCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst, size_t rowBytes, |
Leon Scroggins | 571b30f | 2017-07-11 17:35:31 +0000 | [diff] [blame] | 367 | const Options& options, int* rowsDecodedPtr) { |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 368 | const int index = options.fFrameIndex; |
Leon Scroggins III | 1f6af6b | 2017-06-12 16:41:09 -0400 | [diff] [blame] | 369 | SkASSERT(0 == index || index < fFrameHolder.size()); |
Leon Scroggins III | 42ee284 | 2018-01-14 14:46:51 -0500 | [diff] [blame] | 370 | SkASSERT(0 == index || !options.fSubset); |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 371 | |
| 372 | WebPDecoderConfig config; |
| 373 | if (0 == WebPInitDecoderConfig(&config)) { |
| 374 | // ABI mismatch. |
| 375 | // FIXME: New enum for this? |
| 376 | return kInvalidInput; |
| 377 | } |
| 378 | |
| 379 | // Free any memory associated with the buffer. Must be called last, so we declare it first. |
| 380 | SkAutoTCallVProc<WebPDecBuffer, WebPFreeDecBuffer> autoFree(&(config.output)); |
| 381 | |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 382 | WebPIterator frame; |
| 383 | SkAutoTCallVProc<WebPIterator, WebPDemuxReleaseIterator> autoFrame(&frame); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 384 | // If this succeeded in onGetFrameCount(), it should succeed again here. |
| 385 | SkAssertResult(WebPDemuxGetFrame(fDemux, index + 1, &frame)); |
Matt Sarett | 604971e | 2017-02-06 09:51:48 -0500 | [diff] [blame] | 386 | |
Leon Scroggins III | 1f6af6b | 2017-06-12 16:41:09 -0400 | [diff] [blame] | 387 | const bool independent = index == 0 ? true : |
Nigel Tao | 66bc524 | 2018-08-22 10:56:03 +1000 | [diff] [blame] | 388 | (fFrameHolder.frame(index)->getRequiredFrame() == kNoFrame); |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 389 | // Get the frameRect. libwebp will have already signaled an error if this is not fully |
| 390 | // contained by the canvas. |
| 391 | auto frameRect = SkIRect::MakeXYWH(frame.x_offset, frame.y_offset, frame.width, frame.height); |
Leon Scroggins III | 712476e | 2018-10-03 15:47:00 -0400 | [diff] [blame] | 392 | SkASSERT(this->bounds().contains(frameRect)); |
| 393 | const bool frameIsSubset = frameRect != this->bounds(); |
Leon Scroggins III | 1f6af6b | 2017-06-12 16:41:09 -0400 | [diff] [blame] | 394 | if (independent && frameIsSubset) { |
Leon Scroggins III | e643a9e | 2018-08-03 16:15:04 -0400 | [diff] [blame] | 395 | SkSampler::Fill(dstInfo, dst, rowBytes, options.fZeroInitialized); |
Matt Sarett | 604971e | 2017-02-06 09:51:48 -0500 | [diff] [blame] | 396 | } |
| 397 | |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 398 | int dstX = frameRect.x(); |
| 399 | int dstY = frameRect.y(); |
| 400 | int subsetWidth = frameRect.width(); |
| 401 | int subsetHeight = frameRect.height(); |
| 402 | if (options.fSubset) { |
| 403 | SkIRect subset = *options.fSubset; |
Leon Scroggins III | 712476e | 2018-10-03 15:47:00 -0400 | [diff] [blame] | 404 | SkASSERT(this->bounds().contains(subset)); |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 405 | SkASSERT(SkIsAlign2(subset.fLeft) && SkIsAlign2(subset.fTop)); |
| 406 | SkASSERT(this->getValidSubset(&subset) && subset == *options.fSubset); |
| 407 | |
| 408 | if (!SkIRect::IntersectsNoEmptyCheck(subset, frameRect)) { |
| 409 | return kSuccess; |
| 410 | } |
| 411 | |
| 412 | int minXOffset = SkTMin(dstX, subset.x()); |
| 413 | int minYOffset = SkTMin(dstY, subset.y()); |
| 414 | dstX -= minXOffset; |
| 415 | dstY -= minYOffset; |
| 416 | frameRect.offset(-minXOffset, -minYOffset); |
| 417 | subset.offset(-minXOffset, -minYOffset); |
| 418 | |
| 419 | // Just like we require that the requested subset x and y offset are even, libwebp |
| 420 | // guarantees that the frame x and y offset are even (it's actually impossible to specify |
| 421 | // an odd frame offset). So we can still guarantee that the adjusted offsets are even. |
| 422 | SkASSERT(SkIsAlign2(subset.fLeft) && SkIsAlign2(subset.fTop)); |
| 423 | |
| 424 | SkIRect intersection; |
| 425 | SkAssertResult(intersection.intersect(frameRect, subset)); |
| 426 | subsetWidth = intersection.width(); |
| 427 | subsetHeight = intersection.height(); |
| 428 | |
| 429 | config.options.use_cropping = 1; |
| 430 | config.options.crop_left = subset.x(); |
| 431 | config.options.crop_top = subset.y(); |
| 432 | config.options.crop_width = subsetWidth; |
| 433 | config.options.crop_height = subsetHeight; |
| 434 | } |
| 435 | |
| 436 | // Ignore the frame size and offset when determining if scaling is necessary. |
| 437 | int scaledWidth = subsetWidth; |
| 438 | int scaledHeight = subsetHeight; |
Leon Scroggins III | 712476e | 2018-10-03 15:47:00 -0400 | [diff] [blame] | 439 | SkISize srcSize = options.fSubset ? options.fSubset->size() : this->dimensions(); |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 440 | if (srcSize != dstInfo.dimensions()) { |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 441 | config.options.use_scaling = 1; |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 442 | |
| 443 | if (frameIsSubset) { |
| 444 | float scaleX = ((float) dstInfo.width()) / srcSize.width(); |
| 445 | float scaleY = ((float) dstInfo.height()) / srcSize.height(); |
| 446 | |
| 447 | // We need to be conservative here and floor rather than round. |
| 448 | // Otherwise, we may find ourselves decoding off the end of memory. |
| 449 | dstX = scaleX * dstX; |
| 450 | scaledWidth = scaleX * scaledWidth; |
| 451 | dstY = scaleY * dstY; |
| 452 | scaledHeight = scaleY * scaledHeight; |
| 453 | if (0 == scaledWidth || 0 == scaledHeight) { |
| 454 | return kSuccess; |
| 455 | } |
| 456 | } else { |
| 457 | scaledWidth = dstInfo.width(); |
| 458 | scaledHeight = dstInfo.height(); |
| 459 | } |
| 460 | |
| 461 | config.options.scaled_width = scaledWidth; |
| 462 | config.options.scaled_height = scaledHeight; |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 463 | } |
| 464 | |
Leon Scroggins III | 1f6af6b | 2017-06-12 16:41:09 -0400 | [diff] [blame] | 465 | const bool blendWithPrevFrame = !independent && frame.blend_method == WEBP_MUX_BLEND |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 466 | && frame.has_alpha; |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 467 | |
| 468 | SkBitmap webpDst; |
Leon Scroggins III | ee92f13 | 2017-05-23 15:28:46 -0400 | [diff] [blame] | 469 | auto webpInfo = dstInfo; |
| 470 | if (!frame.has_alpha) { |
| 471 | webpInfo = webpInfo.makeAlphaType(kOpaque_SkAlphaType); |
| 472 | } |
| 473 | if (this->colorXform()) { |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 474 | // Swizzling between RGBA and BGRA is zero cost in a color transform. So when we have a |
| 475 | // color transform, we should decode to whatever is easiest for libwebp, and then let the |
| 476 | // color transform swizzle if necessary. |
| 477 | // Lossy webp is encoded as YUV (so RGBA and BGRA are the same cost). Lossless webp is |
| 478 | // encoded as BGRA. This means decoding to BGRA is either faster or the same cost as RGBA. |
Leon Scroggins III | ee92f13 | 2017-05-23 15:28:46 -0400 | [diff] [blame] | 479 | webpInfo = webpInfo.makeColorType(kBGRA_8888_SkColorType); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 480 | |
Leon Scroggins III | ee92f13 | 2017-05-23 15:28:46 -0400 | [diff] [blame] | 481 | if (webpInfo.alphaType() == kPremul_SkAlphaType) { |
| 482 | webpInfo = webpInfo.makeAlphaType(kUnpremul_SkAlphaType); |
| 483 | } |
| 484 | } |
| 485 | |
| 486 | if ((this->colorXform() && !is_8888(dstInfo.colorType())) || blendWithPrevFrame) { |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 487 | // We will decode the entire image and then perform the color transform. libwebp |
| 488 | // does not provide a row-by-row API. This is a shame particularly when we do not want |
| 489 | // 8888, since we will need to create another image sized buffer. |
Leon Scroggins III | ee92f13 | 2017-05-23 15:28:46 -0400 | [diff] [blame] | 490 | webpDst.allocPixels(webpInfo); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 491 | } else { |
| 492 | // libwebp can decode directly into the output memory. |
Leon Scroggins III | ee92f13 | 2017-05-23 15:28:46 -0400 | [diff] [blame] | 493 | webpDst.installPixels(webpInfo, dst, rowBytes); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 494 | } |
| 495 | |
Leon Scroggins III | 36f7e32 | 2018-08-27 11:55:46 -0400 | [diff] [blame] | 496 | config.output.colorspace = webp_decode_mode(webpInfo.colorType(), |
| 497 | frame.has_alpha && dstInfo.alphaType() == kPremul_SkAlphaType && !this->colorXform()); |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 498 | config.output.is_external_memory = 1; |
| 499 | |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 500 | config.output.u.RGBA.rgba = reinterpret_cast<uint8_t*>(webpDst.getAddr(dstX, dstY)); |
| 501 | config.output.u.RGBA.stride = static_cast<int>(webpDst.rowBytes()); |
Mike Reed | f0ffb89 | 2017-10-03 14:47:21 -0400 | [diff] [blame] | 502 | config.output.u.RGBA.size = webpDst.computeByteSize(); |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 503 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 504 | SkAutoTCallVProc<WebPIDecoder, WebPIDelete> idec(WebPIDecode(nullptr, 0, &config)); |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 505 | if (!idec) { |
| 506 | return kInvalidInput; |
| 507 | } |
| 508 | |
Leon Scroggins III | e567746 | 2017-09-27 16:31:08 -0400 | [diff] [blame] | 509 | int rowsDecoded = 0; |
msarett | e99883f | 2016-09-08 06:05:35 -0700 | [diff] [blame] | 510 | SkCodec::Result result; |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 511 | switch (WebPIUpdate(idec, frame.fragment.bytes, frame.fragment.size)) { |
| 512 | case VP8_STATUS_OK: |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 513 | rowsDecoded = scaledHeight; |
msarett | e99883f | 2016-09-08 06:05:35 -0700 | [diff] [blame] | 514 | result = kSuccess; |
| 515 | break; |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 516 | case VP8_STATUS_SUSPENDED: |
Leon Scroggins III | e567746 | 2017-09-27 16:31:08 -0400 | [diff] [blame] | 517 | if (!WebPIDecGetRGB(idec, &rowsDecoded, nullptr, nullptr, nullptr) |
| 518 | || rowsDecoded <= 0) { |
| 519 | return kInvalidInput; |
| 520 | } |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 521 | *rowsDecodedPtr = rowsDecoded + dstY; |
msarett | e99883f | 2016-09-08 06:05:35 -0700 | [diff] [blame] | 522 | result = kIncompleteInput; |
| 523 | break; |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 524 | default: |
| 525 | return kInvalidInput; |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 526 | } |
msarett | e99883f | 2016-09-08 06:05:35 -0700 | [diff] [blame] | 527 | |
Mike Reed | 7fcfb62 | 2018-02-09 13:26:46 -0500 | [diff] [blame] | 528 | const size_t dstBpp = dstInfo.bytesPerPixel(); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 529 | dst = SkTAddOffset<void>(dst, dstBpp * dstX + rowBytes * dstY); |
| 530 | const size_t srcRowBytes = config.output.u.RGBA.stride; |
| 531 | |
| 532 | const auto dstCT = dstInfo.colorType(); |
Matt Sarett | 313c463 | 2016-10-20 12:35:23 -0400 | [diff] [blame] | 533 | if (this->colorXform()) { |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 534 | uint32_t* xformSrc = (uint32_t*) config.output.u.RGBA.rgba; |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 535 | SkBitmap tmp; |
| 536 | void* xformDst; |
| 537 | |
| 538 | if (blendWithPrevFrame) { |
| 539 | // Xform into temporary bitmap big enough for one row. |
| 540 | tmp.allocPixels(dstInfo.makeWH(scaledWidth, 1)); |
| 541 | xformDst = tmp.getPixels(); |
| 542 | } else { |
| 543 | xformDst = dst; |
| 544 | } |
Leon Scroggins III | 0358841 | 2017-11-17 08:07:32 -0500 | [diff] [blame] | 545 | |
Robert Phillips | b3050b9 | 2017-02-06 13:12:18 +0000 | [diff] [blame] | 546 | for (int y = 0; y < rowsDecoded; y++) { |
Leon Scroggins III | 36f7e32 | 2018-08-27 11:55:46 -0400 | [diff] [blame] | 547 | this->applyColorXform(xformDst, xformSrc, scaledWidth); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 548 | if (blendWithPrevFrame) { |
Mike Klein | 76f5706 | 2018-06-08 14:00:19 -0400 | [diff] [blame] | 549 | blend_line(dstCT, dst, dstCT, xformDst, |
Leon Scroggins III | 0358841 | 2017-11-17 08:07:32 -0500 | [diff] [blame] | 550 | dstInfo.alphaType(), frame.has_alpha, scaledWidth); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 551 | dst = SkTAddOffset<void>(dst, rowBytes); |
| 552 | } else { |
| 553 | xformDst = SkTAddOffset<void>(xformDst, rowBytes); |
| 554 | } |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 555 | xformSrc = SkTAddOffset<uint32_t>(xformSrc, srcRowBytes); |
msarett | e99883f | 2016-09-08 06:05:35 -0700 | [diff] [blame] | 556 | } |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 557 | } else if (blendWithPrevFrame) { |
| 558 | const uint8_t* src = config.output.u.RGBA.rgba; |
| 559 | |
| 560 | for (int y = 0; y < rowsDecoded; y++) { |
Mike Klein | 76f5706 | 2018-06-08 14:00:19 -0400 | [diff] [blame] | 561 | blend_line(dstCT, dst, webpDst.colorType(), src, |
Leon Scroggins III | 0358841 | 2017-11-17 08:07:32 -0500 | [diff] [blame] | 562 | dstInfo.alphaType(), frame.has_alpha, scaledWidth); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 563 | src = SkTAddOffset<const uint8_t>(src, srcRowBytes); |
| 564 | dst = SkTAddOffset<void>(dst, rowBytes); |
| 565 | } |
msarett | e99883f | 2016-09-08 06:05:35 -0700 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | return result; |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 569 | } |
| 570 | |
Leon Scroggins III | 36f7e32 | 2018-08-27 11:55:46 -0400 | [diff] [blame] | 571 | SkWebpCodec::SkWebpCodec(SkEncodedInfo&& info, std::unique_ptr<SkStream> stream, |
Leon Scroggins III | da3e9ad | 2018-01-26 15:48:26 -0500 | [diff] [blame] | 572 | WebPDemuxer* demux, sk_sp<SkData> data, SkEncodedOrigin origin) |
Leon Scroggins III | 36f7e32 | 2018-08-27 11:55:46 -0400 | [diff] [blame] | 573 | : INHERITED(std::move(info), skcms_PixelFormat_BGRA_8888, std::move(stream), |
| 574 | origin) |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 575 | , fDemux(demux) |
| 576 | , fData(std::move(data)) |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 577 | , fFailed(false) |
| 578 | { |
Leon Scroggins III | 36f7e32 | 2018-08-27 11:55:46 -0400 | [diff] [blame] | 579 | const auto& eInfo = this->getEncodedInfo(); |
| 580 | fFrameHolder.setScreenSize(eInfo.width(), eInfo.height()); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 581 | } |