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

Side by Side Diff: src/gpu/GrBitmapTextContext.cpp

Issue 640413004: Revert of Fix color emoji. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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/GrBitmapTextContext.h ('k') | src/gpu/GrDistanceFieldTextContext.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 2013 Google Inc. 2 * Copyright 2013 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 #include "GrBitmapTextContext.h" 8 #include "GrBitmapTextContext.h"
9 #include "GrAtlas.h" 9 #include "GrAtlas.h"
10 #include "GrDrawTarget.h" 10 #include "GrDrawTarget.h"
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 } 363 }
364 } 364 }
365 365
366 if (NULL == glyph->fPlot) { 366 if (NULL == glyph->fPlot) {
367 if (!fStrike->glyphTooLargeForAtlas(glyph)) { 367 if (!fStrike->glyphTooLargeForAtlas(glyph)) {
368 if (fStrike->addGlyphToAtlas(glyph, scaler)) { 368 if (fStrike->addGlyphToAtlas(glyph, scaler)) {
369 goto HAS_ATLAS; 369 goto HAS_ATLAS;
370 } 370 }
371 371
372 // try to clear out an unused plot before we flush 372 // try to clear out an unused plot before we flush
373 if (fContext->getFontCache()->freeUnusedPlot(fStrike, glyph) && 373 if (fContext->getFontCache()->freeUnusedPlot(fStrike) &&
374 fStrike->addGlyphToAtlas(glyph, scaler)) { 374 fStrike->addGlyphToAtlas(glyph, scaler)) {
375 goto HAS_ATLAS; 375 goto HAS_ATLAS;
376 } 376 }
377 377
378 if (c_DumpFontCache) { 378 if (c_DumpFontCache) {
379 #ifdef SK_DEVELOPER 379 #ifdef SK_DEVELOPER
380 fContext->getFontCache()->dump(); 380 fContext->getFontCache()->dump();
381 #endif 381 #endif
382 } 382 }
383 383
384 // flush any accumulated draws to allow us to free up a plot 384 // flush any accumulated draws to allow us to free up a plot
385 this->flush(); 385 this->flush();
386 fContext->flush(); 386 fContext->flush();
387 387
388 // we should have an unused plot now 388 // we should have an unused plot now
389 if (fContext->getFontCache()->freeUnusedPlot(fStrike, glyph) && 389 if (fContext->getFontCache()->freeUnusedPlot(fStrike) &&
390 fStrike->addGlyphToAtlas(glyph, scaler)) { 390 fStrike->addGlyphToAtlas(glyph, scaler)) {
391 goto HAS_ATLAS; 391 goto HAS_ATLAS;
392 } 392 }
393 } 393 }
394 394
395 if (NULL == glyph->fPath) { 395 if (NULL == glyph->fPath) {
396 SkPath* path = SkNEW(SkPath); 396 SkPath* path = SkNEW(SkPath);
397 if (!scaler->getGlyphPath(glyph->glyphID(), path)) { 397 if (!scaler->getGlyphPath(glyph->glyphID(), path)) {
398 // flag the glyph as being dead? 398 // flag the glyph as being dead?
399 delete path; 399 delete path;
(...skipping 15 matching lines...) Expand all
415 415
416 HAS_ATLAS: 416 HAS_ATLAS:
417 SkASSERT(glyph->fPlot); 417 SkASSERT(glyph->fPlot);
418 GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken(); 418 GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken();
419 glyph->fPlot->setDrawToken(drawToken); 419 glyph->fPlot->setDrawToken(drawToken);
420 420
421 // now promote them to fixed (TODO: Rethink using fixed pt). 421 // now promote them to fixed (TODO: Rethink using fixed pt).
422 width = SkIntToFixed(width); 422 width = SkIntToFixed(width);
423 height = SkIntToFixed(height); 423 height = SkIntToFixed(height);
424 424
425 // the current texture/maskformat must match what the glyph needs
426 GrTexture* texture = glyph->fPlot->texture(); 425 GrTexture* texture = glyph->fPlot->texture();
427 SkASSERT(texture); 426 SkASSERT(texture);
428 427
429 if (fCurrTexture != texture || fCurrVertex + 4 > fMaxVertices) { 428 if (fCurrTexture != texture || fCurrVertex + 4 > fMaxVertices) {
430 this->flush(); 429 this->flush();
431 fCurrTexture = texture; 430 fCurrTexture = texture;
432 fCurrTexture->ref(); 431 fCurrTexture->ref();
433 fCurrMaskFormat = glyph->fMaskFormat;
434 } 432 }
435 433
436 bool useColorVerts = kA8_GrMaskFormat == fCurrMaskFormat; 434 bool useColorVerts = kA8_GrMaskFormat == fStrike->getMaskFormat();
437 435
438 if (NULL == fVertices) { 436 if (NULL == fVertices) {
439 // If we need to reserve vertices allow the draw target to suggest 437 // If we need to reserve vertices allow the draw target to suggest
440 // a number of verts to reserve and whether to perform a flush. 438 // a number of verts to reserve and whether to perform a flush.
441 fMaxVertices = kMinRequestedVerts; 439 fMaxVertices = kMinRequestedVerts;
442 if (useColorVerts) { 440 if (useColorVerts) {
443 fDrawTarget->drawState()->setVertexAttribs<gTextVertexWithColorAttri bs>( 441 fDrawTarget->drawState()->setVertexAttribs<gTextVertexWithColorAttri bs>(
444 SK_ARRAY_COUNT(gTextVertexWithColorAttribs), kTextVAColorSize); 442 SK_ARRAY_COUNT(gTextVertexWithColorAttribs), kTextVAColorSize);
445 } else { 443 } else {
446 fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>( 444 fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>(
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 542
545 if (textureUniqueID != fEffectTextureUniqueID) { 543 if (textureUniqueID != fEffectTextureUniqueID) {
546 fCachedGeometryProcessor.reset(GrCustomCoordsTextureEffect::Create(f CurrTexture, 544 fCachedGeometryProcessor.reset(GrCustomCoordsTextureEffect::Create(f CurrTexture,
547 p arams)); 545 p arams));
548 fEffectTextureUniqueID = textureUniqueID; 546 fEffectTextureUniqueID = textureUniqueID;
549 } 547 }
550 548
551 // This effect could be stored with one of the cache objects (atlas?) 549 // This effect could be stored with one of the cache objects (atlas?)
552 drawState->setGeometryProcessor(fCachedGeometryProcessor.get()); 550 drawState->setGeometryProcessor(fCachedGeometryProcessor.get());
553 SkASSERT(fStrike); 551 SkASSERT(fStrike);
554 switch (fCurrMaskFormat) { 552 switch (fStrike->getMaskFormat()) {
555 // Color bitmap text 553 // Color bitmap text
556 case kARGB_GrMaskFormat: 554 case kARGB_GrMaskFormat:
557 SkASSERT(!drawState->hasColorVertexAttribute()); 555 SkASSERT(!drawState->hasColorVertexAttribute());
558 drawState->setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDst BlendCoeff()); 556 drawState->setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDst BlendCoeff());
559 drawState->setAlpha(fSkPaint.getAlpha()); 557 drawState->setColor(0xffffffff);
560 break; 558 break;
561 // LCD text 559 // LCD text
562 case kA888_GrMaskFormat: 560 case kA888_GrMaskFormat:
563 case kA565_GrMaskFormat: { 561 case kA565_GrMaskFormat: {
564 if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() || 562 if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() ||
565 kISA_GrBlendCoeff != fPaint.getDstBlendCoeff() || 563 kISA_GrBlendCoeff != fPaint.getDstBlendCoeff() ||
566 fPaint.numColorStages()) { 564 fPaint.numColorStages()) {
567 GrPrintf("LCD Text will not draw correctly.\n"); 565 GrPrintf("LCD Text will not draw correctly.\n");
568 } 566 }
569 SkASSERT(!drawState->hasColorVertexAttribute()); 567 SkASSERT(!drawState->hasColorVertexAttribute());
(...skipping 10 matching lines...) Expand all
580 break; 578 break;
581 } 579 }
582 // Grayscale/BW text 580 // Grayscale/BW text
583 case kA8_GrMaskFormat: 581 case kA8_GrMaskFormat:
584 // set back to normal in case we took LCD path previously. 582 // set back to normal in case we took LCD path previously.
585 drawState->setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDst BlendCoeff()); 583 drawState->setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDst BlendCoeff());
586 // We're using per-vertex color. 584 // We're using per-vertex color.
587 SkASSERT(drawState->hasColorVertexAttribute()); 585 SkASSERT(drawState->hasColorVertexAttribute());
588 break; 586 break;
589 default: 587 default:
590 SkFAIL("Unexpected mask format."); 588 SkFAIL("Unexepected mask format.");
591 } 589 }
592 int nGlyphs = fCurrVertex / 4; 590 int nGlyphs = fCurrVertex / 4;
593 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); 591 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer());
594 fDrawTarget->drawIndexedInstances(kTriangles_GrPrimitiveType, 592 fDrawTarget->drawIndexedInstances(kTriangles_GrPrimitiveType,
595 nGlyphs, 593 nGlyphs,
596 4, 6, &fVertexBounds); 594 4, 6, &fVertexBounds);
597 595
598 fDrawTarget->resetVertexSource(); 596 fDrawTarget->resetVertexSource();
599 fVertices = NULL; 597 fVertices = NULL;
600 fMaxVertices = 0; 598 fMaxVertices = 0;
601 fCurrVertex = 0; 599 fCurrVertex = 0;
602 fVertexBounds.setLargestInverted(); 600 fVertexBounds.setLargestInverted();
603 SkSafeSetNull(fCurrTexture); 601 SkSafeSetNull(fCurrTexture);
604 } 602 }
605 } 603 }
606 604
607 inline void GrBitmapTextContext::finish() { 605 inline void GrBitmapTextContext::finish() {
608 this->flush(); 606 this->flush();
609 607
610 GrTextContext::finish(); 608 GrTextContext::finish();
611 } 609 }
612 610
OLDNEW
« no previous file with comments | « src/gpu/GrBitmapTextContext.h ('k') | src/gpu/GrDistanceFieldTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698