1 /* 2 * Copyright 2019 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 SkStrikeInterface_DEFINED 9 #define SkStrikeInterface_DEFINED 10 11 #include "include/core/SkPaint.h" 12 #include "include/core/SkPoint.h" 13 #include "include/core/SkSpan.h" 14 #include "include/core/SkTypes.h" 15 #include "src/core/SkGlyph.h" 16 17 #include <memory> 18 19 class SkDescriptor; 20 class SkDrawableGlyphBuffer; 21 class SkGlyph; 22 class SkMaskFilter; 23 class SkPathEffect; 24 class SkSourceGlyphBuffer; 25 class SkStrike; 26 class SkStrikeSpec; 27 class SkTypeface; 28 struct SkGlyphPositionRoundingSpec; 29 struct SkScalerContextEffects; 30 31 class SkStrikeForGPU { 32 public: 33 virtual ~SkStrikeForGPU() = default; 34 virtual const SkDescriptor& getDescriptor() const = 0; 35 36 virtual void prepareForMaskDrawing( 37 SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) = 0; 38 39 virtual void prepareForSDFTDrawing( 40 SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) = 0; 41 42 virtual void prepareForPathDrawing( 43 SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) = 0; 44 45 virtual const SkGlyphPositionRoundingSpec& roundingSpec() const = 0; 46 47 // Used with SkScopedStrikeForGPU to take action at the end of a scope. 48 virtual void onAboutToExitScope() = 0; 49 50 // Return underlying SkStrike for building SubRuns while processing glyph runs. 51 virtual sk_sp<SkStrike> getUnderlyingStrike() const = 0; 52 53 // Common categories for glyph types used by GPU. 54 static bool CanDrawAsMask(const SkGlyph& glyph); 55 static bool CanDrawAsSDFT(const SkGlyph& glyph); 56 static bool CanDrawAsPath(const SkGlyph& glyph); 57 static bool FitsInAtlas(const SkGlyph& glyph); 58 59 60 struct Deleter { operatorDeleter61 void operator()(SkStrikeForGPU* ptr) const { 62 ptr->onAboutToExitScope(); 63 } 64 }; 65 }; 66 67 using SkScopedStrikeForGPU = std::unique_ptr<SkStrikeForGPU, SkStrikeForGPU::Deleter>; 68 69 class SkStrikeForGPUCacheInterface { 70 public: 71 virtual ~SkStrikeForGPUCacheInterface() = default; 72 virtual SkScopedStrikeForGPU findOrCreateScopedStrike(const SkStrikeSpec& strikeSpec) = 0; 73 }; 74 #endif //SkStrikeInterface_DEFINED 75