1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | #include <strings.h> |
17 | #include <vdr/config.h> |
18 | #include "setup.h" |
19 | #include "display.h" |
20 | #include "txtfont.h" |
21 | |
22 | |
23 | Display::Mode Display::mode=Display::Full; |
24 | cDisplay *Display::display=NULL__null; |
25 | |
26 | |
27 | void Display::SetMode(Display::Mode NewMode) { |
28 | |
29 | |
30 | if (display!=NULL__null && NewMode==mode) return; |
| 5 | | Assuming pointer value is null | |
|
31 | |
32 | |
33 | |
34 | int x0=Setup.OSDLeft+(Setup.OSDWidth-ttSetup.OSDwidth)*ttSetup.OSDHAlign/100; |
35 | int y0=Setup.OSDTop +(Setup.OSDHeight-ttSetup.OSDheight)*ttSetup.OSDVAlign/100; |
36 | |
37 | switch (NewMode) { |
| 6 | | Control jumps to 'case HalfUpper:' at line 50 | |
|
38 | case Display::Full: |
39 | |
40 | Delete(); |
41 | |
42 | display=new cDisplay4BPP(x0,y0,ttSetup.OSDwidth,ttSetup.OSDheight); |
43 | if (!display->Valid()) { |
44 | |
45 | delete display; |
46 | |
47 | display=new cDisplay2BPP(x0,y0,ttSetup.OSDwidth,ttSetup.OSDheight); |
48 | } |
49 | break; |
50 | case Display::HalfUpper: |
51 | |
52 | if (mode==Display::HalfLower) { |
| |
53 | |
54 | ((cDisplay4BPPHalf*)display)->SetUpper(true); |
55 | break; |
| 8 | | Execution continues on line 73 | |
|
56 | } |
57 | |
58 | Delete(); |
59 | display=new cDisplay4BPPHalf(x0,y0,ttSetup.OSDwidth,ttSetup.OSDheight,true); |
60 | break; |
61 | case Display::HalfLower: |
62 | |
63 | if (mode==Display::HalfUpper) { |
64 | |
65 | ((cDisplay4BPPHalf*)display)->SetUpper(false); |
66 | break; |
67 | } |
68 | |
69 | Delete(); |
70 | display=new cDisplay4BPPHalf(x0,y0,ttSetup.OSDwidth,ttSetup.OSDheight,false); |
71 | break; |
72 | } |
73 | mode=NewMode; |
74 | |
75 | if (!display->Valid()) Delete(); |
| 9 | | Called C++ object pointer is null |
|
76 | |
77 | SetBackgroundColor((tColor)ttSetup.configuredClrBackground); |
78 | } |
79 | |
80 | void Display::ShowUpperHalf() { |
81 | |
82 | if (GetZoom()==cDisplay::Zoom_Lower) |
| |
83 | SetZoom(cDisplay::Zoom_Upper); |
84 | if (mode==HalfLower) |
| 2 | | Assuming 'mode' is equal to HalfLower | |
|
| |
85 | SetMode(HalfUpper); |
| |
86 | } |
87 | |
88 | |
89 | |
90 | |
91 | |
92 | |
93 | cDisplay2BPP::cDisplay2BPP(int x0, int y0, int width, int height) |
94 | : cDisplay(width,height) { |
95 | |
96 | |
97 | osd = cOsdProvider::NewOsd(x0, y0); |
98 | if (!osd) return; |
99 | |
100 | width=(width+3)&~3; |
101 | |
102 | |
103 | tArea Areas[] = { { 0, 0, width - 1, height - 1, 2 } }; |
104 | if (osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) != oeOk) { |
105 | DELETENULL(osd); |
106 | return; |
107 | } |
108 | osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea)); |
109 | |
110 | InitPalette(); |
111 | |
112 | InitScaler(); |
113 | |
114 | CleanDisplay(); |
115 | } |
116 | |
117 | tColor cDisplay2BPP::GetColorRGB(enumTeletextColor ttc, int Area) { |
118 | switch (ttc) { |
119 | case ttcBlack: return Background; |
120 | case ttcRed: return clrRed; |
121 | case ttcGreen: return clrYellow; |
122 | case ttcYellow: return clrYellow; |
123 | case ttcBlue: return Background; |
124 | case ttcMagenta: return clrRed; |
125 | case ttcCyan: return clrCyan; |
126 | case ttcWhite: return clrCyan; |
127 | case ttcTransparent: return Background; |
128 | default: return Background; |
129 | } |
130 | } |
131 | |
132 | tColor cDisplay2BPP::GetColorRGBAlternate(enumTeletextColor ttc, int Area) { |
133 | switch (ttc) { |
134 | case ttcBlack: return clrCyan; |
135 | case ttcRed: return clrYellow; |
136 | case ttcGreen: return clrRed; |
137 | case ttcYellow: return clrRed; |
138 | case ttcBlue: return clrCyan; |
139 | case ttcMagenta: return clrYellow; |
140 | case ttcCyan: return Background; |
141 | case ttcWhite: return Background; |
142 | case ttcTransparent: return clrCyan; |
143 | default: return Background; |
144 | } |
145 | } |
146 | |
147 | |
148 | |
149 | |
150 | |
151 | cDisplay4BPP::cDisplay4BPP(int x0, int y0, int width, int height) |
152 | : cDisplay(width,height) { |
153 | |
154 | |
155 | osd = cOsdProvider::NewOsd(x0, y0); |
156 | if (!osd) return; |
157 | |
158 | width=(width+1)&~1; |
159 | |
160 | |
161 | tArea Areas[] = { { 0, 0, width - 1, height - 1, 4 } }; |
162 | if (osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) != oeOk) { |
163 | DELETENULL(osd); |
164 | return; |
165 | } |
166 | osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea)); |
167 | |
168 | InitPalette(); |
169 | |
170 | InitScaler(); |
171 | |
172 | CleanDisplay(); |
173 | } |
174 | |
175 | |
176 | cDisplay4BPPHalf::cDisplay4BPPHalf(int x0, int y0, int width, int height, bool upper) |
177 | : cDisplay(width,height), Upper(upper), OsdX0(x0), OsdY0(y0) |
178 | { |
179 | osd=NULL__null; |
180 | |
181 | |
182 | InitOSD(); |
183 | } |
184 | |
185 | void cDisplay4BPPHalf::InitOSD() { |
186 | if (osd) delete osd; |
187 | osd = cOsdProvider::NewOsd(OsdX0, OsdY0); |
188 | if (!osd) return; |
189 | |
190 | int width=(Width+1)&~1; |
191 | |
192 | |
193 | tArea Areas[] = { { 0, 0, width - 1, Height - 1, 4 } }; |
194 | |
195 | |
196 | while (osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) != oeOk) { |
197 | |
198 | if (Upper) { |
199 | |
200 | Areas[0].y2=Areas[0].y2-1; |
201 | } else { |
202 | |
203 | Areas[0].y1=Areas[0].y1+1; |
204 | } |
205 | if (Areas[0].y1>Areas[0].y2) { |
206 | |
207 | DELETENULL(osd); |
208 | return; |
209 | } |
210 | } |
211 | |
212 | |
213 | if (Upper) { |
214 | Areas[0].y2=Areas[0].y2-10; |
215 | } else { |
216 | Areas[0].y1=Areas[0].y1+10; |
217 | } |
218 | |
219 | osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea)); |
220 | |
221 | InitPalette(); |
222 | |
223 | InitScaler(); |
224 | |
225 | CleanDisplay(); |
226 | |
227 | |
228 | Dirty=true; |
229 | DirtyAll=true; |
230 | Flush(); |
231 | } |
232 | |
233 | |
234 | |