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

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

Issue 1485973004: Reduce use of GrRenderTarget in GrTextContexts (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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') | src/gpu/GrAtlasTextContext.cpp » ('J')
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&,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
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); 104 const SkIRect& clipRect);
106 105
107 void internalDrawBMPText(GrAtlasTextBlob*, int runIndex, SkGlyphCache*, cons t SkPaint&, 106 void internalDrawBMPText(GrAtlasTextBlob*, int runIndex, SkGlyphCache*, cons t SkPaint&,
108 GrColor color, const SkMatrix& viewMatrix, 107 GrColor color, const SkMatrix& viewMatrix,
109 const char text[], size_t byteLength, 108 const char text[], size_t byteLength,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 const SkMatrix& viewMatrix, 141 const SkMatrix& viewMatrix,
143 const SkTextBlob* blob, SkScalar x, SkScalar y, 142 const SkTextBlob* blob, SkScalar x, SkScalar y,
144 SkDrawFilter* drawFilter, const SkIRect& clipRect, G rRenderTarget*, 143 SkDrawFilter* drawFilter, const SkIRect& clipRect, G rRenderTarget*,
145 const GrClip&); 144 const GrClip&);
146 inline static bool HasLCD(const SkTextBlob*); 145 inline static bool HasLCD(const SkTextBlob*);
147 inline void initDistanceFieldPaint(GrAtlasTextBlob*, SkPaint*, SkScalar* tex tRatio, 146 inline void initDistanceFieldPaint(GrAtlasTextBlob*, SkPaint*, SkScalar* tex tRatio,
148 const SkMatrix&); 147 const SkMatrix&);
149 148
150 // Test methods 149 // Test methods
151 // TODO this is really ugly. It'd be much nicer if positioning could be mov ed to batch 150 // 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&, 151 inline GrAtlasTextBlob* createDrawTextBlob(GrDrawContext*, const GrClip&, co nst GrPaint&,
153 const SkPaint&, const SkMatrix& vi ewMatrix, 152 const SkPaint&, const SkMatrix& v iewMatrix,
154 const char text[], size_t byteLeng th, 153 const char text[], size_t byteLen gth,
155 SkScalar x, SkScalar y, 154 SkScalar x, SkScalar y,
156 const SkIRect& regionClipBounds); 155 const SkIRect& regionClipBounds);
157 inline GrAtlasTextBlob* createDrawPosTextBlob(GrRenderTarget*, const GrClip& , const GrPaint&, 156 inline GrAtlasTextBlob* createDrawPosTextBlob(GrDrawContext*, const GrClip&, const GrPaint&,
158 const SkPaint&, const SkMatrix& viewMatrix, 157 const SkPaint&, const SkMatrix& viewMatrix,
159 const char text[], size_t byteL ength, 158 const char text[], size_t byteL ength,
160 const SkScalar pos[], int scala rsPerPosition, 159 const SkScalar pos[], int scala rsPerPosition,
161 const SkPoint& offset, 160 const SkPoint& offset,
162 const SkIRect& regionClipBounds ); 161 const SkIRect& regionClipBounds );
163 162
164 // Distance field text needs this table to compute a value for use in the fr agment shader. 163 // 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 164 // Because the GrAtlasTextContext can go out of scope before the final flush , this needs to be
166 // refcnted and malloced 165 // refcnted and malloced
167 struct DistanceAdjustTable : public SkNVRefCnt<DistanceAdjustTable> { 166 struct DistanceAdjustTable : public SkNVRefCnt<DistanceAdjustTable> {
(...skipping 18 matching lines...) Expand all
186 friend class GrAtlasTextBatch; 185 friend class GrAtlasTextBatch;
187 186
188 #ifdef GR_TEST_UTILS 187 #ifdef GR_TEST_UTILS
189 DRAW_BATCH_TEST_FRIEND(TextBlobBatch); 188 DRAW_BATCH_TEST_FRIEND(TextBlobBatch);
190 #endif 189 #endif
191 190
192 typedef GrTextContext INHERITED; 191 typedef GrTextContext INHERITED;
193 }; 192 };
194 193
195 #endif 194 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrAtlasTextContext.cpp » ('j') | src/gpu/GrAtlasTextContext.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698