xref: /aosp_15_r20/external/skia/src/pdf/SkPDFBitmap.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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 SkPDFBitmap_DEFINED
8 #define SkPDFBitmap_DEFINED
9 
10 #include "include/core/SkData.h"
11 #include "include/core/SkRefCnt.h"
12 #include "src/core/SkChecksum.h"
13 
14 #include <cstdint>
15 
16 class SkCodec;
17 class SkImage;
18 class SkPDFDocument;
19 struct SkEncodedInfo;
20 struct SkPDFIndirectReference;
21 
22 /**
23  * Serialize a SkImage as an Image Xobject.
24  *  quality > 100 means lossless
25  */
26 SkPDFIndirectReference SkPDFSerializeImage(const SkImage* img,
27                                            SkPDFDocument* doc,
28                                            int encodingQuality = 101);
29 
30 class SkPDFBitmap {
31 public:
32     static const SkEncodedInfo& GetEncodedInfo(SkCodec&);
33 };
34 
35 struct SkPDFIccProfileKey {
36     sk_sp<SkData> fData;
37     int fChannels;
38     bool operator==(const SkPDFIccProfileKey& that) const {
39         return fChannels == that.fChannels && fData->equals(that.fData.get());
40     }
41     bool operator!=(const SkPDFIccProfileKey& rhs) const { return !(*this == rhs); }
42 
43     struct Hash {
operatorSkPDFIccProfileKey::Hash44         uint32_t operator()(const SkPDFIccProfileKey& k) const {
45             return SkGoodHash()(k.fChannels) ^ SkChecksum::Hash32(k.fData->data(), k.fData->size());
46         }
47     };
48 };
49 
50 #endif  // SkPDFBitmap_DEFINED
51