@@ -151,7 +151,6 @@ class DMABufFeedback final {
151
151
}
152
152
}
153
153
DRMFormat * GetFormat (uint32_t aFormat , bool aRequestScanoutFormat ) {
154
- MOZ_ASSERT (!mPendingTranche );
155
154
for (const auto& tranche : mTranches ) {
156
155
if (aRequestScanoutFormat && !tranche -> IsScanout ()) {
157
156
continue ;
@@ -306,9 +305,8 @@ static const struct zwp_linux_dmabuf_v1_listener dmabuf_v3_listener = {
306
305
307
306
DRMFormat * DMABufFormats ::GetFormat (uint32_t aFormat ,
308
307
bool aRequestScanoutFormat ) {
309
- return mDMABufFeedback
310
- ? mDMABufFeedback -> GetFormat (aFormat , aRequestScanoutFormat )
311
- : nullptr ;
308
+ MOZ_DIAGNOSTIC_ASSERT (mDMABufFeedback );
309
+ return mDMABufFeedback -> GetFormat (aFormat , aRequestScanoutFormat );
312
310
}
313
311
314
312
void DMABufFormats ::InitFeedback (zwp_linux_dmabuf_v1 * aDMABuf ,
@@ -337,6 +335,29 @@ void DMABufFormats::InitV3Done() {
337
335
PendingDMABufFeedbackDone ();
338
336
}
339
337
338
+ void DMABufFormats ::EnsureBasicFormats () {
339
+ MOZ_DIAGNOSTIC_ASSERT (!mPendingDMABufFeedback ,
340
+ "Can't add extra formats during init!" );
341
+ if (!mDMABufFeedback ) {
342
+ mDMABufFeedback = MakeUnique < DMABufFeedback > ( );
343
+ }
344
+ if (!GetFormat (GBM_FORMAT_XRGB8888 )) {
345
+ LOGDMABUF (
346
+ ("DMABufFormats::EnsureBasicFormats(): GBM_FORMAT_XRGB8888 is missing, "
347
+ "adding." ));
348
+ mDMABufFeedback -> PendingTranche ()-> AddFormat (GBM_FORMAT_XRGB8888 ,
349
+ DRM_FORMAT_MOD_INVALID );
350
+ }
351
+ if (!GetFormat (GBM_FORMAT_ARGB8888 )) {
352
+ LOGDMABUF (
353
+ ("DMABufFormats::EnsureBasicFormats(): GBM_FORMAT_ARGB8888 is missing, "
354
+ "adding." ));
355
+ mDMABufFeedback -> PendingTranche ()-> AddFormat (GBM_FORMAT_ARGB8888 ,
356
+ DRM_FORMAT_MOD_INVALID );
357
+ }
358
+ mDMABufFeedback -> PendingTrancheDone ();
359
+ }
360
+
340
361
DMABufFormats ::DMABufFormats () {}
341
362
342
363
DMABufFormats ::~DMABufFormats () {
0 commit comments