1 | /* |
---|---|
2 | * Copyright 2017 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 | #ifndef SkInternalAtlasTextContext_DEFINED |
9 | #define SkInternalAtlasTextContext_DEFINED |
10 | |
11 | #include "include/core/SkRefCnt.h" |
12 | #include "src/core/SkArenaAlloc.h" |
13 | #include "src/core/SkArenaAllocList.h" |
14 | #include "src/gpu/GrDeferredUpload.h" |
15 | |
16 | class GrContext; |
17 | class GrStrikeCache; |
18 | class GrTextBlobCache; |
19 | |
20 | class SkAtlasTextRenderer; |
21 | class SkMatrix; |
22 | |
23 | /** |
24 | * The implementation of SkAtlasTextContext. This exists to hide the details from the public class. |
25 | * and to be able to use other private types. |
26 | */ |
27 | class SkInternalAtlasTextContext : public GrDeferredUploadTarget { |
28 | public: |
29 | static std::unique_ptr<SkInternalAtlasTextContext> Make(sk_sp<SkAtlasTextRenderer>); |
30 | |
31 | ~SkInternalAtlasTextContext() override; |
32 | |
33 | SkAtlasTextRenderer* renderer() const { return fRenderer.get(); } |
34 | |
35 | GrContext* grContext() const { return fGrContext.get(); } |
36 | GrTextBlobCache* textBlobCache(); |
37 | |
38 | const GrTokenTracker* tokenTracker() final { return &fTokenTracker; } |
39 | GrDeferredUploadToken addInlineUpload(GrDeferredTextureUploadFn&&) final; |
40 | GrDeferredUploadToken addASAPUpload(GrDeferredTextureUploadFn&&) final; |
41 | |
42 | void recordDraw(const void* vertexData, int glyphCnt, const SkMatrix&, void* targetHandle); |
43 | |
44 | void flush(); |
45 | |
46 | private: |
47 | class DeferredUploader; |
48 | SkInternalAtlasTextContext() = delete; |
49 | SkInternalAtlasTextContext(const SkInternalAtlasTextContext&) = delete; |
50 | SkInternalAtlasTextContext& operator=(const SkInternalAtlasTextContext&) = delete; |
51 | |
52 | SkInternalAtlasTextContext(sk_sp<SkAtlasTextRenderer>); |
53 | |
54 | sk_sp<SkAtlasTextRenderer> fRenderer; |
55 | |
56 | struct AtlasTexture { |
57 | void* fTextureHandle = nullptr; |
58 | GrTextureProxy* fProxy = nullptr; |
59 | }; |
60 | |
61 | struct Draw { |
62 | int fGlyphCnt; |
63 | GrDeferredUploadToken fToken; |
64 | void* fTargetHandle; |
65 | const void* fVertexData; |
66 | }; |
67 | |
68 | struct InlineUpload { |
69 | GrDeferredTextureUploadFn fUpload; |
70 | GrDeferredUploadToken fToken; |
71 | }; |
72 | |
73 | GrTokenTracker fTokenTracker; |
74 | SkArenaAllocList<InlineUpload> fInlineUploads; |
75 | SkArenaAllocList<Draw> fDraws; |
76 | SkArenaAllocList<GrDeferredTextureUploadFn> fASAPUploads; |
77 | SkArenaAlloc fArena{1024 * 40}; |
78 | sk_sp<GrContext> fGrContext; |
79 | AtlasTexture fDistanceFieldAtlas; |
80 | }; |
81 | |
82 | #endif |
83 |