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 #ifndef SkCodecImageGenerator_DEFINED 8 #define SkCodecImageGenerator_DEFINED 9 10 #include "SkCodec.h" 11 #include "SkColorTable.h" 12 #include "SkData.h" 13 #include "SkImageGenerator.h" 14 15 class SkCodecImageGenerator : public SkImageGenerator { 16 public: 17 /* 18 * If this data represents an encoded image that we know how to decode, 19 * return an SkCodecImageGenerator. Otherwise return nullptr. 20 */ 21 static std::unique_ptr<SkImageGenerator> MakeFromEncodedCodec(sk_sp<SkData>); 22 23 protected: 24 SkData* onRefEncodedData() override; 25 26 bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options& opts) 27 override; 28 29 bool onQueryYUV8(SkYUVSizeInfo*, SkYUVColorSpace*) const override; 30 31 bool onGetYUV8Planes(const SkYUVSizeInfo&, void* planes[3]) override; 32 33 private: 34 /* 35 * Takes ownership of codec 36 */ 37 SkCodecImageGenerator(std::unique_ptr<SkCodec>, sk_sp<SkData>); 38 39 std::unique_ptr<SkCodec> fCodec; 40 sk_sp<SkData> fData; 41 sk_sp<SkColorTable> fColorTable; 42 43 typedef SkImageGenerator INHERITED; 44 }; 45 #endif // SkCodecImageGenerator_DEFINED 46