msarett | 8c8f22a | 2015-04-01 06:58:48 -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 | |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 8 | /* |
| 9 | * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
| 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without |
| 12 | * modification, are permitted provided that the following conditions |
| 13 | * are met: |
| 14 | * 1. Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer. |
| 16 | * 2. Redistributions in binary form must reproduce the above copyright |
| 17 | * notice, this list of conditions and the following disclaimer in the |
| 18 | * documentation and/or other materials provided with the distribution. |
| 19 | * |
| 20 | * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 21 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 27 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 28 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | */ |
| 32 | |
| 33 | #include "SkCodecAnimation.h" |
msarett | 8c8f22a | 2015-04-01 06:58:48 -0700 | [diff] [blame] | 34 | #include "SkCodecPriv.h" |
Cary Clark | a4083c9 | 2017-09-15 11:59:23 -0400 | [diff] [blame] | 35 | #include "SkColorData.h" |
msarett | 8c8f22a | 2015-04-01 06:58:48 -0700 | [diff] [blame] | 36 | #include "SkColorTable.h" |
msarett | 1a46467 | 2016-01-07 13:17:19 -0800 | [diff] [blame] | 37 | #include "SkGifCodec.h" |
Mike Reed | ede7bac | 2017-07-23 15:30:02 -0400 | [diff] [blame] | 38 | #include "SkMakeUnique.h" |
msarett | 8c8f22a | 2015-04-01 06:58:48 -0700 | [diff] [blame] | 39 | #include "SkStream.h" |
| 40 | #include "SkSwizzler.h" |
msarett | 8c8f22a | 2015-04-01 06:58:48 -0700 | [diff] [blame] | 41 | |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 42 | #include <algorithm> |
| 43 | |
| 44 | #define GIF87_STAMP "GIF87a" |
| 45 | #define GIF89_STAMP "GIF89a" |
| 46 | #define GIF_STAMP_LEN 6 |
msarett | 39b2d5a | 2016-02-17 08:26:31 -0800 | [diff] [blame] | 47 | |
msarett | 8c8f22a | 2015-04-01 06:58:48 -0700 | [diff] [blame] | 48 | /* |
| 49 | * Checks the start of the stream to see if the image is a gif |
| 50 | */ |
scroggo | db30be2 | 2015-12-08 18:54:13 -0800 | [diff] [blame] | 51 | bool SkGifCodec::IsGif(const void* buf, size_t bytesRead) { |
| 52 | if (bytesRead >= GIF_STAMP_LEN) { |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 53 | if (memcmp(GIF87_STAMP, buf, GIF_STAMP_LEN) == 0 || |
bungeman | 0153dea | 2015-08-27 16:43:42 -0700 | [diff] [blame] | 54 | memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) |
| 55 | { |
msarett | 8c8f22a | 2015-04-01 06:58:48 -0700 | [diff] [blame] | 56 | return true; |
| 57 | } |
| 58 | } |
| 59 | return false; |
| 60 | } |
| 61 | |
| 62 | /* |
msarett | 8c8f22a | 2015-04-01 06:58:48 -0700 | [diff] [blame] | 63 | * Error function |
| 64 | */ |
bungeman | 0153dea | 2015-08-27 16:43:42 -0700 | [diff] [blame] | 65 | static SkCodec::Result gif_error(const char* msg, SkCodec::Result result = SkCodec::kInvalidInput) { |
msarett | 8c8f22a | 2015-04-01 06:58:48 -0700 | [diff] [blame] | 66 | SkCodecPrintf("Gif Error: %s\n", msg); |
| 67 | return result; |
| 68 | } |
| 69 | |
Mike Reed | ede7bac | 2017-07-23 15:30:02 -0400 | [diff] [blame] | 70 | std::unique_ptr<SkCodec> SkGifCodec::MakeFromStream(std::unique_ptr<SkStream> stream, |
| 71 | Result* result) { |
| 72 | std::unique_ptr<SkGifImageReader> reader(new SkGifImageReader(std::move(stream))); |
Leon Scroggins III | 588fb04 | 2017-07-14 16:32:31 -0400 | [diff] [blame] | 73 | *result = reader->parse(SkGifImageReader::SkGIFSizeQuery); |
| 74 | if (*result != kSuccess) { |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 75 | return nullptr; |
msarett | 8c8f22a | 2015-04-01 06:58:48 -0700 | [diff] [blame] | 76 | } |
msarett | 8c8f22a | 2015-04-01 06:58:48 -0700 | [diff] [blame] | 77 | |
Leon Scroggins III | 4993b95 | 2016-12-08 11:54:04 -0500 | [diff] [blame] | 78 | // If no images are in the data, or the first header is not yet defined, we cannot |
| 79 | // create a codec. In either case, the width and height are not yet known. |
Leon Scroggins III | e726e7c | 2017-07-18 16:22:52 -0400 | [diff] [blame] | 80 | auto* frame = reader->frameContext(0); |
| 81 | if (!frame || !frame->isHeaderDefined()) { |
Leon Scroggins III | 588fb04 | 2017-07-14 16:32:31 -0400 | [diff] [blame] | 82 | *result = kInvalidInput; |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 83 | return nullptr; |
| 84 | } |
| 85 | |
Leon Scroggins III | 4993b95 | 2016-12-08 11:54:04 -0500 | [diff] [blame] | 86 | // isHeaderDefined() will not return true if the screen size is empty. |
| 87 | SkASSERT(reader->screenHeight() > 0 && reader->screenWidth() > 0); |
| 88 | |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 89 | const auto alpha = reader->firstFrameHasAlpha() ? SkEncodedInfo::kBinary_Alpha |
| 90 | : SkEncodedInfo::kOpaque_Alpha; |
| 91 | // Use kPalette since Gifs are encoded with a color table. |
| 92 | // FIXME: Gifs can actually be encoded with 4-bits per pixel. Using 8 works, but we could skip |
| 93 | // expanding to 8 bits and take advantage of the SkSwizzler to work from 4. |
Leon Scroggins III | 5dd47e4 | 2018-09-27 15:26:48 -0400 | [diff] [blame] | 94 | auto encodedInfo = SkEncodedInfo::Make(reader->screenWidth(), reader->screenHeight(), |
| 95 | SkEncodedInfo::kPalette_Color, alpha, 8); |
Leon Scroggins III | 36f7e32 | 2018-08-27 11:55:46 -0400 | [diff] [blame] | 96 | return std::unique_ptr<SkCodec>(new SkGifCodec(std::move(encodedInfo), reader.release())); |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 97 | } |
msarett | 8c8f22a | 2015-04-01 06:58:48 -0700 | [diff] [blame] | 98 | |
scroggo | b427db1 | 2015-08-12 07:24:13 -0700 | [diff] [blame] | 99 | bool SkGifCodec::onRewind() { |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 100 | fReader->clearDecodeState(); |
scroggo | b427db1 | 2015-08-12 07:24:13 -0700 | [diff] [blame] | 101 | return true; |
| 102 | } |
| 103 | |
Leon Scroggins III | 36f7e32 | 2018-08-27 11:55:46 -0400 | [diff] [blame] | 104 | SkGifCodec::SkGifCodec(SkEncodedInfo&& encodedInfo, SkGifImageReader* reader) |
| 105 | : INHERITED(std::move(encodedInfo), skcms_PixelFormat_RGBA_8888, nullptr) |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 106 | , fReader(reader) |
| 107 | , fTmpBuffer(nullptr) |
| 108 | , fSwizzler(nullptr) |
| 109 | , fCurrColorTable(nullptr) |
| 110 | , fCurrColorTableIsReal(false) |
| 111 | , fFilledBackground(false) |
| 112 | , fFirstCallToIncrementalDecode(false) |
| 113 | , fDst(nullptr) |
| 114 | , fDstRowBytes(0) |
| 115 | , fRowsDecoded(0) |
| 116 | { |
| 117 | reader->setClient(this); |
msarett | 8c8f22a | 2015-04-01 06:58:48 -0700 | [diff] [blame] | 118 | } |
msarett | 10522ff | 2015-09-07 08:54:01 -0700 | [diff] [blame] | 119 | |
Leon Scroggins III | 249b8e3 | 2017-04-17 12:46:33 -0400 | [diff] [blame] | 120 | int SkGifCodec::onGetFrameCount() { |
scroggo | f9acbe2 | 2016-10-25 12:43:21 -0700 | [diff] [blame] | 121 | fReader->parse(SkGifImageReader::SkGIFFrameCountQuery); |
Leon Scroggins III | e132e7b | 2017-04-12 10:49:52 -0400 | [diff] [blame] | 122 | return fReader->imagesCount(); |
| 123 | } |
| 124 | |
Leon Scroggins III | 249b8e3 | 2017-04-17 12:46:33 -0400 | [diff] [blame] | 125 | bool SkGifCodec::onGetFrameInfo(int i, SkCodec::FrameInfo* frameInfo) const { |
Leon Scroggins III | e132e7b | 2017-04-12 10:49:52 -0400 | [diff] [blame] | 126 | if (i >= fReader->imagesCount()) { |
| 127 | return false; |
msarett | 10522ff | 2015-09-07 08:54:01 -0700 | [diff] [blame] | 128 | } |
Leon Scroggins III | e132e7b | 2017-04-12 10:49:52 -0400 | [diff] [blame] | 129 | |
| 130 | const SkGIFFrameContext* frameContext = fReader->frameContext(i); |
Leon Scroggins III | e726e7c | 2017-07-18 16:22:52 -0400 | [diff] [blame] | 131 | SkASSERT(frameContext->reachedStartOfData()); |
Leon Scroggins III | e132e7b | 2017-04-12 10:49:52 -0400 | [diff] [blame] | 132 | |
| 133 | if (frameInfo) { |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 134 | frameInfo->fDuration = frameContext->getDuration(); |
Leon Scroggins III | e132e7b | 2017-04-12 10:49:52 -0400 | [diff] [blame] | 135 | frameInfo->fRequiredFrame = frameContext->getRequiredFrame(); |
| 136 | frameInfo->fFullyReceived = frameContext->isComplete(); |
Leon Scroggins III | c8037dc | 2017-12-05 13:55:24 -0500 | [diff] [blame] | 137 | frameInfo->fAlphaType = frameContext->hasAlpha() ? kUnpremul_SkAlphaType |
| 138 | : kOpaque_SkAlphaType; |
Leon Scroggins III | 33deb7e | 2017-06-07 12:31:51 -0400 | [diff] [blame] | 139 | frameInfo->fDisposalMethod = frameContext->getDisposalMethod(); |
Leon Scroggins III | e132e7b | 2017-04-12 10:49:52 -0400 | [diff] [blame] | 140 | } |
| 141 | return true; |
msarett | 10522ff | 2015-09-07 08:54:01 -0700 | [diff] [blame] | 142 | } |
| 143 | |
scroggo | e71b1a1 | 2016-11-01 08:28:28 -0700 | [diff] [blame] | 144 | int SkGifCodec::onGetRepetitionCount() { |
| 145 | fReader->parse(SkGifImageReader::SkGIFLoopCountQuery); |
| 146 | return fReader->loopCount(); |
| 147 | } |
| 148 | |
Leon Scroggins III | 862c196 | 2017-10-02 16:28:49 -0400 | [diff] [blame] | 149 | static constexpr SkColorType kXformSrcColorType = kRGBA_8888_SkColorType; |
Matt Sarett | 562e681 | 2016-11-08 16:13:43 -0500 | [diff] [blame] | 150 | |
Leon Scroggins III | 249b8e3 | 2017-04-17 12:46:33 -0400 | [diff] [blame] | 151 | void SkGifCodec::initializeColorTable(const SkImageInfo& dstInfo, int frameIndex) { |
Matt Sarett | 61eedeb | 2016-11-04 13:19:48 -0400 | [diff] [blame] | 152 | SkColorType colorTableColorType = dstInfo.colorType(); |
| 153 | if (this->colorXform()) { |
Matt Sarett | 562e681 | 2016-11-08 16:13:43 -0500 | [diff] [blame] | 154 | colorTableColorType = kXformSrcColorType; |
Matt Sarett | 61eedeb | 2016-11-04 13:19:48 -0400 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | sk_sp<SkColorTable> currColorTable = fReader->getColorTable(colorTableColorType, frameIndex); |
Hal Canary | 9a0e390 | 2017-07-12 11:59:17 -0400 | [diff] [blame] | 158 | fCurrColorTableIsReal = static_cast<bool>(currColorTable); |
Matt Sarett | 61eedeb | 2016-11-04 13:19:48 -0400 | [diff] [blame] | 159 | if (!fCurrColorTableIsReal) { |
Leon Scroggins III | a049ac4 | 2016-10-27 11:16:11 -0400 | [diff] [blame] | 160 | // This is possible for an empty frame. Create a dummy with one value (transparent). |
| 161 | SkPMColor color = SK_ColorTRANSPARENT; |
| 162 | fCurrColorTable.reset(new SkColorTable(&color, 1)); |
Leon Scroggins III | c6e6a5f | 2017-06-05 15:53:38 -0400 | [diff] [blame] | 163 | } else if (this->colorXform() && !this->xformOnDecode()) { |
Matt Sarett | 61eedeb | 2016-11-04 13:19:48 -0400 | [diff] [blame] | 164 | SkPMColor dstColors[256]; |
Leon Scroggins III | 36f7e32 | 2018-08-27 11:55:46 -0400 | [diff] [blame] | 165 | this->applyColorXform(dstColors, currColorTable->readColors(), |
| 166 | currColorTable->count()); |
Matt Sarett | 61eedeb | 2016-11-04 13:19:48 -0400 | [diff] [blame] | 167 | fCurrColorTable.reset(new SkColorTable(dstColors, currColorTable->count())); |
| 168 | } else { |
| 169 | fCurrColorTable = std::move(currColorTable); |
msarett | 10522ff | 2015-09-07 08:54:01 -0700 | [diff] [blame] | 170 | } |
msarett | 10522ff | 2015-09-07 08:54:01 -0700 | [diff] [blame] | 171 | } |
| 172 | |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 173 | |
Leon Scroggins | 571b30f | 2017-07-11 17:35:31 +0000 | [diff] [blame] | 174 | SkCodec::Result SkGifCodec::prepareToDecode(const SkImageInfo& dstInfo, const Options& opts) { |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 175 | if (opts.fSubset) { |
| 176 | return gif_error("Subsets not supported.\n", kUnimplemented); |
| 177 | } |
| 178 | |
Leon Scroggins III | 249b8e3 | 2017-04-17 12:46:33 -0400 | [diff] [blame] | 179 | const int frameIndex = opts.fFrameIndex; |
Leon Scroggins III | 1f6af6b | 2017-06-12 16:41:09 -0400 | [diff] [blame] | 180 | if (frameIndex > 0 && kRGB_565_SkColorType == dstInfo.colorType()) { |
| 181 | // FIXME: In theory, we might be able to support this, but it's not clear that it |
| 182 | // is necessary (Chromium does not decode to 565, and Android does not decode |
| 183 | // frames beyond the first). Disabling it because it is somewhat difficult: |
| 184 | // - If there is a transparent pixel, and this frame draws on top of another frame |
| 185 | // (if the frame is independent with a transparent pixel, we should not decode to |
| 186 | // 565 anyway, since it is not opaque), we need to skip drawing the transparent |
| 187 | // pixels (see writeTransparentPixels in haveDecodedRow). We currently do this by |
| 188 | // first swizzling into temporary memory, then copying into the destination. (We |
| 189 | // let the swizzler handle it first because it may need to sample.) After |
| 190 | // swizzling to 565, we do not know which pixels in our temporary memory |
| 191 | // correspond to the transparent pixel, so we do not know what to skip. We could |
| 192 | // special case the non-sampled case (no need to swizzle), but as this is |
| 193 | // currently unused we can just not support it. |
| 194 | return gif_error("Cannot decode multiframe gif (except frame 0) as 565.\n", |
| 195 | kInvalidConversion); |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 196 | } |
| 197 | |
Leon Scroggins III | 91f0f73 | 2017-06-07 09:31:23 -0400 | [diff] [blame] | 198 | const auto* frame = fReader->frameContext(frameIndex); |
Leon Scroggins III | 1f6af6b | 2017-06-12 16:41:09 -0400 | [diff] [blame] | 199 | SkASSERT(frame); |
| 200 | if (0 == frameIndex) { |
| 201 | // SkCodec does not have a way to just parse through frame 0, so we |
| 202 | // have to do so manually, here. |
| 203 | fReader->parse((SkGifImageReader::SkGIFParseQuery) 0); |
| 204 | if (!frame->reachedStartOfData()) { |
| 205 | // We have parsed enough to know that there is a color map, but cannot |
| 206 | // parse the map itself yet. Exit now, so we do not build an incorrect |
| 207 | // table. |
| 208 | return gif_error("color map not available yet\n", kIncompleteInput); |
| 209 | } |
| 210 | } else { |
| 211 | // Parsing happened in SkCodec::getPixels. |
| 212 | SkASSERT(frameIndex < fReader->imagesCount()); |
| 213 | SkASSERT(frame->reachedStartOfData()); |
Leon Scroggins III | 3fc97d7 | 2016-12-09 16:39:33 -0500 | [diff] [blame] | 214 | } |
| 215 | |
Leon Scroggins III | 91f0f73 | 2017-06-07 09:31:23 -0400 | [diff] [blame] | 216 | if (this->xformOnDecode()) { |
| 217 | fXformBuffer.reset(new uint32_t[dstInfo.width()]); |
| 218 | sk_bzero(fXformBuffer.get(), dstInfo.width() * sizeof(uint32_t)); |
| 219 | } |
| 220 | |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 221 | fTmpBuffer.reset(new uint8_t[dstInfo.minRowBytes()]); |
| 222 | |
Leon Scroggins III | fc49b40 | 2016-10-31 14:08:56 -0400 | [diff] [blame] | 223 | this->initializeColorTable(dstInfo, frameIndex); |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 224 | this->initializeSwizzler(dstInfo, frameIndex); |
Leon Scroggins III | fc49b40 | 2016-10-31 14:08:56 -0400 | [diff] [blame] | 225 | |
| 226 | SkASSERT(fCurrColorTable); |
msarett | b30d698 | 2016-02-15 10:18:45 -0800 | [diff] [blame] | 227 | return kSuccess; |
msarett | 10522ff | 2015-09-07 08:54:01 -0700 | [diff] [blame] | 228 | } |
| 229 | |
Leon Scroggins III | 249b8e3 | 2017-04-17 12:46:33 -0400 | [diff] [blame] | 230 | void SkGifCodec::initializeSwizzler(const SkImageInfo& dstInfo, int frameIndex) { |
scroggo | f9acbe2 | 2016-10-25 12:43:21 -0700 | [diff] [blame] | 231 | const SkGIFFrameContext* frame = fReader->frameContext(frameIndex); |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 232 | // This is only called by prepareToDecode, which ensures frameIndex is in range. |
| 233 | SkASSERT(frame); |
msarett | 10522ff | 2015-09-07 08:54:01 -0700 | [diff] [blame] | 234 | |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 235 | const int xBegin = frame->xOffset(); |
Leon Scroggins III | 557fbbe | 2017-05-23 09:37:21 -0400 | [diff] [blame] | 236 | const int xEnd = std::min(frame->frameRect().right(), fReader->screenWidth()); |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 237 | |
| 238 | // CreateSwizzler only reads left and right of the frame. We cannot use the frame's raw |
| 239 | // frameRect, since it might extend beyond the edge of the frame. |
| 240 | SkIRect swizzleRect = SkIRect::MakeLTRB(xBegin, 0, xEnd, 0); |
| 241 | |
Matt Sarett | 61eedeb | 2016-11-04 13:19:48 -0400 | [diff] [blame] | 242 | SkImageInfo swizzlerInfo = dstInfo; |
| 243 | if (this->colorXform()) { |
Matt Sarett | 562e681 | 2016-11-08 16:13:43 -0500 | [diff] [blame] | 244 | swizzlerInfo = swizzlerInfo.makeColorType(kXformSrcColorType); |
Matt Sarett | 61eedeb | 2016-11-04 13:19:48 -0400 | [diff] [blame] | 245 | if (kPremul_SkAlphaType == dstInfo.alphaType()) { |
| 246 | swizzlerInfo = swizzlerInfo.makeAlphaType(kUnpremul_SkAlphaType); |
| 247 | } |
| 248 | } |
| 249 | |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 250 | // The default Options should be fine: |
| 251 | // - we'll ignore if the memory is zero initialized - unless we're the first frame, this won't |
| 252 | // matter anyway. |
| 253 | // - subsets are not supported for gif |
| 254 | // - the swizzler does not need to know about the frame. |
| 255 | // We may not be able to use the real Options anyway, since getPixels does not store it (due to |
| 256 | // a bug). |
Leon Scroggins III | 65f4aea | 2018-10-24 12:17:22 -0400 | [diff] [blame] | 257 | fSwizzler = SkSwizzler::Make(this->getEncodedInfo(), fCurrColorTable->readColors(), |
| 258 | swizzlerInfo, Options(), &swizzleRect); |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 259 | SkASSERT(fSwizzler.get()); |
msarett | 10522ff | 2015-09-07 08:54:01 -0700 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | /* |
| 263 | * Initiates the gif decode |
| 264 | */ |
| 265 | SkCodec::Result SkGifCodec::onGetPixels(const SkImageInfo& dstInfo, |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 266 | void* pixels, size_t dstRowBytes, |
msarett | 10522ff | 2015-09-07 08:54:01 -0700 | [diff] [blame] | 267 | const Options& opts, |
msarett | e6dd004 | 2015-10-09 11:07:34 -0700 | [diff] [blame] | 268 | int* rowsDecoded) { |
Leon Scroggins | 571b30f | 2017-07-11 17:35:31 +0000 | [diff] [blame] | 269 | Result result = this->prepareToDecode(dstInfo, opts); |
Leon Scroggins III | 3fc97d7 | 2016-12-09 16:39:33 -0500 | [diff] [blame] | 270 | switch (result) { |
| 271 | case kSuccess: |
| 272 | break; |
| 273 | case kIncompleteInput: |
| 274 | // onStartIncrementalDecode treats this as incomplete, since it may |
| 275 | // provide more data later, but in this case, no more data will be |
| 276 | // provided, and there is nothing to draw. We also cannot return |
| 277 | // kIncompleteInput, which will make SkCodec attempt to fill |
| 278 | // remaining rows, but that requires an SkSwizzler, which we have |
| 279 | // not created. |
| 280 | return kInvalidInput; |
| 281 | default: |
| 282 | return result; |
msarett | 10522ff | 2015-09-07 08:54:01 -0700 | [diff] [blame] | 283 | } |
| 284 | |
Leon Scroggins III | 712476e | 2018-10-03 15:47:00 -0400 | [diff] [blame] | 285 | if (dstInfo.dimensions() != this->dimensions()) { |
msarett | 10522ff | 2015-09-07 08:54:01 -0700 | [diff] [blame] | 286 | return gif_error("Scaling not supported.\n", kInvalidScale); |
| 287 | } |
| 288 | |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 289 | fDst = pixels; |
| 290 | fDstRowBytes = dstRowBytes; |
| 291 | |
| 292 | return this->decodeFrame(true, opts, rowsDecoded); |
| 293 | } |
| 294 | |
| 295 | SkCodec::Result SkGifCodec::onStartIncrementalDecode(const SkImageInfo& dstInfo, |
| 296 | void* pixels, size_t dstRowBytes, |
Leon Scroggins | 571b30f | 2017-07-11 17:35:31 +0000 | [diff] [blame] | 297 | const SkCodec::Options& opts) { |
| 298 | Result result = this->prepareToDecode(dstInfo, opts); |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 299 | if (result != kSuccess) { |
| 300 | return result; |
msarett | 10522ff | 2015-09-07 08:54:01 -0700 | [diff] [blame] | 301 | } |
| 302 | |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 303 | fDst = pixels; |
| 304 | fDstRowBytes = dstRowBytes; |
| 305 | |
| 306 | fFirstCallToIncrementalDecode = true; |
| 307 | |
msarett | 10522ff | 2015-09-07 08:54:01 -0700 | [diff] [blame] | 308 | return kSuccess; |
| 309 | } |
| 310 | |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 311 | SkCodec::Result SkGifCodec::onIncrementalDecode(int* rowsDecoded) { |
| 312 | // It is possible the client has appended more data. Parse, if needed. |
| 313 | const auto& options = this->options(); |
Leon Scroggins III | 249b8e3 | 2017-04-17 12:46:33 -0400 | [diff] [blame] | 314 | const int frameIndex = options.fFrameIndex; |
scroggo | f9acbe2 | 2016-10-25 12:43:21 -0700 | [diff] [blame] | 315 | fReader->parse((SkGifImageReader::SkGIFParseQuery) frameIndex); |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 316 | |
| 317 | const bool firstCallToIncrementalDecode = fFirstCallToIncrementalDecode; |
| 318 | fFirstCallToIncrementalDecode = false; |
| 319 | return this->decodeFrame(firstCallToIncrementalDecode, options, rowsDecoded); |
msarett | e6dd004 | 2015-10-09 11:07:34 -0700 | [diff] [blame] | 320 | } |
| 321 | |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 322 | SkCodec::Result SkGifCodec::decodeFrame(bool firstAttempt, const Options& opts, int* rowsDecoded) { |
| 323 | const SkImageInfo& dstInfo = this->dstInfo(); |
Leon Scroggins III | cbf66a2 | 2018-02-16 12:03:03 -0500 | [diff] [blame] | 324 | const int scaledHeight = get_scaled_dimension(dstInfo.height(), fSwizzler->sampleY()); |
| 325 | |
Leon Scroggins III | 249b8e3 | 2017-04-17 12:46:33 -0400 | [diff] [blame] | 326 | const int frameIndex = opts.fFrameIndex; |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 327 | SkASSERT(frameIndex < fReader->imagesCount()); |
scroggo | f9acbe2 | 2016-10-25 12:43:21 -0700 | [diff] [blame] | 328 | const SkGIFFrameContext* frameContext = fReader->frameContext(frameIndex); |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 329 | if (firstAttempt) { |
| 330 | // rowsDecoded reports how many rows have been initialized, so a layer above |
| 331 | // can fill the rest. In some cases, we fill the background before decoding |
| 332 | // (or it is already filled for us), so we report rowsDecoded to be the full |
| 333 | // height. |
| 334 | bool filledBackground = false; |
Nigel Tao | 66bc524 | 2018-08-22 10:56:03 +1000 | [diff] [blame] | 335 | if (frameContext->getRequiredFrame() == kNoFrame) { |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 336 | // We may need to clear to transparent for one of the following reasons: |
| 337 | // - The frameRect does not cover the full bounds. haveDecodedRow will |
| 338 | // only draw inside the frameRect, so we need to clear the rest. |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 339 | // - The frame is interlaced. There is no obvious way to fill |
| 340 | // afterwards for an incomplete image. (FIXME: Does the first pass |
| 341 | // cover all rows? If so, we do not have to fill here.) |
scroggo | 8bce117 | 2016-10-25 13:08:40 -0700 | [diff] [blame] | 342 | // - There is no color table for this frame. In that case will not |
| 343 | // draw anything, so we need to fill. |
Leon Scroggins III | 712476e | 2018-10-03 15:47:00 -0400 | [diff] [blame] | 344 | if (frameContext->frameRect() != this->bounds() |
scroggo | 8bce117 | 2016-10-25 13:08:40 -0700 | [diff] [blame] | 345 | || frameContext->interlaced() || !fCurrColorTableIsReal) { |
Leon Scroggins III | a6161b1 | 2018-10-18 14:45:26 -0400 | [diff] [blame] | 346 | auto fillInfo = dstInfo.makeWH(fSwizzler->fillWidth(), scaledHeight); |
| 347 | SkSampler::Fill(fillInfo, fDst, fDstRowBytes, opts.fZeroInitialized); |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 348 | filledBackground = true; |
| 349 | } |
| 350 | } else { |
Leon Scroggins III | 1f6af6b | 2017-06-12 16:41:09 -0400 | [diff] [blame] | 351 | // Not independent. |
| 352 | // SkCodec ensured that the prior frame has been decoded. |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 353 | filledBackground = true; |
msarett | 10522ff | 2015-09-07 08:54:01 -0700 | [diff] [blame] | 354 | } |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 355 | |
| 356 | fFilledBackground = filledBackground; |
| 357 | if (filledBackground) { |
| 358 | // Report the full (scaled) height, since the client will never need to fill. |
Leon Scroggins III | cbf66a2 | 2018-02-16 12:03:03 -0500 | [diff] [blame] | 359 | fRowsDecoded = scaledHeight; |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 360 | } else { |
| 361 | // This will be updated by haveDecodedRow. |
| 362 | fRowsDecoded = 0; |
| 363 | } |
msarett | 10522ff | 2015-09-07 08:54:01 -0700 | [diff] [blame] | 364 | } |
msarett | e6dd004 | 2015-10-09 11:07:34 -0700 | [diff] [blame] | 365 | |
Leon Scroggins III | 3fc97d7 | 2016-12-09 16:39:33 -0500 | [diff] [blame] | 366 | if (!fCurrColorTableIsReal) { |
| 367 | // Nothing to draw this frame. |
| 368 | return kSuccess; |
| 369 | } |
| 370 | |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 371 | bool frameDecoded = false; |
Leon Scroggins III | 674a184 | 2017-07-06 12:26:09 -0400 | [diff] [blame] | 372 | const bool fatalError = !fReader->decode(frameIndex, &frameDecoded); |
Leon Scroggins III | cbf66a2 | 2018-02-16 12:03:03 -0500 | [diff] [blame] | 373 | if (fatalError || !frameDecoded || fRowsDecoded != scaledHeight) { |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 374 | if (rowsDecoded) { |
| 375 | *rowsDecoded = fRowsDecoded; |
| 376 | } |
Leon Scroggins III | 674a184 | 2017-07-06 12:26:09 -0400 | [diff] [blame] | 377 | if (fatalError) { |
| 378 | return kErrorInInput; |
| 379 | } |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 380 | return kIncompleteInput; |
| 381 | } |
| 382 | |
| 383 | return kSuccess; |
msarett | 10522ff | 2015-09-07 08:54:01 -0700 | [diff] [blame] | 384 | } |
scroggo | 46c5747 | 2015-09-30 08:57:13 -0700 | [diff] [blame] | 385 | |
Matt Sarett | 61eedeb | 2016-11-04 13:19:48 -0400 | [diff] [blame] | 386 | void SkGifCodec::applyXformRow(const SkImageInfo& dstInfo, void* dst, const uint8_t* src) const { |
Leon Scroggins III | c6e6a5f | 2017-06-05 15:53:38 -0400 | [diff] [blame] | 387 | if (this->xformOnDecode()) { |
| 388 | SkASSERT(this->colorXform()); |
Matt Sarett | 61eedeb | 2016-11-04 13:19:48 -0400 | [diff] [blame] | 389 | fSwizzler->swizzle(fXformBuffer.get(), src); |
| 390 | |
Matt Sarett | 61eedeb | 2016-11-04 13:19:48 -0400 | [diff] [blame] | 391 | const int xformWidth = get_scaled_dimension(dstInfo.width(), fSwizzler->sampleX()); |
Leon Scroggins III | 36f7e32 | 2018-08-27 11:55:46 -0400 | [diff] [blame] | 392 | this->applyColorXform(dst, fXformBuffer.get(), xformWidth); |
Matt Sarett | 61eedeb | 2016-11-04 13:19:48 -0400 | [diff] [blame] | 393 | } else { |
| 394 | fSwizzler->swizzle(dst, src); |
| 395 | } |
| 396 | } |
| 397 | |
Leon Scroggins III | 1f1aa2d | 2017-09-05 14:17:19 -0400 | [diff] [blame] | 398 | template <typename T> |
| 399 | static void blend_line(void* dstAsVoid, const void* srcAsVoid, int width) { |
| 400 | T* dst = reinterpret_cast<T*>(dstAsVoid); |
| 401 | const T* src = reinterpret_cast<const T*>(srcAsVoid); |
| 402 | while (width --> 0) { |
| 403 | if (*src != 0) { // GIF pixels are either transparent (== 0) or opaque (!= 0). |
| 404 | *dst = *src; |
| 405 | } |
| 406 | src++; |
| 407 | dst++; |
| 408 | } |
| 409 | } |
| 410 | |
Leon Scroggins III | 223ec29 | 2017-08-22 14:13:15 -0400 | [diff] [blame] | 411 | void SkGifCodec::haveDecodedRow(int frameIndex, const unsigned char* rowBegin, |
Leon Scroggins III | 249b8e3 | 2017-04-17 12:46:33 -0400 | [diff] [blame] | 412 | int rowNumber, int repeatCount, bool writeTransparentPixels) |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 413 | { |
scroggo | f9acbe2 | 2016-10-25 12:43:21 -0700 | [diff] [blame] | 414 | const SkGIFFrameContext* frameContext = fReader->frameContext(frameIndex); |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 415 | // The pixel data and coordinates supplied to us are relative to the frame's |
| 416 | // origin within the entire image size, i.e. |
| 417 | // (frameContext->xOffset, frameContext->yOffset). There is no guarantee |
| 418 | // that width == (size().width() - frameContext->xOffset), so |
| 419 | // we must ensure we don't run off the end of either the source data or the |
| 420 | // row's X-coordinates. |
Leon Scroggins III | 249b8e3 | 2017-04-17 12:46:33 -0400 | [diff] [blame] | 421 | const int width = frameContext->width(); |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 422 | const int xBegin = frameContext->xOffset(); |
| 423 | const int yBegin = frameContext->yOffset() + rowNumber; |
Leon Scroggins III | 712476e | 2018-10-03 15:47:00 -0400 | [diff] [blame] | 424 | const int xEnd = std::min(xBegin + width, this->dimensions().width()); |
| 425 | const int yEnd = std::min(yBegin + rowNumber + repeatCount, this->dimensions().height()); |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 426 | // FIXME: No need to make the checks on width/xBegin/xEnd for every row. We could instead do |
| 427 | // this once in prepareToDecode. |
| 428 | if (!width || (xBegin < 0) || (yBegin < 0) || (xEnd <= xBegin) || (yEnd <= yBegin)) |
Leon Scroggins III | 223ec29 | 2017-08-22 14:13:15 -0400 | [diff] [blame] | 429 | return; |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 430 | |
| 431 | // yBegin is the first row in the non-sampled image. dstRow will be the row in the output, |
| 432 | // after potentially scaling it. |
| 433 | int dstRow = yBegin; |
| 434 | |
| 435 | const int sampleY = fSwizzler->sampleY(); |
| 436 | if (sampleY > 1) { |
| 437 | // Check to see whether this row or one that falls in the repeatCount is needed in the |
| 438 | // output. |
| 439 | bool foundNecessaryRow = false; |
Leon Scroggins III | 249b8e3 | 2017-04-17 12:46:33 -0400 | [diff] [blame] | 440 | for (int i = 0; i < repeatCount; i++) { |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 441 | const int potentialRow = yBegin + i; |
| 442 | if (fSwizzler->rowNeeded(potentialRow)) { |
| 443 | dstRow = potentialRow / sampleY; |
| 444 | const int scaledHeight = get_scaled_dimension(this->dstInfo().height(), sampleY); |
| 445 | if (dstRow >= scaledHeight) { |
Leon Scroggins III | 223ec29 | 2017-08-22 14:13:15 -0400 | [diff] [blame] | 446 | return; |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 447 | } |
| 448 | |
| 449 | foundNecessaryRow = true; |
| 450 | repeatCount -= i; |
| 451 | |
| 452 | repeatCount = (repeatCount - 1) / sampleY + 1; |
| 453 | |
| 454 | // Make sure the repeatCount does not take us beyond the end of the dst |
Leon Scroggins III | 249b8e3 | 2017-04-17 12:46:33 -0400 | [diff] [blame] | 455 | if (dstRow + repeatCount > scaledHeight) { |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 456 | repeatCount = scaledHeight - dstRow; |
| 457 | SkASSERT(repeatCount >= 1); |
| 458 | } |
| 459 | break; |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | if (!foundNecessaryRow) { |
Leon Scroggins III | 223ec29 | 2017-08-22 14:13:15 -0400 | [diff] [blame] | 464 | return; |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 465 | } |
Matt Sarett | 8a4e9c5 | 2016-10-25 14:24:50 -0400 | [diff] [blame] | 466 | } else { |
| 467 | // Make sure the repeatCount does not take us beyond the end of the dst |
| 468 | SkASSERT(this->dstInfo().height() >= yBegin); |
Leon Scroggins III | 249b8e3 | 2017-04-17 12:46:33 -0400 | [diff] [blame] | 469 | repeatCount = SkTMin(repeatCount, this->dstInfo().height() - yBegin); |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 470 | } |
| 471 | |
| 472 | if (!fFilledBackground) { |
| 473 | // At this point, we are definitely going to write the row, so count it towards the number |
| 474 | // of rows decoded. |
| 475 | // We do not consider the repeatCount, which only happens for interlaced, in which case we |
| 476 | // have already set fRowsDecoded to the proper value (reflecting that we have filled the |
| 477 | // background). |
| 478 | fRowsDecoded++; |
| 479 | } |
| 480 | |
Leon Scroggins III | 3fc97d7 | 2016-12-09 16:39:33 -0500 | [diff] [blame] | 481 | // decodeFrame will early exit if this is false, so this method will not be |
| 482 | // called. |
| 483 | SkASSERT(fCurrColorTableIsReal); |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 484 | |
| 485 | // The swizzler takes care of offsetting into the dst width-wise. |
| 486 | void* dstLine = SkTAddOffset<void>(fDst, dstRow * fDstRowBytes); |
| 487 | |
| 488 | // We may or may not need to write transparent pixels to the buffer. |
scroggo | 1285f41 | 2016-10-26 13:48:03 -0700 | [diff] [blame] | 489 | // If we're compositing against a previous image, it's wrong, but if |
| 490 | // we're decoding an interlaced gif and displaying it "Haeberli"-style, |
| 491 | // we must write these for passes beyond the first, or the initial passes |
| 492 | // will "show through" the later ones. |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 493 | const auto dstInfo = this->dstInfo(); |
scroggo | 53f63b6 | 2016-10-27 08:29:13 -0700 | [diff] [blame] | 494 | if (writeTransparentPixels) { |
Matt Sarett | 61eedeb | 2016-11-04 13:19:48 -0400 | [diff] [blame] | 495 | this->applyXformRow(dstInfo, dstLine, rowBegin); |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 496 | } else { |
Matt Sarett | 61eedeb | 2016-11-04 13:19:48 -0400 | [diff] [blame] | 497 | this->applyXformRow(dstInfo, fTmpBuffer.get(), rowBegin); |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 498 | |
Leon Scroggins III | e43fdb3 | 2017-07-17 19:41:46 -0400 | [diff] [blame] | 499 | size_t offsetBytes = fSwizzler->swizzleOffsetBytes(); |
| 500 | if (dstInfo.colorType() == kRGBA_F16_SkColorType) { |
| 501 | // Account for the fact that post-swizzling we converted to F16, |
| 502 | // which is twice as wide. |
| 503 | offsetBytes *= 2; |
| 504 | } |
Leon Scroggins III | 1f1aa2d | 2017-09-05 14:17:19 -0400 | [diff] [blame] | 505 | const void* src = SkTAddOffset<void>(fTmpBuffer.get(), offsetBytes); |
| 506 | void* dst = SkTAddOffset<void>(dstLine, offsetBytes); |
Mike Klein | 45c16fa | 2017-07-18 18:15:13 -0400 | [diff] [blame] | 507 | |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 508 | switch (dstInfo.colorType()) { |
| 509 | case kBGRA_8888_SkColorType: |
Leon Scroggins III | e43fdb3 | 2017-07-17 19:41:46 -0400 | [diff] [blame] | 510 | case kRGBA_8888_SkColorType: |
Leon Scroggins III | 1f1aa2d | 2017-09-05 14:17:19 -0400 | [diff] [blame] | 511 | blend_line<uint32_t>(dst, src, fSwizzler->swizzleWidth()); |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 512 | break; |
Leon Scroggins III | e43fdb3 | 2017-07-17 19:41:46 -0400 | [diff] [blame] | 513 | case kRGBA_F16_SkColorType: |
Leon Scroggins III | 1f1aa2d | 2017-09-05 14:17:19 -0400 | [diff] [blame] | 514 | blend_line<uint64_t>(dst, src, fSwizzler->swizzleWidth()); |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 515 | break; |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 516 | default: |
| 517 | SkASSERT(false); |
Leon Scroggins III | 223ec29 | 2017-08-22 14:13:15 -0400 | [diff] [blame] | 518 | return; |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 519 | } |
| 520 | } |
| 521 | |
| 522 | // Tell the frame to copy the row data if need be. |
| 523 | if (repeatCount > 1) { |
Mike Reed | 7fcfb62 | 2018-02-09 13:26:46 -0500 | [diff] [blame] | 524 | const size_t bytesPerPixel = this->dstInfo().bytesPerPixel(); |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 525 | const size_t bytesToCopy = fSwizzler->swizzleWidth() * bytesPerPixel; |
| 526 | void* copiedLine = SkTAddOffset<void>(dstLine, fSwizzler->swizzleOffsetBytes()); |
| 527 | void* dst = copiedLine; |
Leon Scroggins III | 249b8e3 | 2017-04-17 12:46:33 -0400 | [diff] [blame] | 528 | for (int i = 1; i < repeatCount; i++) { |
scroggo | 19b9153 | 2016-10-24 09:03:26 -0700 | [diff] [blame] | 529 | dst = SkTAddOffset<void>(dst, fDstRowBytes); |
| 530 | memcpy(dst, copiedLine, bytesToCopy); |
msarett | 72261c0 | 2015-11-19 15:29:26 -0800 | [diff] [blame] | 531 | } |
| 532 | } |
msarett | 72261c0 | 2015-11-19 15:29:26 -0800 | [diff] [blame] | 533 | } |