author Wes Kocher <>
Wed, 10 May 2017 10:01:18 -0700
changeset 407965 ce2218406119c36a551e3faea4e192186ee46cc5
parent 407937 af6f19870b2a00759ac1d83dedc3db57213abfee
child 408167 0ded74baeaf23d7985401fe9bbabdb3d9385ac22
permissions -rw-r--r--
Backed out 9 changesets (bug 1340627) for graphical glitches a=backout Backed out changeset 0b1371055c7f (bug 1340627) Backed out changeset f152be1fadb7 (bug 1340627) Backed out changeset c691e2ab6a0c (bug 1340627) Backed out changeset 3cb4bceb8d79 (bug 1340627) Backed out changeset 026aadd76d06 (bug 1340627) Backed out changeset fdbd5d281287 (bug 1340627) Backed out changeset 75fb0d9858a9 (bug 1340627) Backed out changeset 0d4ec7d38a00 (bug 1340627) Backed out changeset af6f19870b2a (bug 1340627) MozReview-Commit-ID: 9dHr7xMZezY

 * Copyright 2015 Google Inc.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.

#ifndef SkCodec_wbmp_DEFINED
#define SkCodec_wbmp_DEFINED

#include "SkCodec.h"
#include "SkColorSpace.h"
#include "SkSwizzler.h"

class SkWbmpCodec final : public SkCodec {
    static bool IsWbmp(const void*, size_t);

     * Assumes IsWbmp was called and returned true
     * Creates a wbmp codec
     * Takes ownership of the stream
    static SkCodec* NewFromStream(SkStream*);

    SkEncodedFormat onGetEncodedFormat() const override;
    Result onGetPixels(const SkImageInfo&, void*, size_t,
                       const Options&, SkPMColor[], int*, int*) override;
    bool onRewind() override;
     * Returns a swizzler on success, nullptr on failure
    SkSwizzler* initializeSwizzler(const SkImageInfo& info, const SkPMColor* ctable,
                                   const Options& opts);
    SkSampler* getSampler(bool createIfNecessary) override {
        SkASSERT(fSwizzler || !createIfNecessary);
        return fSwizzler;

     * Read a src row from the encoded stream
    bool readRow(uint8_t* row);

    SkWbmpCodec(int width, int height, const SkEncodedInfo&, SkStream*);

    const size_t                 fSrcRowBytes;

    // Used for scanline decodes:
    SkAutoTDelete<SkSwizzler>    fSwizzler;
    SkAutoTUnref<SkColorTable>   fColorTable;
    SkAutoTMalloc<uint8_t>       fSrcBuffer;

    int onGetScanlines(void* dst, int count, size_t dstRowBytes) override;
    bool onSkipScanlines(int count) override;
    Result onStartScanlineDecode(const SkImageInfo& dstInfo, const Options& options,
            SkPMColor inputColorTable[], int* inputColorCount) override;

    typedef SkCodec INHERITED;

#endif  // SkCodec_wbmp_DEFINED