blob: cdba3ad8b0d44a21f61dc7cddc9ac9162765a5e8 (
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
76
77
78
79
80
81
82
83
|
/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkInternalAtlasTextContext_DEFINED
#define SkInternalAtlasTextContext_DEFINED
#include "GrDeferredUpload.h"
#include "SkArenaAlloc.h"
#include "SkArenaAllocList.h"
#include "SkRefCnt.h"
class GrAtlasGlyphCache;
class GrContext;
class GrTextBlobCache;
class SkAtlasTextRenderer;
class SkMatrix;
/**
* The implementation of SkAtlasTextContext. This exists to hide the details from the public class.
* and to be able to use other private types.
*/
class SkInternalAtlasTextContext : public GrDeferredUploadTarget {
public:
static std::unique_ptr<SkInternalAtlasTextContext> Make(sk_sp<SkAtlasTextRenderer>);
~SkInternalAtlasTextContext() override;
SkAtlasTextRenderer* renderer() const { return fRenderer.get(); }
GrContext* grContext() const { return fGrContext.get(); }
GrAtlasGlyphCache* atlasGlyphCache();
GrTextBlobCache* textBlobCache();
const GrTokenTracker* tokenTracker() final { return &fTokenTracker; }
GrDeferredUploadToken addInlineUpload(GrDeferredTextureUploadFn&&) final;
GrDeferredUploadToken addASAPUpload(GrDeferredTextureUploadFn&&) final;
void recordDraw(const void* vertexData, int glyphCnt, const SkMatrix&, void* targetHandle);
void flush();
private:
class DeferredUploader;
SkInternalAtlasTextContext() = delete;
SkInternalAtlasTextContext(const SkInternalAtlasTextContext&) = delete;
SkInternalAtlasTextContext& operator=(const SkInternalAtlasTextContext&) = delete;
SkInternalAtlasTextContext(sk_sp<SkAtlasTextRenderer>);
sk_sp<SkAtlasTextRenderer> fRenderer;
struct AtlasTexture {
void* fTextureHandle = nullptr;
GrTextureProxy* fProxy = nullptr;
};
struct Draw {
int fGlyphCnt;
GrDeferredUploadToken fToken;
void* fTargetHandle;
const void* fVertexData;
};
struct InlineUpload {
GrDeferredTextureUploadFn fUpload;
GrDeferredUploadToken fToken;
};
GrTokenTracker fTokenTracker;
SkArenaAllocList<InlineUpload> fInlineUploads;
SkArenaAllocList<Draw> fDraws;
SkArenaAllocList<GrDeferredTextureUploadFn> fASAPUploads;
SkArenaAlloc fArena{1024 * 40};
sk_sp<GrContext> fGrContext;
AtlasTexture fDistanceFieldAtlas;
};
#endif
|