1 //============================================================================
2 //
3 //   SSSS    tt          lll  lll
4 //  SS  SS   tt           ll   ll
5 //  SS     tttttt  eeee   ll   ll   aaaa
6 //   SSSS    tt   ee  ee  ll   ll      aa
7 //      SS   tt   eeeeee  ll   ll   aaaaa  --  "An Atari 2600 VCS Emulator"
8 //  SS  SS   tt   ee      ll   ll  aa  aa
9 //   SSSS     ttt  eeeee llll llll  aaaaa
10 //
11 // Copyright (c) 1995-2021 by Bradford W. Mott, Stephen Anthony
12 // and the Stella Team
13 //
14 // See the file "License.txt" for information on usage and redistribution of
15 // this file, and for a DISCLAIMER OF ALL WARRANTIES.
16 //============================================================================
17 
18 #ifndef FB_BACKEND_LIBRETRO_HXX
19 #define FB_BACKEND_LIBRETRO_HXX
20 
21 class OSystem;
22 
23 #include "bspf.hxx"
24 #include "FBBackend.hxx"
25 
26 /**
27   This class implements a standard LIBRETRO framebuffer backend.  Most of
28   the functionality is not used, since libretro has its own rendering system.
29 
30   @author  Stephen Anthony
31 */
32 class FBBackendLIBRETRO : public FBBackend
33 {
34   public:
FBBackendLIBRETRO(OSystem &)35     explicit FBBackendLIBRETRO(OSystem&) { }
~FBBackendLIBRETRO()36     ~FBBackendLIBRETRO() override { }
37 
38   protected:
39     /**
40       This method is called to map a given R/G/B triple to the screen palette.
41 
42       @param r  The red component of the color.
43       @param g  The green component of the color.
44       @param b  The blue component of the color.
45     */
mapRGB(uInt8 r,uInt8 g,uInt8 b) const46     uInt32 mapRGB(uInt8 r, uInt8 g, uInt8 b) const override {
47       return (r << 16) | (g << 8) | b;
48     }
49 
50     /**
51       This method is called to query and initialize the video hardware
52       for desktop and fullscreen resolution information.  Since several
53       monitors may be attached, we need the resolution for all of them.
54 
55       @param fullscreenRes  Maximum resolution supported in fullscreen mode
56       @param windowedRes    Maximum resolution supported in windowed mode
57       @param renderers      List of renderer names (internal name -> end-user name)
58     */
59     void queryHardware(vector<Common::Size>& fullscreenRes,
60                        vector<Common::Size>& windowedRes,
61                        VariantList& renderers) override;
62 
63     /**
64       This method is called to create a surface with the given attributes.
65 
66       @param w     The requested width of the new surface.
67       @param h     The requested height of the new surface.
68     */
69     unique_ptr<FBSurface>
70       createSurface(uInt32 w, uInt32 h, ScalingInterpolation,
71                     const uInt32*) const override;
72 
73     /**
74       This method is called to provide information about the backend.
75     */
about() const76     string about() const override { return "Video system: libretro"; }
77 
78 
79     //////////////////////////////////////////////////////////////////////
80     // Most methods here aren't used at all.  See FBBacked class for
81     // description, if needed.
82     //////////////////////////////////////////////////////////////////////
83 
scaleX(int x) const84     int scaleX(int x) const override { return x; }
scaleY(int y) const85     int scaleY(int y) const override { return y; }
setTitle(const string &)86     void setTitle(const string&) override { }
showCursor(bool)87     void showCursor(bool) override { }
fullScreen() const88     bool fullScreen() const override { return true; }
getRGB(uInt32,uInt8 *,uInt8 *,uInt8 *) const89     void getRGB(uInt32, uInt8*, uInt8*, uInt8*) const override { }
readPixels(uInt8 *,uInt32,const Common::Rect &) const90     void readPixels(uInt8*, uInt32, const Common::Rect&) const override { }
isCurrentWindowPositioned() const91     bool isCurrentWindowPositioned() const override { return true; }
getCurrentWindowPos() const92     Common::Point getCurrentWindowPos() const override { return Common::Point{}; }
getCurrentDisplayIndex() const93     Int32 getCurrentDisplayIndex() const override { return 0; }
clear()94     void clear() override { }
setVideoMode(const VideoModeHandler::Mode &,int,const Common::Point &)95     bool setVideoMode(const VideoModeHandler::Mode&,
96                       int, const Common::Point&) override { return true; }
grabMouse(bool)97     void grabMouse(bool) override { }
renderToScreen()98     void renderToScreen() override { }
refreshRate() const99     int refreshRate() const override { return 0; }
100 
101   private:
102     // Following constructors and assignment operators not supported
103     FBBackendLIBRETRO() = delete;
104     FBBackendLIBRETRO(const FBBackendLIBRETRO&) = delete;
105     FBBackendLIBRETRO(FBBackendLIBRETRO&&) = delete;
106     FBBackendLIBRETRO& operator=(const FBBackendLIBRETRO&) = delete;
107     FBBackendLIBRETRO& operator=(FBBackendLIBRETRO&&) = delete;
108 };
109 
110 #endif
111