2010-06-08 23:44:05 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2014-02-18 02:34:18 +01:00
|
|
|
*
|
2010-06-08 23:44:05 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2014-02-18 02:34:18 +01:00
|
|
|
*
|
2010-06-08 23:44:05 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BACKENDS_GRAPHICS_ABSTRACT_H
|
|
|
|
#define BACKENDS_GRAPHICS_ABSTRACT_H
|
|
|
|
|
|
|
|
#include "common/system.h"
|
|
|
|
#include "common/noncopyable.h"
|
2010-07-11 04:32:24 +00:00
|
|
|
#include "common/keyboard.h"
|
2010-06-08 23:44:05 +00:00
|
|
|
|
2017-10-01 16:23:22 -05:00
|
|
|
#include "graphics/mode.h"
|
2011-02-07 17:52:38 +00:00
|
|
|
#include "graphics/palette.h"
|
|
|
|
|
2010-07-05 01:10:29 +00:00
|
|
|
/**
|
|
|
|
* Abstract class for graphics manager. Subclasses
|
|
|
|
* implement the real functionality.
|
|
|
|
*/
|
2011-02-07 17:52:38 +00:00
|
|
|
class GraphicsManager : public PaletteManager {
|
2010-06-08 23:44:05 +00:00
|
|
|
public:
|
|
|
|
virtual ~GraphicsManager() {}
|
|
|
|
|
BACKENDS: Refactor OpenGL & SDL graphics backends
This patch refactors the OpenGL and SDL graphics backends,
primarily to unify window scaling and mouse handling, and to
fix coordinate mapping between the ScummVM window and the
virtual game screen when they have different aspect ratios.
Unified code for these two backends has been moved to a new
header-only WindowedGraphicsManager class, so named because it
contains code for managing graphics managers that interact with
a windowing system and render virtual screens within a larger
physical content window.
The biggest behavioral change here is with the coordinate
system mapping:
Previously, mouse offsets were converted by mapping the whole
space within the window as input to the virtual game screen
without maintaining aspect ratio. This was done to prevent
'stickiness' when the mouse cursor was within the window but
outside of the virtual game screen, but it caused noticeable
distortion of mouse movement speed on the axis with blank
space.
Instead of introducing mouse speed distortion to prevent
stickiness, this patch changes coordinate transformation to
show the system cursor when the mouse moves outside of the virtual
game screen when mouse grab is off, or by holding the mouse inside
the virtual game screen (instead of the entire window) when mouse
grab is on.
This patch also improves some other properties of the
GraphicsManager/PaletteManager interfaces:
* Nullipotent operations (getWidth, getHeight, etc.) of the
PaletteManager/GraphicsManager interfaces are now const
* Methods marked `virtual` but not inherited by any subclass have
been de-virtualized
* Extra unnecessary calculations of hardware height in
SurfaceSdlGraphicsManager have been removed
* Methods have been renamed where appropriate for clarity
(setWindowSize -> handleResize, etc.)
* C++11 support improved with `override` specifier added on
overridden virtual methods in subclasses (primarily to avoid
myself accidentally creating new methods in the subclasses
by changing types/names during refactoring)
Additional refactoring can and should be done at some point to
continue to deduplicate code between the OpenGL and SDL backends.
Since the primary goal here was to improve the coordinate mapping,
full refactoring of these backends was not completed here.
2017-07-19 19:15:12 -05:00
|
|
|
virtual bool hasFeature(OSystem::Feature f) const = 0;
|
2010-06-08 23:44:05 +00:00
|
|
|
virtual void setFeatureState(OSystem::Feature f, bool enable) = 0;
|
BACKENDS: Refactor OpenGL & SDL graphics backends
This patch refactors the OpenGL and SDL graphics backends,
primarily to unify window scaling and mouse handling, and to
fix coordinate mapping between the ScummVM window and the
virtual game screen when they have different aspect ratios.
Unified code for these two backends has been moved to a new
header-only WindowedGraphicsManager class, so named because it
contains code for managing graphics managers that interact with
a windowing system and render virtual screens within a larger
physical content window.
The biggest behavioral change here is with the coordinate
system mapping:
Previously, mouse offsets were converted by mapping the whole
space within the window as input to the virtual game screen
without maintaining aspect ratio. This was done to prevent
'stickiness' when the mouse cursor was within the window but
outside of the virtual game screen, but it caused noticeable
distortion of mouse movement speed on the axis with blank
space.
Instead of introducing mouse speed distortion to prevent
stickiness, this patch changes coordinate transformation to
show the system cursor when the mouse moves outside of the virtual
game screen when mouse grab is off, or by holding the mouse inside
the virtual game screen (instead of the entire window) when mouse
grab is on.
This patch also improves some other properties of the
GraphicsManager/PaletteManager interfaces:
* Nullipotent operations (getWidth, getHeight, etc.) of the
PaletteManager/GraphicsManager interfaces are now const
* Methods marked `virtual` but not inherited by any subclass have
been de-virtualized
* Extra unnecessary calculations of hardware height in
SurfaceSdlGraphicsManager have been removed
* Methods have been renamed where appropriate for clarity
(setWindowSize -> handleResize, etc.)
* C++11 support improved with `override` specifier added on
overridden virtual methods in subclasses (primarily to avoid
myself accidentally creating new methods in the subclasses
by changing types/names during refactoring)
Additional refactoring can and should be done at some point to
continue to deduplicate code between the OpenGL and SDL backends.
Since the primary goal here was to improve the coordinate mapping,
full refactoring of these backends was not completed here.
2017-07-19 19:15:12 -05:00
|
|
|
virtual bool getFeatureState(OSystem::Feature f) const = 0;
|
2010-06-08 23:44:05 +00:00
|
|
|
|
2019-12-12 23:01:10 +00:00
|
|
|
virtual const OSystem::GraphicsMode *getSupportedGraphicsModes() const {
|
|
|
|
static const OSystem::GraphicsMode noGraphicsModes[] = {{"NONE", "Normal", 0}, {nullptr, nullptr, 0 }};
|
|
|
|
return noGraphicsModes;
|
|
|
|
};
|
|
|
|
virtual int getDefaultGraphicsMode() const { return 0; }
|
|
|
|
virtual bool setGraphicsMode(int mode) { return (mode == 0); }
|
|
|
|
virtual void resetGraphicsScale() {}
|
|
|
|
virtual int getGraphicsMode() const { return 0; }
|
2017-03-05 00:56:02 +01:00
|
|
|
virtual const OSystem::GraphicsMode *getSupportedShaders() const {
|
|
|
|
static const OSystem::GraphicsMode no_shader[2] = {{"NONE", "Normal (no shader)", 0}, {0, 0, 0}};
|
2017-03-01 14:00:17 -06:00
|
|
|
return no_shader;
|
|
|
|
};
|
2020-01-31 23:11:09 +00:00
|
|
|
virtual int getDefaultShader() const { return 0; }
|
2017-03-01 14:00:17 -06:00
|
|
|
virtual bool setShader(int id) { return false; }
|
2017-03-05 00:56:02 +01:00
|
|
|
virtual int getShader() const { return 0; }
|
2018-07-01 19:24:25 +01:00
|
|
|
virtual const OSystem::GraphicsMode *getSupportedStretchModes() const {
|
|
|
|
static const OSystem::GraphicsMode noStretchModes[] = {{"NONE", "Normal", 0}, {nullptr, nullptr, 0 }};
|
|
|
|
return noStretchModes;
|
|
|
|
}
|
|
|
|
virtual int getDefaultStretchMode() const { return 0; }
|
|
|
|
virtual bool setStretchMode(int mode) { return false; }
|
|
|
|
virtual int getStretchMode() const { return 0; }
|
2017-03-05 00:56:02 +01:00
|
|
|
|
2010-06-11 01:55:59 +00:00
|
|
|
#ifdef USE_RGB_COLOR
|
2010-06-08 23:44:05 +00:00
|
|
|
virtual Graphics::PixelFormat getScreenFormat() const = 0;
|
2010-07-13 04:31:15 +00:00
|
|
|
virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const = 0;
|
2010-06-11 01:55:59 +00:00
|
|
|
#endif
|
2010-06-08 23:44:05 +00:00
|
|
|
virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format = NULL) = 0;
|
2017-10-07 12:01:23 -05:00
|
|
|
virtual void initSizeHint(const Graphics::ModeList &modes) {}
|
2010-06-11 01:55:59 +00:00
|
|
|
virtual int getScreenChangeID() const = 0;
|
|
|
|
|
|
|
|
virtual void beginGFXTransaction() = 0;
|
|
|
|
virtual OSystem::TransactionError endGFXTransaction() = 0;
|
|
|
|
|
BACKENDS: Refactor OpenGL & SDL graphics backends
This patch refactors the OpenGL and SDL graphics backends,
primarily to unify window scaling and mouse handling, and to
fix coordinate mapping between the ScummVM window and the
virtual game screen when they have different aspect ratios.
Unified code for these two backends has been moved to a new
header-only WindowedGraphicsManager class, so named because it
contains code for managing graphics managers that interact with
a windowing system and render virtual screens within a larger
physical content window.
The biggest behavioral change here is with the coordinate
system mapping:
Previously, mouse offsets were converted by mapping the whole
space within the window as input to the virtual game screen
without maintaining aspect ratio. This was done to prevent
'stickiness' when the mouse cursor was within the window but
outside of the virtual game screen, but it caused noticeable
distortion of mouse movement speed on the axis with blank
space.
Instead of introducing mouse speed distortion to prevent
stickiness, this patch changes coordinate transformation to
show the system cursor when the mouse moves outside of the virtual
game screen when mouse grab is off, or by holding the mouse inside
the virtual game screen (instead of the entire window) when mouse
grab is on.
This patch also improves some other properties of the
GraphicsManager/PaletteManager interfaces:
* Nullipotent operations (getWidth, getHeight, etc.) of the
PaletteManager/GraphicsManager interfaces are now const
* Methods marked `virtual` but not inherited by any subclass have
been de-virtualized
* Extra unnecessary calculations of hardware height in
SurfaceSdlGraphicsManager have been removed
* Methods have been renamed where appropriate for clarity
(setWindowSize -> handleResize, etc.)
* C++11 support improved with `override` specifier added on
overridden virtual methods in subclasses (primarily to avoid
myself accidentally creating new methods in the subclasses
by changing types/names during refactoring)
Additional refactoring can and should be done at some point to
continue to deduplicate code between the OpenGL and SDL backends.
Since the primary goal here was to improve the coordinate mapping,
full refactoring of these backends was not completed here.
2017-07-19 19:15:12 -05:00
|
|
|
virtual int16 getHeight() const = 0;
|
|
|
|
virtual int16 getWidth() const = 0;
|
2010-06-08 23:44:05 +00:00
|
|
|
virtual void setPalette(const byte *colors, uint start, uint num) = 0;
|
BACKENDS: Refactor OpenGL & SDL graphics backends
This patch refactors the OpenGL and SDL graphics backends,
primarily to unify window scaling and mouse handling, and to
fix coordinate mapping between the ScummVM window and the
virtual game screen when they have different aspect ratios.
Unified code for these two backends has been moved to a new
header-only WindowedGraphicsManager class, so named because it
contains code for managing graphics managers that interact with
a windowing system and render virtual screens within a larger
physical content window.
The biggest behavioral change here is with the coordinate
system mapping:
Previously, mouse offsets were converted by mapping the whole
space within the window as input to the virtual game screen
without maintaining aspect ratio. This was done to prevent
'stickiness' when the mouse cursor was within the window but
outside of the virtual game screen, but it caused noticeable
distortion of mouse movement speed on the axis with blank
space.
Instead of introducing mouse speed distortion to prevent
stickiness, this patch changes coordinate transformation to
show the system cursor when the mouse moves outside of the virtual
game screen when mouse grab is off, or by holding the mouse inside
the virtual game screen (instead of the entire window) when mouse
grab is on.
This patch also improves some other properties of the
GraphicsManager/PaletteManager interfaces:
* Nullipotent operations (getWidth, getHeight, etc.) of the
PaletteManager/GraphicsManager interfaces are now const
* Methods marked `virtual` but not inherited by any subclass have
been de-virtualized
* Extra unnecessary calculations of hardware height in
SurfaceSdlGraphicsManager have been removed
* Methods have been renamed where appropriate for clarity
(setWindowSize -> handleResize, etc.)
* C++11 support improved with `override` specifier added on
overridden virtual methods in subclasses (primarily to avoid
myself accidentally creating new methods in the subclasses
by changing types/names during refactoring)
Additional refactoring can and should be done at some point to
continue to deduplicate code between the OpenGL and SDL backends.
Since the primary goal here was to improve the coordinate mapping,
full refactoring of these backends was not completed here.
2017-07-19 19:15:12 -05:00
|
|
|
virtual void grabPalette(byte *colors, uint start, uint num) const = 0;
|
2012-06-16 02:18:01 +02:00
|
|
|
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) = 0;
|
2010-06-08 23:44:05 +00:00
|
|
|
virtual Graphics::Surface *lockScreen() = 0;
|
|
|
|
virtual void unlockScreen() = 0;
|
|
|
|
virtual void fillScreen(uint32 col) = 0;
|
|
|
|
virtual void updateScreen() = 0;
|
2019-11-15 01:38:21 -08:00
|
|
|
virtual void setShakePos(int shakeXOffset, int shakeYOffset) = 0;
|
2010-06-11 01:55:59 +00:00
|
|
|
virtual void setFocusRectangle(const Common::Rect& rect) = 0;
|
|
|
|
virtual void clearFocusRectangle() = 0;
|
|
|
|
|
2010-06-08 23:44:05 +00:00
|
|
|
virtual void showOverlay() = 0;
|
|
|
|
virtual void hideOverlay() = 0;
|
|
|
|
virtual Graphics::PixelFormat getOverlayFormat() const = 0;
|
|
|
|
virtual void clearOverlay() = 0;
|
BACKENDS: Refactor OpenGL & SDL graphics backends
This patch refactors the OpenGL and SDL graphics backends,
primarily to unify window scaling and mouse handling, and to
fix coordinate mapping between the ScummVM window and the
virtual game screen when they have different aspect ratios.
Unified code for these two backends has been moved to a new
header-only WindowedGraphicsManager class, so named because it
contains code for managing graphics managers that interact with
a windowing system and render virtual screens within a larger
physical content window.
The biggest behavioral change here is with the coordinate
system mapping:
Previously, mouse offsets were converted by mapping the whole
space within the window as input to the virtual game screen
without maintaining aspect ratio. This was done to prevent
'stickiness' when the mouse cursor was within the window but
outside of the virtual game screen, but it caused noticeable
distortion of mouse movement speed on the axis with blank
space.
Instead of introducing mouse speed distortion to prevent
stickiness, this patch changes coordinate transformation to
show the system cursor when the mouse moves outside of the virtual
game screen when mouse grab is off, or by holding the mouse inside
the virtual game screen (instead of the entire window) when mouse
grab is on.
This patch also improves some other properties of the
GraphicsManager/PaletteManager interfaces:
* Nullipotent operations (getWidth, getHeight, etc.) of the
PaletteManager/GraphicsManager interfaces are now const
* Methods marked `virtual` but not inherited by any subclass have
been de-virtualized
* Extra unnecessary calculations of hardware height in
SurfaceSdlGraphicsManager have been removed
* Methods have been renamed where appropriate for clarity
(setWindowSize -> handleResize, etc.)
* C++11 support improved with `override` specifier added on
overridden virtual methods in subclasses (primarily to avoid
myself accidentally creating new methods in the subclasses
by changing types/names during refactoring)
Additional refactoring can and should be done at some point to
continue to deduplicate code between the OpenGL and SDL backends.
Since the primary goal here was to improve the coordinate mapping,
full refactoring of these backends was not completed here.
2017-07-19 19:15:12 -05:00
|
|
|
virtual void grabOverlay(void *buf, int pitch) const = 0;
|
|
|
|
virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) = 0;
|
|
|
|
virtual int16 getOverlayHeight() const = 0;
|
|
|
|
virtual int16 getOverlayWidth() const = 0;
|
2010-06-11 01:55:59 +00:00
|
|
|
|
2010-06-08 23:44:05 +00:00
|
|
|
virtual bool showMouse(bool visible) = 0;
|
|
|
|
virtual void warpMouse(int x, int y) = 0;
|
2012-06-16 03:10:43 +02:00
|
|
|
virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = NULL) = 0;
|
2010-06-11 01:55:59 +00:00
|
|
|
virtual void setCursorPalette(const byte *colors, uint start, uint num) = 0;
|
|
|
|
|
|
|
|
virtual void displayMessageOnOSD(const char *msg) {}
|
2016-09-13 20:25:13 +02:00
|
|
|
virtual void displayActivityIconOnOSD(const Graphics::Surface *icon) {}
|
2016-06-04 15:56:15 +06:00
|
|
|
|
2011-08-08 21:27:32 +02:00
|
|
|
|
|
|
|
// Graphics::PaletteManager interface
|
|
|
|
//virtual void setPalette(const byte *colors, uint start, uint num) = 0;
|
2017-10-15 13:46:41 -05:00
|
|
|
//virtual void grabPalette(byte *colors, uint start, uint num) const = 0;
|
2010-06-08 23:44:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|