| 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/SkTypes.h" | 
| 14 | #include "src/core/SkGlyph.h" | 
| 15 | #include "src/core/SkSpan.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 SkTypeface; | 
| 26 | struct SkGlyphPositionRoundingSpec; | 
| 27 | struct SkScalerContextEffects; | 
| 28 | |
| 29 | class SkStrikeForGPU { | 
| 30 | public: | 
| 31 | virtual ~SkStrikeForGPU() = default; | 
| 32 | virtual const SkDescriptor& getDescriptor() const = 0; | 
| 33 | |
| 34 | virtual void prepareForMaskDrawing( | 
| 35 | SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) = 0; | 
| 36 | |
| 37 | virtual void prepareForSDFTDrawing( | 
| 38 | SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) = 0; | 
| 39 | |
| 40 | virtual void prepareForPathDrawing( | 
| 41 | SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) = 0; | 
| 42 | |
| 43 | virtual const SkGlyphPositionRoundingSpec& roundingSpec() const = 0; | 
| 44 | |
| 45 | // Used with SkScopedStrikeForGPU to take action at the end of a scope. | 
| 46 | virtual void onAboutToExitScope() = 0; | 
| 47 | |
| 48 | // Common categories for glyph types used by GPU. | 
| 49 | static bool CanDrawAsMask(const SkGlyph& glyph); | 
| 50 | static bool CanDrawAsSDFT(const SkGlyph& glyph); | 
| 51 | static bool CanDrawAsPath(const SkGlyph& glyph); | 
| 52 | static bool FitsInAtlas(const SkGlyph& glyph); | 
| 53 | |
| 54 | |
| 55 | struct Deleter { | 
| 56 | void operator()(SkStrikeForGPU* ptr) const { | 
| 57 | ptr->onAboutToExitScope(); | 
| 58 | } | 
| 59 | }; | 
| 60 | }; | 
| 61 | |
| 62 | using SkScopedStrikeForGPU = std::unique_ptr<SkStrikeForGPU, SkStrikeForGPU::Deleter>; | 
| 63 | |
| 64 | class SkStrikeForGPUCacheInterface { | 
| 65 | public: | 
| 66 | virtual ~SkStrikeForGPUCacheInterface() = default; | 
| 67 | virtual SkScopedStrikeForGPU findOrCreateScopedStrike(const SkDescriptor& desc, | 
| 68 | const SkScalerContextEffects& effects, | 
| 69 | const SkTypeface& typeface) = 0; | 
| 70 | }; | 
| 71 | #endif //SkStrikeInterface_DEFINED | 
| 72 | 
