summaryrefslogtreecommitdiffstats
path: root/mpeglib/lib/util/render/x11/imageDGAFull.h
blob: ddb8f493e166eb7a5d4975519171b70954023cfd (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
  xfree 4.0 dga fullscreen mode
  Copyright (C) 2000  Martin Vogt, Christian Gerlach

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU Library General Public License as published by
  the Free Software Foundation.

  For more information look at the file COPYRIGHT in this package

 */


#ifndef __IMAGEDGAFULL_H
#define __IMAGEDGAFULL_H
#include "xinit.h"

#include "../imageBase.h"



#include <stdio.h>
#include <unistd.h>
#include <limits.h>
#include <sys/types.h>




#define DGA_MINMAJOR 2
#define DGA_MINMINOR 0




/**
   
   Displays and renders X11 images in software with the help
   of the ditherWrapper class. It switches to xfree 4.0 dga 2.0
   and needs root priviliges for that
   
*/


class ImageDGAFull : public ImageBase {


  XWindow* m_pxWindow;

  // DGA status
  int m_iMajorVersion;
  int m_iMinorVersion;
  int m_iEventBase;
  int m_iErrorBase;
  
  int m_iScreen;
  
  Display    *m_pDisplay;
  
  int         m_iNumberModes;

#ifdef X11_DGA2
  XDGAMode   *m_pDGAModes;
  XDGADevice *m_pDevice;
#endif
  
  int         m_iScreenWidth;
  int         m_iScreenHeight;
  
  char       *m_pAddr;            // Base address of the screen
  
  // DGA parameter
  int  m_iVideoWidth;
  int  m_iVideoHeight;
  
  int   m_iBytesPerLine;
  int   m_iBytesPerRow;           // Size of one image line
  int   m_iBytesPerPixel;
  int   m_iOffsetScreen;
  int   m_iOffsetLine;
  char *m_pStartAddr;             // Start address for a centered image
  
  int  m_iImageMode;
  int  m_iMode;
  bool m_bZoom;
  bool m_bAllowZoom;

  bool m_bIsActive;

  int lSupport;
  DitherWrapper* ditherWrapper;


 public:
  ImageDGAFull();
  ~ImageDGAFull();

  void init(XWindow *xWindow, YUVPicture* pic = NULL);

  int support();

  int openImage(int mode);
  int closeImage();

  void ditherImage(YUVPicture* pic);
  void putImage();

  int active() { return m_bIsActive; }

 private:
  
  // Tries to find a fullscreen-mode which matches the resolution best
  int findMode(int width, int height, int bpp);

  // Returns TRUE if an event is waiting
  int event();

  // Returns the start address of the upper left corner of the video frame
  unsigned char *address();
  
  // Number of bytes from the end of a row to the beginning of next one
  int  offset();

  // Disables DGA-View (performs a mode-switch if neccesary)
  void stop();



};

#endif