The Pedigree Project  0.1
pedigree_fb.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef _WINMAN_UTIL_H
21 #define _WINMAN_UTIL_H
22 
23 #ifndef TARGET_LINUX
24 #include <sys/fb.h>
25 #else
26 #include <SDL/SDL.h>
27 #endif
28 
29 #include <cairo/cairo.h>
30 
37 class Framebuffer
38 {
39  public:
40  Framebuffer();
41  virtual ~Framebuffer();
42 
44  bool initialise();
45 
47  void storeMode();
48 
50  void restoreMode();
51 
53  int enterMode(size_t desiredW, size_t desiredH, size_t desiredBpp);
54 
56  void *getFramebuffer() const
57  {
58  return m_pFramebuffer;
59  }
60 
62  void flush(size_t x, size_t y, size_t w, size_t h);
63 
65  cairo_format_t getFormat() const
66  {
67  return m_Format;
68  }
69 
71  size_t getWidth() const
72  {
73  return m_Width;
74  }
75  size_t getHeight() const
76  {
77  return m_Height;
78  }
79 
80  private:
81  void *m_pFramebuffer;
82  size_t m_FramebufferSize;
83 
84  cairo_format_t m_Format;
85 
86  size_t m_Width;
87  size_t m_Height;
88 
89 #ifdef TARGET_LINUX
90  SDL_Surface *m_pScreen;
91  SDL_Surface *m_pBackbuffer;
92 #else
93  int m_Fb;
94 
95  bool m_bStoredMode;
96  pedigree_fb_mode m_StoredMode;
97 #endif
98 };
99 
100 #endif
void restoreMode()
Definition: fb.cc:85
int enterMode(size_t desiredW, size_t desiredH, size_t desiredBpp)
Definition: fb.cc:98
bool initialise()
Definition: fb.cc:56
cairo_format_t getFormat() const
Definition: pedigree_fb.h:65
void flush(size_t x, size_t y, size_t w, size_t h)
Definition: fb.cc:186
void * getFramebuffer() const
Definition: pedigree_fb.h:56
Abstracts the system&#39;s framebuffer offering.
void storeMode()
Definition: fb.cc:70
size_t getWidth() const
Definition: pedigree_fb.h:71