30 {
31 auto recorder = context->makeRecorder();
32 if (!recorder) {
34 return;
35 }
36
38
43 topPM.alloc(
info.makeDimensions({1, 1}));
45
47 auto mbet = sk_gpu_test::ManagedGraphiteTexture::MakeMipmappedFromPixmaps(recorder.get(),
48 levelPMs,
50 isProtected);
51
52 if (!mbet) {
54 return;
55 }
56
57 std::unique_ptr<Recording> recording = recorder->snap();
58
60 std::unique_ptr<Recording>(
static_cast<Recording*
>(context));
61 };
62
67 if (!context->insertRecording(recordingInfo)) {
69 return;
70 }
71
72 static constexpr struct TestCase {
77
78 for (const auto& testCase : kTestCases) {
79 recorder = context->makeRecorder();
80 if (!recorder) {
82 return;
83 }
84
86 mbet->texture(),
90 Origin::kTopLeft,
91 testCase.genMipmaps,
92 sk_gpu_test::ManagedGraphiteTexture::ImageReleaseProc,
93 mbet->releaseContext());
94 if (!recorder) {
96 return;
97 }
98
99
100
102 if (!recorder) {
104 return;
105 }
106
111
112 surface->getCanvas()->scale(0.05f, 0.05f);
114 paint.setShader(std::move(shader));
116
117 recording = recorder->snap();
120 if (!context->insertRecording(recordingInfo)) {
122 return;
123 }
124
125 struct ReadContext {
126 bool called = false;
127 bool success = false;
129 };
131 std::unique_ptr<const SkImage::AsyncReadResult>
result) {
132 auto& readContext = *static_cast<ReadContext*>(context);
133 readContext.called = true;
135 readContext.success = true;
136 readContext.color = *
static_cast<const uint32_t*
>(
result->data(0));
137 }
138 };
139 ReadContext readContext;
140 context->asyncRescaleAndReadPixels(
surface.get(),
145 readPixelsCallback,
146 &readContext);
147 context->submit();
148 while (!readContext.called) {
149 testContext->tick();
150 context->checkAsyncWorkCompletion();
151 }
152
153 if (!readContext.success) {
155 return;
156 }
157
159 }
160}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorGREEN
#define REPORTER_ASSERT(r, cond,...)
void alloc(const SkImageInfo &)
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
SK_API sk_sp< SkImage > WrapTexture(skgpu::graphite::Recorder *, const skgpu::graphite::BackendTexture &, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace, skgpu::Origin origin, GenerateMipmapsFromBase generateMipmapsFromBase, TextureReleaseProc=nullptr, ReleaseContext=nullptr, std::string_view label={})
sk_sp< const SkImage > image
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)
SkSamplingOptions(SkFilterMode::kLinear))
static constexpr SkIRect MakeSize(const SkISize &size)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
GpuFinishedContext fFinishedContext
GpuFinishedProc fFinishedProc