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 | |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 8 | #include "SkBitmap.h" |
| 9 | #include "SkCanvas.h" |
Leon Scroggins III | 33deb7e | 2017-06-07 12:31:51 -0400 | [diff] [blame^] | 10 | #include "SkCodecAnimation.h" |
| 11 | #include "SkCodecAnimationPriv.h" |
scroggo | cc2feb1 | 2015-08-14 08:32:46 -0700 | [diff] [blame] | 12 | #include "SkCodecPriv.h" |
msarett | e99883f | 2016-09-08 06:05:35 -0700 | [diff] [blame] | 13 | #include "SkColorSpaceXform.h" |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 14 | #include "SkRasterPipeline.h" |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 15 | #include "SkSampler.h" |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 16 | #include "SkStreamPriv.h" |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 17 | #include "SkTemplates.h" |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 18 | #include "SkWebpCodec.h" |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 19 | |
| 20 | // A WebP decoder on top of (subset of) libwebp |
| 21 | // For more information on WebP image format, and libwebp library, see: |
| 22 | // https://code.google.com/speed/webp/ |
| 23 | // http://www.webmproject.org/code/#libwebp-webp-image-library |
| 24 | // https://chromium.googlesource.com/webm/libwebp |
| 25 | |
| 26 | // If moving libwebp out of skia source tree, path for webp headers must be |
| 27 | // updated accordingly. Here, we enforce using local copy in webp sub-directory. |
| 28 | #include "webp/decode.h" |
msarett | 9d15dab | 2016-08-24 07:36:06 -0700 | [diff] [blame] | 29 | #include "webp/demux.h" |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 30 | #include "webp/encode.h" |
| 31 | |
scroggo | db30be2 | 2015-12-08 18:54:13 -0800 | [diff] [blame] | 32 | bool SkWebpCodec::IsWebp(const void* buf, size_t bytesRead) { |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 33 | // WEBP starts with the following: |
| 34 | // RIFFXXXXWEBPVP |
| 35 | // Where XXXX is unspecified. |
scroggo | db30be2 | 2015-12-08 18:54:13 -0800 | [diff] [blame] | 36 | const char* bytes = static_cast<const char*>(buf); |
| 37 | return bytesRead >= 14 && !memcmp(bytes, "RIFF", 4) && !memcmp(&bytes[8], "WEBPVP", 6); |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 38 | } |
| 39 | |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 40 | static SkAlphaType alpha_type(bool hasAlpha) { |
| 41 | return hasAlpha ? kUnpremul_SkAlphaType : kOpaque_SkAlphaType; |
| 42 | } |
| 43 | |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 44 | // 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] | 45 | // Returns an SkWebpCodec on success |
msarett | ac6c750 | 2016-04-25 09:30:24 -0700 | [diff] [blame] | 46 | SkCodec* SkWebpCodec::NewFromStream(SkStream* stream) { |
Ben Wagner | 145dbcd | 2016-11-03 14:40:50 -0400 | [diff] [blame] | 47 | std::unique_ptr<SkStream> streamDeleter(stream); |
msarett | ac6c750 | 2016-04-25 09:30:24 -0700 | [diff] [blame] | 48 | |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 49 | // Webp demux needs a contiguous data buffer. |
| 50 | sk_sp<SkData> data = nullptr; |
| 51 | if (stream->getMemoryBase()) { |
| 52 | // It is safe to make without copy because we'll hold onto the stream. |
| 53 | data = SkData::MakeWithoutCopy(stream->getMemoryBase(), stream->getLength()); |
| 54 | } else { |
| 55 | data = SkCopyStreamToData(stream); |
scroggo | db30be2 | 2015-12-08 18:54:13 -0800 | [diff] [blame] | 56 | |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 57 | // If we are forced to copy the stream to a data, we can go ahead and delete the stream. |
| 58 | streamDeleter.reset(nullptr); |
| 59 | } |
| 60 | |
| 61 | // It's a little strange that the |demux| will outlive |webpData|, though it needs the |
| 62 | // pointer in |webpData| to remain valid. This works because the pointer remains valid |
| 63 | // until the SkData is freed. |
| 64 | WebPData webpData = { data->bytes(), data->size() }; |
| 65 | SkAutoTCallVProc<WebPDemuxer, WebPDemuxDelete> demux(WebPDemuxPartial(&webpData, nullptr)); |
| 66 | if (nullptr == demux) { |
msarett | ac6c750 | 2016-04-25 09:30:24 -0700 | [diff] [blame] | 67 | return nullptr; |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 68 | } |
| 69 | |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 70 | const int width = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH); |
| 71 | const int height = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT); |
| 72 | |
| 73 | // Sanity check for image size that's about to be decoded. |
| 74 | { |
| 75 | const int64_t size = sk_64_mul(width, height); |
| 76 | if (!sk_64_isS32(size)) { |
| 77 | return nullptr; |
| 78 | } |
| 79 | // now check that if we are 4-bytes per pixel, we also don't overflow |
| 80 | if (sk_64_asS32(size) > (0x7FFFFFFF >> 2)) { |
| 81 | return nullptr; |
| 82 | } |
| 83 | } |
| 84 | |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 85 | WebPChunkIterator chunkIterator; |
| 86 | SkAutoTCallVProc<WebPChunkIterator, WebPDemuxReleaseChunkIterator> autoCI(&chunkIterator); |
| 87 | sk_sp<SkColorSpace> colorSpace = nullptr; |
raftias | d737bee | 2016-12-08 10:53:24 -0500 | [diff] [blame] | 88 | bool unsupportedICC = false; |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 89 | if (WebPDemuxGetChunk(demux, "ICCP", 1, &chunkIterator)) { |
Brian Osman | 526972e | 2016-10-24 09:24:02 -0400 | [diff] [blame] | 90 | colorSpace = SkColorSpace::MakeICC(chunkIterator.chunk.bytes, chunkIterator.chunk.size); |
raftias | d737bee | 2016-12-08 10:53:24 -0500 | [diff] [blame] | 91 | if (!colorSpace) { |
| 92 | unsupportedICC = true; |
| 93 | } |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 94 | } |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 95 | if (!colorSpace) { |
Matt Sarett | 77a7a1b | 2017-02-07 13:56:11 -0500 | [diff] [blame] | 96 | colorSpace = SkColorSpace::MakeSRGB(); |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 97 | } |
| 98 | |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 99 | // 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] | 100 | WebPIterator frame; |
| 101 | SkAutoTCallVProc<WebPIterator, WebPDemuxReleaseIterator> autoFrame(&frame); |
| 102 | if (!WebPDemuxGetFrame(demux, 1, &frame)) { |
| 103 | return nullptr; |
| 104 | } |
| 105 | |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 106 | WebPBitstreamFeatures features; |
| 107 | VP8StatusCode status = WebPGetFeatures(frame.fragment.bytes, frame.fragment.size, &features); |
| 108 | if (VP8_STATUS_OK != status) { |
| 109 | return nullptr; |
| 110 | } |
| 111 | |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 112 | const bool hasAlpha = SkToBool(frame.has_alpha) |
| 113 | || frame.width != width || frame.height != height; |
msarett | ac6c750 | 2016-04-25 09:30:24 -0700 | [diff] [blame] | 114 | SkEncodedInfo::Color color; |
| 115 | SkEncodedInfo::Alpha alpha; |
| 116 | switch (features.format) { |
| 117 | case 0: |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 118 | // This indicates a "mixed" format. We could see this for |
| 119 | // animated webps (multiple fragments). |
msarett | ac6c750 | 2016-04-25 09:30:24 -0700 | [diff] [blame] | 120 | // We could also guess kYUV here, but I think it makes more |
| 121 | // sense to guess kBGRA which is likely closer to the final |
| 122 | // output. Otherwise, we might end up converting |
| 123 | // BGRA->YUVA->BGRA. |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 124 | // Fallthrough: |
| 125 | case 2: |
| 126 | // This is the lossless format (BGRA). |
| 127 | if (hasAlpha) { |
| 128 | color = SkEncodedInfo::kBGRA_Color; |
| 129 | alpha = SkEncodedInfo::kUnpremul_Alpha; |
| 130 | } else { |
| 131 | color = SkEncodedInfo::kBGRX_Color; |
| 132 | alpha = SkEncodedInfo::kOpaque_Alpha; |
| 133 | } |
msarett | ac6c750 | 2016-04-25 09:30:24 -0700 | [diff] [blame] | 134 | break; |
| 135 | case 1: |
| 136 | // This is the lossy format (YUV). |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 137 | if (hasAlpha) { |
msarett | ac6c750 | 2016-04-25 09:30:24 -0700 | [diff] [blame] | 138 | color = SkEncodedInfo::kYUVA_Color; |
msarett | c30c418 | 2016-04-20 11:53:35 -0700 | [diff] [blame] | 139 | alpha = SkEncodedInfo::kUnpremul_Alpha; |
msarett | ac6c750 | 2016-04-25 09:30:24 -0700 | [diff] [blame] | 140 | } else { |
| 141 | color = SkEncodedInfo::kYUV_Color; |
| 142 | alpha = SkEncodedInfo::kOpaque_Alpha; |
| 143 | } |
| 144 | break; |
msarett | ac6c750 | 2016-04-25 09:30:24 -0700 | [diff] [blame] | 145 | default: |
| 146 | return nullptr; |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 147 | } |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 148 | |
msarett | ac6c750 | 2016-04-25 09:30:24 -0700 | [diff] [blame] | 149 | SkEncodedInfo info = SkEncodedInfo::Make(color, alpha, 8); |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 150 | SkWebpCodec* codecOut = new SkWebpCodec(width, height, info, std::move(colorSpace), |
| 151 | streamDeleter.release(), demux.release(), |
| 152 | std::move(data)); |
raftias | d737bee | 2016-12-08 10:53:24 -0500 | [diff] [blame] | 153 | codecOut->setUnsupportedICC(unsupportedICC); |
| 154 | return codecOut; |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 155 | } |
| 156 | |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 157 | SkISize SkWebpCodec::onGetScaledDimensions(float desiredScale) const { |
| 158 | SkISize dim = this->getInfo().dimensions(); |
msarett | a0c414d | 2015-06-19 07:34:30 -0700 | [diff] [blame] | 159 | // SkCodec treats zero dimensional images as errors, so the minimum size |
| 160 | // that we will recommend is 1x1. |
| 161 | dim.fWidth = SkTMax(1, SkScalarRoundToInt(desiredScale * dim.fWidth)); |
| 162 | dim.fHeight = SkTMax(1, SkScalarRoundToInt(desiredScale * dim.fHeight)); |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 163 | return dim; |
| 164 | } |
| 165 | |
scroggo | e7fc14b | 2015-10-02 13:14:46 -0700 | [diff] [blame] | 166 | bool SkWebpCodec::onDimensionsSupported(const SkISize& dim) { |
| 167 | const SkImageInfo& info = this->getInfo(); |
| 168 | return dim.width() >= 1 && dim.width() <= info.width() |
| 169 | && dim.height() >= 1 && dim.height() <= info.height(); |
| 170 | } |
| 171 | |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 172 | static WEBP_CSP_MODE webp_decode_mode(const SkImageInfo& info) { |
| 173 | const bool premultiply = info.alphaType() == kPremul_SkAlphaType; |
| 174 | switch (info.colorType()) { |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 175 | case kBGRA_8888_SkColorType: |
| 176 | return premultiply ? MODE_bgrA : MODE_BGRA; |
| 177 | case kRGBA_8888_SkColorType: |
| 178 | return premultiply ? MODE_rgbA : MODE_RGBA; |
scroggo | 74992b5 | 2015-08-06 13:50:15 -0700 | [diff] [blame] | 179 | case kRGB_565_SkColorType: |
| 180 | return MODE_RGB_565; |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 181 | default: |
| 182 | return MODE_LAST; |
| 183 | } |
| 184 | } |
| 185 | |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 186 | SkWebpCodec::Frame* SkWebpCodec::FrameHolder::appendNewFrame(bool hasAlpha) { |
| 187 | const int i = this->size(); |
| 188 | fFrames.emplace_back(i, hasAlpha); |
| 189 | return &fFrames[i]; |
| 190 | } |
| 191 | |
scroggo | b636b45 | 2015-07-22 07:16:20 -0700 | [diff] [blame] | 192 | bool SkWebpCodec::onGetValidSubset(SkIRect* desiredSubset) const { |
| 193 | if (!desiredSubset) { |
| 194 | return false; |
| 195 | } |
| 196 | |
msarett | fdb4757 | 2015-10-13 12:50:14 -0700 | [diff] [blame] | 197 | SkIRect dimensions = SkIRect::MakeSize(this->getInfo().dimensions()); |
| 198 | if (!dimensions.contains(*desiredSubset)) { |
scroggo | b636b45 | 2015-07-22 07:16:20 -0700 | [diff] [blame] | 199 | return false; |
| 200 | } |
| 201 | |
| 202 | // As stated below, libwebp snaps to even left and top. Make sure top and left are even, so we |
| 203 | // decode this exact subset. |
| 204 | // Leave right and bottom unmodified, so we suggest a slightly larger subset than requested. |
| 205 | desiredSubset->fLeft = (desiredSubset->fLeft >> 1) << 1; |
| 206 | desiredSubset->fTop = (desiredSubset->fTop >> 1) << 1; |
| 207 | return true; |
| 208 | } |
| 209 | |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 210 | int SkWebpCodec::onGetRepetitionCount() { |
| 211 | auto flags = WebPDemuxGetI(fDemux.get(), WEBP_FF_FORMAT_FLAGS); |
| 212 | if (!(flags & ANIMATION_FLAG)) { |
| 213 | return 0; |
| 214 | } |
| 215 | |
| 216 | const int repCount = WebPDemuxGetI(fDemux.get(), WEBP_FF_LOOP_COUNT); |
| 217 | if (0 == repCount) { |
| 218 | return kRepetitionCountInfinite; |
| 219 | } |
| 220 | |
| 221 | return repCount; |
| 222 | } |
| 223 | |
| 224 | int SkWebpCodec::onGetFrameCount() { |
| 225 | auto flags = WebPDemuxGetI(fDemux.get(), WEBP_FF_FORMAT_FLAGS); |
| 226 | if (!(flags & ANIMATION_FLAG)) { |
| 227 | return 1; |
| 228 | } |
| 229 | |
| 230 | const uint32_t oldFrameCount = fFrameHolder.size(); |
| 231 | if (fFailed) { |
| 232 | return oldFrameCount; |
| 233 | } |
| 234 | |
| 235 | const uint32_t frameCount = WebPDemuxGetI(fDemux, WEBP_FF_FRAME_COUNT); |
| 236 | if (oldFrameCount == frameCount) { |
| 237 | // We have already parsed this. |
| 238 | return frameCount; |
| 239 | } |
| 240 | |
| 241 | fFrameHolder.reserve(frameCount); |
| 242 | |
| 243 | for (uint32_t i = oldFrameCount; i < frameCount; i++) { |
| 244 | WebPIterator iter; |
| 245 | SkAutoTCallVProc<WebPIterator, WebPDemuxReleaseIterator> autoIter(&iter); |
| 246 | |
| 247 | if (!WebPDemuxGetFrame(fDemux.get(), i + 1, &iter)) { |
| 248 | fFailed = true; |
| 249 | break; |
| 250 | } |
| 251 | |
| 252 | // libwebp only reports complete frames of an animated image. |
| 253 | SkASSERT(iter.complete); |
| 254 | |
| 255 | Frame* frame = fFrameHolder.appendNewFrame(iter.has_alpha); |
| 256 | frame->setXYWH(iter.x_offset, iter.y_offset, iter.width, iter.height); |
| 257 | frame->setDisposalMethod(iter.dispose_method == WEBP_MUX_DISPOSE_BACKGROUND ? |
Leon Scroggins III | 33deb7e | 2017-06-07 12:31:51 -0400 | [diff] [blame^] | 258 | SkCodecAnimation::DisposalMethod::kRestoreBGColor : |
| 259 | SkCodecAnimation::DisposalMethod::kKeep); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 260 | frame->setDuration(iter.duration); |
| 261 | if (WEBP_MUX_BLEND != iter.blend_method) { |
| 262 | frame->setBlend(SkCodecAnimation::Blend::kBG); |
| 263 | } |
| 264 | fFrameHolder.setAlphaAndRequiredFrame(frame); |
| 265 | } |
| 266 | |
| 267 | return fFrameHolder.size(); |
| 268 | |
| 269 | } |
| 270 | |
| 271 | const SkFrame* SkWebpCodec::FrameHolder::onGetFrame(int i) const { |
| 272 | return static_cast<const SkFrame*>(this->frame(i)); |
| 273 | } |
| 274 | |
| 275 | const SkWebpCodec::Frame* SkWebpCodec::FrameHolder::frame(int i) const { |
| 276 | SkASSERT(i >= 0 && i < this->size()); |
| 277 | return &fFrames[i]; |
| 278 | } |
| 279 | |
| 280 | bool SkWebpCodec::onGetFrameInfo(int i, FrameInfo* frameInfo) const { |
| 281 | if (i >= fFrameHolder.size()) { |
| 282 | return false; |
| 283 | } |
| 284 | |
| 285 | const Frame* frame = fFrameHolder.frame(i); |
| 286 | if (!frame) { |
| 287 | return false; |
| 288 | } |
| 289 | |
| 290 | if (frameInfo) { |
| 291 | frameInfo->fRequiredFrame = frame->getRequiredFrame(); |
| 292 | frameInfo->fDuration = frame->getDuration(); |
| 293 | // libwebp only reports fully received frames for an |
| 294 | // animated image. |
| 295 | frameInfo->fFullyReceived = true; |
| 296 | frameInfo->fAlphaType = alpha_type(frame->hasAlpha()); |
Leon Scroggins III | 33deb7e | 2017-06-07 12:31:51 -0400 | [diff] [blame^] | 297 | frameInfo->fDisposalMethod = frame->getDisposalMethod(); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | return true; |
| 301 | } |
| 302 | |
| 303 | static bool is_8888(SkColorType colorType) { |
| 304 | switch (colorType) { |
| 305 | case kRGBA_8888_SkColorType: |
| 306 | case kBGRA_8888_SkColorType: |
| 307 | return true; |
| 308 | default: |
| 309 | return false; |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | static void pick_memory_stages(SkColorType ct, SkRasterPipeline::StockStage* load, |
| 314 | SkRasterPipeline::StockStage* store) { |
| 315 | switch(ct) { |
| 316 | case kUnknown_SkColorType: |
| 317 | case kAlpha_8_SkColorType: |
| 318 | case kARGB_4444_SkColorType: |
| 319 | case kIndex_8_SkColorType: |
| 320 | case kGray_8_SkColorType: |
| 321 | SkASSERT(false); |
| 322 | break; |
| 323 | case kRGB_565_SkColorType: |
| 324 | if (load) *load = SkRasterPipeline::load_565; |
| 325 | if (store) *store = SkRasterPipeline::store_565; |
| 326 | break; |
| 327 | case kRGBA_8888_SkColorType: |
| 328 | case kBGRA_8888_SkColorType: |
| 329 | if (load) *load = SkRasterPipeline::load_8888; |
| 330 | if (store) *store = SkRasterPipeline::store_8888; |
| 331 | break; |
| 332 | case kRGBA_F16_SkColorType: |
| 333 | if (load) *load = SkRasterPipeline::load_f16; |
| 334 | if (store) *store = SkRasterPipeline::store_f16; |
| 335 | break; |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | static void blend_line(SkColorType dstCT, void* dst, |
| 340 | SkColorType srcCT, void* src, |
| 341 | bool needsSrgbToLinear, SkAlphaType at, |
| 342 | int width) { |
| 343 | // Setup conversion from the source and dest, which will be the same. |
Mike Klein | b24704d | 2017-05-24 07:53:00 -0400 | [diff] [blame] | 344 | SkRasterPipeline_<256> convert_to_linear_premul; |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 345 | if (needsSrgbToLinear) { |
| 346 | convert_to_linear_premul.append_from_srgb(at); |
| 347 | } |
| 348 | if (kUnpremul_SkAlphaType == at) { |
| 349 | // srcover assumes premultiplied inputs. |
| 350 | convert_to_linear_premul.append(SkRasterPipeline::premul); |
| 351 | } |
| 352 | |
Mike Klein | b24704d | 2017-05-24 07:53:00 -0400 | [diff] [blame] | 353 | SkRasterPipeline_<256> p; |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 354 | SkRasterPipeline::StockStage load_dst, store_dst; |
| 355 | pick_memory_stages(dstCT, &load_dst, &store_dst); |
| 356 | |
| 357 | // Load the final dst. |
| 358 | p.append(load_dst, dst); |
| 359 | p.extend(convert_to_linear_premul); |
| 360 | p.append(SkRasterPipeline::move_src_dst); |
| 361 | |
| 362 | // Load the src. |
| 363 | SkRasterPipeline::StockStage load_src; |
| 364 | pick_memory_stages(srcCT, &load_src, nullptr); |
| 365 | p.append(load_src, src); |
| 366 | if (dstCT != srcCT) { |
| 367 | SkASSERT(kBGRA_8888_SkColorType == srcCT); |
| 368 | p.append(SkRasterPipeline::swap_rb); |
| 369 | } |
| 370 | p.extend(convert_to_linear_premul); |
| 371 | |
| 372 | p.append(SkRasterPipeline::srcover); |
| 373 | |
| 374 | // Convert back to dst. |
| 375 | if (kUnpremul_SkAlphaType == at) { |
| 376 | p.append(SkRasterPipeline::unpremul); |
| 377 | } |
| 378 | if (needsSrgbToLinear) { |
| 379 | p.append(SkRasterPipeline::to_srgb); |
| 380 | } |
| 381 | p.append(store_dst, dst); |
| 382 | |
Mike Klein | 761d27c | 2017-06-01 12:37:08 -0400 | [diff] [blame] | 383 | p.run(0,0, width); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 384 | } |
| 385 | |
scroggo | eb602a5 | 2015-07-09 08:16:03 -0700 | [diff] [blame] | 386 | SkCodec::Result SkWebpCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst, size_t rowBytes, |
msarett | e6dd004 | 2015-10-09 11:07:34 -0700 | [diff] [blame] | 387 | const Options& options, SkPMColor*, int*, |
msarett | e99883f | 2016-09-08 06:05:35 -0700 | [diff] [blame] | 388 | int* rowsDecodedPtr) { |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 389 | // Ensure that we have parsed this far. |
| 390 | const int index = options.fFrameIndex; |
| 391 | if (index >= this->onGetFrameCount()) { |
| 392 | return kIncompleteInput; |
| 393 | } |
| 394 | |
| 395 | const auto& srcInfo = this->getInfo(); |
Matt Sarett | cf3f234 | 2017-03-23 15:32:25 -0400 | [diff] [blame] | 396 | { |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 397 | auto info = srcInfo; |
| 398 | if (index > 0) { |
| 399 | auto alphaType = alpha_type(fFrameHolder.frame(index)->hasAlpha()); |
| 400 | info = info.makeAlphaType(alphaType); |
| 401 | } |
| 402 | if (!conversion_possible(dstInfo, info) || |
| 403 | !this->initializeColorXform(dstInfo, options.fPremulBehavior)) |
| 404 | { |
| 405 | return kInvalidConversion; |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | if (index > 0 && (options.fSubset || dstInfo.dimensions() != srcInfo.dimensions())) { |
| 410 | // Subsetting and scaling are tricky when asking for frames beyond frame 0. In order to |
| 411 | // support it, we'll need to determine the proper rectangle for a |
| 412 | // WEBP_MUX_DISPOSE_BACKGROUND required frame before erasing it. (Currently the order |
| 413 | // is backwards.) Disable until it becomes clear that supporting it is important. |
| 414 | return kUnimplemented; |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | WebPDecoderConfig config; |
| 418 | if (0 == WebPInitDecoderConfig(&config)) { |
| 419 | // ABI mismatch. |
| 420 | // FIXME: New enum for this? |
| 421 | return kInvalidInput; |
| 422 | } |
| 423 | |
| 424 | // Free any memory associated with the buffer. Must be called last, so we declare it first. |
| 425 | SkAutoTCallVProc<WebPDecBuffer, WebPFreeDecBuffer> autoFree(&(config.output)); |
| 426 | |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 427 | WebPIterator frame; |
| 428 | SkAutoTCallVProc<WebPIterator, WebPDemuxReleaseIterator> autoFrame(&frame); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 429 | // If this succeeded in onGetFrameCount(), it should succeed again here. |
| 430 | SkAssertResult(WebPDemuxGetFrame(fDemux, index + 1, &frame)); |
Matt Sarett | 604971e | 2017-02-06 09:51:48 -0500 | [diff] [blame] | 431 | |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 432 | const int requiredFrame = index == 0 ? kNone : fFrameHolder.frame(index)->getRequiredFrame(); |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 433 | // Get the frameRect. libwebp will have already signaled an error if this is not fully |
| 434 | // contained by the canvas. |
| 435 | auto frameRect = SkIRect::MakeXYWH(frame.x_offset, frame.y_offset, frame.width, frame.height); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 436 | SkASSERT(srcInfo.bounds().contains(frameRect)); |
| 437 | const bool frameIsSubset = frameRect != srcInfo.bounds(); |
| 438 | if (kNone == requiredFrame) { |
| 439 | if (frameIsSubset) { |
| 440 | SkSampler::Fill(dstInfo, dst, rowBytes, 0, options.fZeroInitialized); |
| 441 | } |
| 442 | } else { |
Leon Scroggins III | 33deb7e | 2017-06-07 12:31:51 -0400 | [diff] [blame^] | 443 | // FIXME: Share with GIF |
| 444 | if (options.fPriorFrame != kNone) { |
| 445 | if (options.fPriorFrame < requiredFrame || options.fPriorFrame >= index) { |
| 446 | return kInvalidParameters; |
| 447 | } |
| 448 | } else { |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 449 | Options prevFrameOpts(options); |
| 450 | prevFrameOpts.fFrameIndex = requiredFrame; |
Leon Scroggins III | 33deb7e | 2017-06-07 12:31:51 -0400 | [diff] [blame^] | 451 | prevFrameOpts.fPriorFrame = kNone; |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 452 | const auto result = this->getPixels(dstInfo, dst, rowBytes, &prevFrameOpts, |
| 453 | nullptr, nullptr); |
| 454 | switch (result) { |
| 455 | case kSuccess: |
| 456 | break; |
| 457 | case kIncompleteInput: |
| 458 | return kInvalidInput; |
| 459 | default: |
| 460 | return result; |
| 461 | } |
| 462 | } |
| 463 | |
Leon Scroggins III | 33deb7e | 2017-06-07 12:31:51 -0400 | [diff] [blame^] | 464 | if (options.fPriorFrame == requiredFrame || options.fPriorFrame == kNone) { |
| 465 | // Dispose bg color |
| 466 | const Frame* priorFrame = fFrameHolder.frame(requiredFrame); |
| 467 | if (priorFrame->getDisposalMethod() |
| 468 | == SkCodecAnimation::DisposalMethod::kRestoreBGColor) { |
| 469 | // FIXME: If we add support for scaling/subsets, this rectangle needs to be |
| 470 | // adjusted. |
| 471 | const auto priorRect = priorFrame->frameRect(); |
| 472 | const auto info = dstInfo.makeWH(priorRect.width(), priorRect.height()); |
| 473 | const size_t bpp = SkColorTypeBytesPerPixel(dstInfo.colorType()); |
| 474 | const size_t offset = priorRect.x() * bpp + priorRect.y() * rowBytes; |
| 475 | auto* eraseDst = SkTAddOffset<void>(dst, offset); |
| 476 | SkSampler::Fill(info, eraseDst, rowBytes, 0, kNo_ZeroInitialized); |
| 477 | } |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 478 | } |
Matt Sarett | 604971e | 2017-02-06 09:51:48 -0500 | [diff] [blame] | 479 | } |
| 480 | |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 481 | int dstX = frameRect.x(); |
| 482 | int dstY = frameRect.y(); |
| 483 | int subsetWidth = frameRect.width(); |
| 484 | int subsetHeight = frameRect.height(); |
| 485 | if (options.fSubset) { |
| 486 | SkIRect subset = *options.fSubset; |
| 487 | SkASSERT(this->getInfo().bounds().contains(subset)); |
| 488 | SkASSERT(SkIsAlign2(subset.fLeft) && SkIsAlign2(subset.fTop)); |
| 489 | SkASSERT(this->getValidSubset(&subset) && subset == *options.fSubset); |
| 490 | |
| 491 | if (!SkIRect::IntersectsNoEmptyCheck(subset, frameRect)) { |
| 492 | return kSuccess; |
| 493 | } |
| 494 | |
| 495 | int minXOffset = SkTMin(dstX, subset.x()); |
| 496 | int minYOffset = SkTMin(dstY, subset.y()); |
| 497 | dstX -= minXOffset; |
| 498 | dstY -= minYOffset; |
| 499 | frameRect.offset(-minXOffset, -minYOffset); |
| 500 | subset.offset(-minXOffset, -minYOffset); |
| 501 | |
| 502 | // Just like we require that the requested subset x and y offset are even, libwebp |
| 503 | // guarantees that the frame x and y offset are even (it's actually impossible to specify |
| 504 | // an odd frame offset). So we can still guarantee that the adjusted offsets are even. |
| 505 | SkASSERT(SkIsAlign2(subset.fLeft) && SkIsAlign2(subset.fTop)); |
| 506 | |
| 507 | SkIRect intersection; |
| 508 | SkAssertResult(intersection.intersect(frameRect, subset)); |
| 509 | subsetWidth = intersection.width(); |
| 510 | subsetHeight = intersection.height(); |
| 511 | |
| 512 | config.options.use_cropping = 1; |
| 513 | config.options.crop_left = subset.x(); |
| 514 | config.options.crop_top = subset.y(); |
| 515 | config.options.crop_width = subsetWidth; |
| 516 | config.options.crop_height = subsetHeight; |
| 517 | } |
| 518 | |
| 519 | // Ignore the frame size and offset when determining if scaling is necessary. |
| 520 | int scaledWidth = subsetWidth; |
| 521 | int scaledHeight = subsetHeight; |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 522 | SkISize srcSize = options.fSubset ? options.fSubset->size() : srcInfo.dimensions(); |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 523 | if (srcSize != dstInfo.dimensions()) { |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 524 | config.options.use_scaling = 1; |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 525 | |
| 526 | if (frameIsSubset) { |
| 527 | float scaleX = ((float) dstInfo.width()) / srcSize.width(); |
| 528 | float scaleY = ((float) dstInfo.height()) / srcSize.height(); |
| 529 | |
| 530 | // We need to be conservative here and floor rather than round. |
| 531 | // Otherwise, we may find ourselves decoding off the end of memory. |
| 532 | dstX = scaleX * dstX; |
| 533 | scaledWidth = scaleX * scaledWidth; |
| 534 | dstY = scaleY * dstY; |
| 535 | scaledHeight = scaleY * scaledHeight; |
| 536 | if (0 == scaledWidth || 0 == scaledHeight) { |
| 537 | return kSuccess; |
| 538 | } |
| 539 | } else { |
| 540 | scaledWidth = dstInfo.width(); |
| 541 | scaledHeight = dstInfo.height(); |
| 542 | } |
| 543 | |
| 544 | config.options.scaled_width = scaledWidth; |
| 545 | config.options.scaled_height = scaledHeight; |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 546 | } |
| 547 | |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 548 | const bool blendWithPrevFrame = requiredFrame != kNone && frame.blend_method == WEBP_MUX_BLEND |
| 549 | && frame.has_alpha; |
| 550 | if (blendWithPrevFrame && options.fPremulBehavior == SkTransferFunctionBehavior::kRespect) { |
| 551 | // Blending is done with SkRasterPipeline, which requires a color space that is valid for |
| 552 | // rendering. |
| 553 | const auto* cs = dstInfo.colorSpace(); |
| 554 | if (!cs || (!cs->gammaCloseToSRGB() && !cs->gammaIsLinear())) { |
| 555 | return kInvalidConversion; |
| 556 | } |
| 557 | } |
| 558 | |
| 559 | SkBitmap webpDst; |
Leon Scroggins III | ee92f13 | 2017-05-23 15:28:46 -0400 | [diff] [blame] | 560 | auto webpInfo = dstInfo; |
| 561 | if (!frame.has_alpha) { |
| 562 | webpInfo = webpInfo.makeAlphaType(kOpaque_SkAlphaType); |
| 563 | } |
| 564 | if (this->colorXform()) { |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 565 | // Swizzling between RGBA and BGRA is zero cost in a color transform. So when we have a |
| 566 | // color transform, we should decode to whatever is easiest for libwebp, and then let the |
| 567 | // color transform swizzle if necessary. |
| 568 | // Lossy webp is encoded as YUV (so RGBA and BGRA are the same cost). Lossless webp is |
| 569 | // 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] | 570 | webpInfo = webpInfo.makeColorType(kBGRA_8888_SkColorType); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 571 | |
Leon Scroggins III | ee92f13 | 2017-05-23 15:28:46 -0400 | [diff] [blame] | 572 | if (webpInfo.alphaType() == kPremul_SkAlphaType) { |
| 573 | webpInfo = webpInfo.makeAlphaType(kUnpremul_SkAlphaType); |
| 574 | } |
| 575 | } |
| 576 | |
| 577 | if ((this->colorXform() && !is_8888(dstInfo.colorType())) || blendWithPrevFrame) { |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 578 | // We will decode the entire image and then perform the color transform. libwebp |
| 579 | // does not provide a row-by-row API. This is a shame particularly when we do not want |
| 580 | // 8888, since we will need to create another image sized buffer. |
Leon Scroggins III | ee92f13 | 2017-05-23 15:28:46 -0400 | [diff] [blame] | 581 | webpDst.allocPixels(webpInfo); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 582 | } else { |
| 583 | // libwebp can decode directly into the output memory. |
Leon Scroggins III | ee92f13 | 2017-05-23 15:28:46 -0400 | [diff] [blame] | 584 | webpDst.installPixels(webpInfo, dst, rowBytes); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 585 | } |
| 586 | |
Leon Scroggins III | ee92f13 | 2017-05-23 15:28:46 -0400 | [diff] [blame] | 587 | config.output.colorspace = webp_decode_mode(webpInfo); |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 588 | config.output.is_external_memory = 1; |
| 589 | |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 590 | config.output.u.RGBA.rgba = reinterpret_cast<uint8_t*>(webpDst.getAddr(dstX, dstY)); |
| 591 | config.output.u.RGBA.stride = static_cast<int>(webpDst.rowBytes()); |
| 592 | config.output.u.RGBA.size = webpDst.getSafeSize(); |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 593 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 594 | SkAutoTCallVProc<WebPIDecoder, WebPIDelete> idec(WebPIDecode(nullptr, 0, &config)); |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 595 | if (!idec) { |
| 596 | return kInvalidInput; |
| 597 | } |
| 598 | |
msarett | e99883f | 2016-09-08 06:05:35 -0700 | [diff] [blame] | 599 | int rowsDecoded; |
| 600 | SkCodec::Result result; |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 601 | switch (WebPIUpdate(idec, frame.fragment.bytes, frame.fragment.size)) { |
| 602 | case VP8_STATUS_OK: |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 603 | rowsDecoded = scaledHeight; |
msarett | e99883f | 2016-09-08 06:05:35 -0700 | [diff] [blame] | 604 | result = kSuccess; |
| 605 | break; |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 606 | case VP8_STATUS_SUSPENDED: |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 607 | WebPIDecGetRGB(idec, &rowsDecoded, nullptr, nullptr, nullptr); |
| 608 | *rowsDecodedPtr = rowsDecoded + dstY; |
msarett | e99883f | 2016-09-08 06:05:35 -0700 | [diff] [blame] | 609 | result = kIncompleteInput; |
| 610 | break; |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 611 | default: |
| 612 | return kInvalidInput; |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 613 | } |
msarett | e99883f | 2016-09-08 06:05:35 -0700 | [diff] [blame] | 614 | |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 615 | // We're only transforming the new part of the frame, so no need to worry about the |
| 616 | // final composited alpha. |
| 617 | const auto srcAlpha = 0 == index ? srcInfo.alphaType() : alpha_type(frame.has_alpha); |
| 618 | const auto xformAlphaType = select_xform_alpha(dstInfo.alphaType(), srcAlpha); |
| 619 | const bool needsSrgbToLinear = dstInfo.gammaCloseToSRGB() && |
| 620 | options.fPremulBehavior == SkTransferFunctionBehavior::kRespect; |
| 621 | |
| 622 | const size_t dstBpp = SkColorTypeBytesPerPixel(dstInfo.colorType()); |
| 623 | dst = SkTAddOffset<void>(dst, dstBpp * dstX + rowBytes * dstY); |
| 624 | const size_t srcRowBytes = config.output.u.RGBA.stride; |
| 625 | |
| 626 | const auto dstCT = dstInfo.colorType(); |
Matt Sarett | 313c463 | 2016-10-20 12:35:23 -0400 | [diff] [blame] | 627 | if (this->colorXform()) { |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 628 | uint32_t* xformSrc = (uint32_t*) config.output.u.RGBA.rgba; |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 629 | SkBitmap tmp; |
| 630 | void* xformDst; |
| 631 | |
| 632 | if (blendWithPrevFrame) { |
| 633 | // Xform into temporary bitmap big enough for one row. |
| 634 | tmp.allocPixels(dstInfo.makeWH(scaledWidth, 1)); |
| 635 | xformDst = tmp.getPixels(); |
| 636 | } else { |
| 637 | xformDst = dst; |
| 638 | } |
Robert Phillips | b3050b9 | 2017-02-06 13:12:18 +0000 | [diff] [blame] | 639 | for (int y = 0; y < rowsDecoded; y++) { |
Leon Scroggins III | c6e6a5f | 2017-06-05 15:53:38 -0400 | [diff] [blame] | 640 | this->applyColorXform(xformDst, xformSrc, scaledWidth, xformAlphaType); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 641 | if (blendWithPrevFrame) { |
| 642 | blend_line(dstCT, &dst, dstCT, &xformDst, needsSrgbToLinear, xformAlphaType, |
| 643 | scaledWidth); |
| 644 | dst = SkTAddOffset<void>(dst, rowBytes); |
| 645 | } else { |
| 646 | xformDst = SkTAddOffset<void>(xformDst, rowBytes); |
| 647 | } |
Matt Sarett | 5c49617 | 2017-02-07 17:01:16 -0500 | [diff] [blame] | 648 | xformSrc = SkTAddOffset<uint32_t>(xformSrc, srcRowBytes); |
msarett | e99883f | 2016-09-08 06:05:35 -0700 | [diff] [blame] | 649 | } |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 650 | } else if (blendWithPrevFrame) { |
| 651 | const uint8_t* src = config.output.u.RGBA.rgba; |
| 652 | |
| 653 | for (int y = 0; y < rowsDecoded; y++) { |
| 654 | blend_line(dstCT, &dst, webpDst.colorType(), &src, needsSrgbToLinear, |
| 655 | xformAlphaType, scaledWidth); |
| 656 | src = SkTAddOffset<const uint8_t>(src, srcRowBytes); |
| 657 | dst = SkTAddOffset<void>(dst, rowBytes); |
| 658 | } |
msarett | e99883f | 2016-09-08 06:05:35 -0700 | [diff] [blame] | 659 | } |
| 660 | |
| 661 | return result; |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 662 | } |
| 663 | |
msarett | 9d15dab | 2016-08-24 07:36:06 -0700 | [diff] [blame] | 664 | SkWebpCodec::SkWebpCodec(int width, int height, const SkEncodedInfo& info, |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 665 | sk_sp<SkColorSpace> colorSpace, SkStream* stream, WebPDemuxer* demux, |
| 666 | sk_sp<SkData> data) |
Leon Scroggins III | c6e6a5f | 2017-06-05 15:53:38 -0400 | [diff] [blame] | 667 | : INHERITED(width, height, info, SkColorSpaceXform::kBGRA_8888_ColorFormat, stream, |
| 668 | std::move(colorSpace)) |
msarett | ff2a6c8 | 2016-09-07 11:23:28 -0700 | [diff] [blame] | 669 | , fDemux(demux) |
| 670 | , fData(std::move(data)) |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 671 | , fFailed(false) |
| 672 | { |
| 673 | fFrameHolder.setScreenSize(width, height); |
| 674 | } |