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

Side by Side Diff: src/gpu/text/GrAtlasTextBlob.h

Issue 1684253002: start to chip away at friending of GrAtlasTextBatch/GrAtlasTextBlob (Closed) Base URL: https://skia.googlesource.com/skia.git@tc-cleanup-6-lastmember
Patch Set: Created 4 years, 10 months 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 | « src/gpu/batches/GrAtlasTextBatch.cpp ('k') | no next file » | 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 GrAtlasTextBlob_DEFINED 8 #ifndef GrAtlasTextBlob_DEFINED
9 #define GrAtlasTextBlob_DEFINED 9 #define GrAtlasTextBlob_DEFINED
10 10
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // flush a throwaway GrAtlasTextBlob *not* associated with an SkTextBlob 193 // flush a throwaway GrAtlasTextBlob *not* associated with an SkTextBlob
194 void flushThrowaway(GrContext* context, 194 void flushThrowaway(GrContext* context,
195 GrDrawContext* dc, 195 GrDrawContext* dc,
196 const SkSurfaceProps& props, 196 const SkSurfaceProps& props,
197 const GrDistanceFieldAdjustTable* distanceAdjustTable, 197 const GrDistanceFieldAdjustTable* distanceAdjustTable,
198 const SkPaint& skPaint, 198 const SkPaint& skPaint,
199 const GrPaint& grPaint, 199 const GrPaint& grPaint,
200 const GrClip& clip, 200 const GrClip& clip,
201 const SkIRect& clipBounds); 201 const SkIRect& clipBounds);
202 202
203 void computeSubRunBounds(SkRect* outBounds, int runIndex, int subRunIndex) {
204 // We don't yet position distance field text on the cpu, so we have to m ap the vertex bounds
205 // into device space.
206 // We handle vertex bounds differently for distance field text and bitma p text because
207 // the vertex bounds of bitmap text are in device space. If we are flus hing multiple runs
208 // from one blob then we are going to pay the price here of mapping the rect for each run.
209 const Run& run = fRuns[runIndex];
210 const Run::SubRunInfo& subRun = run.fSubRunInfo[subRunIndex];
211 *outBounds = subRun.vertexBounds();
212 if (subRun.drawAsDistanceFields()) {
213 // Distance field text is positioned with the (X,Y) as part of the g lyph position,
214 // and currently the view matrix is applied on the GPU
215 outBounds->offset(fX - fInitialX, fY - fInitialY);
216 fViewMatrix.mapRect(outBounds);
217 } else {
218 // Bitmap text is fully positioned on the CPU, and offset by an (X,Y ) translate in
219 // device space.
220 SkMatrix boundsMatrix = fInitialViewMatrixInverse;
221
222 boundsMatrix.postTranslate(-fInitialX, -fInitialY);
223
224 boundsMatrix.postTranslate(fX, fY);
225
226 boundsMatrix.postConcat(fViewMatrix);
227 boundsMatrix.mapRect(outBounds);
228
229 // Due to floating point numerical inaccuracies, we have to round ou t here
230 outBounds->roundOut(outBounds);
231 }
232 }
233
234 const SkMatrix& viewMatrix() const { return fViewMatrix; }
235
236
203 // position + local coord 237 // position + local coord
204 static const size_t kColorTextVASize = sizeof(SkPoint) + sizeof(SkIPoint16); 238 static const size_t kColorTextVASize = sizeof(SkPoint) + sizeof(SkIPoint16);
205 static const size_t kGrayTextVASize = sizeof(SkPoint) + sizeof(GrColor) + si zeof(SkIPoint16); 239 static const size_t kGrayTextVASize = sizeof(SkPoint) + sizeof(GrColor) + si zeof(SkIPoint16);
206 static const size_t kLCDTextVASize = kGrayTextVASize; 240 static const size_t kLCDTextVASize = kGrayTextVASize;
207 static const size_t kMaxVASize = kGrayTextVASize; 241 static const size_t kMaxVASize = kGrayTextVASize;
208 static const int kVerticesPerGlyph = 4; 242 static const int kVerticesPerGlyph = 4;
209 243
210 static void AssertEqual(const GrAtlasTextBlob&, const GrAtlasTextBlob&); 244 static void AssertEqual(const GrAtlasTextBlob&, const GrAtlasTextBlob&);
211 245
212 // The color here is the GrPaint color, and it is used to determine whether we 246 // The color here is the GrPaint color, and it is used to determine whether we
213 // have to regenerate LCD text blobs. 247 // have to regenerate LCD text blobs.
214 // We use this color vs the SkPaint color because it has the colorfilter app lied. 248 // We use this color vs the SkPaint color because it has the colorfilter app lied.
215 void initReusableBlob(GrColor color, const SkMatrix& viewMatrix, SkScalar x, SkScalar y) { 249 void initReusableBlob(GrColor color, const SkMatrix& viewMatrix, SkScalar x, SkScalar y) {
216 fPaintColor = color; 250 fPaintColor = color;
217 this->setupViewMatrix(viewMatrix, x, y); 251 this->setupViewMatrix(viewMatrix, x, y);
218 } 252 }
219 253
220 void initThrowawayBlob(const SkMatrix& viewMatrix, SkScalar x, SkScalar y) { 254 void initThrowawayBlob(const SkMatrix& viewMatrix, SkScalar x, SkScalar y) {
221 this->setupViewMatrix(viewMatrix, x, y); 255 this->setupViewMatrix(viewMatrix, x, y);
222 } 256 }
223 257
224 GrDrawBatch* test_createBatch(int glyphCount, int run, int subRun,
225 GrColor color, SkScalar transX, SkScalar trans Y,
226 const SkPaint& skPaint, const SkSurfaceProps& props,
227 const GrDistanceFieldAdjustTable* distanceAdju stTable,
228 GrBatchFontCache* cache);
229
230 const Key& key() const { return fKey; } 258 const Key& key() const { return fKey; }
231 259
232 ~GrAtlasTextBlob() { 260 ~GrAtlasTextBlob() {
233 for (int i = 0; i < fRunCount; i++) { 261 for (int i = 0; i < fRunCount; i++) {
234 fRuns[i].~Run(); 262 fRuns[i].~Run();
235 } 263 }
236 } 264 }
237 265
266 //////////////////////////////////////////////////////////////////////////// ////////////////////
267 // Internal test methods
268 GrDrawBatch* test_createBatch(int glyphCount, int run, int subRun,
269 GrColor color, SkScalar transX, SkScalar trans Y,
270 const SkPaint& skPaint, const SkSurfaceProps& props,
271 const GrDistanceFieldAdjustTable* distanceAdju stTable,
272 GrBatchFontCache* cache);
273
238 private: 274 private:
239 GrAtlasTextBlob() 275 GrAtlasTextBlob()
240 : fMaxMinScale(-SK_ScalarMax) 276 : fMaxMinScale(-SK_ScalarMax)
241 , fMinMaxScale(SK_ScalarMax) 277 , fMinMaxScale(SK_ScalarMax)
242 , fTextType(0) {} 278 , fTextType(0) {}
243 279
244 void appendLargeGlyph(GrGlyph* glyph, GrFontScaler* scaler, const SkGlyph& s kGlyph, 280 void appendLargeGlyph(GrGlyph* glyph, GrFontScaler* scaler, const SkGlyph& s kGlyph,
245 SkScalar x, SkScalar y, SkScalar scale, bool applyVM); 281 SkScalar x, SkScalar y, SkScalar scale, bool applyVM);
246 282
247 inline void flushRun(GrDrawContext* dc, GrPipelineBuilder* pipelineBuilder, 283 inline void flushRun(GrDrawContext* dc, GrPipelineBuilder* pipelineBuilder,
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 // maximum minimum scale, and minimum maximum scale, we can support before w e need to regen 508 // maximum minimum scale, and minimum maximum scale, we can support before w e need to regen
473 SkScalar fMaxMinScale; 509 SkScalar fMaxMinScale;
474 SkScalar fMinMaxScale; 510 SkScalar fMinMaxScale;
475 int fRunCount; 511 int fRunCount;
476 uint8_t fTextType; 512 uint8_t fTextType;
477 513
478 friend class GrAtlasTextBatch; // We might be able to get rid of this friend ing 514 friend class GrAtlasTextBatch; // We might be able to get rid of this friend ing
479 }; 515 };
480 516
481 #endif 517 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAtlasTextBatch.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698