Ginga  0.13.6
 All Classes Namespaces Functions Variables
SDLSurface.h
1 /******************************************************************************
2 Este arquivo eh parte da implementacao do ambiente declarativo do middleware
3 Ginga (Ginga-NCL).
4 
5 Direitos Autorais Reservados (c) 1989-2007 PUC-Rio/Laboratorio TeleMidia
6 
7 Este programa eh software livre; voce pode redistribui-lo e/ou modificah-lo sob
8 os termos da Licenca Publica Geral GNU versao 2 conforme publicada pela Free
9 Software Foundation.
10 
11 Este programa eh distribuido na expectativa de que seja util, porem, SEM
12 NENHUMA GARANTIA; nem mesmo a garantia implicita de COMERCIABILIDADE OU
13 ADEQUACAO A UMA FINALIDADE ESPECIFICA. Consulte a Licenca Publica Geral do
14 GNU versao 2 para mais detalhes.
15 
16 Voce deve ter recebido uma copia da Licenca Publica Geral do GNU versao 2 junto
17 com este programa; se nao, escreva para a Free Software Foundation, Inc., no
18 endereco 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
19 
20 Para maiores informacoes:
21 ncl @ telemidia.puc-rio.br
22 http://www.ncl.org.br
23 http://www.ginga.org.br
24 http://www.telemidia.puc-rio.br
25 ******************************************************************************
26 This file is part of the declarative environment of middleware Ginga (Ginga-NCL)
27 
28 Copyright: 1989-2007 PUC-RIO/LABORATORIO TELEMIDIA, All Rights Reserved.
29 
30 This program is free software; you can redistribute it and/or modify it under
31 the terms of the GNU General Public License version 2 as published by
32 the Free Software Foundation.
33 
34 This program is distributed in the hope that it will be useful, but WITHOUT ANY
35 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
36 PARTICULAR PURPOSE. See the GNU General Public License version 2 for more
37 details.
38 
39 You should have received a copy of the GNU General Public License version 2
40 along with this program; if not, write to the Free Software
41 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
42 
43 For further information contact:
44 ncl @ telemidia.puc-rio.br
45 http://www.ncl.org.br
46 http://www.ginga.org.br
47 http://www.telemidia.puc-rio.br
48 *******************************************************************************/
49 
50 #ifndef SDLSURFACE_H_
51 #define SDLSURFACE_H_
52 
53 #include "SDL.h"
54 
55 #include <pthread.h>
56 
57 #include "mb/interface/IWindow.h"
58 #include "mb/interface/sdl/output/SDLWindow.h"
59 #include "mb/interface/IFontProvider.h"
60 
61 #include <vector>
62 using namespace std;
63 
64 namespace br {
65 namespace pucrio {
66 namespace telemidia {
67 namespace ginga {
68 namespace core {
69 namespace mb {
70  class SDLSurface : public ISurface {
71  private:
72  GingaScreenID myScreen;
73  SDL_Surface* sur;
74  SDL_Surface* pending;
75  IWindow* parent;
76  bool hasExtHandler;
77  IColor* chromaColor;
78  IColor* borderColor;
79  IColor* bgColor;
80  IColor* surfaceColor;
81  IFontProvider* iFont;
82  int caps;
83  bool isDeleting;
84 
85  vector<DrawData*> drawData;
86  pthread_mutex_t ddMutex;
87 
88  pthread_mutex_t sMutex;
89  pthread_mutex_t pMutex;
90 
91  public:
92  SDLSurface(GingaScreenID screenId);
93  SDLSurface(GingaScreenID screenId, void* underlyingSurface);
94 
95  virtual ~SDLSurface();
96 
97  private:
98  void releasePendingSurface();
99  bool createPendingSurface();
100  void checkPendingSurface();
101  void fill();
102  void releaseChromaColor();
103  void releaseBgColor();
104  void releaseBorderColor();
105  void releaseSurfaceColor();
106 
107  void releaseFont();
108  void releaseDrawData();
109 
110  void initialize(GingaScreenID screenId);
111 
112  public:
113  void takeOwnership();
114 
115  SDL_Surface* getPendingSurface();
116 
117  void setExternalHandler(bool extHandler);
118  bool hasExternalHandler();
119 
120  void addCaps(int caps);
121  void setCaps(int caps);
122  int getCap(string cap);
123  int getCaps();
124  bool setParentWindow(void* parentWindow); //IWindow
125  void* getParentWindow(); //IWindow
126  void* getSurfaceContent();
127  void setSurfaceContent(void* surface);
128  void clearContent();
129  void clearSurface();
130 
131  vector<DrawData*>* createDrawDataList();
132 
133  private:
134  void pushDrawData(int c1, int c2, int c3, int c4, short type);
135 
136  public:
137  void drawLine(int x1, int y1, int x2, int y2);
138  void drawRectangle(int x, int y, int w, int h);
139  void fillRectangle(int x, int y, int w, int h);
140  void drawString(int x, int y, const char* txt);
141  void setChromaColor(int r, int g, int b, int alpha);
142  IColor* getChromaColor();
143  void setBorderColor(int r, int g, int b, int alpha);
144  IColor* getBorderColor();
145  void setBgColor(int r, int g, int b, int alpha);
146  IColor* getBgColor();
147  void setColor(int r, int g, int b, int alpha);
148  IColor* getColor();
149  void setSurfaceFont(void* font);
150  void getStringExtents(const char* text, int* w, int* h);
151  void flip();
152  void scale(double x, double y);
153 
154  private:
155  void initContentSurface();
156  SDL_Surface* createSurface();
157 
158  public:
159  void blit(
160  int x,
161  int y,
162  ISurface* src=NULL,
163  int srcX=-1, int srcY=-1, int srcW=-1, int srcH=-1);
164 
165  void setClip(int x, int y, int w, int h);
166  void getSize(int* width, int* height);
167  string getDumpFileUri();
168  void setMatrix(void* matrix);
169  };
170 }
171 }
172 }
173 }
174 }
175 }
176 
177 #endif /*SDLSURFACE_H_*/
Definition: IColor.h:64