Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: src/gpu/GrAtlasTextContext.h

Issue 1486323002: Remove plumbing of clipRect in GrAtlasTextContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove dead code Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/gpu/GrAtlasTextContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrAtlasTextContext_DEFINED 8 #ifndef GrAtlasTextContext_DEFINED
9 #define GrAtlasTextContext_DEFINED 9 #define GrAtlasTextContext_DEFINED
10 10
(...skipping 18 matching lines...) Expand all
29 * This class implements GrTextContext using standard bitmap fonts, and can also process textblobs. 29 * This class implements GrTextContext using standard bitmap fonts, and can also process textblobs.
30 */ 30 */
31 class GrAtlasTextContext : public GrTextContext { 31 class GrAtlasTextContext : public GrTextContext {
32 public: 32 public:
33 static GrAtlasTextContext* Create(GrContext*, const SkSurfaceProps&); 33 static GrAtlasTextContext* Create(GrContext*, const SkSurfaceProps&);
34 34
35 private: 35 private:
36 GrAtlasTextContext(GrContext*, const SkSurfaceProps&); 36 GrAtlasTextContext(GrContext*, const SkSurfaceProps&);
37 ~GrAtlasTextContext() override {} 37 ~GrAtlasTextContext() override {}
38 38
39 bool canDraw(const GrRenderTarget*, const GrClip&, const GrPaint&, 39 bool canDraw(const SkPaint&, const SkMatrix& viewMatrix) override;
40 const SkPaint&, const SkMatrix& viewMatrix) override;
41 40
42 void onDrawText(GrDrawContext*, GrRenderTarget*, const GrClip&, const GrPain t&, const SkPaint&, 41 void onDrawText(GrDrawContext*, GrRenderTarget*, const GrClip&, const GrPain t&, const SkPaint&,
43 const SkMatrix& viewMatrix, const char text[], size_t byteLe ngth, 42 const SkMatrix& viewMatrix, const char text[], size_t byteLe ngth,
44 SkScalar x, SkScalar y, const SkIRect& regionClipBounds) ove rride; 43 SkScalar x, SkScalar y, const SkIRect& regionClipBounds) ove rride;
45 void onDrawPosText(GrDrawContext*, GrRenderTarget*, const GrClip&, const GrP aint&, 44 void onDrawPosText(GrDrawContext*, GrRenderTarget*, const GrClip&, const GrP aint&,
46 const SkPaint&, const SkMatrix& viewMatrix, 45 const SkPaint&, const SkMatrix& viewMatrix,
47 const char text[], size_t byteLength, 46 const char text[], size_t byteLength,
48 const SkScalar pos[], int scalarsPerPosition, 47 const SkScalar pos[], int scalarsPerPosition,
49 const SkPoint& offset, const SkIRect& regionClipBounds) o verride; 48 const SkPoint& offset, const SkIRect& regionClipBounds) o verride;
50 void drawTextBlob(GrDrawContext*, GrRenderTarget*, const GrClip&, const SkPa int&, 49 void drawTextBlob(GrDrawContext*, GrRenderTarget*, const GrClip&, const SkPa int&,
51 const SkMatrix& viewMatrix, const SkTextBlob*, SkScalar x, SkScalar y, 50 const SkMatrix& viewMatrix, const SkTextBlob*, SkScalar x, SkScalar y,
52 SkDrawFilter*, const SkIRect& clipBounds) override; 51 SkDrawFilter*, const SkIRect& clipBounds) override;
53 52
54 typedef GrAtlasTextBlob::Run Run; 53 typedef GrAtlasTextBlob::Run Run;
55 typedef Run::SubRunInfo PerSubRunInfo; 54 typedef Run::SubRunInfo PerSubRunInfo;
56 55
57 inline bool canDrawAsDistanceFields(const SkPaint&, const SkMatrix& viewMatr ix); 56 inline bool canDrawAsDistanceFields(const SkPaint&, const SkMatrix& viewMatr ix);
58 GrAtlasTextBlob* setupDFBlob(int glyphCount, const SkPaint& origPaint, 57 GrAtlasTextBlob* setupDFBlob(int glyphCount, const SkPaint& origPaint,
59 const SkMatrix& viewMatrix, SkPaint* dfPaint, 58 const SkMatrix& viewMatrix, SkPaint* dfPaint,
60 SkScalar* textRatio); 59 SkScalar* textRatio);
61 void bmpAppendGlyph(GrAtlasTextBlob*, int runIndex, const SkGlyph&, int left , int top, 60 void bmpAppendGlyph(GrAtlasTextBlob*, int runIndex, const SkGlyph&, int left , int top,
62 GrColor color, GrFontScaler*, const SkIRect& clipRect); 61 GrColor color, GrFontScaler*);
63 bool dfAppendGlyph(GrAtlasTextBlob*, int runIndex, const SkGlyph&, SkScalar sx, SkScalar sy, 62 bool dfAppendGlyph(GrAtlasTextBlob*, int runIndex, const SkGlyph&, SkScalar sx, SkScalar sy,
64 GrColor color, GrFontScaler*, const SkIRect& clipRect, Sk Scalar textRatio, 63 GrColor color, GrFontScaler*, SkScalar textRatio,
65 const SkMatrix& viewMatrix); 64 const SkMatrix& viewMatrix);
66 inline void appendGlyphPath(GrAtlasTextBlob*, GrGlyph*, GrFontScaler*, const SkGlyph&, 65 inline void appendGlyphPath(GrAtlasTextBlob*, GrGlyph*, GrFontScaler*, const SkGlyph&,
67 SkScalar x, SkScalar y, SkScalar scale = 1.0f, 66 SkScalar x, SkScalar y, SkScalar scale = 1.0f,
68 bool applyVM = false); 67 bool applyVM = false);
69 inline void appendGlyphCommon(GrAtlasTextBlob*, Run*, Run::SubRunInfo*, 68 inline void appendGlyphCommon(GrAtlasTextBlob*, Run*, Run::SubRunInfo*,
70 const SkRect& positions, GrColor color, 69 const SkRect& positions, GrColor color,
71 size_t vertexStride, bool useVertexColor, 70 size_t vertexStride, bool useVertexColor,
72 GrGlyph*); 71 GrGlyph*);
73 72
74 inline void flushRunAsPaths(GrDrawContext*, 73 inline void flushRunAsPaths(GrDrawContext*,
(...skipping 14 matching lines...) Expand all
89 // We have to flush SkTextBlobs differently from drawText / drawPosText 88 // We have to flush SkTextBlobs differently from drawText / drawPosText
90 void flush(const SkTextBlob*, GrAtlasTextBlob*, GrDrawContext*, GrRenderTarg et*, 89 void flush(const SkTextBlob*, GrAtlasTextBlob*, GrDrawContext*, GrRenderTarg et*,
91 const SkPaint&, const GrPaint&, SkDrawFilter*, const GrClip&, 90 const SkPaint&, const GrPaint&, SkDrawFilter*, const GrClip&,
92 const SkMatrix& viewMatrix, const SkIRect& clipBounds, SkScalar x , SkScalar y, 91 const SkMatrix& viewMatrix, const SkIRect& clipBounds, SkScalar x , SkScalar y,
93 SkScalar transX, SkScalar transY); 92 SkScalar transX, SkScalar transY);
94 void flush(GrAtlasTextBlob*, GrDrawContext*, GrRenderTarget*, const SkPaint& , 93 void flush(GrAtlasTextBlob*, GrDrawContext*, GrRenderTarget*, const SkPaint& ,
95 const GrPaint&, const GrClip&, const SkIRect& clipBounds); 94 const GrPaint&, const GrClip&, const SkIRect& clipBounds);
96 95
97 // A helper for drawing BitmapText in a run of distance fields 96 // A helper for drawing BitmapText in a run of distance fields
98 inline void fallbackDrawPosText(GrAtlasTextBlob*, int runIndex, 97 inline void fallbackDrawPosText(GrAtlasTextBlob*, int runIndex,
99 GrRenderTarget*, const GrClip&, GrColor colo r, 98 const GrClip&, GrColor color,
100 const SkPaint&, const SkMatrix& viewMatrix, 99 const SkPaint&, const SkMatrix& viewMatrix,
101 const SkTDArray<char>& fallbackTxt, 100 const SkTDArray<char>& fallbackTxt,
102 const SkTDArray<SkScalar>& fallbackPos, 101 const SkTDArray<SkScalar>& fallbackPos,
103 int scalarsPerPosition, 102 int scalarsPerPosition,
104 const SkPoint& offset, 103 const SkPoint& offset);
105 const SkIRect& clipRect);
106 104
107 void internalDrawBMPText(GrAtlasTextBlob*, int runIndex, SkGlyphCache*, cons t SkPaint&, 105 void internalDrawBMPText(GrAtlasTextBlob*, int runIndex, SkGlyphCache*, cons t SkPaint&,
108 GrColor color, const SkMatrix& viewMatrix, 106 GrColor color, const SkMatrix& viewMatrix,
109 const char text[], size_t byteLength, 107 const char text[], size_t byteLength,
110 SkScalar x, SkScalar y, const SkIRect& clipRect); 108 SkScalar x, SkScalar y);
111 void internalDrawBMPPosText(GrAtlasTextBlob*, int runIndex, SkGlyphCache*, c onst SkPaint&, 109 void internalDrawBMPPosText(GrAtlasTextBlob*, int runIndex, SkGlyphCache*, c onst SkPaint&,
112 GrColor color, const SkMatrix& viewMatrix, 110 GrColor color, const SkMatrix& viewMatrix,
113 const char text[], size_t byteLength, 111 const char text[], size_t byteLength,
114 const SkScalar pos[], int scalarsPerPosition, 112 const SkScalar pos[], int scalarsPerPosition,
115 const SkPoint& offset, const SkIRect& clipRect); 113 const SkPoint& offset);
116 114
117 void internalDrawDFText(GrAtlasTextBlob*, int runIndex, const SkPaint&, 115 void internalDrawDFText(GrAtlasTextBlob*, int runIndex, const SkPaint&,
118 GrColor color, const SkMatrix& viewMatrix, 116 GrColor color, const SkMatrix& viewMatrix,
119 const char text[], size_t byteLength, 117 const char text[], size_t byteLength,
120 SkScalar x, SkScalar y, const SkIRect& clipRect, 118 SkScalar x, SkScalar y,
121 SkScalar textRatio, 119 SkScalar textRatio,
122 SkTDArray<char>* fallbackTxt, 120 SkTDArray<char>* fallbackTxt,
123 SkTDArray<SkScalar>* fallbackPos, 121 SkTDArray<SkScalar>* fallbackPos,
124 SkPoint* offset, const SkPaint& origPaint); 122 SkPoint* offset, const SkPaint& origPaint);
125 void internalDrawDFPosText(GrAtlasTextBlob*, int runIndex, const SkPaint&, 123 void internalDrawDFPosText(GrAtlasTextBlob*, int runIndex, const SkPaint&,
126 GrColor color, const SkMatrix& viewMatrix, 124 GrColor color, const SkMatrix& viewMatrix,
127 const char text[], size_t byteLength, 125 const char text[], size_t byteLength,
128 const SkScalar pos[], int scalarsPerPosition, 126 const SkScalar pos[], int scalarsPerPosition,
129 const SkPoint& offset, const SkIRect& clipRect, 127 const SkPoint& offset,
130 SkScalar textRatio, 128 SkScalar textRatio,
131 SkTDArray<char>* fallbackTxt, 129 SkTDArray<char>* fallbackTxt,
132 SkTDArray<SkScalar>* fallbackPos); 130 SkTDArray<SkScalar>* fallbackPos);
133 131
134 // sets up the descriptor on the blob and returns a detached cache. Client must attach 132 // sets up the descriptor on the blob and returns a detached cache. Client must attach
135 inline static GrColor ComputeCanonicalColor(const SkPaint&, bool lcd); 133 inline static GrColor ComputeCanonicalColor(const SkPaint&, bool lcd);
136 inline SkGlyphCache* setupCache(Run*, const SkPaint&, const SkMatrix* viewMa trix, bool noGamma); 134 inline SkGlyphCache* setupCache(Run*, const SkPaint&, const SkMatrix* viewMa trix, bool noGamma);
137 static inline bool MustRegenerateBlob(SkScalar* outTransX, SkScalar* outTran sY, 135 static inline bool MustRegenerateBlob(SkScalar* outTransX, SkScalar* outTran sY,
138 const GrAtlasTextBlob&, const SkPaint& , GrColor, 136 const GrAtlasTextBlob&, const SkPaint& , GrColor,
139 const SkMaskFilter::BlurRec&, 137 const SkMaskFilter::BlurRec&,
140 const SkMatrix& viewMatrix, SkScalar x , SkScalar y); 138 const SkMatrix& viewMatrix, SkScalar x , SkScalar y);
141 void regenerateTextBlob(GrAtlasTextBlob* bmp, const SkPaint& skPaint, GrColo r, 139 void regenerateTextBlob(GrAtlasTextBlob* bmp, const SkPaint& skPaint, GrColo r,
142 const SkMatrix& viewMatrix, 140 const SkMatrix& viewMatrix,
143 const SkTextBlob* blob, SkScalar x, SkScalar y, 141 const SkTextBlob* blob, SkScalar x, SkScalar y,
144 SkDrawFilter* drawFilter, const SkIRect& clipRect, G rRenderTarget*, 142 SkDrawFilter* drawFilter,
145 const GrClip&); 143 const GrClip&);
146 inline static bool HasLCD(const SkTextBlob*); 144 inline static bool HasLCD(const SkTextBlob*);
147 inline void initDistanceFieldPaint(GrAtlasTextBlob*, SkPaint*, SkScalar* tex tRatio, 145 inline void initDistanceFieldPaint(GrAtlasTextBlob*, SkPaint*, SkScalar* tex tRatio,
148 const SkMatrix&); 146 const SkMatrix&);
149 147
150 // Test methods 148 // Test methods
151 // TODO this is really ugly. It'd be much nicer if positioning could be mov ed to batch 149 // TODO this is really ugly. It'd be much nicer if positioning could be mov ed to batch
152 inline GrAtlasTextBlob* createDrawTextBlob(GrRenderTarget*, const GrClip&, c onst GrPaint&, 150 inline GrAtlasTextBlob* createDrawTextBlob(const GrClip&, const GrPaint&,
153 const SkPaint&, const SkMatrix& vi ewMatrix, 151 const SkPaint&, const SkMatrix& v iewMatrix,
154 const char text[], size_t byteLeng th, 152 const char text[], size_t byteLen gth,
155 SkScalar x, SkScalar y, 153 SkScalar x, SkScalar y,
156 const SkIRect& regionClipBounds); 154 const SkIRect& regionClipBounds);
157 inline GrAtlasTextBlob* createDrawPosTextBlob(GrRenderTarget*, const GrClip& , const GrPaint&, 155 inline GrAtlasTextBlob* createDrawPosTextBlob(const GrClip&, const GrPaint&,
158 const SkPaint&, const SkMatrix& viewMatrix, 156 const SkPaint&, const SkMatrix & viewMatrix,
159 const char text[], size_t byteL ength, 157 const char text[], size_t byte Length,
160 const SkScalar pos[], int scala rsPerPosition, 158 const SkScalar pos[], int scal arsPerPosition,
161 const SkPoint& offset, 159 const SkPoint& offset,
162 const SkIRect& regionClipBounds ); 160 const SkIRect& regionClipBound s);
163 161
164 // Distance field text needs this table to compute a value for use in the fr agment shader. 162 // Distance field text needs this table to compute a value for use in the fr agment shader.
165 // Because the GrAtlasTextContext can go out of scope before the final flush , this needs to be 163 // Because the GrAtlasTextContext can go out of scope before the final flush , this needs to be
166 // refcnted and malloced 164 // refcnted and malloced
167 struct DistanceAdjustTable : public SkNVRefCnt<DistanceAdjustTable> { 165 struct DistanceAdjustTable : public SkNVRefCnt<DistanceAdjustTable> {
168 DistanceAdjustTable() { this->buildDistanceAdjustTable(); } 166 DistanceAdjustTable() { this->buildDistanceAdjustTable(); }
169 ~DistanceAdjustTable() { delete[] fTable; } 167 ~DistanceAdjustTable() { delete[] fTable; }
170 168
171 const SkScalar& operator[] (int i) const { 169 const SkScalar& operator[] (int i) const {
172 return fTable[i]; 170 return fTable[i];
(...skipping 13 matching lines...) Expand all
186 friend class GrAtlasTextBatch; 184 friend class GrAtlasTextBatch;
187 185
188 #ifdef GR_TEST_UTILS 186 #ifdef GR_TEST_UTILS
189 DRAW_BATCH_TEST_FRIEND(TextBlobBatch); 187 DRAW_BATCH_TEST_FRIEND(TextBlobBatch);
190 #endif 188 #endif
191 189
192 typedef GrTextContext INHERITED; 190 typedef GrTextContext INHERITED;
193 }; 191 };
194 192
195 #endif 193 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrAtlasTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698