blob: 58aac4f01a2e65aa9b767e36b075772d41760d17 [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"
Leon Scroggins III0cbc10f2017-10-30 09:07:53 -040013#include "SkEncodedOrigin.h"
msarett18976312016-03-09 14:20:58 -080014#include "SkImageGenerator.h"
15#include "SkTemplates.h"
16
17class SkImageGeneratorCG : public SkImageGenerator {
18public:
Leon Scroggins III0cbc10f2017-10-30 09:07:53 -040019#ifdef SK_LEGACY_NEW_FROM_ENCODED_CG
msarett18976312016-03-09 14:20:58 -080020 /*
21 * Refs the data if an image generator can be returned. Otherwise does
22 * not affect the data.
23 */
24 static SkImageGenerator* NewFromEncodedCG(SkData* data);
Leon Scroggins III0cbc10f2017-10-30 09:07:53 -040025#endif
26
27 static std::unique_ptr<SkImageGenerator> MakeFromEncodedCG(sk_sp<SkData>);
msarett18976312016-03-09 14:20:58 -080028
29protected:
Brian Osman2feb7962017-04-25 16:41:47 -040030 SkData* onRefEncodedData() override;
msarett18976312016-03-09 14:20:58 -080031
Matt Sarettebb1b5c2017-05-12 11:41:27 -040032 bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options&)
33 override;
msarett18976312016-03-09 14:20:58 -080034
35private:
36 /*
37 * Takes ownership of the imageSrc
msarett18976312016-03-09 14:20:58 -080038 */
Leon Scroggins III0cbc10f2017-10-30 09:07:53 -040039 SkImageGeneratorCG(const SkImageInfo& info, const void* imageSrc, sk_sp<SkData> data,
40 SkEncodedOrigin origin);
msarett18976312016-03-09 14:20:58 -080041
42 SkAutoTCallVProc<const void, CFRelease> fImageSrc;
bungemanffae30d2016-08-03 13:32:32 -070043 sk_sp<SkData> fData;
Leon Scroggins III0cbc10f2017-10-30 09:07:53 -040044 const SkEncodedOrigin fOrigin;
halcanary9d524f22016-03-29 09:03:52 -070045
msarett18976312016-03-09 14:20:58 -080046 typedef SkImageGenerator INHERITED;
47};
48
49#endif //defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)