| 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 | 7 |
| 8 #include "sk_tool_utils.h" | 8 #include "sk_tool_utils.h" |
| 9 |
| 10 #include "GrTest.h" |
| 9 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
| 10 #include "SkPaint.h" | 12 #include "SkPaint.h" |
| 11 #include "SkPoint.h" | 13 #include "SkPoint.h" |
| 12 #include "SkTextBlob.h" | 14 #include "SkTextBlob.h" |
| 13 #include "SkFontMgr.h" | 15 #include "SkFontMgr.h" |
| 14 #include "SkGraphics.h" | 16 #include "SkGraphics.h" |
| 15 #include "SkSurface.h" | 17 #include "SkSurface.h" |
| 16 #include "SkTypeface.h" | 18 #include "SkTypeface.h" |
| 17 #include "../src/fonts/SkRandomScalerContext.h" | 19 #include "../src/fonts/SkRandomScalerContext.h" |
| 18 | 20 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 44 canvas->drawTextBlob(blob, 0, SkIntToScalar(yOffset), paint); | 46 canvas->drawTextBlob(blob, 0, SkIntToScalar(yOffset), paint); |
| 45 } | 47 } |
| 46 } | 48 } |
| 47 } | 49 } |
| 48 | 50 |
| 49 static const int kWidth = 1024; | 51 static const int kWidth = 1024; |
| 50 static const int kHeight = 768; | 52 static const int kHeight = 768; |
| 51 | 53 |
| 52 // This test hammers the GPU textblobcache and font atlas | 54 // This test hammers the GPU textblobcache and font atlas |
| 53 static void text_blob_cache_inner(skiatest::Reporter* reporter, GrContextFactory
* factory, | 55 static void text_blob_cache_inner(skiatest::Reporter* reporter, GrContextFactory
* factory, |
| 54 int maxTotalText, int maxGlyphID, int maxFamil
ies, bool normal) { | 56 int maxTotalText, int maxGlyphID, int maxFamil
ies, bool normal, |
| 57 bool stressTest) { |
| 55 // setup surface | 58 // setup surface |
| 56 uint32_t flags = 0; | 59 uint32_t flags = 0; |
| 57 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType); | 60 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType); |
| 58 | 61 |
| 59 // We don't typically actually draw with this unittest | 62 // We don't typically actually draw with this unittest |
| 60 GrContext* ctx = factory->get(GrContextFactory::kNull_GLContextType); | 63 GrContext* ctx = factory->get(GrContextFactory::kNull_GLContextType); |
| 64 |
| 65 // configure our context for maximum stressing of cache and atlas |
| 66 if (stressTest) { |
| 67 GrTest::SetupAlwaysEvictAtlas(ctx); |
| 68 ctx->setTextBlobCacheLimit_ForTesting(0); |
| 69 } |
| 70 |
| 61 SkImageInfo info = SkImageInfo::Make(kWidth, kHeight, kN32_SkColorType, kPre
mul_SkAlphaType); | 71 SkImageInfo info = SkImageInfo::Make(kWidth, kHeight, kN32_SkColorType, kPre
mul_SkAlphaType); |
| 62 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkSurface::k
No_Budgeted, info, | 72 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkSurface::k
No_Budgeted, info, |
| 63 0, &props)); | 73 0, &props)); |
| 64 REPORTER_ASSERT(reporter, surface); | 74 REPORTER_ASSERT(reporter, surface); |
| 65 if (!surface) { | 75 if (!surface) { |
| 66 return; | 76 return; |
| 67 } | 77 } |
| 68 | 78 |
| 69 SkCanvas* canvas = surface->getCanvas(); | 79 SkCanvas* canvas = surface->getCanvas(); |
| 70 | 80 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 154 |
| 145 ctx->freeGpuResources(); | 155 ctx->freeGpuResources(); |
| 146 draw(canvasNoLCD, 1, blobs); | 156 draw(canvasNoLCD, 1, blobs); |
| 147 | 157 |
| 148 // test draw after abandon | 158 // test draw after abandon |
| 149 ctx->abandonContext(); | 159 ctx->abandonContext(); |
| 150 draw(canvas, 1, blobs); | 160 draw(canvas, 1, blobs); |
| 151 } | 161 } |
| 152 | 162 |
| 153 DEF_GPUTEST(TextBlobCache, reporter, factory) { | 163 DEF_GPUTEST(TextBlobCache, reporter, factory) { |
| 154 text_blob_cache_inner(reporter, factory, 4096, 256, 30, true); | 164 text_blob_cache_inner(reporter, factory, 1024, 256, 30, true, false); |
| 165 } |
| 166 |
| 167 DEF_GPUTEST(TextBlobStressCache, reporter, factory) { |
| 168 text_blob_cache_inner(reporter, factory, 256, 256, 10, true, true); |
| 155 } | 169 } |
| 156 | 170 |
| 157 DEF_GPUTEST(TextBlobAbnormal, reporter, factory) { | 171 DEF_GPUTEST(TextBlobAbnormal, reporter, factory) { |
| 158 #ifdef SK_BUILD_FOR_ANDROID | 172 text_blob_cache_inner(reporter, factory, 256, 256, 10, false, false); |
| 159 text_blob_cache_inner(reporter, factory, 256, 256, 30, false); | 173 } |
| 160 #else | 174 |
| 161 text_blob_cache_inner(reporter, factory, 512, 256, 30, false); | 175 DEF_GPUTEST(TextBlobStressAbnormal, reporter, factory) { |
| 162 #endif | 176 text_blob_cache_inner(reporter, factory, 256, 256, 10, false, true); |
| 163 } | 177 } |
| 164 #endif | 178 #endif |
| OLD | NEW |