More sophisticated detection whether qis is supported.

This commit is contained in:
Christian Speckner 2019-12-13 21:00:23 +01:00
parent 59b5a5cc88
commit 4e444f7383
3 changed files with 36 additions and 11 deletions

View File

@ -27,10 +27,6 @@ unique_ptr<Blitter> BlitterFactory::createBlitter(FrameBufferSDL2& fb)
throw runtime_error("BlitterFactory requires an initialized framebuffer!");
}
SDL_RendererInfo info;
SDL_GetRendererInfo(fb.renderer(), &info);
return (info.flags & SDL_RENDERER_TARGETTEXTURE) ?
return HqBlitter::isSupported(fb) ?
unique_ptr<Blitter>(new HqBlitter(fb)) : unique_ptr<Blitter>(new BilinearBlitter(fb));
}

View File

@ -36,6 +36,31 @@ HqBlitter::~HqBlitter()
free();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool HqBlitter::isSupported(FrameBufferSDL2 &fb)
{
ASSERT_MAIN_THREAD;
if (!fb.isInitialized()) throw runtime_error("frambuffer not initialized");
SDL_RendererInfo info;
SDL_GetRendererInfo(fb.renderer(), &info);
if (!(info.flags & SDL_RENDERER_TARGETTEXTURE)) return false;
SDL_Texture* tex = SDL_CreateTexture(fb.renderer(), fb.pixelFormat().format, SDL_TEXTUREACCESS_TARGET, 16, 16);
if (!tex) return false;
int sdlError = SDL_SetRenderTarget(fb.renderer(), tex);
SDL_SetRenderTarget(fb.renderer(), nullptr);
SDL_DestroyTexture(tex);
return sdlError == 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void HqBlitter::reinitialize(
SDL_Rect srcRect,
@ -103,6 +128,8 @@ void HqBlitter::blit(SDL_Surface& surface)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void HqBlitter::blitToIntermediate()
{
ASSERT_MAIN_THREAD;
SDL_Rect r = mySrcRect;
r.x = r.y = 0;

View File

@ -28,6 +28,8 @@ class HqBlitter : public Blitter {
HqBlitter(FrameBufferSDL2& fb);
static bool isSupported(FrameBufferSDL2 &fb);
virtual ~HqBlitter();
virtual void reinitialize(