From c4b9f966b6d13e2091a0a7b789fd9d8f7ab7d86c Mon Sep 17 00:00:00 2001 From: Pawel Kolodziejski Date: Mon, 5 Oct 2020 19:09:58 +0200 Subject: [PATCH] GRIM: Drop side textures feature from backend. --- backends/graphics/graphics.h | 1 - .../openglsdl/openglsdl-graphics3d.cpp | 41 ------------------ .../openglsdl/openglsdl-graphics3d.h | 8 ---- .../surfacesdl/surfacesdl-graphics3d.cpp | 42 ------------------- .../surfacesdl/surfacesdl-graphics3d.h | 9 ---- backends/modular-backend.cpp | 5 --- backends/modular-backend.h | 1 - backends/platform/android3d/graphics.cpp | 5 --- backends/platform/android3d/graphics.h | 1 - common/system.h | 23 ---------- engines/grim/grim.cpp | 16 ------- engines/grim/grim.h | 2 - 12 files changed, 154 deletions(-) diff --git a/backends/graphics/graphics.h b/backends/graphics/graphics.h index 81a8f868001..6d71a062612 100644 --- a/backends/graphics/graphics.h +++ b/backends/graphics/graphics.h @@ -114,7 +114,6 @@ public: // ResidualVM specific methods: virtual Graphics::PixelBuffer getScreenPixelBuffer() { return Graphics::PixelBuffer(); } - virtual void suggestSideTextures(Graphics::Surface *left, Graphics::Surface *right) {} virtual void saveScreenshot() {} virtual bool lockMouse(bool lock) { return false; } }; diff --git a/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp b/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp index 3b77e10116c..8c7f7d715ff 100644 --- a/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp +++ b/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp @@ -64,8 +64,6 @@ OpenGLSdlGraphics3dManager::OpenGLSdlGraphics3dManager(SdlEventSource *eventSour ConfMan.registerDefault("antialiasing", 0); ConfMan.registerDefault("aspect_ratio", true); - _sideTextures[0] = _sideTextures[1] = nullptr; - // Don't start at zero so that the value is never the same as the surface graphics manager _screenChangeCount = 1 << (sizeof(int) * 5 - 2); } @@ -539,27 +537,6 @@ void OpenGLSdlGraphics3dManager::drawOverlay() { _surfaceRenderer->restorePreviousState(); } -void OpenGLSdlGraphics3dManager::drawSideTextures() { - if (_fullscreen && _lockAspectRatio) { - _surfaceRenderer->setFlipY(true); - - const Math::Vector2d nudge(1.0 / float(_overlayScreen->getWidth()), 0); - if (_sideTextures[0] != nullptr) { - float left = _gameRect.getBottomLeft().getX() - (float(_overlayScreen->getHeight()) / float(_sideTextures[0]->getHeight())) * _sideTextures[0]->getWidth() / float(_overlayScreen->getWidth()); - Math::Rect2d leftRect(Math::Vector2d(left, 0.0), _gameRect.getBottomLeft() + nudge); - _surfaceRenderer->render(_sideTextures[0], leftRect); - } - - if (_sideTextures[1] != nullptr) { - float right = _gameRect.getTopRight().getX() + (float(_overlayScreen->getHeight()) / float(_sideTextures[1]->getHeight())) * _sideTextures[1]->getWidth() / float(_overlayScreen->getWidth()); - Math::Rect2d rightRect(_gameRect.getTopRight() - nudge, Math::Vector2d(right, 1.0)); - _surfaceRenderer->render(_sideTextures[1], rightRect); - } - - _surfaceRenderer->setFlipY(false); - } -} - #ifndef AMIGAOS OpenGL::FrameBuffer *OpenGLSdlGraphics3dManager::createFramebuffer(uint width, uint height) { #if !defined(USE_GLES2) @@ -579,7 +556,6 @@ void OpenGLSdlGraphics3dManager::updateScreen() { glViewport(0, 0, _overlayScreen->getWidth(), _overlayScreen->getHeight()); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); _surfaceRenderer->prepareState(); - drawSideTextures(); _surfaceRenderer->render(_frameBuffer, _gameRect); _surfaceRenderer->restorePreviousState(); } @@ -625,19 +601,6 @@ int16 OpenGLSdlGraphics3dManager::getWidth() const { #pragma mark --- Overlays --- #pragma mark - -void OpenGLSdlGraphics3dManager::suggestSideTextures(Graphics::Surface *left, Graphics::Surface *right) { - delete _sideTextures[0]; - _sideTextures[0] = nullptr; - delete _sideTextures[1]; - _sideTextures[1] = nullptr; - if (left) { - _sideTextures[0] = new OpenGL::TextureGL(*left); - } - if (right) { - _sideTextures[1] = new OpenGL::TextureGL(*right); - } -} - void OpenGLSdlGraphics3dManager::showOverlay() { if (_overlayVisible) { return; @@ -691,10 +654,6 @@ void OpenGLSdlGraphics3dManager::grabOverlay(void *buf, int pitch) const { } void OpenGLSdlGraphics3dManager::closeOverlay() { - delete _sideTextures[0]; - delete _sideTextures[1]; - _sideTextures[0] = _sideTextures[1] = nullptr; - if (_overlayScreen) { delete _overlayScreen; _overlayScreen = nullptr; diff --git a/backends/graphics3d/openglsdl/openglsdl-graphics3d.h b/backends/graphics3d/openglsdl/openglsdl-graphics3d.h index 497539ac669..e94ffb64048 100644 --- a/backends/graphics3d/openglsdl/openglsdl-graphics3d.h +++ b/backends/graphics3d/openglsdl/openglsdl-graphics3d.h @@ -94,12 +94,6 @@ public: int16 getOverlayHeight() const override; virtual bool isOverlayVisible() const override { return _overlayVisible; } - /* Render the passed Surfaces besides the game texture. - * This is used for widescreen support in the Grim engine. - * Note: we must copy the Surfaces, as they are free()d after this call. - */ - virtual void suggestSideTextures(Graphics::Surface *left, Graphics::Surface *right) override; - // GraphicsManager API - Mouse virtual void warpMouse(int x, int y) override; @@ -158,7 +152,6 @@ protected: OpenGL::TiledSurface *_overlayScreen; OpenGL::TiledSurface *_overlayBackground; - OpenGL::TextureGL *_sideTextures[2]; OpenGL::SurfaceRenderer *_surfaceRenderer; Graphics::PixelFormat _overlayFormat; @@ -168,7 +161,6 @@ protected: void initializeOpenGLContext() const; void drawOverlay(); - void drawSideTextures(); void closeOverlay(); OpenGL::FrameBuffer *_frameBuffer; diff --git a/backends/graphics3d/surfacesdl/surfacesdl-graphics3d.cpp b/backends/graphics3d/surfacesdl/surfacesdl-graphics3d.cpp index 7dc4ba703f5..4789391b07f 100644 --- a/backends/graphics3d/surfacesdl/surfacesdl-graphics3d.cpp +++ b/backends/graphics3d/surfacesdl/surfacesdl-graphics3d.cpp @@ -59,8 +59,6 @@ SurfaceSdlGraphics3dManager::SurfaceSdlGraphics3dManager(SdlEventSource *sdlEven _engineRequestedHeight(0), _transactionMode(kTransactionNone) { ConfMan.registerDefault("aspect_ratio", true); - - _sideSurfaces[0] = _sideSurfaces[1] = nullptr; } SurfaceSdlGraphics3dManager::~SurfaceSdlGraphics3dManager() { @@ -240,27 +238,6 @@ Graphics::PixelBuffer SurfaceSdlGraphics3dManager::getScreenPixelBuffer() { return Graphics::PixelBuffer(_screenFormat, (byte *)_subScreen->pixels); } -void SurfaceSdlGraphics3dManager::drawSideTextures() { - if (_fullscreen && _lockAspectRatio) { - if (_sideSurfaces[0]) { - SDL_Rect dstrect; - dstrect.x = _gameRect.getTopLeft().getX() - _sideSurfaces[0]->w; - dstrect.y = _gameRect.getTopLeft().getY(); - dstrect.w = _sideSurfaces[0]->w; - dstrect.h = _sideSurfaces[0]->h; - SDL_BlitSurface(_sideSurfaces[0], NULL, _screen, &dstrect); - } - if (_sideSurfaces[1]) { - SDL_Rect dstrect; - dstrect.x = _gameRect.getTopRight().getX(); - dstrect.y = _gameRect.getTopLeft().getY(); - dstrect.w = _sideSurfaces[1]->w; - dstrect.h = _sideSurfaces[1]->h; - SDL_BlitSurface(_sideSurfaces[1], NULL, _screen, &dstrect); - } - } -} - void SurfaceSdlGraphics3dManager::drawOverlay() { if (!_overlayscreen) return; @@ -279,7 +256,6 @@ void SurfaceSdlGraphics3dManager::updateScreen() { if (_overlayVisible) { drawOverlay(); } - drawSideTextures(); #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_UpdateTexture(_screenTexture, nullptr, _screen->pixels, _screen->pitch); @@ -318,21 +294,6 @@ void SurfaceSdlGraphics3dManager::clearOverlay() { _overlayDirty = true; } -void SurfaceSdlGraphics3dManager::suggestSideTextures(Graphics::Surface *left, Graphics::Surface *right) { - delete _sideSurfaces[0]; - _sideSurfaces[0] = nullptr; - delete _sideSurfaces[1]; - _sideSurfaces[1] = nullptr; - if (left) { - _sideSurfaces[0] = SDL_CreateRGBSurface(SDL_SWSURFACE, left->w, left->h, 32, 0xff << left->format.rShift, 0xff << left->format.gShift, 0xff << left->format.bShift, 0xff << left->format.aShift); - memcpy(_sideSurfaces[0]->pixels, left->getPixels(), left->w * left->h * 4); - } - if (right) { - _sideSurfaces[1] = SDL_CreateRGBSurface(SDL_SWSURFACE, right->w, right->h, 32, 0xff << right->format.rShift, 0xff << right->format.gShift, 0xff << right->format.bShift, 0xff << right->format.aShift); - memcpy(_sideSurfaces[1]->pixels, right->getPixels(), right->w * right->h * 4); - } -} - void SurfaceSdlGraphics3dManager::showOverlay() { if (_overlayVisible) return; @@ -414,9 +375,6 @@ void SurfaceSdlGraphics3dManager::copyRectToOverlay(const void *buf, int pitch, } void SurfaceSdlGraphics3dManager::closeOverlay() { - SDL_FreeSurface(_sideSurfaces[0]); - SDL_FreeSurface(_sideSurfaces[1]); - _sideSurfaces[0] = _sideSurfaces[1] = nullptr; if (_overlayscreen) { SDL_FreeSurface(_overlayscreen); _overlayscreen = nullptr; diff --git a/backends/graphics3d/surfacesdl/surfacesdl-graphics3d.h b/backends/graphics3d/surfacesdl/surfacesdl-graphics3d.h index b7e9fa5509e..9338eebcad7 100644 --- a/backends/graphics3d/surfacesdl/surfacesdl-graphics3d.h +++ b/backends/graphics3d/surfacesdl/surfacesdl-graphics3d.h @@ -72,12 +72,6 @@ public: virtual int16 getOverlayHeight() const override { return _overlayscreen->h; } virtual bool isOverlayVisible() const override { return _overlayVisible; } - /* Render the passed Surfaces besides the game texture. - * This is used for widescreen support in the Grim engine. - * Note: we must copy the Surfaces, as they are free()d after this call. - */ - virtual void suggestSideTextures(Graphics::Surface *left, Graphics::Surface *right) override; - // GraphicsManager API - Mouse virtual void warpMouse(int x, int y) override; @@ -113,10 +107,7 @@ protected: Math::Rect2d _gameRect; - SDL_Surface *_sideSurfaces[2]; - void drawOverlay(); - void drawSideTextures(); void closeOverlay(); virtual bool saveScreenshot(const Common::String &filename) const override; diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp index eb799c20ea0..5e2fce25ea2 100644 --- a/backends/modular-backend.cpp +++ b/backends/modular-backend.cpp @@ -130,11 +130,6 @@ Graphics::PixelBuffer ModularGraphicsBackend::getScreenPixelBuffer() { return _graphicsManager->getScreenPixelBuffer(); } -// ResidualVM specific method -void ModularGraphicsBackend::suggestSideTextures(Graphics::Surface *left, Graphics::Surface *right) { - _graphicsManager->suggestSideTextures(left, right); -} - void ModularGraphicsBackend::initSize(uint w, uint h, const Graphics::PixelFormat *format ) { _graphicsManager->initSize(w, h, format); } diff --git a/backends/modular-backend.h b/backends/modular-backend.h index eac26a7c345..0eed88af448 100644 --- a/backends/modular-backend.h +++ b/backends/modular-backend.h @@ -83,7 +83,6 @@ public: #endif virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format = NULL) override final; virtual Graphics::PixelBuffer getScreenPixelBuffer() override; // ResidualVM specific method - virtual void suggestSideTextures(Graphics::Surface *left, Graphics::Surface *right) override; // ResidualVM specific method virtual void initSizeHint(const Graphics::ModeList &modes) override final; virtual int getScreenChangeID() const override final; diff --git a/backends/platform/android3d/graphics.cpp b/backends/platform/android3d/graphics.cpp index 67607bdefd8..9db95a23aa6 100644 --- a/backends/platform/android3d/graphics.cpp +++ b/backends/platform/android3d/graphics.cpp @@ -693,11 +693,6 @@ Graphics::PixelBuffer AndroidGraphicsManager::getScreenPixelBuffer() { return _game_pbuf; } - -void AndroidGraphicsManager::suggestSideTextures(Graphics::Surface *left, Graphics::Surface *right) { - // TODO -} - void AndroidGraphicsManager::clipMouse(Common::Point &p) const { const GLESBaseTexture *tex = getActiveTexture(); diff --git a/backends/platform/android3d/graphics.h b/backends/platform/android3d/graphics.h index 55a8bd1a92b..4ee11767ce7 100644 --- a/backends/platform/android3d/graphics.h +++ b/backends/platform/android3d/graphics.h @@ -97,7 +97,6 @@ public: // ResidualVM specific method void setupScreen(uint screenW, uint screenH, bool fullscreen, bool accel3d, bool isGame); virtual Graphics::PixelBuffer getScreenPixelBuffer() override; - virtual void suggestSideTextures(Graphics::Surface *left, Graphics::Surface *right) override; void updateScreenRect(); const GLESBaseTexture *getActiveTexture() const; void clipMouse(Common::Point &p) const; diff --git a/common/system.h b/common/system.h index c48b2c7b967..5a3117150eb 100644 --- a/common/system.h +++ b/common/system.h @@ -381,14 +381,6 @@ public: */ kFeatureOpenGL, - /** - * This feature flag can be used to check if rendering side textures - * on the both sides of widescreen is supported. - * - * ResidualVM specific - */ - kFeatureSideTextures, - /** * If supported, this feature flag can be used to check if * waiting for vertical sync before refreshing the screen to reduce @@ -945,21 +937,6 @@ public: */ virtual Graphics::PixelBuffer getScreenPixelBuffer() { return Graphics::PixelBuffer(); } - /** - * Suggest textures to render at the side of the game window. - * This enables eg. Grim to render the game in a widescreen format. - * - * The system must take a copy of the Surfaces, as they will be free()d - * automatically. - * - * !!! ResidualVM specific method: !!! - * - * @param left Texture to be used on the left - * @param height Texture to be used on the right - */ - virtual void suggestSideTextures(Graphics::Surface *left, - Graphics::Surface *right) {}; - /** * Returns the currently set virtual screen height. * @see initSize diff --git a/engines/grim/grim.cpp b/engines/grim/grim.cpp index 35596420c70..71ae1cf6500 100644 --- a/engines/grim/grim.cpp +++ b/engines/grim/grim.cpp @@ -698,7 +698,6 @@ void GrimEngine::drawNormalMode() { if (_setupChanged) { cameraPostChangeHandle(_currSet->getSetup()); _setupChanged = false; - setSideTextures(_currSet->getCurrSetup()->_name.c_str()); } // Draw actors @@ -1413,21 +1412,6 @@ Graphics::Surface *loadPNG(const Common::String &filename) { return srf; } -void GrimEngine::setSideTextures(const Common::String &setup) { - if (! g_system->hasFeature(OSystem::kFeatureSideTextures)) - return; - Graphics::Surface *t1 = loadPNG(Common::String::format("%s_left.png", setup.c_str())); - Graphics::Surface *t2 = loadPNG(Common::String::format("%s_right.png", setup.c_str())); - g_system->suggestSideTextures(t1, t2); - if (t1) - t1->free(); - if (t2) - t2->free(); - delete t1; - delete t2; -} - - void GrimEngine::debugLua(const Common::String &str) { lua_dostring(str.c_str()); } diff --git a/engines/grim/grim.h b/engines/grim/grim.h index a6783b048e0..9a67226b2e5 100644 --- a/engines/grim/grim.h +++ b/engines/grim/grim.h @@ -174,8 +174,6 @@ public: void debugLua(const Common::String &str); - void setSideTextures(const Common::String &setup); - protected: virtual void pauseEngineIntern(bool pause) override;