• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/SkColorType.h"
12 #include "include/core/SkSurfaceProps.h"
13 #include "src/core/SkGlyphBuffer.h"
14 #include "src/core/SkScalerContext.h"
15 
16 class SkColorSpace;
17 class SkDrawableGlyphBuffer;
18 namespace sktext { class GlyphRunList; }
19 
20 // -- SkGlyphRunListPainterCPU ---------------------------------------------------------------------
21 class SkGlyphRunListPainterCPU {
22 public:
23     class BitmapDevicePainter {
24     public:
25         BitmapDevicePainter() = default;
26         BitmapDevicePainter(const BitmapDevicePainter&) = default;
27         virtual ~BitmapDevicePainter() = default;
28 
29         virtual void paintMasks(SkZip<const SkGlyph*, SkPoint> accepted,
30                                 const SkPaint& paint) const = 0;
31         virtual void drawBitmap(const SkBitmap&, const SkMatrix&, const SkRect* dstOrNull,
32                                 const SkSamplingOptions&, const SkPaint&) const = 0;
33     };
34 
35     SkGlyphRunListPainterCPU(const SkSurfaceProps& props,
36                              SkColorType colorType,
37                              SkColorSpace* cs);
38 
39     void drawForBitmapDevice(
40             SkCanvas* canvas, const BitmapDevicePainter* bitmapDevice,
41             const sktext::GlyphRunList& glyphRunList, const SkPaint& paint,
42             const SkMatrix& drawMatrix);
43 private:
44     // The props as on the actual device.
45     const SkSurfaceProps fDeviceProps;
46 
47     // The props for when the bitmap device can't draw LCD text.
48     const SkSurfaceProps fBitmapFallbackProps;
49     const SkColorType fColorType;
50     const SkScalerContextFlags fScalerContextFlags;
51 };
52 #endif  // SkGlyphRunPainter_DEFINED
53