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 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "GrContextFactory.h" | 25 #include "GrContextFactory.h" |
26 | 26 |
27 struct TextBlobWrapper { | 27 struct TextBlobWrapper { |
28 explicit TextBlobWrapper(const SkTextBlob* blob) : fBlob(SkRef(blob)) {} | 28 explicit TextBlobWrapper(const SkTextBlob* blob) : fBlob(SkRef(blob)) {} |
29 TextBlobWrapper(const TextBlobWrapper& blob) : fBlob(SkRef(blob.fBlob.get())
) {} | 29 TextBlobWrapper(const TextBlobWrapper& blob) : fBlob(SkRef(blob.fBlob.get())
) {} |
30 | 30 |
31 SkAutoTUnref<const SkTextBlob> fBlob; | 31 SkAutoTUnref<const SkTextBlob> fBlob; |
32 }; | 32 }; |
33 | 33 |
34 static void draw(SkCanvas* canvas, int redraw, const SkTArray<TextBlobWrapper>&
blobs) { | 34 static void draw(SkCanvas* canvas, int redraw, const SkTArray<TextBlobWrapper>&
blobs) { |
| 35 int yOffset = 0; |
35 for (int r = 0; r < redraw; r++) { | 36 for (int r = 0; r < redraw; r++) { |
36 for (int i = 0; i < blobs.count(); i++) { | 37 for (int i = 0; i < blobs.count(); i++) { |
| 38 const SkTextBlob* blob = blobs[i].fBlob.get(); |
| 39 const SkRect& bounds = blob->bounds(); |
| 40 yOffset += SkScalarCeilToInt(bounds.height()); |
37 SkPaint paint; | 41 SkPaint paint; |
38 canvas->drawTextBlob(blobs[i].fBlob.get(), 0, 0, paint); | 42 canvas->drawTextBlob(blob, 0, SkIntToScalar(yOffset), paint); |
39 } | 43 } |
40 } | 44 } |
41 } | 45 } |
42 | 46 |
43 // limit this just so we don't take too long to draw | 47 // limit this just so we don't take too long to draw |
44 #define MAX_TOTAL_TEXT 4096 | 48 #define MAX_TOTAL_TEXT 4096 |
45 #define MAX_CHAR 256 | 49 #define MAX_CHAR 256 |
46 #define MAX_FAMILIES 5 | 50 #define MAX_FAMILIES 5 |
47 | 51 |
48 // This test hammers the GPU textblobcache and font atlas | 52 // This test hammers the GPU textblobcache and font atlas |
49 DEF_TEST(TextBlobCache, reporter) { | 53 DEF_GPUTEST(TextBlobCache, reporter, factory) { |
50 SkAutoTDelete<GrContextFactory> grFactory(SkNEW(GrContextFactory)); | |
51 | |
52 // setup surface | 54 // setup surface |
53 uint32_t flags = 0; | 55 uint32_t flags = 0; |
54 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType); | 56 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType); |
55 | 57 |
56 GrContext* ctx = grFactory->get(GrContextFactory::kNative_GLContextType); | 58 GrContext* ctx = factory->get(GrContextFactory::kNative_GLContextType); |
57 SkImageInfo info = SkImageInfo::Make(1024, 768, kN32_SkColorType, kPremul_Sk
AlphaType); | 59 SkImageInfo info = SkImageInfo::Make(1024, 768, kN32_SkColorType, kPremul_Sk
AlphaType); |
58 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkSurface::k
No_Budgeted, info, | 60 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkSurface::k
No_Budgeted, info, |
59 0, &props)); | 61 0, &props)); |
60 REPORTER_ASSERT(reporter, surface); | 62 REPORTER_ASSERT(reporter, surface); |
61 if (!surface) { | 63 if (!surface) { |
62 return; | 64 return; |
63 } | 65 } |
64 | 66 |
65 SkCanvas* canvas = surface->getCanvas(); | 67 SkCanvas* canvas = surface->getCanvas(); |
66 | 68 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 116 |
115 // test draw after free | 117 // test draw after free |
116 ctx->freeGpuResources(); | 118 ctx->freeGpuResources(); |
117 draw(canvas, 1, blobs); | 119 draw(canvas, 1, blobs); |
118 | 120 |
119 // test draw after abandon | 121 // test draw after abandon |
120 ctx->abandonContext(); | 122 ctx->abandonContext(); |
121 draw(canvas, 1, blobs); | 123 draw(canvas, 1, blobs); |
122 } | 124 } |
123 #endif | 125 #endif |
OLD | NEW |