-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathpainter.hpp
33 lines (31 loc) · 831 Bytes
/
painter.hpp
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
#pragma once
#include "color.hpp"
#include <SDL.h>
#include <SDL_ttf.h>
#include <string>
#include <map>
#include <tuple>
#include <list>
class PaintDevice;
class Painter
{
public:
Painter(PaintDevice *);
~Painter();
void drawLine(int x1, int y1, int x2, int y2);
void drawPoint(int x, int y);
void drawRect(int x1, int y1, int x2, int y2);
void setColor(Color);
void renderGlyph(wchar_t ch, int x, int y, Color fg, Color bg);
int glyphWidth() const;
int glyphHeight() const;
private:
SDL_Renderer *renderer_;
int width_;
int height_;
TTF_Font *font_;
typedef std::tuple<wchar_t, Color, Color> GlyphCacheKey;
typedef std::map<GlyphCacheKey, std::tuple<SDL_Texture *, int, int, std::list<GlyphCacheKey>::iterator> > GlyphCache;
GlyphCache glyphCache_;
std::list<GlyphCacheKey> glyphCacheAge_;
};