blob: d68e471289482801f8cb7902aa71b441bd2b63ac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkPDFCanon_DEFINED
#define SkPDFCanon_DEFINED
#include "SkBitmapKey.h"
#include "SkPDFGradientShader.h"
#include "SkPDFGraphicState.h"
#include "SkPDFShader.h"
#ifdef SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER
#include "SkPixelSerializer.h"
#endif
#include "SkTDArray.h"
#include "SkTHash.h"
#include "SkTypeface.h"
class SkPDFFont;
struct SkAdvancedTypefaceMetrics;
/**
* The SkPDFCanon canonicalizes objects across PDF pages
* (SkPDFDevices) and across draw calls.
*/
class SkPDFCanon {
public:
~SkPDFCanon();
SkPDFCanon();
SkPDFCanon(const SkPDFCanon&) = delete;
SkPDFCanon& operator=(const SkPDFCanon&) = delete;
SkTHashMap<SkPDFImageShaderKey, sk_sp<SkPDFObject>> fImageShaderMap;
SkPDFGradientShader::HashMap fGradientPatternMap;
SkTHashMap<SkBitmapKey, sk_sp<SkPDFObject>> fPDFBitmapMap;
SkTHashMap<uint32_t, std::unique_ptr<SkAdvancedTypefaceMetrics>> fTypefaceMetrics;
SkTHashMap<uint32_t, sk_sp<SkPDFDict>> fFontDescriptors;
SkTHashMap<uint64_t, sk_sp<SkPDFFont>> fFontMap;
SkTHashMap<SkPDFStrokeGraphicState, sk_sp<SkPDFDict>> fStrokeGSMap;
SkTHashMap<SkPDFFillGraphicState, sk_sp<SkPDFDict>> fFillGSMap;
#ifdef SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER
sk_sp<SkPixelSerializer> fPixelSerializer;
#endif
sk_sp<SkPDFStream> fInvertFunction;
sk_sp<SkPDFDict> fNoSmaskGraphicState;
sk_sp<SkPDFArray> fRangeObject;
SK_BEGIN_REQUIRE_DENSE
struct BitmapGlyphKey {
SkFontID fFontID; // uint32_t
SkScalar fTextSize; // float32
SkScalar fTextScaleX; // float32
SkScalar fTextSkewX; // float32
SkGlyphID fGlyphID; // uint16_t
uint16_t fPadding;
};
SK_END_REQUIRE_DENSE
struct BitmapGlyph {
sk_sp<SkImage> fImage;
SkIPoint fOffset;
};
SkTHashMap<BitmapGlyphKey, BitmapGlyph> fBitmapGlyphImages;
};
inline bool operator==(const SkPDFCanon::BitmapGlyphKey& u, const SkPDFCanon::BitmapGlyphKey& v) {
return memcmp(&u, &u, sizeof(SkPDFCanon::BitmapGlyphKey)) == 0;
}
#endif // SkPDFCanon_DEFINED
|