Flutter Engine
The Flutter Engine
Classes | Namespaces | Functions | Variables
LazyProxyTest.cpp File Reference
#include "include/core/SkAlphaType.h"
#include "include/core/SkColorSpace.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSize.h"
#include "include/core/SkSurfaceProps.h"
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h"
#include "include/gpu/GrTypes.h"
#include "include/gpu/mock/GrMockTypes.h"
#include "include/private/SkColorData.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/core/SkRectPriv.h"
#include "src/gpu/AtlasTypes.h"
#include "src/gpu/SkBackingFit.h"
#include "src/gpu/Swizzle.h"
#include "src/gpu/ganesh/GrAppliedClip.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrClip.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrFragmentProcessor.h"
#include "src/gpu/ganesh/GrOnFlushResourceProvider.h"
#include "src/gpu/ganesh/GrProcessorSet.h"
#include "src/gpu/ganesh/GrProxyProvider.h"
#include "src/gpu/ganesh/GrRecordingContextPriv.h"
#include "src/gpu/ganesh/GrResourceProvider.h"
#include "src/gpu/ganesh/GrSurface.h"
#include "src/gpu/ganesh/GrSurfaceProxy.h"
#include "src/gpu/ganesh/GrSurfaceProxyPriv.h"
#include "src/gpu/ganesh/GrTexture.h"
#include "src/gpu/ganesh/GrTextureProxy.h"
#include "src/gpu/ganesh/SurfaceDrawContext.h"
#include "src/gpu/ganesh/effects/GrTextureEffect.h"
#include "src/gpu/ganesh/ops/GrDrawOp.h"
#include "src/gpu/ganesh/ops/GrOp.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
#include <functional>
#include <initializer_list>
#include <memory>
#include <utility>

Go to the source code of this file.

Classes

class  LazyProxyTest
 
class  LazyProxyTest::Op
 
class  LazyProxyTest::ClipFP
 
class  LazyProxyTest::Clip
 
class  LazyFailedInstantiationTestOp
 

Namespaces

namespace  skgpu
 

Functions

 DEF_GANESH_TEST (LazyProxyTest, reporter,, CtsEnforcement::kApiLevel_T)
 
 DEF_GANESH_TEST (LazyProxyReleaseTest, reporter,, CtsEnforcement::kApiLevel_T)
 
 DEF_GANESH_TEST (LazyProxyFailedInstantiationTest, reporter,, CtsEnforcement::kApiLevel_T)
 

Variables

static const int kSize = 16
 

Function Documentation

◆ DEF_GANESH_TEST() [1/3]

DEF_GANESH_TEST ( LazyProxyFailedInstantiationTest  ,
reporter  ,
CtsEnforcement::kApiLevel_T   
)

Definition at line 467 of file LazyProxyTest.cpp.

470 {
471 GrMockOptions mockOptions;
473 GrProxyProvider* proxyProvider = ctx->priv().proxyProvider();
474 for (bool failInstantiation : {false, true}) {
477 nullptr,
479 {100, 100},
481 /*label=*/{});
483
484 sdc->clear(SkPMColor4f::FromBytes_RGBA(0xbaaaaaad));
485
486 int executeTestValue = 0;
487 sdc->addDrawOp(LazyFailedInstantiationTestOp::Make(ctx.get(), proxyProvider,
488 &executeTestValue, failInstantiation));
489 ctx->flushAndSubmit();
490
491 if (failInstantiation) {
492 REPORTER_ASSERT(reporter, 1 == executeTestValue);
493 } else {
494 REPORTER_ASSERT(reporter, 2 == executeTestValue);
495 }
496 }
497}
reporter
Definition: FontMgrTest.cpp:39
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
static sk_sp< GrDirectContext > MakeMock(const GrMockOptions *, const GrContextOptions &)
void flushAndSubmit(GrSyncCpu sync=GrSyncCpu::kNo)
GrDirectContextPriv priv()
GrProxyProvider * proxyProvider()
static DEFINE_OP_CLASS_ID GrOp::Owner Make(GrRecordingContext *rContext, GrProxyProvider *proxyProvider, int *testExecuteValue, bool shouldFailInstantiation)
T * get() const
Definition: SkRefCnt.h:303
static std::unique_ptr< SurfaceDrawContext > Make(GrRecordingContext *, GrColorType, sk_sp< GrSurfaceProxy >, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &)
static SkRGBA4f FromBytes_RGBA(uint32_t color)

◆ DEF_GANESH_TEST() [2/3]

DEF_GANESH_TEST ( LazyProxyReleaseTest  ,
reporter  ,
CtsEnforcement::kApiLevel_T   
)

Definition at line 287 of file LazyProxyTest.cpp.

287 {
288 GrMockOptions mockOptions;
290 auto proxyProvider = ctx->priv().proxyProvider();
291 const GrCaps* caps = ctx->priv().caps();
292
295
296 auto tex = ctx->priv().resourceProvider()->createTexture({kSize, kSize},
297 format,
300 1,
304 /*label=*/{});
305 using LazyInstantiationResult = GrSurfaceProxy::LazyCallbackResult;
306 for (bool doInstantiate : {true, false}) {
307 for (bool releaseCallback : {false, true}) {
308 int testCount = 0;
309 // Sets an integer to 1 when the callback is called and -1 when it is deleted.
310 class TestCallback {
311 public:
312 TestCallback(int* value, bool releaseCallback, sk_sp<GrTexture> tex)
313 : fValue(value)
314 , fReleaseCallback(releaseCallback)
315 , fTexture(std::move(tex)) {}
316 TestCallback(const TestCallback& that) { SkASSERT(0); }
317 TestCallback(TestCallback&& that)
318 : fValue(that.fValue)
319 , fReleaseCallback(that.fReleaseCallback)
320 , fTexture(std::move(that.fTexture)) {
321 that.fValue = nullptr;
322 }
323
324 ~TestCallback() { fValue ? (void)(*fValue = -1) : void(); }
325
326 TestCallback& operator=(TestCallback&& that) {
327 fValue = std::exchange(that.fValue, nullptr);
328 return *this;
329 }
330 TestCallback& operator=(const TestCallback& that) = delete;
331
332 LazyInstantiationResult operator()(GrResourceProvider*,
333 const GrSurfaceProxy::LazySurfaceDesc&) const {
334 *fValue = 1;
335 return {fTexture, fReleaseCallback};
336 }
337
338 private:
339 int* fValue = nullptr;
340 bool fReleaseCallback;
341 sk_sp<GrTexture> fTexture;
342 };
344 proxyProvider->createLazyProxy(TestCallback(&testCount, releaseCallback, tex),
345 format,
346 {kSize, kSize},
354 /*label=*/{});
355
356 REPORTER_ASSERT(reporter, proxy.get());
358
359 if (doInstantiate) {
361 if (releaseCallback) {
362 // We will call the cleanup and delete the callback in the
363 // doLazyInstantiationCall.
365 } else {
367 }
368 proxy.reset();
370 } else {
371 proxy.reset();
373 }
374 }
375 }
376}
static const int kSize
static const size_t testCount
#define SkASSERT(cond)
Definition: SkAssert.h:116
const GrCaps * caps() const
Definition: GrCaps.h:57
GrBackendFormat getDefaultBackendFormat(GrColorType, GrRenderable) const
Definition: GrCaps.cpp:400
GrResourceProvider * resourceProvider()
sk_sp< GrTexture > createTexture(SkISize dimensions, const GrBackendFormat &format, GrTextureType textureType, skgpu::Renderable renderable, int renderTargetSampleCnt, skgpu::Mipmapped mipmapped, skgpu::Budgeted budgeted, skgpu::Protected isProtected, std::string_view label)
bool doLazyInstantiation(GrResourceProvider *)
GrSurfaceProxyPriv priv()
void reset(T *ptr=nullptr)
Definition: SkRefCnt.h:310
uint8_t value
uint32_t uint32_t * format
Definition: ref_ptr.h:256

◆ DEF_GANESH_TEST() [3/3]

DEF_GANESH_TEST ( LazyProxyTest  ,
reporter  ,
CtsEnforcement::kApiLevel_T   
)

Definition at line 252 of file LazyProxyTest.cpp.

252 {
253 GrMockOptions mockOptions;
254 mockOptions.fConfigOptions[(int)GrColorType::kAlpha_F16].fRenderability =
255 GrMockOptions::ConfigOptions::Renderability::kNonMSAA;
256 mockOptions.fConfigOptions[(int)GrColorType::kAlpha_F16].fTexturable = true;
258 GrProxyProvider* proxyProvider = ctx->priv().proxyProvider();
259 for (bool nullTexture : {false, true}) {
264 nullptr,
266 {100, 100},
268 /*label=*/{});
270 auto mockAtlas = skgpu::ganesh::SurfaceDrawContext::Make(ctx.get(),
272 nullptr,
274 {10, 10},
276 /*label=*/{});
277 REPORTER_ASSERT(reporter, mockAtlas);
278 LazyProxyTest::Clip clip(&test, mockAtlas->asTextureProxy());
279 sdc->addDrawOp(&clip,
280 LazyProxyTest::Op::Make(ctx.get(), proxyProvider, &test, nullTexture));
281 ctx->priv().testingOnly_flushAndRemoveOnFlushCallbackObject(&test);
282 }
283}
#define test(name)
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
void addOnFlushCallbackObject(GrOnFlushCallbackObject *)
static DEFINE_OP_CLASS_ID GrOp::Owner Make(GrRecordingContext *context, GrProxyProvider *proxyProvider, LazyProxyTest *test, bool nullTexture)
ConfigOptions fConfigOptions[kGrColorTypeCnt]
Definition: GrMockTypes.h:151

Variable Documentation

◆ kSize

const int kSize = 16
static

Definition at line 285 of file LazyProxyTest.cpp.