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 2199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2210 } | 2210 } |
2211 | 2211 |
2212 // Now flush big glyphs | 2212 // Now flush big glyphs |
2213 this->flushBigGlyphs(cacheBlob, rt, skPaint, 0, 0, clipBounds); | 2213 this->flushBigGlyphs(cacheBlob, rt, skPaint, 0, 0, clipBounds); |
2214 } | 2214 } |
2215 | 2215 |
2216 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 2216 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
2217 | 2217 |
2218 #ifdef GR_TEST_UTILS | 2218 #ifdef GR_TEST_UTILS |
2219 | 2219 |
2220 BATCH_TEST_DEFINE(TextBlob) { | 2220 BATCH_TEST_DEFINE(TextBlobBatch) { |
2221 static uint32_t gContextID = SK_InvalidGenID; | 2221 static uint32_t gContextID = SK_InvalidGenID; |
2222 static GrAtlasTextContext* gTextContext = NULL; | 2222 static GrAtlasTextContext* gTextContext = NULL; |
2223 static SkDeviceProperties gDeviceProperties(SkDeviceProperties::kLegacyLCD_I
nitType); | 2223 static SkDeviceProperties gDeviceProperties(SkDeviceProperties::kLegacyLCD_I
nitType); |
2224 | 2224 |
2225 if (context->uniqueID() != gContextID) { | 2225 if (context->uniqueID() != gContextID) { |
2226 gContextID = context->uniqueID(); | 2226 gContextID = context->uniqueID(); |
2227 SkDELETE(gTextContext); | 2227 SkDELETE(gTextContext); |
2228 // We don't yet test the fall back to paths in the GrTextContext base cl
ass. This is mostly | 2228 // We don't yet test the fall back to paths in the GrTextContext base cl
ass. This is mostly |
2229 // because we don't really want to have a gpu device here. | 2229 // because we don't really want to have a gpu device here. |
2230 // We enable distance fields by twiddling a knob on the paint | 2230 // We enable distance fields by twiddling a knob on the paint |
2231 gTextContext = GrAtlasTextContext::Create(context, NULL, gDeviceProperti
es, false); | 2231 gTextContext = GrAtlasTextContext::Create(context, NULL, gDeviceProperti
es, false); |
2232 } | 2232 } |
2233 | 2233 |
2234 // create dummy render target | 2234 // create dummy render target |
2235 GrSurfaceDesc desc; | 2235 GrSurfaceDesc desc; |
2236 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 2236 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
2237 desc.fWidth = 1024; | 2237 desc.fWidth = 1024; |
2238 desc.fHeight = 1024; | 2238 desc.fHeight = 1024; |
2239 desc.fConfig = kRGBA_8888_GrPixelConfig; | 2239 desc.fConfig = kRGBA_8888_GrPixelConfig; |
2240 desc.fSampleCnt = 1; | 2240 desc.fSampleCnt = 1; |
2241 SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(de
sc, true, NULL, 0)); | 2241 SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(de
sc, true, NULL, 0)); |
2242 SkASSERT(texture); | 2242 SkASSERT(texture); |
2243 SkASSERT(NULL != texture->asRenderTarget()); | 2243 SkASSERT(NULL != texture->asRenderTarget()); |
2244 GrRenderTarget* rt = texture->asRenderTarget(); | 2244 GrRenderTarget* rt = texture->asRenderTarget(); |
2245 | 2245 |
2246 // Setup dummy SkPaint / GrPaint | 2246 // Setup dummy SkPaint / GrPaint |
2247 GrColor color = GrRandomColor(random); | 2247 GrColor color = GrRandomColor(random); |
2248 SkMatrix viewMatrix = GrTest::TestMatrix(random); | 2248 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); |
2249 SkPaint skPaint; | 2249 SkPaint skPaint; |
2250 skPaint.setDistanceFieldTextTEMP(random->nextBool()); | 2250 skPaint.setDistanceFieldTextTEMP(random->nextBool()); |
2251 skPaint.setColor(color); | 2251 skPaint.setColor(color); |
2252 skPaint.setLCDRenderText(random->nextBool()); | 2252 skPaint.setLCDRenderText(random->nextBool()); |
2253 skPaint.setAntiAlias(skPaint.isLCDRenderText() ? true : random->nextBool()); | 2253 skPaint.setAntiAlias(skPaint.isLCDRenderText() ? true : random->nextBool()); |
2254 skPaint.setSubpixelText(random->nextBool()); | 2254 skPaint.setSubpixelText(random->nextBool()); |
2255 | 2255 |
2256 GrPaint grPaint; | 2256 GrPaint grPaint; |
2257 if (!SkPaint2GrPaint(context, rt, skPaint, viewMatrix, true, &grPaint)) { | 2257 if (!SkPaint2GrPaint(context, rt, skPaint, viewMatrix, true, &grPaint)) { |
2258 SkFAIL("couldn't convert paint\n"); | 2258 SkFAIL("couldn't convert paint\n"); |
(...skipping 12 matching lines...) Expand all Loading... |
2271 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat
rix, text, | 2271 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat
rix, text, |
2272 static_cast<size_t>(textLen), 0, 0,
noClip)); | 2272 static_cast<size_t>(textLen), 0, 0,
noClip)); |
2273 | 2273 |
2274 SkScalar transX = static_cast<SkScalar>(random->nextU()); | 2274 SkScalar transX = static_cast<SkScalar>(random->nextU()); |
2275 SkScalar transY = static_cast<SkScalar>(random->nextU()); | 2275 SkScalar transY = static_cast<SkScalar>(random->nextU()); |
2276 const GrAtlasTextContext::BitmapTextBlob::Run::SubRunInfo& info = blob->fRun
s[0].fSubRunInfo[0]; | 2276 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); | 2277 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t
ransY, skPaint); |
2278 } | 2278 } |
2279 | 2279 |
2280 #endif | 2280 #endif |
OLD | NEW |