1 // Copyright 2019 Google LLC. 2 // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. 3 #ifndef SkTextBlobTrace_DEFINED 4 #define SkTextBlobTrace_DEFINED 5 6 #include "include/core/SkTypes.h" 7 8 #include "include/core/SkPaint.h" 9 #include "include/core/SkPoint.h" 10 #include "include/core/SkStream.h" 11 #include "include/core/SkTextBlob.h" 12 #include "src/core/SkWriteBuffer.h" 13 #include "src/text/GlyphRun.h" 14 15 #include <cstdint> 16 #include <vector> 17 18 namespace SkTextBlobTrace { 19 20 struct Record { 21 uint32_t origUniqueID; 22 SkPaint paint; 23 SkPoint offset; 24 sk_sp<SkTextBlob> blob; 25 }; 26 27 std::vector<SkTextBlobTrace::Record> CreateBlobTrace(SkStream* stream); 28 29 void DumpTrace(const std::vector<SkTextBlobTrace::Record>&); 30 31 class Capture { 32 public: 33 Capture(); 34 ~Capture(); 35 void capture(const sktext::GlyphRunList&, const SkPaint&); 36 // If `dst` is nullptr, write to a file. 37 void dump(SkWStream* dst = nullptr) const; 38 39 private: 40 size_t fBlobCount = 0; 41 sk_sp<SkRefCntSet> fTypefaceSet; 42 SkBinaryWriteBuffer fWriteBuffer; 43 44 Capture(const Capture&) = delete; 45 Capture& operator=(const Capture&) = delete; 46 }; 47 48 } // namespace SkTextBlobTrace 49 #endif // SkTextBlobTrace_DEFINED 50