xref: /aosp_15_r20/external/skia/src/core/SkDraw.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 
2 /*
3  * Copyright 2006 The Android Open Source Project
4  *
5  * Use of this source code is governed by a BSD-style license that can be
6  * found in the LICENSE file.
7  */
8 
9 
10 #ifndef SkDraw_DEFINED
11 #define SkDraw_DEFINED
12 
13 #include "include/core/SkCanvas.h"
14 #include "include/core/SkColor.h"
15 #include "include/core/SkRefCnt.h"
16 #include "include/core/SkSamplingOptions.h"
17 #include "src/base/SkZip.h"
18 #include "src/core/SkDrawBase.h"
19 #include <cstddef>
20 
21 class SkArenaAlloc;
22 class SkBitmap;
23 class SkBlender;
24 class SkDevice;
25 class SkGlyph;
26 class SkGlyphRunListPainterCPU;
27 class SkMatrix;
28 class SkPaint;
29 class SkVertices;
30 namespace sktext { class GlyphRunList; }
31 struct SkPoint3;
32 struct SkPoint;
33 struct SkRSXform;
34 struct SkRect;
35 
36 
37 // defaults to use SkBlitter::Choose()
38 class SkDraw : public SkDrawBase {
39 public:
40     SkDraw();
41 
42     /* If dstOrNull is null, computes a dst by mapping the bitmap's bounds through the matrix. */
43     void    drawBitmap(const SkBitmap&, const SkMatrix&, const SkRect* dstOrNull,
44                        const SkSamplingOptions&, const SkPaint&) const override;
45     void    drawSprite(const SkBitmap&, int x, int y, const SkPaint&) const;
46     void    drawGlyphRunList(SkCanvas* canvas,
47                              SkGlyphRunListPainterCPU* glyphPainter,
48                              const sktext::GlyphRunList& glyphRunList,
49                              const SkPaint& paint) const;
50 
51     void paintMasks(SkZip<const SkGlyph*, SkPoint> accepted, const SkPaint& paint) const override;
52 
53     void drawPoints(SkCanvas::PointMode, size_t count, const SkPoint[],
54                     const SkPaint&, SkDevice*) const;
55     /* If skipColorXform, skips color conversion when assigning per-vertex colors */
56     void drawVertices(const SkVertices*,
57                       sk_sp<SkBlender>,
58                       const SkPaint&,
59                       bool skipColorXform) const;
60     void drawAtlas(const SkRSXform[], const SkRect[], const SkColor[], int count,
61                    sk_sp<SkBlender>, const SkPaint&);
62 
63 #if defined(SK_SUPPORT_LEGACY_ALPHA_BITMAP_AS_COVERAGE)
64     void drawDevMask(const SkMask& mask, const SkPaint&) const;
65     void drawBitmapAsMask(const SkBitmap&, const SkSamplingOptions&, const SkPaint&) const;
66 #endif
67 
68 private:
69     void drawFixedVertices(const SkVertices* vertices,
70                            sk_sp<SkBlender> blender,
71                            const SkPaint& paint,
72                            const SkMatrix& ctmInverse,
73                            const SkPoint* dev2,
74                            const SkPoint3* dev3,
75                            SkArenaAlloc* outerAlloc,
76                            bool skipColorXform) const;
77 };
78 
79 #endif
80