/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim:expandtab:shiftwidth=2:tabstop=2:
*/ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include"mozilla/gfx/Logging.h"// for gfxCriticalNote
// TODO: Provide fallback formats if beedback is not received yet // Get from display?
namespace mozilla::widget {
// Table of all supported DRM formats, every format is stored as // FOURCC format + modifier pair and // one FOURCC format can be stored with more modifiers. // The format table data are provided via. mapped memory // so we don't copy it, just map fd and read. class DMABufFormatTable final { public: bool IsSet() { return mData && mSize && mData != MAP_FAILED; }
void DMABufFeedbackTranche::SetFormats(DMABufFormatTable* aFormatTable,
wl_array* aIndices) { // Formats are reported as array with appropriate modifiers. // Modifiers are sorted from the most preffered. // There's a sample output of weston-simple-dmabuf-feedback utility // which prints the format table: // // format ABGR16161616F, modifier AMD_GFX10_RBPLUS,64KB_R_X,PIPE_XOR_BITS=3... // format ABGR16161616F, modifier AMD_GFX10,64KB_S_X,PIPE_XOR_BITS=3 // format ABGR16161616F, modifier AMD_GFX9,64KB_D // format ABGR16161616F, modifier AMD_GFX9,64KB_S // format ABGR16161616F, modifier LINEAR
RefPtr<DRMFormat> currentDrmFormat;
// We need to use such ugly constructions because wl_array_for_each // is not C++ compliant // (https://gitlab.freedesktop.org/wayland/wayland/-/issues/34)
uint16_t* index = (uint16_t*)aIndices->data;
uint16_t* lastIndex =
(uint16_t*)((constchar*)aIndices->data + aIndices->size);
for (; index < lastIndex; index++) {
uint32_t format;
uint64_t modifier; if (!aFormatTable->GetFormat(*index, &format, &modifier)) { return;
}
LOGDMABUF(("DMABufFeedbackTranche [%p] format 0x%x modifier %" PRIx64, this,
format, modifier)); if (!currentDrmFormat || !currentDrmFormat->Matches(format)) {
currentDrmFormat = new DRMFormat(format, modifier);
mFormats.AppendElement(currentDrmFormat); continue;
}
currentDrmFormat->AddModifier(modifier);
}
}
class DMABufFeedback final { public:
DMABufFormatTable* FormatTable() { return &mFormatTable; }
DMABufFeedbackTranche* PendingTranche() { if (!mPendingTranche) {
mPendingTranche = MakeUnique<DMABufFeedbackTranche>();
} return mPendingTranche.get();
} void PendingTrancheDone() { // It's possible that Wayland compositor doesn't send us any format, // so !mPendingTranche if (mPendingTranche) {
mTranches.AppendElement(std::move(mPendingTranche));
}
}
DRMFormat* GetFormat(uint32_t aFormat, bool aRequestScanoutFormat) {
MOZ_ASSERT(!mPendingTranche); for (constauto& tranche : mTranches) { if (aRequestScanoutFormat && !tranche->IsScanout()) { continue;
} if (DRMFormat* format = tranche->GetFormat(aFormat)) { return format;
}
} return nullptr;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.