Home | History | Annotate | Download | only in codec
      1 /*
      2  * Copyright 2017 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 #ifndef SkBmpBaseCodec_DEFINED
      8 #define SkBmpBaseCodec_DEFINED
      9 
     10 #include "SkBmpCodec.h"
     11 #include "SkTemplates.h"
     12 
     13 /*
     14  * Common base class for SkBmpStandardCodec and SkBmpMaskCodec.
     15  */
     16 class SkBmpBaseCodec : public SkBmpCodec {
     17 public:
     18     ~SkBmpBaseCodec() override;
     19 
     20     /*
     21      * Whether fSrcBuffer was successfully created.
     22      *
     23      * If false, this Codec must not be used.
     24      */
     25     bool didCreateSrcBuffer() const { return fSrcBuffer != nullptr; }
     26 
     27 protected:
     28     SkBmpBaseCodec(int width, int height, const SkEncodedInfo& info, std::unique_ptr<SkStream>,
     29                    uint16_t bitsPerPixel, SkCodec::SkScanlineOrder rowOrder);
     30 
     31     uint8_t* srcBuffer() { return reinterpret_cast<uint8_t*>(fSrcBuffer.get()); }
     32 
     33 private:
     34     SkAutoFree fSrcBuffer;
     35 
     36     typedef SkBmpCodec INHERITED;
     37 };
     38 #endif // SkBmpBaseCodec_DEFINED
     39