-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGfxPretty.h
96 lines (68 loc) · 2.8 KB
/
GfxPretty.h
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
Copyright 2011 Matt DeVore
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
struct IDirectDrawClipper;
class GfxPretty : public Gfx {
public:
class SurfacePretty : public Surface {
public:
SurfacePretty(GfxPretty *owner, int width, int height)
: Surface(owner, width, height,
owner->CreateOffscreenSurface(width, height * 2)) {}
virtual void Draw(int x, int y, bool transparency);
virtual void DrawScale(const RECT *dest_rect, const RECT *source_rect,
bool transparency);
virtual bool Refill();
};
class FontPretty : public Font {
friend class GfxPretty;
public:
FontPretty(GfxPretty *owner, void *resource_data, int font_width,
int font_height, int first_font_char, int last_font_char)
: Font(owner, resource_data, font_width, font_height,
first_font_char, last_font_char) {}
virtual void WriteChar(int x, int y, int ch, BYTE color);
};
protected:
/** Indicates the "dimmer" version of each color. */
BYTE dim_palette[256];
AutoComPtr<IDirectDrawClipper> clipper;
RECT physical_clip_rect;
void WriteToFrontBuffer(FontPretty *font, BYTE *surf, int pitch,
int ch, BYTE color, BYTE back_color);
static GfxPretty *gfx_pretty;
GfxPretty(HWND hWnd);
public:
virtual ~GfxPretty() {gfx_pretty = 0;}
static inline GfxPretty *Get() {return gfx_pretty;}
static void Initialize(HWND hWnd) {
gfx_pretty = new GfxPretty(hWnd);
gfx.reset(gfx_pretty);
}
virtual std::auto_ptr<Font>
LoadFont(HGLOBAL resource_handle, int font_width, int font_height,
int first_font_char, int last_font_char);
virtual void Flip();
virtual void Lock();
virtual void Rectangle(const RECT *area, BYTE color, bool clip);
virtual void SetPalette(PALETTEENTRY *pe, int entry_count,
bool visual_effect);
virtual std::auto_ptr<Surface> CreateSurface
(int w, int h, std::auto_ptr<SurfaceFiller> filler);
virtual void DrawLine(int x0, int y0, int x1, int y1, LineDrawer *drawer);
virtual void CopyFrontBufferToBackBuffer();
void FrontBufferRectangle(RECT *area, BYTE color);
void ClearBorderArea();
void WriteToFrontBuffer(Font *font, int x, int y,
const char *str, BYTE color, BYTE back_color);
virtual void AttachScalingClipper();
};