]> git.vomp.tv Git - vompclient.git/blob - osddirectfb.cc
Fix text corruption in channel number display on live tv
[vompclient.git] / osddirectfb.cc
1 /*
2     Copyright 2004-2005 Chris Tallon 2009 Marten Richter
3     portions 2008 Jon Gettler, Martin Vallevand
4
5     This file is part of VOMP.
6
7     VOMP is free software; you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation; either version 2 of the License, or
10     (at your option) any later version.
11
12     VOMP is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16
17     You should have received a copy of the GNU General Public License
18     along with VOMP; if not, write to the Free Software
19     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 */
21 // Many thanks to Martin Vallevand for help
22
23
24 #include "osddirectfb.h"
25 #include "videonmt.h" //TODO abstract base calss for more directfb devices
26 #include <dlfcn.h>
27
28
29
30 OsdDirectFB::OsdDirectFB()
31 {
32   if (instance) return;
33   dfb=NULL;
34   osd_layer=NULL;
35 }
36
37 OsdDirectFB::~OsdDirectFB()
38 {
39   if (initted) shutdown();
40 }
41
42 int OsdDirectFB::getFD()
43 {
44   if (!initted) return 0;
45   return 0;
46 }
47
48 int OsdDirectFB::init(void* device)
49 {
50
51   if (initted) return 0;
52
53   if ( DirectFBInit(NULL,NULL)!=DFB_OK) 
54   {
55     Log::getInstance()->log("OSD", Log::DEBUG, "Could not find init DirectFB");
56
57     return 0;
58   }
59
60   if (!((VideoNMT*)Video::getInstance())->directFBsetOptions()) return 0;
61   
62   if (DirectFBCreate(&dfb) != DFB_OK) 
63   {
64         Log::getInstance()->log("OSD", Log::DEBUG, 
65              "Could not set create DirectFB");
66         return 0;
67   }
68   dfb->SetCooperativeLevel(dfb,DFSCL_FULLSCREEN);
69   
70   if (dfb->GetDisplayLayer(dfb,DLID_PRIMARY, &osd_layer) != DFB_OK) 
71   {
72         Log::getInstance()->log("OSD", Log::DEBUG, 
73              "Could not get display layer DirectFB");
74         return 0;
75   }
76   
77   osd_layer->SetCooperativeLevel(osd_layer,DLSCL_EXCLUSIVE);
78   osd_layer->GetConfiguration(osd_layer,&layer_config);
79   
80   
81   initted = 1; // must set this here or create surface won't work
82     /* TODO clean up sizes */
83   Video* video = Video::getInstance();
84  
85   screen = new SurfaceDirectFB(Surface::SCREEN);
86   screen->create(video->getScreenWidth(), video->getScreenHeight());
87   screen->display();
88
89   return 1;
90 }
91
92 int OsdDirectFB::shutdown()
93 {
94   if (!initted) return 0;
95   initted = 0;
96   delete screen;
97   if (osd_layer) osd_layer->Release(osd_layer);
98   if (dfb) dfb->Release(dfb);
99   //dlclose(dl_handle);
100   return 1;
101 }
102
103 void OsdDirectFB::screenShot(char* fileName)
104 {
105   screen->screenShot(fileName);
106 }