/* * 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 SkAtlasTextRenderer; class SkMatrix; class GrContext; class GrAtlasGlyphCache; class GrTextBlobCache; /** * 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 Make(sk_sp); ~SkInternalAtlasTextContext() override; SkAtlasTextRenderer* renderer() const { return fRenderer.get(); } GrContext* grContext() const { return fGrContext.get(); } GrAtlasGlyphCache* atlasGlyphCache(); GrTextBlobCache* textBlobCache(); GrDeferredUploadToken addInlineUpload(GrDeferredTextureUploadFn&&) override; GrDeferredUploadToken addASAPUpload(GrDeferredTextureUploadFn&&) override; 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); sk_sp 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; }; SkArenaAllocList fInlineUploads; SkArenaAllocList fDraws; SkArenaAllocList fASAPUploads; SkArenaAlloc fArena{1024 * 40}; sk_sp fGrContext; AtlasTexture fDistanceFieldAtlas; }; #endif