1 /*
2  * Copyright 2015 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 GrTextTarget_DEFINED
9 #define GrTextTarget_DEFINED
10 
11 #include "include/core/SkPaint.h"
12 #include "src/gpu/GrColorInfo.h"
13 
14 class GrAtlasTextOp;
15 class GrClip;
16 class GrPaint;
17 class GrRecordingContext;
18 class GrShape;
19 class SkGlyphRunListPainter;
20 class SkMatrix;
21 struct SkIRect;
22 
23 class GrTextTarget {
24 public:
25     virtual ~GrTextTarget() = default;
26 
width()27     int width() const { return fWidth; }
28 
height()29     int height() const { return fHeight; }
30 
colorInfo()31     const GrColorInfo& colorInfo() const { return fColorInfo; }
32 
33     virtual void addDrawOp(const GrClip&, std::unique_ptr<GrAtlasTextOp> op) = 0;
34 
35     virtual void drawShape(const GrClip&, const SkPaint&,
36                            const SkMatrix& viewMatrix, const GrShape&) = 0;
37 
38     virtual void makeGrPaint(GrMaskFormat, const SkPaint&, const SkMatrix& viewMatrix,
39                              GrPaint*) = 0;
40 
41     virtual GrRecordingContext* getContext() = 0;
42 
43     virtual SkGlyphRunListPainter* glyphPainter() = 0;
44 
45 protected:
GrTextTarget(int width,int height,const GrColorInfo & colorInfo)46     GrTextTarget(int width, int height, const GrColorInfo& colorInfo)
47             : fWidth(width), fHeight(height), fColorInfo(colorInfo) {
48         SkASSERT(kPremul_SkAlphaType == colorInfo.alphaType());
49     }
50 
51 private:
52     int fWidth;
53     int fHeight;
54     const GrColorInfo& fColorInfo;
55 };
56 #endif  // GrTextTarget_DEFINED
57