OLD | NEW |
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 "GrBitmapTextContext.h" | 10 #include "GrBitmapTextContext.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 return false; | 62 return false; |
63 } | 63 } |
64 | 64 |
65 // No hairlines unless we can map the 1 px width to the object space. | 65 // No hairlines unless we can map the 1 px width to the object space. |
66 if (skPaint.getStyle() == SkPaint::kStroke_Style | 66 if (skPaint.getStyle() == SkPaint::kStroke_Style |
67 && skPaint.getStrokeWidth() == 0 | 67 && skPaint.getStrokeWidth() == 0 |
68 && viewMatrix.hasPerspective()) { | 68 && viewMatrix.hasPerspective()) { |
69 return false; | 69 return false; |
70 } | 70 } |
71 | 71 |
| 72 if (skPaint.isAntiAlias() && |
| 73 GrRenderTarget::kStencil_SampleConfig == rt->sampleConfig() && |
| 74 !paint.getXPFactory()->canTweakAlphaForCoverage()) { |
| 75 return false; |
| 76 } |
| 77 |
72 // No color bitmap fonts. | 78 // No color bitmap fonts. |
73 SkScalerContext::Rec rec; | 79 SkScalerContext::Rec rec; |
74 SkScalerContext::MakeRec(skPaint, &fDeviceProperties, NULL, &rec); | 80 SkScalerContext::MakeRec(skPaint, &fDeviceProperties, NULL, &rec); |
75 return rec.getFormat() != SkMask::kARGB32_Format; | 81 return rec.getFormat() != SkMask::kARGB32_Format; |
76 } | 82 } |
77 | 83 |
78 void GrStencilAndCoverTextContext::onDrawText(GrRenderTarget* rt, | 84 void GrStencilAndCoverTextContext::onDrawText(GrRenderTarget* rt, |
79 const GrClip& clip, | 85 const GrClip& clip, |
80 const GrPaint& paint, | 86 const GrPaint& paint, |
81 const SkPaint& skPaint, | 87 const SkPaint& skPaint, |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 fGlyphCache = fSkPaint.detachCache(&fDeviceProperties, NULL, true /*igno
reGamma*/); | 373 fGlyphCache = fSkPaint.detachCache(&fDeviceProperties, NULL, true /*igno
reGamma*/); |
368 fGlyphs = canUseRawPaths ? | 374 fGlyphs = canUseRawPaths ? |
369 get_gr_glyphs(fContext, fSkPaint.getTypeface(), NULL, fStr
oke) : | 375 get_gr_glyphs(fContext, fSkPaint.getTypeface(), NULL, fStr
oke) : |
370 get_gr_glyphs(fContext, fGlyphCache->getScalerContext()->g
etTypeface(), | 376 get_gr_glyphs(fContext, fGlyphCache->getScalerContext()->g
etTypeface(), |
371 &fGlyphCache->getDescriptor(), fStroke); | 377 &fGlyphCache->getDescriptor(), fStroke); |
372 } | 378 } |
373 | 379 |
374 fStateRestore.set(&fPipelineBuilder); | 380 fStateRestore.set(&fPipelineBuilder); |
375 | 381 |
376 fPipelineBuilder.setFromPaint(fPaint, fRenderTarget, fClip); | 382 fPipelineBuilder.setFromPaint(fPaint, fRenderTarget, fClip); |
| 383 SkASSERT(fRenderTarget->isMultisampled(GrRenderTarget::BufferBits::kStencil_
BufferBit)); |
| 384 fPipelineBuilder.setState(GrPipelineBuilder::kHWAntialias_StateBit, fPaint.i
sAntiAlias()); |
377 | 385 |
378 GR_STATIC_CONST_SAME_STENCIL(kStencilPass, | 386 GR_STATIC_CONST_SAME_STENCIL(kStencilPass, |
379 kZero_StencilOp, | 387 kZero_StencilOp, |
380 kZero_StencilOp, | 388 kZero_StencilOp, |
381 kNotEqual_StencilFunc, | 389 kNotEqual_StencilFunc, |
382 0xffff, | 390 0xffff, |
383 0x0000, | 391 0x0000, |
384 0xffff); | 392 0xffff); |
385 | 393 |
386 *fPipelineBuilder.stencil() = kStencilPass; | 394 *fPipelineBuilder.stencil() = kStencilPass; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 | 487 |
480 SkGlyphCache::AttachCache(fGlyphCache); | 488 SkGlyphCache::AttachCache(fGlyphCache); |
481 fGlyphCache = NULL; | 489 fGlyphCache = NULL; |
482 | 490 |
483 fPipelineBuilder.stencil()->setDisabled(); | 491 fPipelineBuilder.stencil()->setDisabled(); |
484 fStateRestore.set(NULL); | 492 fStateRestore.set(NULL); |
485 fViewMatrix = fContextInitialMatrix; | 493 fViewMatrix = fContextInitialMatrix; |
486 GrTextContext::finish(); | 494 GrTextContext::finish(); |
487 } | 495 } |
488 | 496 |
OLD | NEW |