Disable the window mode options for always full-screen renderers

This commit is contained in:
Cameron Gutman 2020-02-09 11:35:05 -08:00
parent 5b7e2521cc
commit 57a1c5eb76
15 changed files with 64 additions and 38 deletions

View file

@ -114,11 +114,7 @@ void SystemProperties::querySdlVideoInfo()
return;
}
hasHardwareAcceleration =
Session::isHardwareDecodeAvailable(testWindow,
StreamingPreferences::VDS_AUTO,
VIDEO_FORMAT_H264,
1920, 1080, 60);
Session::getDecoderInfo(testWindow, hasHardwareAcceleration, rendererAlwaysFullScreen);
SDL_DestroyWindow(testWindow);

View file

@ -11,6 +11,7 @@ public:
SystemProperties();
Q_PROPERTY(bool hasHardwareAcceleration MEMBER hasHardwareAcceleration CONSTANT)
Q_PROPERTY(bool rendererAlwaysFullScreen MEMBER rendererAlwaysFullScreen CONSTANT)
Q_PROPERTY(bool isRunningWayland MEMBER isRunningWayland CONSTANT)
Q_PROPERTY(bool isRunningXWayland MEMBER isRunningXWayland CONSTANT)
Q_PROPERTY(bool isWow64 MEMBER isWow64 CONSTANT)
@ -30,6 +31,7 @@ private:
void querySdlVideoInfo();
bool hasHardwareAcceleration;
bool rendererAlwaysFullScreen;
bool isRunningWayland;
bool isRunningXWayland;
bool isWow64;

View file

@ -340,7 +340,7 @@ Flickable {
currentIndex = 0
if (SystemProperties.hasWindowManager) {
if (SystemProperties.hasWindowManager && !SystemProperties.rendererAlwaysFullScreen) {
var savedWm = StreamingPreferences.windowMode
for (var i = 0; i < windowModeListModel.count; i++) {
var thisWm = windowModeListModel.get(i).val;
@ -355,7 +355,7 @@ Flickable {
}
id: windowModeComboBox
enabled: SystemProperties.hasWindowManager
enabled: SystemProperties.hasWindowManager && !SystemProperties.rendererAlwaysFullScreen
hoverEnabled: true
textRole: "text"
model: ListModel {

View file

@ -252,6 +252,24 @@ int Session::drSubmitDecodeUnit(PDECODE_UNIT du)
}
}
void Session::getDecoderInfo(SDL_Window* window,
bool& isHardwareAccelerated, bool& isFullScreenOnly)
{
IVideoDecoder* decoder;
if (!chooseDecoder(StreamingPreferences::VDS_AUTO,
window, VIDEO_FORMAT_H264, 1920, 1080, 60,
true, false, true, decoder)) {
isHardwareAccelerated = isFullScreenOnly = false;
return;
}
isHardwareAccelerated = decoder->isHardwareAccelerated();
isFullScreenOnly = decoder->isAlwaysFullScreen();
delete decoder;
}
bool Session::isHardwareDecodeAvailable(SDL_Window* window,
StreamingPreferences::VideoDecoderSelection vds,
int videoFormat, int width, int height, int frameRate)

View file

@ -25,9 +25,8 @@ public:
Q_INVOKABLE void exec(int displayOriginX, int displayOriginY);
static
bool isHardwareDecodeAvailable(SDL_Window* window,
StreamingPreferences::VideoDecoderSelection vds,
int videoFormat, int width, int height, int frameRate);
void getDecoderInfo(SDL_Window* window,
bool& isHardwareAccelerated, bool& isFullScreenOnly);
static Session* get()
{
@ -78,6 +77,11 @@ private:
void updateOptimalWindowDisplayMode();
static
bool isHardwareDecodeAvailable(SDL_Window* window,
StreamingPreferences::VideoDecoderSelection vds,
int videoFormat, int width, int height, int frameRate);
static
bool chooseDecoder(StreamingPreferences::VideoDecoderSelection vds,
SDL_Window* window, int videoFormat, int width, int height,

View file

@ -43,6 +43,7 @@ public:
virtual ~IVideoDecoder() {}
virtual bool initialize(PDECODER_PARAMETERS params) = 0;
virtual bool isHardwareAccelerated() = 0;
virtual bool isAlwaysFullScreen() = 0;
virtual int getDecoderCapabilities() = 0;
virtual int getDecoderColorspace() = 0;
virtual int submitDecodeUnit(PDECODE_UNIT du) = 0;

View file

@ -194,6 +194,12 @@ enum AVPixelFormat DrmRenderer::getPreferredPixelFormat(int)
return AV_PIX_FMT_DRM_PRIME;
}
int DrmRenderer::getRendererAttributes()
{
// This renderer can only draw in full-screen
return RENDERER_ATTRIBUTE_FULLSCREEN_ONLY;
}
void DrmRenderer::renderFrame(AVFrame* frame)
{
AVDRMFrameDescriptor* drmFrame = (AVDRMFrameDescriptor*)frame->data[0];

View file

@ -13,6 +13,7 @@ public:
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
virtual void renderFrame(AVFrame* frame) override;
virtual enum AVPixelFormat getPreferredPixelFormat(int videoFormat) override;
virtual int getRendererAttributes() override;
private:
int m_DrmFd;

View file

@ -127,6 +127,12 @@ enum AVPixelFormat MmalRenderer::getPreferredPixelFormat(int videoFormat)
return AV_PIX_FMT_MMAL;
}
int MmalRenderer::getRendererAttributes()
{
// This renderer can only draw in full-screen
return RENDERER_ATTRIBUTE_FULLSCREEN_ONLY;
}
bool MmalRenderer::needsTestFrame()
{
// We won't be able to decode if the GPU memory is 64 MB or lower,

View file

@ -16,6 +16,7 @@ public:
virtual void renderFrame(AVFrame* frame) override;
virtual enum AVPixelFormat getPreferredPixelFormat(int videoFormat) override;
virtual bool needsTestFrame() override;
virtual int getRendererAttributes() override;
private:
static void InputPortCallback(MMAL_PORT_T* port, MMAL_BUFFER_HEADER_T* buffer);

View file

@ -9,14 +9,10 @@ extern "C" {
#include <libavcodec/avcodec.h>
}
#define RENDERER_ATTRIBUTE_FULLSCREEN_ONLY 0x01
class IFFmpegRenderer : public Overlay::IOverlayRenderer {
public:
enum FramePacingConstraint {
PACING_FORCE_OFF,
PACING_FORCE_ON,
PACING_ANY
};
virtual bool initialize(PDECODER_PARAMETERS params) = 0;
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) = 0;
virtual void renderFrame(AVFrame* frame) = 0;
@ -31,16 +27,16 @@ public:
return 0;
}
virtual int getRendererAttributes() {
// No special attributes by default
return 0;
}
virtual int getDecoderColorspace() {
// Rec 601 is default
return COLORSPACE_REC_601;
}
virtual FramePacingConstraint getFramePacingConstraint() {
// No pacing preference
return PACING_ANY;
}
virtual bool isRenderThreadSupported() {
// Render thread is supported by default
return true;

View file

@ -45,6 +45,11 @@ bool FFmpegVideoDecoder::isHardwareAccelerated()
(m_VideoDecoderCtx->codec->capabilities & AV_CODEC_CAP_HARDWARE) != 0;
}
bool FFmpegVideoDecoder::isAlwaysFullScreen()
{
return m_BackendRenderer->getRendererAttributes() & RENDERER_ATTRIBUTE_FULLSCREEN_ONLY;
}
int FFmpegVideoDecoder::getDecoderCapabilities()
{
int capabilities = m_BackendRenderer->getDecoderCapabilities();
@ -187,23 +192,6 @@ bool FFmpegVideoDecoder::createFrontendRenderer(PDECODER_PARAMETERS params)
}
}
// Determine whether the frontend renderer prefers frame pacing
auto vsyncConstraint = m_FrontendRenderer->getFramePacingConstraint();
if (vsyncConstraint == IFFmpegRenderer::PACING_FORCE_OFF && params->enableFramePacing) {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
"Frame pacing is forcefully disabled by the frontend renderer");
params->enableFramePacing = false;
}
else if (vsyncConstraint == IFFmpegRenderer::PACING_FORCE_ON && !params->enableFramePacing) {
// FIXME: This duplicates logic in Session.cpp
int displayHz = StreamUtils::getDisplayRefreshRate(params->window);
if (displayHz + 5 >= params->frameRate) {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
"Frame pacing is forcefully enabled by the frontend renderer");
params->enableFramePacing = true;
}
}
return true;
}

View file

@ -16,6 +16,7 @@ public:
virtual ~FFmpegVideoDecoder() override;
virtual bool initialize(PDECODER_PARAMETERS params) override;
virtual bool isHardwareAccelerated() override;
virtual bool isAlwaysFullScreen() override;
virtual int getDecoderCapabilities() override;
virtual int getDecoderColorspace() override;
virtual int submitDecodeUnit(PDECODE_UNIT du) override;

View file

@ -25,6 +25,11 @@ SLVideoDecoder::isHardwareAccelerated()
return true;
}
bool SLVideoDecoder::isAlwaysFullScreen()
{
return true;
}
int
SLVideoDecoder::getDecoderCapabilities()
{

View file

@ -11,6 +11,7 @@ public:
virtual ~SLVideoDecoder();
virtual bool initialize(PDECODER_PARAMETERS params);
virtual bool isHardwareAccelerated();
virtual bool isAlwaysFullScreen();
virtual int getDecoderCapabilities();
virtual int getDecoderColorspace();
virtual int submitDecodeUnit(PDECODE_UNIT du);