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