Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Typedefs | Functions
RecorderTest.cpp File Reference
#include "tests/Test.h"
#include "include/gpu/graphite/Context.h"
#include "include/gpu/graphite/Recorder.h"
#include "src/gpu/SkBackingFit.h"
#include "src/gpu/graphite/Device.h"
#include "src/gpu/graphite/RecorderPriv.h"

Go to the source code of this file.

Typedefs

using Mipmapped = skgpu::Mipmapped
 

Functions

 DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS (RecorderDevicePtrTest, reporter, context, CtsEnforcement::kNextRelease)
 

Typedef Documentation

◆ Mipmapped

Definition at line 17 of file RecorderTest.cpp.

Function Documentation

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS()

DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( RecorderDevicePtrTest  ,
reporter  ,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 20 of file RecorderTest.cpp.

21 {
22 std::unique_ptr<Recorder> recorder = context->makeRecorder();
23
25
26 // Add multiple devices to later test different patterns of destruction.
27 sk_sp<Device> device1 = Device::Make(recorder.get(),
28 info,
30 Mipmapped::kNo,
33 LoadOp::kClear);
34 sk_sp<Device> device2 = Device::Make(recorder.get(),
35 info,
37 Mipmapped::kNo,
40 LoadOp::kClear);
41 sk_sp<Device> device3 = Device::Make(recorder.get(),
42 info,
44 Mipmapped::kNo,
47 LoadOp::kClear);
48 sk_sp<Device> device4 = Device::Make(recorder.get(),
49 info,
51 Mipmapped::kNo,
54 LoadOp::kClear);
55 REPORTER_ASSERT(reporter, device1->recorder() == recorder.get());
56 REPORTER_ASSERT(reporter, device2->recorder() == recorder.get());
57 REPORTER_ASSERT(reporter, device3->recorder() == recorder.get());
58 REPORTER_ASSERT(reporter, device4->recorder() == recorder.get());
59 REPORTER_ASSERT(reporter, recorder->priv().deviceIsRegistered(device1.get()));
60 REPORTER_ASSERT(reporter, recorder->priv().deviceIsRegistered(device2.get()));
61 REPORTER_ASSERT(reporter, recorder->priv().deviceIsRegistered(device3.get()));
62 REPORTER_ASSERT(reporter, recorder->priv().deviceIsRegistered(device4.get()));
63
64 // Test freeing a device in the middle, marking it as immutable as ~Surface() our FilterResult
65 // would when done with the device.
66 device2->setImmutable();
67 REPORTER_ASSERT(reporter, device2->recorder() == nullptr);
68 REPORTER_ASSERT(reporter, device2->unique()); // Only the test holds a ref now
69 REPORTER_ASSERT(reporter, !recorder->priv().deviceIsRegistered(device2.get()));
70 device2.reset();
71
72 REPORTER_ASSERT(reporter, recorder->priv().deviceIsRegistered(device1.get()));
73 REPORTER_ASSERT(reporter, recorder->priv().deviceIsRegistered(device3.get()));
74 REPORTER_ASSERT(reporter, recorder->priv().deviceIsRegistered(device4.get()));
75
76 // Test freeing a device that wasn't marked as immutable, which should have its ref dropped
77 // automatically when the recorder flushes.
78 Device* dev4Ptr = device4.get();
79 device4.reset();
80 REPORTER_ASSERT(reporter, dev4Ptr->unique()); // The recorder holds a ref still
81 REPORTER_ASSERT(reporter, recorder->priv().deviceIsRegistered(dev4Ptr));
82 recorder->priv().flushTrackedDevices(); // should delete device4 now
83 REPORTER_ASSERT(reporter, !recorder->priv().deviceIsRegistered(dev4Ptr));
84
85 REPORTER_ASSERT(reporter, recorder->priv().deviceIsRegistered(device1.get()));
86 REPORTER_ASSERT(reporter, recorder->priv().deviceIsRegistered(device3.get()));
87
88 // Delete the recorder and make sure remaining devices no longer have a valid recorder.
89 recorder.reset();
90 REPORTER_ASSERT(reporter, device1->recorder() == nullptr);
91 REPORTER_ASSERT(reporter, device3->recorder() == nullptr);
92
93 // Make sure freeing Devices after recorder doesn't cause any crash. This would get checked
94 // naturually when these devices go out of scope, but manually reseting will give us a better
95 // stack trace if something does go wrong.
96 device1.reset();
97 device3.reset();
98}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
reporter
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition SkAlphaType.h:29
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition SkColorType.h:24
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
bool unique() const
Definition SkRefCnt.h:50
T * get() const
Definition SkRefCnt.h:303
void reset(T *ptr=nullptr)
Definition SkRefCnt.h:310
static sk_sp< Device > Make(Recorder *recorder, sk_sp< TextureProxy >, SkISize deviceSize, const SkColorInfo &, const SkSurfaceProps &, LoadOp initialLoadOp, bool registerWithRecorder=true)
Definition Device.cpp:268
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)