| 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 "GrDrawContext.h" | 9 #include "GrDrawContext.h" |
| 10 #include "GrDrawTarget.h" | 10 #include "GrDrawTarget.h" |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 // applyFontToPaint() always overwrites the exact same attributes, | 183 // applyFontToPaint() always overwrites the exact same attributes, |
| 184 // so it is safe to not re-seed the paint for this reason. | 184 // so it is safe to not re-seed the paint for this reason. |
| 185 it.applyFontToPaint(&runPaint); | 185 it.applyFontToPaint(&runPaint); |
| 186 | 186 |
| 187 if (drawFilter && !drawFilter->filter(&runPaint, SkDrawFilter::kText_Typ
e)) { | 187 if (drawFilter && !drawFilter->filter(&runPaint, SkDrawFilter::kText_Typ
e)) { |
| 188 // A false return from filter() means we should abort the current dr
aw. | 188 // A false return from filter() means we should abort the current dr
aw. |
| 189 runPaint = skPaint; | 189 runPaint = skPaint; |
| 190 continue; | 190 continue; |
| 191 } | 191 } |
| 192 | 192 |
| 193 runPaint.setFlags(FilterTextFlags(props, runPaint)); | 193 runPaint.setFlags(GrTextUtils::FilterTextFlags(props, runPaint)); |
| 194 | 194 |
| 195 cacheBlob->push_back_run(run); | 195 cacheBlob->push_back_run(run); |
| 196 | 196 |
| 197 if (GrTextUtils::CanDrawAsDistanceFields(runPaint, viewMatrix, props, sh
aderCaps)) { | 197 if (GrTextUtils::CanDrawAsDistanceFields(runPaint, viewMatrix, props, sh
aderCaps)) { |
| 198 switch (it.positioning()) { | 198 switch (it.positioning()) { |
| 199 case SkTextBlob::kDefault_Positioning: { | 199 case SkTextBlob::kDefault_Positioning: { |
| 200 GrTextUtils::DrawDFText(cacheBlob, run, fontCache, | 200 GrTextUtils::DrawDFText(cacheBlob, run, fontCache, |
| 201 props, runPaint, color, viewMatrix, | 201 props, runPaint, color, viewMatrix, |
| 202 (const char *)it.glyphs(), textLen, | 202 (const char *)it.glyphs(), textLen, |
| 203 x + offset.x(), y + offset.y()); | 203 x + offset.x(), y + offset.y()); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 | 366 |
| 367 DRAW_BATCH_TEST_DEFINE(TextBlobBatch) { | 367 DRAW_BATCH_TEST_DEFINE(TextBlobBatch) { |
| 368 static uint32_t gContextID = SK_InvalidGenID; | 368 static uint32_t gContextID = SK_InvalidGenID; |
| 369 static GrAtlasTextContext* gTextContext = nullptr; | 369 static GrAtlasTextContext* gTextContext = nullptr; |
| 370 static SkSurfaceProps gSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType
); | 370 static SkSurfaceProps gSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType
); |
| 371 | 371 |
| 372 if (context->uniqueID() != gContextID) { | 372 if (context->uniqueID() != gContextID) { |
| 373 gContextID = context->uniqueID(); | 373 gContextID = context->uniqueID(); |
| 374 delete gTextContext; | 374 delete gTextContext; |
| 375 | 375 |
| 376 // We don't yet test the fall back to paths in the GrTextContext base cl
ass. This is mostly | |
| 377 // because we don't really want to have a gpu device here. | |
| 378 // We enable distance fields by twiddling a knob on the paint | |
| 379 gTextContext = GrAtlasTextContext::Create(); | 376 gTextContext = GrAtlasTextContext::Create(); |
| 380 } | 377 } |
| 381 | 378 |
| 382 // Setup dummy SkPaint / GrPaint | 379 // Setup dummy SkPaint / GrPaint |
| 383 GrColor color = GrRandomColor(random); | 380 GrColor color = GrRandomColor(random); |
| 384 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); | 381 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); |
| 385 SkPaint skPaint; | 382 SkPaint skPaint; |
| 386 skPaint.setColor(color); | 383 skPaint.setColor(color); |
| 387 skPaint.setLCDRenderText(random->nextBool()); | 384 skPaint.setLCDRenderText(random->nextBool()); |
| 388 skPaint.setAntiAlias(skPaint.isLCDRenderText() ? true : random->nextBool()); | 385 skPaint.setAntiAlias(skPaint.isLCDRenderText() ? true : random->nextBool()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 412 // We'd like to be able to test this with random translations, but currently
the vertex | 409 // We'd like to be able to test this with random translations, but currently
the vertex |
| 413 // bounds and vertices will get out of sync | 410 // bounds and vertices will get out of sync |
| 414 SkScalar transX = 0.f;//SkIntToScalar(random->nextU()); | 411 SkScalar transX = 0.f;//SkIntToScalar(random->nextU()); |
| 415 SkScalar transY = 0.f;//SkIntToScalar(random->nextU()); | 412 SkScalar transY = 0.f;//SkIntToScalar(random->nextU()); |
| 416 return blob->test_createBatch(textLen, 0, 0, color, transX, transY, skPaint, | 413 return blob->test_createBatch(textLen, 0, 0, color, transX, transY, skPaint, |
| 417 gSurfaceProps, gTextContext->dfAdjustTable(), | 414 gSurfaceProps, gTextContext->dfAdjustTable(), |
| 418 context->getBatchFontCache()); | 415 context->getBatchFontCache()); |
| 419 } | 416 } |
| 420 | 417 |
| 421 #endif | 418 #endif |
| OLD | NEW |