Debian Codegraph @

modules/skparagraph/src/ParagraphPainterImpl.h

raw
1 // Copyright 2019 Google LLC.
2 #ifndef ParagraphPainterImpl_DEFINED
3 #define ParagraphPainterImpl_DEFINED
4
5 #include "include/core/SkCanvas.h"
6 #include "modules/skparagraph/include/ParagraphPainter.h"
7
8 namespace skia {
9 namespace textlayout {
10
11 class CanvasParagraphPainter : public ParagraphPainter {
12 public:
13 explicit CanvasParagraphPainter(SkCanvas* canvas);
14
15 void drawTextBlob(const sk_sp<SkTextBlob>& blob, SkScalar x, SkScalar y, const SkPaintOrID& paint) override;
16 void drawTextShadow(const sk_sp<SkTextBlob>& blob, SkScalar x, SkScalar y, SkColor color, SkScalar blurSigma) override;
17 void drawRect(const SkRect& rect, const SkPaintOrID& paint) override;
18 void drawFilledRect(const SkRect& rect, const DecorationStyle& decorStyle) override;
19 void drawPath(const SkPath& path, const DecorationStyle& decorStyle) override;
20 void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const DecorationStyle& decorStyle) override;
21
22 void clipRect(const SkRect& rect) override;
23 void translate(SkScalar dx, SkScalar dy) override;
24
25 void save() override;
26 void restore() override;
27
28 private:
29 SkCanvas* fCanvas;
30 };
31
32 class ParagraphPainterAutoRestore {
33 public:
34 explicit ParagraphPainterAutoRestore(ParagraphPainter* painter) : fPainter(painter) {
35 fPainter->save();
36 }
37
38 ~ParagraphPainterAutoRestore() {
39 fPainter->restore();
40 }
41
42 private:
43 ParagraphPainter* fPainter;
44 };
45
46 } // namespace textlayout
47 } // namespace skia
48
49 #endif // ParagraphPainterImpl_DEFINED