Flutter Engine
The Flutter Engine
Functions
GpuDrawPathTest.cpp File Reference
#include "tests/Test.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPath.h"
#include "include/core/SkPathEffect.h"
#include "include/core/SkPathTypes.h"
#include "include/core/SkRRect.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
#include "include/core/SkSurface.h"
#include "include/core/SkTypes.h"
#include "include/effects/SkDashPathEffect.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "tests/CtsEnforcement.h"
#include <initializer_list>

Go to the source code of this file.

Functions

static void test_drawPathEmpty (skiatest::Reporter *, SkCanvas *canvas)
 
static void fill_and_stroke (SkCanvas *canvas, const SkPath &p1, const SkPath &p2, sk_sp< SkPathEffect > effect)
 
static void test_drawSameRectOvals (skiatest::Reporter *, SkCanvas *canvas)
 
 DEF_GANESH_TEST_FOR_GL_CONTEXT (GpuDrawPath, reporter, ctxInfo, CtsEnforcement::kNever)
 
 DEF_GANESH_TEST_FOR_ALL_CONTEXTS (GrDrawCollapsedPath, reporter, ctxInfo, CtsEnforcement::kApiLevel_T)
 
 DEF_GANESH_TEST_FOR_ALL_CONTEXTS (PathTest_CrBug1232834, reporter, ctxInfo, CtsEnforcement::kApiLevel_T)
 

Function Documentation

◆ DEF_GANESH_TEST_FOR_ALL_CONTEXTS() [1/2]

DEF_GANESH_TEST_FOR_ALL_CONTEXTS ( GrDrawCollapsedPath  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kApiLevel_T   
)

Definition at line 99 of file GpuDrawPathTest.cpp.

102 {
103 // From https://bugs.fuchsia.dev/p/fuchsia/issues/detail?id=37330, it's possible for a convex
104 // path to be accepted by AAConvexPathRenderer, then be transformed to something without a
105 // computable first direction by a perspective matrix.
107 auto dContext = ctxInfo.directContext();
109
111 paint.setAntiAlias(true);
112
113 SkPath path;
114 path.moveTo(0, 0);
115 path.lineTo(50, 0);
116 path.lineTo(0, 50);
117 path.close();
118
119 SkMatrix m;
120 m.setAll( 0.966006875f , -0.125156224f , 72.0899811f,
121 -0.00885376986f , -0.112347461f , 64.7121124f,
122 -8.94321693e-06f, -0.00173384184f, 0.998692870f);
123 surface->getCanvas()->setMatrix(m);
124 surface->getCanvas()->drawPath(path, paint);
125 dContext->flushAndSubmit(surface.get(), GrSyncCpu::kNo);
126}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
Definition: SkPath.h:59
const Paint & paint
Definition: color_source.cc:38
VkSurfaceKHR surface
Definition: main.cc:49
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
static SkImageInfo MakeN32Premul(int width, int height)

◆ DEF_GANESH_TEST_FOR_ALL_CONTEXTS() [2/2]

DEF_GANESH_TEST_FOR_ALL_CONTEXTS ( PathTest_CrBug1232834  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kApiLevel_T   
)

Definition at line 128 of file GpuDrawPathTest.cpp.

131 {
132 // AAHairlinePathRenderer chops this path to quads that include infinities (and then NaNs).
133 // It used to trigger asserts, now the degenerate quad segments should cause it to be rejected.
135 auto dContext = ctxInfo.directContext();
137
139 paint.setAntiAlias(true);
141
142 SkPath path;
143 path.moveTo(9.0072E15f, 60);
144 path.cubicTo(0, 3.40282e+38f, 0, 3.40282e+38f, 0, 0);
145
146 surface->getCanvas()->drawPath(path, paint);
147 dContext->flushAndSubmit(surface.get(), GrSyncCpu::kNo);
148}
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194

◆ DEF_GANESH_TEST_FOR_GL_CONTEXT()

DEF_GANESH_TEST_FOR_GL_CONTEXT ( GpuDrawPath  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 85 of file GpuDrawPathTest.cpp.

85 {
86 for (auto& test_func : { &test_drawPathEmpty, &test_drawSameRectOvals }) {
87 for (auto& sampleCount : {1, 4, 16}) {
90 ctxInfo.directContext(), skgpu::Budgeted::kNo, info, sampleCount, nullptr));
91 if (!surface) {
92 continue;
93 }
94 test_func(reporter, surface->getCanvas());
95 }
96 }
97}
reporter
Definition: FontMgrTest.cpp:39
static void test_drawSameRectOvals(skiatest::Reporter *, SkCanvas *canvas)
static void test_drawPathEmpty(skiatest::Reporter *, SkCanvas *canvas)

◆ fill_and_stroke()

static void fill_and_stroke ( SkCanvas canvas,
const SkPath p1,
const SkPath p2,
sk_sp< SkPathEffect effect 
)
static

Definition at line 57 of file GpuDrawPathTest.cpp.

58 {
60 paint.setAntiAlias(true);
61 paint.setPathEffect(effect);
62
63 canvas->drawPath(p1, paint);
64 canvas->drawPath(p2, paint);
65
67 canvas->drawPath(p1, paint);
68 canvas->drawPath(p2, paint);
69}
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747

◆ test_drawPathEmpty()

static void test_drawPathEmpty ( skiatest::Reporter ,
SkCanvas canvas 
)
static

Definition at line 34 of file GpuDrawPathTest.cpp.

34 {
35 // Filling an empty path should not crash.
37 SkRect emptyRect = SkRect::MakeEmpty();
38 canvas->drawRect(emptyRect, paint);
39 canvas->drawPath(SkPath(), paint);
40 canvas->drawOval(emptyRect, paint);
41 canvas->drawRect(emptyRect, paint);
42 canvas->drawRRect(SkRRect::MakeRect(emptyRect), paint);
43
44 // Stroking an empty path should not crash.
45 paint.setAntiAlias(true);
47 paint.setColor(SK_ColorGRAY);
48 paint.setStrokeWidth(SkIntToScalar(20));
49 paint.setStrokeJoin(SkPaint::kRound_Join);
50 canvas->drawRect(emptyRect, paint);
51 canvas->drawPath(SkPath(), paint);
52 canvas->drawOval(emptyRect, paint);
53 canvas->drawRect(emptyRect, paint);
54 canvas->drawRRect(SkRRect::MakeRect(emptyRect), paint);
55}
constexpr SkColor SK_ColorGRAY
Definition: SkColor.h:113
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void drawOval(const SkRect &oval, const SkPaint &paint)
Definition: SkCanvas.cpp:1698
void drawRRect(const SkRRect &rrect, const SkPaint &paint)
Definition: SkCanvas.cpp:1705
@ kRound_Join
adds circle
Definition: SkPaint.h:360
static SkRRect MakeRect(const SkRect &r)
Definition: SkRRect.h:149
static constexpr SkRect MakeEmpty()
Definition: SkRect.h:595

◆ test_drawSameRectOvals()

static void test_drawSameRectOvals ( skiatest::Reporter ,
SkCanvas canvas 
)
static

Definition at line 71 of file GpuDrawPathTest.cpp.

71 {
72 // Drawing ovals with similar bounds but different points order should not crash.
73
74 SkPath oval1, oval2;
75 const SkRect rect = SkRect::MakeWH(100, 50);
78
79 fill_and_stroke(canvas, oval1, oval2, nullptr);
80
81 const SkScalar intervals[] = { 1, 1 };
82 fill_and_stroke(canvas, oval1, oval2, SkDashPathEffect::Make(intervals, 2, 0));
83}
static void fill_and_stroke(SkCanvas *canvas, const SkPath &p1, const SkPath &p2, sk_sp< SkPathEffect > effect)
static sk_sp< SkPathEffect > Make(const SkScalar intervals[], int count, SkScalar phase)
SkPath & addOval(const SkRect &oval, SkPathDirection dir=SkPathDirection::kCW)
Definition: SkPath.cpp:1106
float SkScalar
Definition: extension.cpp:12
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609