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