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

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

Issue 1227153003: Remove setFromPaint from GrPipelineBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 "GrStencilAndCoverTextContext.h" 8 #include "GrStencilAndCoverTextContext.h"
9 #include "GrAtlasTextContext.h" 9 #include "GrAtlasTextContext.h"
10 #include "GrDrawContext.h" 10 #include "GrDrawContext.h"
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 fViewMatrix.preConcat(textMatrix); 371 fViewMatrix.preConcat(textMatrix);
372 fLocalMatrix = textMatrix; 372 fLocalMatrix = textMatrix;
373 373
374 fGlyphCache = fSkPaint.detachCache(&fSurfaceProps, NULL, true /*ignoreGa mma*/); 374 fGlyphCache = fSkPaint.detachCache(&fSurfaceProps, NULL, true /*ignoreGa mma*/);
375 fGlyphs = canUseRawPaths ? 375 fGlyphs = canUseRawPaths ?
376 get_gr_glyphs(fContext, fSkPaint.getTypeface(), NULL, fStr oke) : 376 get_gr_glyphs(fContext, fSkPaint.getTypeface(), NULL, fStr oke) :
377 get_gr_glyphs(fContext, fGlyphCache->getScalerContext()->g etTypeface(), 377 get_gr_glyphs(fContext, fGlyphCache->getScalerContext()->g etTypeface(),
378 &fGlyphCache->getDescriptor(), fStroke); 378 &fGlyphCache->getDescriptor(), fStroke);
379 } 379 }
380 380
381 fStateRestore.set(&fPipelineBuilder);
382
383 fPipelineBuilder.setFromPaint(fPaint, fRenderTarget, fClip);
384 SkASSERT(fRenderTarget->isStencilBufferMultisampled() || !fPaint.isAntiAlias ());
385 fPipelineBuilder.setState(GrPipelineBuilder::kHWAntialias_Flag, fPaint.isAnt iAlias());
386
387 GR_STATIC_CONST_SAME_STENCIL(kStencilPass,
388 kZero_StencilOp,
389 kZero_StencilOp,
390 kNotEqual_StencilFunc,
391 0xffff,
392 0x0000,
393 0xffff);
394
395 *fPipelineBuilder.stencil() = kStencilPass;
396
397 SkASSERT(0 == fQueuedGlyphCount);
398 SkASSERT(kGlyphBufferSize == fFallbackGlyphsIdx);
399 } 381 }
400 382
401 bool GrStencilAndCoverTextContext::mapToFallbackContext(SkMatrix* inverse) { 383 bool GrStencilAndCoverTextContext::mapToFallbackContext(SkMatrix* inverse) {
402 // The current view matrix is flipped because GPU path rendering glyphs have an 384 // The current view matrix is flipped because GPU path rendering glyphs have an
403 // inverted y-direction. Unflip the view matrix for the fallback context. If using 385 // inverted y-direction. Unflip the view matrix for the fallback context. If using
404 // device-space glyphs, we'll also need to restore the original view matrix since 386 // device-space glyphs, we'll also need to restore the original view matrix since
405 // we moved that transfomation into our local glyph cache for this scenario. Also 387 // we moved that transfomation into our local glyph cache for this scenario. Also
406 // track the inverse operation so the caller can unmap the paint and glyph p ositions. 388 // track the inverse operation so the caller can unmap the paint and glyph p ositions.
407 if (fUsingDeviceSpaceGlyphs) { 389 if (fUsingDeviceSpaceGlyphs) {
408 fViewMatrix = fContextInitialMatrix; 390 fViewMatrix = fContextInitialMatrix;
(...skipping 29 matching lines...) Expand all
438 420
439 return &pointArray[0].fX; 421 return &pointArray[0].fX;
440 } 422 }
441 423
442 void GrStencilAndCoverTextContext::flush() { 424 void GrStencilAndCoverTextContext::flush() {
443 if (fQueuedGlyphCount > 0) { 425 if (fQueuedGlyphCount > 0) {
444 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(fPaint.getColor (), 426 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(fPaint.getColor (),
445 fViewMatrix, 427 fViewMatrix,
446 fLocalMatrix)); 428 fLocalMatrix));
447 429
448 fDrawContext->drawPaths(&fPipelineBuilder, pp, fGlyphs, 430
robertphillips 2015/07/09 19:52:52 Is doing this here going to kill performance ?
431 GrPipelineBuilder pipelineBuilder(fPaint, fRenderTarget, fClip);
432 SkASSERT(fRenderTarget->isStencilBufferMultisampled() || !fPaint.isAntiA lias());
433 pipelineBuilder.setState(GrPipelineBuilder::kHWAntialias_Flag, fPaint.is AntiAlias());
434
435 GR_STATIC_CONST_SAME_STENCIL(kStencilPass,
436 kZero_StencilOp,
437 kZero_StencilOp,
438 kNotEqual_StencilFunc,
439 0xffff,
440 0x0000,
441 0xffff);
442
443 *pipelineBuilder.stencil() = kStencilPass;
444
445 SkASSERT(0 == fQueuedGlyphCount);
446 SkASSERT(kGlyphBufferSize == fFallbackGlyphsIdx);
447
448 fDrawContext->drawPaths(&pipelineBuilder, pp, fGlyphs,
449 fGlyphIndices, GrPathRange::kU16_PathIndexType, 449 fGlyphIndices, GrPathRange::kU16_PathIndexType,
450 get_xy_scalar_array(fGlyphPositions), 450 get_xy_scalar_array(fGlyphPositions),
451 GrPathRendering::kTranslate_PathTransformType, 451 GrPathRendering::kTranslate_PathTransformType,
452 fQueuedGlyphCount, GrPathRendering::kWinding_Fil lType); 452 fQueuedGlyphCount, GrPathRendering::kWinding_Fil lType);
453 453
454 fQueuedGlyphCount = 0; 454 fQueuedGlyphCount = 0;
455 } 455 }
456 456
457 if (fFallbackGlyphsIdx < kGlyphBufferSize) { 457 if (fFallbackGlyphsIdx < kGlyphBufferSize) {
458 int fallbackGlyphCount = kGlyphBufferSize - fFallbackGlyphsIdx; 458 int fallbackGlyphCount = kGlyphBufferSize - fFallbackGlyphsIdx;
(...skipping 24 matching lines...) Expand all
483 483
484 void GrStencilAndCoverTextContext::finish() { 484 void GrStencilAndCoverTextContext::finish() {
485 this->flush(); 485 this->flush();
486 486
487 fGlyphs->unref(); 487 fGlyphs->unref();
488 fGlyphs = NULL; 488 fGlyphs = NULL;
489 489
490 SkGlyphCache::AttachCache(fGlyphCache); 490 SkGlyphCache::AttachCache(fGlyphCache);
491 fGlyphCache = NULL; 491 fGlyphCache = NULL;
492 492
493 fPipelineBuilder.stencil()->setDisabled();
494 fStateRestore.set(NULL);
495 fViewMatrix = fContextInitialMatrix; 493 fViewMatrix = fContextInitialMatrix;
496 } 494 }
497 495
OLDNEW
« src/gpu/GrPipelineBuilder.h ('K') | « src/gpu/GrStencilAndCoverTextContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698