]> git.vomp.tv Git - vompclient.git/blob - osddirectfb.cc
Bitmap and VPictureBanner CWFs
[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::init()
43 {
44
45   if (initted) return 0;
46
47   if ( DirectFBInit(NULL,NULL)!=DFB_OK) 
48   {
49     Log::getInstance()->log("OSD", Log::DEBUG, "Could not find init DirectFB");
50
51     return 0;
52   }
53
54   if (!((VideoNMT*)Video::getInstance())->directFBsetOptions()) return 0;
55   
56   if (DirectFBCreate(&dfb) != DFB_OK) 
57   {
58         Log::getInstance()->log("OSD", Log::DEBUG, 
59              "Could not set create DirectFB");
60         return 0;
61   }
62   dfb->SetCooperativeLevel(dfb,DFSCL_FULLSCREEN);
63   
64   if (dfb->GetDisplayLayer(dfb,DLID_PRIMARY, &osd_layer) != DFB_OK) 
65   {
66         Log::getInstance()->log("OSD", Log::DEBUG, 
67              "Could not get display layer DirectFB");
68         return 0;
69   }
70   
71   osd_layer->SetCooperativeLevel(osd_layer,DLSCL_EXCLUSIVE);
72   osd_layer->GetConfiguration(osd_layer,&layer_config);
73   
74   
75   initted = true; // must set this here or create surface won't work
76     /* TODO clean up sizes */
77   Video* video = Video::getInstance();
78  
79   screen = new SurfaceDirectFB(Surface::SCREEN);
80   screen->create(video->getScreenWidth(), video->getScreenHeight());
81   screen->display();
82
83   return 1;
84 }
85
86 int OsdDirectFB::shutdown()
87 {
88   if (!initted) return 0;
89   initted = false;
90   delete screen;
91   if (osd_layer) osd_layer->Release(osd_layer);
92   if (dfb) dfb->Release(dfb);
93   //dlclose(dl_handle);
94   return 1;
95 }
96
97 bool OsdDirectFB::screenShot(const char* fileName)
98 {
99   return screen->screenShot(fileName);
100 }