1 /* 2 * Copyright 2016 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 8 #include "SkTypes.h" 9 #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) 10 11 #include "SkCGUtils.h" 12 #include "SkData.h" 13 #include "SkImageGenerator.h" 14 #include "SkTemplates.h" 15 16 class SkImageGeneratorCG : public SkImageGenerator { 17 public: 18 /* 19 * Refs the data if an image generator can be returned. Otherwise does 20 * not affect the data. 21 */ 22 static SkImageGenerator* NewFromEncodedCG(SkData* data); 23 24 protected: 25 SkData* onRefEncodedData() override; 26 27 bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options&) 28 override; 29 30 private: 31 /* 32 * Takes ownership of the imageSrc 33 * Refs the data 34 */ 35 SkImageGeneratorCG(const SkImageInfo& info, const void* imageSrc, SkData* data); 36 37 SkAutoTCallVProc<const void, CFRelease> fImageSrc; 38 sk_sp<SkData> fData; 39 40 typedef SkImageGenerator INHERITED; 41 }; 42 43 #endif //defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) 44