1 /* 2 * Copyright 2022 Google LLC 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 skgpu_graphite_geom_SubRunData_DEFINED 9 #define skgpu_graphite_geom_SubRunData_DEFINED 10 11 #include "src/gpu/graphite/geom/Rect.h" 12 13 namespace sktext::gpu { class AtlasSubRun; } 14 15 namespace skgpu::graphite { 16 17 class Recorder; 18 19 /** 20 * SubRunData contains all the data we need to render AtlasSubRuns 21 */ 22 class SubRunData { 23 public: 24 SubRunData() = delete; 25 SubRunData(const SubRunData& subRun) = default; 26 SubRunData(SubRunData&&) = delete; 27 SubRunData(const sktext::gpu::AtlasSubRun * subRun,sk_sp<SkRefCnt> supportDataKeepAlive,Rect deviceBounds,int startGlyphIndex,int glyphCount,Recorder * recorder)28 SubRunData(const sktext::gpu::AtlasSubRun* subRun, 29 sk_sp<SkRefCnt> supportDataKeepAlive, 30 Rect deviceBounds, 31 int startGlyphIndex, 32 int glyphCount, 33 Recorder* recorder) 34 : fSubRun(subRun) 35 , fSupportDataKeepAlive(std::move(supportDataKeepAlive)) 36 , fBounds(deviceBounds) 37 , fStartGlyphIndex(startGlyphIndex) 38 , fGlyphCount(glyphCount) 39 , fRecorder(recorder) {} 40 41 ~SubRunData() = default; 42 43 // NOTE: None of the geometry types benefit from move semantics, so we don't bother 44 // defining a move assignment operator for SubRunData. 45 SubRunData& operator=(SubRunData&&) = delete; 46 SubRunData& operator=(const SubRunData& that) = default; 47 48 // The bounding box of the subrun data. bounds()49 Rect bounds() const { return fBounds; } 50 51 // Access the individual elements of the subrun data. subRun()52 const sktext::gpu::AtlasSubRun* subRun() const { return fSubRun; } startGlyphIndex()53 int startGlyphIndex() const { return fStartGlyphIndex; } glyphCount()54 int glyphCount() const { return fGlyphCount; } recorder()55 Recorder* recorder() const { return fRecorder; } 56 57 private: 58 const sktext::gpu::AtlasSubRun* fSubRun; 59 // Keep the TextBlob or Slug alive until we're done with the Geometry. 60 sk_sp<SkRefCnt> fSupportDataKeepAlive; 61 62 Rect fBounds; // bounds of the data stored in the SubRun 63 int fStartGlyphIndex; 64 int fGlyphCount; 65 Recorder* fRecorder; // this SubRun can only be associated with this Recorder's atlas 66 }; 67 68 } // namespace skgpu::graphite 69 70 #endif // skgpu_graphite_geom_SubRunData_DEFINED 71