1 // Copyright 2021 Google LLC. 2 #ifndef Wrapper_DEFINED 3 #define Wrapper_DEFINED 4 5 #include "experimental/sktext/include/Processor.h" 6 #include "experimental/sktext/src/Line.h" 7 #include "experimental/sktext/src/TextRun.h" 8 9 namespace skia { 10 namespace text { 11 12 class Wrapper { 13 14 public: Wrapper(Processor * processor,SkScalar width,SkScalar height)15 Wrapper(Processor* processor, SkScalar width, SkScalar height) : fProcessor(processor), fWidth(width), fHeight(height) { } 16 bool process(); 17 addLine(Stretch & stretch,Stretch & spaces)18 void addLine(Stretch& stretch, Stretch& spaces) { 19 fProcessor->fLines.emplace_back(fProcessor, stretch, spaces); 20 stretch.clean(); 21 spaces.clean(); 22 } 23 glyphRangeWidth(const TextRun * run,const GlyphRange & glyphRange)24 SkScalar glyphRangeWidth(const TextRun* run, const GlyphRange& glyphRange) { 25 return run->fPositions[glyphRange.fEnd].fX - run->fPositions[glyphRange.fStart].fX; 26 } 27 28 static GlyphRange glyphRange(const TextRun* run, const TextRange& textRange); 29 static TextRange textRange(const TextRun* run, const GlyphRange& glyphRange); 30 bool breakTextIntoLines(SkScalar width); 31 32 private: 33 Processor* fProcessor; 34 SkScalar fWidth; 35 // TODO: Implement 36 SkScalar fHeight; 37 }; 38 39 } // namespace text 40 } // namespace skia 41 #endif 42