msarett | 1897631 | 2016-03-09 14:20:58 -0800 | [diff] [blame] | 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: |
Brian Osman | 2feb796 | 2017-04-25 16:41:47 -0400 | [diff] [blame] | 25 | SkData* onRefEncodedData() override; |
msarett | 1897631 | 2016-03-09 14:20:58 -0800 | [diff] [blame] | 26 | |
Matt Sarett | ebb1b5c | 2017-05-12 11:41:27 -0400 | [diff] [blame] | 27 | bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options&) |
| 28 | override; |
msarett | 1897631 | 2016-03-09 14:20:58 -0800 | [diff] [blame] | 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; |
bungeman | ffae30d | 2016-08-03 13:32:32 -0700 | [diff] [blame] | 38 | sk_sp<SkData> fData; |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 39 | |
msarett | 1897631 | 2016-03-09 14:20:58 -0800 | [diff] [blame] | 40 | typedef SkImageGenerator INHERITED; |
| 41 | }; |
| 42 | |
| 43 | #endif //defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) |