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

Side by Side Diff: tests/DFPathRendererTest.cpp

Issue 2144663004: Make GrBatchAtlas robust against attempts to add large rects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix warning Created 4 years, 5 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/batches/GrAADistanceFieldPathRenderer.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
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "Test.h"
9
10 #if SK_SUPPORT_GPU
11 #include "GrContext.h"
12 #include "GrTest.h"
13 #include "batches/GrAADistanceFieldPathRenderer.h"
14 #include "SkPath.h"
15
16 // This test case including path coords and matrix taken from crbug.com/627443.
17 // Because of inaccuracies in large floating point values this causes the
18 // the path renderer to attempt to add a path DF to its atlas that is larger
19 // than the plot size which used to crash rather than fail gracefully.
20 static void test_far_from_origin(GrDrawContext* drawContext, GrPathRenderer* pr,
21 GrResourceProvider* rp) {
22 SkPath path;
23 path.lineTo(49.0255089839f, 0.473541f);
24 static constexpr SkScalar mvals[] = {14.0348252854f, 2.13026182736f,
25 13.6122547187f, 118.309922702f,
26 1912337682.09f, 2105391889.87f};
27 SkMatrix matrix;
28 matrix.setAffine(mvals);
29 SkMatrix inverse;
30 SkAssertResult(matrix.invert(&inverse));
31 path.transform(inverse);
32
33 SkStrokeRec rec(SkStrokeRec::kFill_InitStyle);
34 rec.setStrokeStyle(1.f);
35 rec.setStrokeParams(SkPaint::kRound_Cap, SkPaint::kRound_Join, 1.f);
36 GrStyle style(rec, nullptr);
37
38 GrShape shape(path, style);
39 shape = shape.applyStyle(GrStyle::Apply::kPathEffectAndStrokeRec, 1.f);
40
41 GrPaint paint;
42 paint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
43
44 GrNoClip noClip;
45 GrPathRenderer::DrawPathArgs args;
46 args.fPaint = &paint;
47 args.fUserStencilSettings = &GrUserStencilSettings::kUnused;
48 args.fDrawContext = drawContext;
49 args.fClip = &noClip;
50 args.fResourceProvider = rp;
51 args.fViewMatrix = &matrix;
52 args.fShape = &shape;
53 args.fAntiAlias = true;
54
55 pr->drawPath(args);
56 }
57
58 DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(AADistanceFieldPathRenderer, reporter, ctxInfo) {
59 // The DF PR only works with contexts that support derivatives
60 if (!ctxInfo.grContext()->caps()->shaderCaps()->shaderDerivativeSupport()) {
61 return;
62 }
63 sk_sp<GrDrawContext> drawContext(ctxInfo.grContext()->newDrawContext(SkBacki ngFit::kApprox,
64 800, 80 0,
65 kSkia88 88_GrPixelConfig,
66 0,
67 kTopLef t_GrSurfaceOrigin));
68 if (!drawContext) {
69 return;
70 }
71
72 GrAADistanceFieldPathRenderer dfpr;
73 GrTestTarget tt;
74 ctxInfo.grContext()->getTestTarget(&tt, drawContext);
75 GrResourceProvider* rp = tt.resourceProvider();
76
77 test_far_from_origin(drawContext.get(), &dfpr, rp);
78 ctxInfo.grContext()->flush();
79 }
80 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAADistanceFieldPathRenderer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698