summaryrefslogtreecommitdiff
path: root/Widgets/FrameBuffer.h
blob: 56b2f5306262623032e4c3a5eb8fa9743f3d992a (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
#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);

    void blit(const Point&, GraphicsBitmap&);
    void flush();

    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
};