summaryrefslogtreecommitdiff
path: root/Widgets/FrameBuffer.h
blob: 109519fba51d6241f47f5ecc11ece04b2ce77666 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once

#include "AbstractScreen.h"
#include "Color.h"

#ifdef USE_SDL
#include <SDL.h>
#endif

class GraphicsBitmap;

class FrameBuffer final : public AbstractScreen {
public:
    FrameBuffer(unsigned width, unsigned height);
    FrameBuffer(RGBA32*, unsigned width, unsigned height);
    virtual ~FrameBuffer() override;

    void show();

#ifdef USE_SDL
    SDL_Surface* surface() { return m_surface; }
#endif

    static FrameBuffer& the();

    RGBA32* scanline(int y);

#ifdef USE_SDL
    void flush();
#else
    void flush() { }
#endif

    static void initialize();

private:
#ifdef USE_SDL
    void initializeSDL();
    SDL_Window* m_window { nullptr };
    SDL_Surface* m_surface { nullptr };
#endif
#ifdef SERENITY
    RGBA32* m_data { nullptr };
#endif
};