summaryrefslogtreecommitdiff
path: root/netosd.c
blob: 08ab350328fbb50900df3df95f6bfb3a25823153 (plain)
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
/* 
 * netosd.c: OSD over network
 *
 * See the README file for copyright information and how to reach the author.
 *
 */

#include "netosd.h"
#include "osdworker.h"

//////////////////////////////////////////////////////////////////////////////////////////////////
cNetOSD::cNetOSD(int Left, int Top) : cOsd(Left, Top)
{
#ifdef DEBUG   
   fprintf(stderr,"[ffnetdev] NetOSD: Constructor cNetOSD.\n");
#endif
}

cNetOSD::~cNetOSD()
{
#ifdef DEBUG
   fprintf(stderr,"[ffnetdev] NetOSD: Destructor cNetOSD.\n");
#endif
   
   cOSDWorker::ClearScreen();    
}

eOsdError cNetOSD::CanHandleAreas(const tArea *Areas, int NumAreas)
{
   eOsdError Result = cOsd::CanHandleAreas(Areas, NumAreas);
   if (Result == oeOk) {
      if (NumAreas > 7)			
    	 return oeTooManyAreas;
      int TotalMemory = 0;
      for (int i = 0; i < NumAreas; i++) {
         if (Areas[i].bpp != 1 && Areas[i].bpp != 2 && Areas[i].bpp != 4 && Areas[i].bpp != 8)
            return oeBppNotSupported;
         if ((Areas[i].Width() & (8 / Areas[i].bpp - 1)) != 0)
            return oeWrongAlignment;
         TotalMemory += Areas[i].Width() * Areas[i].Height() / (8 / Areas[i].bpp);
     }
#ifdef DEBUG
     fprintf(stderr, "[ffnetdev] NetOSD: CanHandleAreas: OSD area size: %d bytes.\r\n", TotalMemory); 
#endif
     if (TotalMemory > MAXOSDMEMORY)
        return oeOutOfMemory;
     }
     return Result;
}


void cNetOSD::Flush(void)
{
    cBitmap *Bitmap;
    int x1=0, x2=0, y1=0, y2=0;

    for (int i = 0; (Bitmap = GetBitmap(i)) != NULL; i++)
    {   
       if (Bitmap->Dirty(x1, y1, x2, y2))   
       {  
#ifdef DEBUG         
	        //fprintf(stderr, "[ffnetdev] NetOSD: Left: %d, Top: %d, X0: %d, Y0: %d, Width: %d, Height: %d\n", 
               	//		 Left(), Top(), Bitmap->X0(), Bitmap->Y0(), Bitmap->Width(), Bitmap->Height()); 
       		//fprintf(stderr, "[ffnetdev] NetOSD: Dirty area x1: %d, y1: %d, x2: %d, y2: %d\n",x1,y1,x2,y2);
#endif
		cOSDWorker::DrawBitmap(Left() + Bitmap->X0(), Top() + Bitmap->Y0(), *Bitmap);
       		
	}
        Bitmap->Clean();
    }
     
    cOSDWorker::SendScreen(); 
}