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 QIS_BLITTER_HXX
19 #define QIS_BLITTER_HXX
20 
21 class FBBackendSDL2;
22 
23 #include "Blitter.hxx"
24 #include "SDL_lib.hxx"
25 
26 class QisBlitter : public Blitter {
27 
28   public:
29 
30     explicit QisBlitter(FBBackendSDL2& fb);
31 
32     static bool isSupported(FBBackendSDL2& fb);
33 
34     ~QisBlitter() override;
35 
36     virtual void reinitialize(
37       SDL_Rect srcRect,
38       SDL_Rect destRect,
39       FBSurface::Attributes attributes,
40       SDL_Surface* staticData = nullptr
41     ) override;
42 
43     virtual void blit(SDL_Surface& surface) override;
44 
45   private:
46 
47     FBBackendSDL2& myFB;
48 
49     SDL_Texture* mySrcTexture{nullptr};
50     SDL_Texture* mySecondarySrcTexture{nullptr};
51     SDL_Texture* myIntermediateTexture{nullptr};
52     SDL_Texture* mySecondaryIntermedateTexture{nullptr};
53 
54     SDL_Rect mySrcRect{0, 0, 0, 0}, myIntermediateRect{0, 0, 0, 0}, myDstRect{0, 0, 0, 0};
55     FBSurface::Attributes myAttributes;
56 
57     bool myTexturesAreAllocated{false};
58     bool myRecreateTextures{false};
59 
60     SDL_Surface* myStaticData{nullptr};
61 
62   private:
63 
64     void free();
65 
66     void recreateTexturesIfNecessary();
67 
68     void blitToIntermediate();
69 
70   private:
71 
72     QisBlitter(const QisBlitter&) = delete;
73 
74     QisBlitter(QisBlitter&&) = delete;
75 
76     QisBlitter& operator=(const QisBlitter&) = delete;
77 
78     QisBlitter& operator=(QisBlitter&&) = delete;
79 };
80 
81 #endif // QIS_BLITTER_HXX
82