Flutter Engine
The Flutter Engine
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,
33 LoadOp::kClear,
34 "RecorderTestTexture");
35 sk_sp<Device> device2 = Device::Make(recorder.get(),
36 info,
41 LoadOp::kClear,
42 "RecorderTestTexture");
43 sk_sp<Device> device3 = Device::Make(recorder.get(),
44 info,
49 LoadOp::kClear,
50 "RecorderTestTexture");
51 sk_sp<Device> device4 = Device::Make(recorder.get(),
52 info,
57 LoadOp::kClear,
58 "RecorderTestTexture");
59 REPORTER_ASSERT(reporter, device1->recorder() == recorder.get());
60 REPORTER_ASSERT(reporter, device2->recorder() == recorder.get());
61 REPORTER_ASSERT(reporter, device3->recorder() == recorder.get());
62 REPORTER_ASSERT(reporter, device4->recorder() == recorder.get());
63 REPORTER_ASSERT(reporter, recorder->priv().deviceIsRegistered(device1.get()));
64 REPORTER_ASSERT(reporter, recorder->priv().deviceIsRegistered(device2.get()));
65 REPORTER_ASSERT(reporter, recorder->priv().deviceIsRegistered(device3.get()));
66 REPORTER_ASSERT(reporter, recorder->priv().deviceIsRegistered(device4.get()));
67
68 // Test freeing a device in the middle, marking it as immutable as ~Surface() our FilterResult
69 // would when done with the device.
70 device2->setImmutable();
71 REPORTER_ASSERT(reporter, device2->recorder() == nullptr);
72 REPORTER_ASSERT(reporter, device2->unique()); // Only the test holds a ref now
73 REPORTER_ASSERT(reporter, !recorder->priv().deviceIsRegistered(device2.get()));
74 device2.reset();
75
76 REPORTER_ASSERT(reporter, recorder->priv().deviceIsRegistered(device1.get()));
77 REPORTER_ASSERT(reporter, recorder->priv().deviceIsRegistered(device3.get()));
78 REPORTER_ASSERT(reporter, recorder->priv().deviceIsRegistered(device4.get()));
79
80 // Test freeing a device that wasn't marked as immutable, which should have its ref dropped
81 // automatically when the recorder flushes.
82 Device* dev4Ptr = device4.get();
83 device4.reset();
84 REPORTER_ASSERT(reporter, dev4Ptr->unique()); // The recorder holds a ref still
85 REPORTER_ASSERT(reporter, recorder->priv().deviceIsRegistered(dev4Ptr));
86 recorder->priv().flushTrackedDevices(); // should delete device4 now
87 REPORTER_ASSERT(reporter, !recorder->priv().deviceIsRegistered(dev4Ptr));
88
89 REPORTER_ASSERT(reporter, recorder->priv().deviceIsRegistered(device1.get()));
90 REPORTER_ASSERT(reporter, recorder->priv().deviceIsRegistered(device3.get()));
91
92 // Delete the recorder and make sure remaining devices no longer have a valid recorder.
93 recorder.reset();
94 REPORTER_ASSERT(reporter, device1->recorder() == nullptr);
95 REPORTER_ASSERT(reporter, device3->recorder() == nullptr);
96
97 // Make sure freeing Devices after recorder doesn't cause any crash. This would get checked
98 // naturually when these devices go out of scope, but manually reseting will give us a better
99 // stack trace if something does go wrong.
100 device1.reset();
101 device3.reset();
102}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
reporter
Definition: FontMgrTest.cpp:39
@ 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
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)