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

Side by Side Diff: tests/TextBlobCacheTest.cpp

Issue 1267623004: Revert of Modifying TextBlobCacheTest to use SkRandomScalerContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « src/gpu/GrBatchFontCache.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
11 #include "SkPoint.h" 11 #include "SkPoint.h"
12 #include "SkTextBlob.h" 12 #include "SkTextBlob.h"
13 #include "SkFontMgr.h" 13 #include "SkFontMgr.h"
14 #include "SkGraphics.h" 14 #include "SkGraphics.h"
15 #include "SkSurface.h" 15 #include "SkSurface.h"
16 #include "SkTypeface.h" 16 #include "SkTypeface.h"
17 #include "../src/fonts/SkRandomScalerContext.h"
18 #include "../src/fonts/SkGScalerContext.h"
19 17
20 #ifdef SK_BUILD_FOR_WIN 18 #ifdef SK_BUILD_FOR_WIN
21 #include "SkTypeface_win.h" 19 #include "SkTypeface_win.h"
22 #endif 20 #endif
23 21
24 #include "Test.h" 22 #include "Test.h"
25 23
26 #if SK_SUPPORT_GPU 24 #if SK_SUPPORT_GPU
27 #include "GrContextFactory.h" 25 #include "GrContextFactory.h"
28 26
(...skipping 25 matching lines...) Expand all
54 52
55 static const int kWidth = 1024; 53 static const int kWidth = 1024;
56 static const int kHeight = 768; 54 static const int kHeight = 768;
57 55
58 // This test hammers the GPU textblobcache and font atlas 56 // This test hammers the GPU textblobcache and font atlas
59 DEF_GPUTEST(TextBlobCache, reporter, factory) { 57 DEF_GPUTEST(TextBlobCache, reporter, factory) {
60 // setup surface 58 // setup surface
61 uint32_t flags = 0; 59 uint32_t flags = 0;
62 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType); 60 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
63 61
64 // We don't typically actually draw with this unittest 62 GrContext* ctx = factory->get(GrContextFactory::kNative_GLContextType);
65 GrContext* ctx = factory->get(GrContextFactory::kNull_GLContextType);
66 SkImageInfo info = SkImageInfo::Make(kWidth, kHeight, kN32_SkColorType, kPre mul_SkAlphaType); 63 SkImageInfo info = SkImageInfo::Make(kWidth, kHeight, kN32_SkColorType, kPre mul_SkAlphaType);
67 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkSurface::k No_Budgeted, info, 64 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkSurface::k No_Budgeted, info,
68 0, &props)); 65 0, &props));
69 REPORTER_ASSERT(reporter, surface); 66 REPORTER_ASSERT(reporter, surface);
70 if (!surface) { 67 if (!surface) {
71 return; 68 return;
72 } 69 }
73 70
74 SkCanvas* canvas = surface->getCanvas(); 71 SkCanvas* canvas = surface->getCanvas();
75 72
(...skipping 14 matching lines...) Expand all
90 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 87 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
91 paint.setTextSize(48); // draw big glyphs to really stress the atlas 88 paint.setTextSize(48); // draw big glyphs to really stress the atlas
92 89
93 SkString familyName; 90 SkString familyName;
94 fm->getFamilyName(i, &familyName); 91 fm->getFamilyName(i, &familyName);
95 SkAutoTUnref<SkFontStyleSet> set(fm->createStyleSet(i)); 92 SkAutoTUnref<SkFontStyleSet> set(fm->createStyleSet(i));
96 for (int j = 0; j < set->count(); ++j) { 93 for (int j = 0; j < set->count(); ++j) {
97 SkFontStyle fs; 94 SkFontStyle fs;
98 set->getStyle(j, &fs, NULL); 95 set->getStyle(j, &fs, NULL);
99 96
100 // We use a typeface which randomy returns unexpected mask formats t o fuzz 97 SkSafeUnref(paint.setTypeface(set->createTypeface(j)));
101 SkAutoTUnref<SkTypeface> orig(set->createTypeface(j));
102 SkAutoTUnref<SkTypeface> typeface(SkNEW_ARGS(SkRandomTypeface, (orig , paint, true)));
103 paint.setTypeface(typeface);
104 98
105 SkTextBlobBuilder builder; 99 SkTextBlobBuilder builder;
106 for (int aa = 0; aa < 2; aa++) { 100 for (int aa = 0; aa < 2; aa++) {
107 for (int subpixel = 0; subpixel < 2; subpixel++) { 101 for (int subpixel = 0; subpixel < 2; subpixel++) {
108 for (int lcd = 0; lcd < 2; lcd++) { 102 for (int lcd = 0; lcd < 2; lcd++) {
109 paint.setAntiAlias(SkToBool(aa)); 103 paint.setAntiAlias(SkToBool(aa));
110 paint.setSubpixelText(SkToBool(subpixel)); 104 paint.setSubpixelText(SkToBool(subpixel));
111 paint.setLCDRenderText(SkToBool(lcd)); 105 paint.setLCDRenderText(SkToBool(lcd));
112 if (!SkToBool(lcd)) {
113 paint.setTextSize(160);
114 }
115 const SkTextBlobBuilder::RunBuffer& run = builder.allocR un(paint, 106 const SkTextBlobBuilder::RunBuffer& run = builder.allocR un(paint,
116 MAX_TOTAL_TEXT, 107 MAX_TOTAL_TEXT,
117 0, 0, 108 0, 0,
118 NULL); 109 NULL);
119 memcpy(run.glyphs, text, MAX_TOTAL_TEXT * sizeof(uint16_ t)); 110 memcpy(run.glyphs, text, MAX_TOTAL_TEXT * sizeof(uint16_ t));
120 } 111 }
121 } 112 }
122 } 113 }
123 SkNEW_APPEND_TO_TARRAY(&blobs, TextBlobWrapper, (builder.build())); 114 SkNEW_APPEND_TO_TARRAY(&blobs, TextBlobWrapper, (builder.build()));
124 } 115 }
(...skipping 19 matching lines...) Expand all
144 draw(canvas, 1, blobs); 135 draw(canvas, 1, blobs);
145 136
146 ctx->freeGpuResources(); 137 ctx->freeGpuResources();
147 draw(canvasNoLCD, 1, blobs); 138 draw(canvasNoLCD, 1, blobs);
148 139
149 // test draw after abandon 140 // test draw after abandon
150 ctx->abandonContext(); 141 ctx->abandonContext();
151 draw(canvas, 1, blobs); 142 draw(canvas, 1, blobs);
152 } 143 }
153 #endif 144 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrBatchFontCache.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698