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 "GrBatch.h" | 9 #include "GrBatch.h" |
10 #include "GrBatchFontCache.h" | 10 #include "GrBatchFontCache.h" |
(...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1527 SkDebugf("Could not allocate backing texture for atlas\n"); | 1527 SkDebugf("Could not allocate backing texture for atlas\n"); |
1528 return; | 1528 return; |
1529 } | 1529 } |
1530 | 1530 |
1531 SkAutoTUnref<const GrGeometryProcessor> gp; | 1531 SkAutoTUnref<const GrGeometryProcessor> gp; |
1532 if (fUseDistanceFields) { | 1532 if (fUseDistanceFields) { |
1533 gp.reset(this->setupDfProcessor(this->viewMatrix(), fFilteredColor,
this->color(), | 1533 gp.reset(this->setupDfProcessor(this->viewMatrix(), fFilteredColor,
this->color(), |
1534 texture)); | 1534 texture)); |
1535 } else { | 1535 } else { |
1536 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::k
None_FilterMode); | 1536 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::k
None_FilterMode); |
1537 | |
1538 // This will be ignored in the non A8 case | |
1539 bool opaqueVertexColors = GrColorIsOpaque(this->color()); | |
1540 gp.reset(GrBitmapTextGeoProc::Create(this->color(), | 1537 gp.reset(GrBitmapTextGeoProc::Create(this->color(), |
1541 texture, | 1538 texture, |
1542 params, | 1539 params, |
1543 fMaskFormat, | 1540 fMaskFormat, |
1544 opaqueVertexColors, | |
1545 localMatrix)); | 1541 localMatrix)); |
1546 } | 1542 } |
1547 | 1543 |
1548 FlushInfo flushInfo; | 1544 FlushInfo flushInfo; |
1549 flushInfo.fGlyphsToFlush = 0; | 1545 flushInfo.fGlyphsToFlush = 0; |
1550 size_t vertexStride = gp->getVertexStride(); | 1546 size_t vertexStride = gp->getVertexStride(); |
1551 SkASSERT(vertexStride == (fUseDistanceFields ? | 1547 SkASSERT(vertexStride == (fUseDistanceFields ? |
1552 get_vertex_stride_df(fMaskFormat, fUseLCDText)
: | 1548 get_vertex_stride_df(fMaskFormat, fUseLCDText)
: |
1553 get_vertex_stride(fMaskFormat))); | 1549 get_vertex_stride(fMaskFormat))); |
1554 | 1550 |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1993 blueCorrecti
on); | 1989 blueCorrecti
on); |
1994 | 1990 |
1995 return GrDistanceFieldLCDTextGeoProc::Create(color, | 1991 return GrDistanceFieldLCDTextGeoProc::Create(color, |
1996 viewMatrix, | 1992 viewMatrix, |
1997 texture, | 1993 texture, |
1998 params, | 1994 params, |
1999 widthAdjust, | 1995 widthAdjust, |
2000 flags); | 1996 flags); |
2001 } else { | 1997 } else { |
2002 flags |= kColorAttr_DistanceFieldEffectFlag; | 1998 flags |= kColorAttr_DistanceFieldEffectFlag; |
2003 bool opaque = GrColorIsOpaque(color); | |
2004 #ifdef SK_GAMMA_APPLY_TO_A8 | 1999 #ifdef SK_GAMMA_APPLY_TO_A8 |
2005 U8CPU lum = SkColorSpaceLuminance::computeLuminance(fGamma, filtered
Color); | 2000 U8CPU lum = SkColorSpaceLuminance::computeLuminance(fGamma, filtered
Color); |
2006 float correction = (*fDistanceAdjustTable)[lum >> kDistanceAdjustLum
Shift]; | 2001 float correction = (*fDistanceAdjustTable)[lum >> kDistanceAdjustLum
Shift]; |
2007 return GrDistanceFieldA8TextGeoProc::Create(color, | 2002 return GrDistanceFieldA8TextGeoProc::Create(color, |
2008 viewMatrix, | 2003 viewMatrix, |
2009 texture, | 2004 texture, |
2010 params, | 2005 params, |
2011 correction, | 2006 correction, |
2012 flags, | 2007 flags); |
2013 opaque); | |
2014 #else | 2008 #else |
2015 return GrDistanceFieldA8TextGeoProc::Create(color, | 2009 return GrDistanceFieldA8TextGeoProc::Create(color, |
2016 viewMatrix, | 2010 viewMatrix, |
2017 texture, | 2011 texture, |
2018 params, | 2012 params, |
2019 flags, | 2013 flags); |
2020 opaque); | |
2021 #endif | 2014 #endif |
2022 } | 2015 } |
2023 | 2016 |
2024 } | 2017 } |
2025 | 2018 |
2026 struct BatchTracker { | 2019 struct BatchTracker { |
2027 GrColor fColor; | 2020 GrColor fColor; |
2028 SkMatrix fViewMatrix; | 2021 SkMatrix fViewMatrix; |
2029 bool fUsesLocalCoords; | 2022 bool fUsesLocalCoords; |
2030 bool fColorIgnored; | 2023 bool fColorIgnored; |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2271 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat
rix, text, | 2264 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat
rix, text, |
2272 static_cast<size_t>(textLen), 0, 0,
noClip)); | 2265 static_cast<size_t>(textLen), 0, 0,
noClip)); |
2273 | 2266 |
2274 SkScalar transX = static_cast<SkScalar>(random->nextU()); | 2267 SkScalar transX = static_cast<SkScalar>(random->nextU()); |
2275 SkScalar transY = static_cast<SkScalar>(random->nextU()); | 2268 SkScalar transY = static_cast<SkScalar>(random->nextU()); |
2276 const GrAtlasTextContext::BitmapTextBlob::Run::SubRunInfo& info = blob->fRun
s[0].fSubRunInfo[0]; | 2269 const GrAtlasTextContext::BitmapTextBlob::Run::SubRunInfo& info = blob->fRun
s[0].fSubRunInfo[0]; |
2277 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t
ransY, skPaint); | 2270 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t
ransY, skPaint); |
2278 } | 2271 } |
2279 | 2272 |
2280 #endif | 2273 #endif |
OLD | NEW |