Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
DefaultPathRendererTest.cpp File Reference
#include "include/core/SkBitmap.h"
#include "include/core/SkColor.h"
#include "include/core/SkColorSpace.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPath.h"
#include "include/core/SkPathTypes.h"
#include "include/core/SkRect.h"
#include "include/core/SkStrokeRec.h"
#include "include/core/SkSurfaceProps.h"
#include "include/core/SkTypes.h"
#include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrDirectContext.h"
#include "include/private/SkColorData.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/gpu/SkBackingFit.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrFragmentProcessor.h"
#include "src/gpu/ganesh/GrPaint.h"
#include "src/gpu/ganesh/GrStyle.h"
#include "src/gpu/ganesh/SurfaceDrawContext.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
#include "tools/gpu/ContextType.h"
#include <memory>
#include <utility>

Go to the source code of this file.

Functions

static void only_allow_default (GrContextOptions *options)
 
static SkBitmap read_back (GrDirectContext *dContext, skgpu::ganesh::SurfaceDrawContext *sdc, int width, int height)
 
static SkPath make_path (const SkRect &outer, int inset, SkPathFillType fill)
 
static void run_test (GrDirectContext *dContext, skiatest::Reporter *reporter)
 
 DEF_GANESH_TEST_FOR_CONTEXTS (DefaultPathRendererTest, skgpu::IsRenderingContext, reporter, ctxInfo, only_allow_default, CtsEnforcement::kApiLevel_T)
 

Variables

static const int kBigSize = 64
 
static const int kPad = 3
 

Function Documentation

◆ DEF_GANESH_TEST_FOR_CONTEXTS()

DEF_GANESH_TEST_FOR_CONTEXTS ( DefaultPathRendererTest  ,
skgpu::IsRenderingContext  ,
reporter  ,
ctxInfo  ,
only_allow_default  ,
CtsEnforcement::kApiLevel_T   
)

Definition at line 139 of file DefaultPathRendererTest.cpp.

144 {
145 auto ctx = ctxInfo.directContext();
146
147 run_test(ctx, reporter);
148}
static void run_test(GrDirectContext *dContext, skiatest::Reporter *reporter)
reporter

◆ make_path()

static SkPath make_path ( const SkRect outer,
int  inset,
SkPathFillType  fill 
)
static

Definition at line 54 of file DefaultPathRendererTest.cpp.

54 {
55 SkPath p;
56
57 p.addRect(outer, SkPathDirection::kCW);
59 p.setFillType(fill);
60 return p;
61}
static SkRect inset(const SkRect &r)
SkRect makeInset(float dx, float dy) const
Definition SkRect.h:987

◆ only_allow_default()

static void only_allow_default ( GrContextOptions options)
static

Definition at line 36 of file DefaultPathRendererTest.cpp.

36 {
37 options->fGpuPathRenderers = GpuPathRenderers::kNone;
38}
const char * options

◆ read_back()

static SkBitmap read_back ( GrDirectContext dContext,
skgpu::ganesh::SurfaceDrawContext sdc,
int  width,
int  height 
)
static

Definition at line 40 of file DefaultPathRendererTest.cpp.

43 {
45
46 SkBitmap bm;
47 bm.allocPixels(dstII);
48
49 sdc->readPixels(dContext, bm.pixmap(), {0, 0});
50
51 return bm;
52}
void allocPixels(const SkImageInfo &info, size_t rowBytes)
Definition SkBitmap.cpp:258
const SkPixmap & pixmap() const
Definition SkBitmap.h:133
bool readPixels(GrDirectContext *dContext, GrPixmap dst, SkIPoint srcPt)
int32_t height
int32_t width
static SkImageInfo MakeN32Premul(int width, int height)

◆ run_test()

static void run_test ( GrDirectContext dContext,
skiatest::Reporter reporter 
)
static

Definition at line 77 of file DefaultPathRendererTest.cpp.

77 {
82
84
85 {
88 nullptr,
90 {kBigSize / 2 + 1, kBigSize / 2 + 1},
92 /*label=*/{});
93
94 sdc->clear(SK_PMColor4fBLACK);
95
97
98 const SkPMColor4f color = { 1.0f, 0.0f, 0.0f, 1.0f };
100 paint.setColorFragmentProcessor(std::move(fp));
101
102 sdc->drawPath(nullptr, std::move(paint), GrAA::kNo, SkMatrix::I(), invPath, style);
103
104 dContext->priv().flushSurface(sdc->asSurfaceProxy());
105 }
106
107 {
108 auto sdc = skgpu::ganesh::SurfaceDrawContext::Make(dContext,
110 nullptr,
114 /*label=*/{});
115
116 sdc->clear(SK_PMColor4fBLACK);
117
119
120 const SkPMColor4f color = { 0.0f, 1.0f, 0.0f, 1.0f };
122 paint.setColorFragmentProcessor(std::move(fp));
123
124 sdc->drawPath(nullptr, std::move(paint), GrAA::kNo,
125 SkMatrix::I(), path, style);
126
127 SkBitmap bm = read_back(dContext, sdc.get(), kBigSize, kBigSize);
128
129 bool correct = true;
130 for (int y = kBigSize/2+1; y < kBigSize-kPad-1 && correct; ++y) {
131 for (int x = kPad+1; x < kBigSize-kPad-1 && correct; ++x) {
132 correct = bm.getColor(x, y) == SK_ColorBLACK;
133 REPORTER_ASSERT(reporter, correct);
134 }
135 }
136 }
137}
static SkBitmap read_back(GrDirectContext *dContext, skgpu::ganesh::SurfaceDrawContext *sdc, int width, int height)
static const int kPad
static const int kBigSize
SkColor4f color
constexpr SkPMColor4f SK_PMColor4fBLACK
constexpr SkColor SK_ColorBLACK
Definition SkColor.h:103
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
GrSemaphoresSubmitted flushSurface(GrSurfaceProxy *proxy, SkSurfaces::BackendSurfaceAccess access=SkSurfaces::BackendSurfaceAccess::kNoAccess, const GrFlushInfo &info={}, const skgpu::MutableTextureState *newState=nullptr)
GrDirectContextPriv priv()
static std::unique_ptr< GrFragmentProcessor > MakeColor(SkPMColor4f color)
SkColor getColor(int x, int y) const
Definition SkBitmap.h:874
static const SkMatrix & I()
static std::unique_ptr< SurfaceDrawContext > Make(GrRecordingContext *, GrColorType, sk_sp< GrSurfaceProxy >, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &)
const Paint & paint
double y
double x
const uint32_t fp
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 SkPath make_path()
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition SkRect.h:659

Variable Documentation

◆ kBigSize

const int kBigSize = 64
static

Definition at line 64 of file DefaultPathRendererTest.cpp.

◆ kPad

const int kPad = 3
static

Definition at line 65 of file DefaultPathRendererTest.cpp.