| OLD | NEW |
| 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 #include "GrAtlasTextContext.h" | 7 #include "GrAtlasTextContext.h" |
| 8 | 8 |
| 9 #include "GrBatchFontCache.h" | 9 #include "GrBatchFontCache.h" |
| 10 #include "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 | 382 |
| 383 SkIRect clipRect; | 383 SkIRect clipRect; |
| 384 clip.getConservativeBounds(rt->width(), rt->height(), &clipRect); | 384 clip.getConservativeBounds(rt->width(), rt->height(), &clipRect); |
| 385 | 385 |
| 386 SkScalar transX = 0.f; | 386 SkScalar transX = 0.f; |
| 387 SkScalar transY = 0.f; | 387 SkScalar transY = 0.f; |
| 388 | 388 |
| 389 // Though for the time being runs in the textblob can override the paint, th
ey only touch font | 389 // Though for the time being runs in the textblob can override the paint, th
ey only touch font |
| 390 // info. | 390 // info. |
| 391 GrPaint grPaint; | 391 GrPaint grPaint; |
| 392 if (!SkPaint2GrPaint(fContext, rt, skPaint, viewMatrix, true, &grPaint)) { | 392 if (!SkPaint2GrPaint(fContext, skPaint, viewMatrix, true, &grPaint)) { |
| 393 return; | 393 return; |
| 394 } | 394 } |
| 395 | 395 |
| 396 if (cacheBlob) { | 396 if (cacheBlob) { |
| 397 if (MustRegenerateBlob(&transX, &transY, *cacheBlob, skPaint, grPaint.ge
tColor(), blurRec, | 397 if (MustRegenerateBlob(&transX, &transY, *cacheBlob, skPaint, grPaint.ge
tColor(), blurRec, |
| 398 viewMatrix, x, y)) { | 398 viewMatrix, x, y)) { |
| 399 // We have to remake the blob because changes may invalidate our mas
ks. | 399 // We have to remake the blob because changes may invalidate our mas
ks. |
| 400 // TODO we could probably get away reuse most of the time if the poi
nter is unique, | 400 // TODO we could probably get away reuse most of the time if the poi
nter is unique, |
| 401 // but we'd have to clear the subrun information | 401 // but we'd have to clear the subrun information |
| 402 fCache->remove(cacheBlob); | 402 fCache->remove(cacheBlob); |
| (...skipping 1855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2258 // Setup dummy SkPaint / GrPaint | 2258 // Setup dummy SkPaint / GrPaint |
| 2259 GrColor color = GrRandomColor(random); | 2259 GrColor color = GrRandomColor(random); |
| 2260 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); | 2260 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); |
| 2261 SkPaint skPaint; | 2261 SkPaint skPaint; |
| 2262 skPaint.setColor(color); | 2262 skPaint.setColor(color); |
| 2263 skPaint.setLCDRenderText(random->nextBool()); | 2263 skPaint.setLCDRenderText(random->nextBool()); |
| 2264 skPaint.setAntiAlias(skPaint.isLCDRenderText() ? true : random->nextBool()); | 2264 skPaint.setAntiAlias(skPaint.isLCDRenderText() ? true : random->nextBool()); |
| 2265 skPaint.setSubpixelText(random->nextBool()); | 2265 skPaint.setSubpixelText(random->nextBool()); |
| 2266 | 2266 |
| 2267 GrPaint grPaint; | 2267 GrPaint grPaint; |
| 2268 if (!SkPaint2GrPaint(context, rt, skPaint, viewMatrix, true, &grPaint)) { | 2268 if (!SkPaint2GrPaint(context, skPaint, viewMatrix, true, &grPaint)) { |
| 2269 SkFAIL("couldn't convert paint\n"); | 2269 SkFAIL("couldn't convert paint\n"); |
| 2270 } | 2270 } |
| 2271 | 2271 |
| 2272 const char* text = "The quick brown fox jumps over the lazy dog."; | 2272 const char* text = "The quick brown fox jumps over the lazy dog."; |
| 2273 int textLen = (int)strlen(text); | 2273 int textLen = (int)strlen(text); |
| 2274 | 2274 |
| 2275 // Setup clip | 2275 // Setup clip |
| 2276 GrClip clip; | 2276 GrClip clip; |
| 2277 SkIRect noClip = SkIRect::MakeLargest(); | 2277 SkIRect noClip = SkIRect::MakeLargest(); |
| 2278 | 2278 |
| 2279 // right now we don't handle textblobs, nor do we handle drawPosText. Since
we only | 2279 // right now we don't handle textblobs, nor do we handle drawPosText. Since
we only |
| 2280 // intend to test the batch with this unit test, that is okay. | 2280 // intend to test the batch with this unit test, that is okay. |
| 2281 SkAutoTUnref<GrAtlasTextBlob> blob( | 2281 SkAutoTUnref<GrAtlasTextBlob> blob( |
| 2282 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat
rix, text, | 2282 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat
rix, text, |
| 2283 static_cast<size_t>(textLen), 0, 0,
noClip)); | 2283 static_cast<size_t>(textLen), 0, 0,
noClip)); |
| 2284 | 2284 |
| 2285 SkScalar transX = static_cast<SkScalar>(random->nextU()); | 2285 SkScalar transX = static_cast<SkScalar>(random->nextU()); |
| 2286 SkScalar transY = static_cast<SkScalar>(random->nextU()); | 2286 SkScalar transY = static_cast<SkScalar>(random->nextU()); |
| 2287 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0]
; | 2287 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0]
; |
| 2288 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t
ransY, skPaint); | 2288 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t
ransY, skPaint); |
| 2289 } | 2289 } |
| 2290 | 2290 |
| 2291 #endif | 2291 #endif |
| OLD | NEW |