Bug 1874803 - Add sentinel invalid recorded event type. r=gfx-reviewers,lsalzman

RecordedEvent::EventType::INVALID should never be seen in a recording
and so can be used as a sentinel value that we can assert against. If it
is seen, then the recording should fail gracefully.

Differential Revision: https://phabricator.services.mozilla.com/D198649
This commit is contained in:
Andrew Osmond 2024-01-16 03:38:34 +00:00
Родитель 2fa4750e87
Коммит 2d90dfa6d7
4 изменённых файлов: 5 добавлений и 4 удалений

Просмотреть файл

@ -42,7 +42,7 @@ bool InlineTranslator::TranslateRecording(char* aData, size_t aLen) {
return false;
}
uint8_t eventType;
uint8_t eventType = RecordedEvent::EventType::INVALID;
ReadElement(reader, eventType);
while (reader.good()) {
bool success = RecordedEvent::DoWithEvent(

Просмотреть файл

@ -367,7 +367,8 @@ class EventStream {
class RecordedEvent {
public:
enum EventType : uint8_t {
DRAWTARGETCREATION = 0,
INVALID = 0,
DRAWTARGETCREATION,
DRAWTARGETDESTRUCTION,
SETCURRENTDRAWTARGET,
FILLRECT,

Просмотреть файл

@ -538,7 +538,7 @@ void CanvasTranslator::TranslateRecording() {
});
mHeader->readerState = State::Processing;
EventType eventType;
EventType eventType = EventType::INVALID;
while (ReadNextEvent(eventType)) {
bool success = RecordedEvent::DoWithEventFromReader(
mCurrentMemReader, eventType,

Просмотреть файл

@ -48,7 +48,7 @@ bool PrintTranslator::TranslateRecording(PRFileDescStream& aRecording) {
return false;
}
uint8_t eventType;
uint8_t eventType = RecordedEvent::EventType::INVALID;
ReadElement(aRecording, eventType);
while (aRecording.good()) {
bool success = RecordedEvent::DoWithEventFromStream(