blob: 65300a6de203627eb8fc08bac4e16a2ea49e7b5f [file] [log] [blame]
msarett18976312016-03-09 14:20:58 -08001/*
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
16class SkImageGeneratorCG : public SkImageGenerator {
17public:
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
24protected:
Brian Osman2feb7962017-04-25 16:41:47 -040025 SkData* onRefEncodedData() override;
msarett18976312016-03-09 14:20:58 -080026
Matt Sarettebb1b5c2017-05-12 11:41:27 -040027 bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options&)
28 override;
msarett18976312016-03-09 14:20:58 -080029
30private:
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;
bungemanffae30d2016-08-03 13:32:32 -070038 sk_sp<SkData> fData;
halcanary9d524f22016-03-29 09:03:52 -070039
msarett18976312016-03-09 14:20:58 -080040 typedef SkImageGenerator INHERITED;
41};
42
43#endif //defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)