1 /* 2 * Copyright 2018 The Android Open Source Project 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 SkGlyphRunPainter_DEFINED 9 #define SkGlyphRunPainter_DEFINED 10 11 #include "include/core/SkSamplingOptions.h" 12 #include "include/core/SkSurfaceProps.h" 13 #include "src/base/SkZip.h" 14 15 #include <cstdint> 16 17 class SkBitmap; 18 class SkCanvas; 19 class SkColorSpace; 20 class SkGlyph; 21 class SkMatrix; 22 class SkPaint; 23 enum SkColorType : int; 24 enum class SkScalerContextFlags : uint32_t; 25 namespace sktext { class GlyphRunList; } 26 struct SkPoint; 27 struct SkRect; 28 29 class SkGlyphRunListPainterCPU { 30 public: 31 class BitmapDevicePainter { 32 public: 33 BitmapDevicePainter() = default; 34 BitmapDevicePainter(const BitmapDevicePainter&) = default; 35 virtual ~BitmapDevicePainter() = default; 36 37 virtual void paintMasks(SkZip<const SkGlyph*, SkPoint> accepted, 38 const SkPaint& paint) const = 0; 39 virtual void drawBitmap(const SkBitmap&, const SkMatrix&, const SkRect* dstOrNull, 40 const SkSamplingOptions&, const SkPaint&) const = 0; 41 }; 42 43 SkGlyphRunListPainterCPU(const SkSurfaceProps& props, 44 SkColorType colorType, 45 SkColorSpace* cs); 46 47 void drawForBitmapDevice( 48 SkCanvas* canvas, const BitmapDevicePainter* bitmapDevice, 49 const sktext::GlyphRunList& glyphRunList, const SkPaint& paint, 50 const SkMatrix& drawMatrix); 51 private: 52 // The props as on the actual device. 53 const SkSurfaceProps fDeviceProps; 54 55 // The props for when the bitmap device can't draw LCD text. 56 const SkSurfaceProps fBitmapFallbackProps; 57 const SkColorType fColorType; 58 const SkScalerContextFlags fScalerContextFlags; 59 }; 60 #endif // SkGlyphRunPainter_DEFINED 61