The Pedigree Project  0.1
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
Framebuffer Class Reference

Abstracts the system's framebuffer offering. More...

#include <Framebuffer.h>

+ Inheritance diagram for Framebuffer:
+ Collaboration diagram for Framebuffer:

Public Member Functions

virtual void * getFramebuffer ()
 
virtual bool getPixelFormat (Display::PixelFormat *pPf)
 
virtual bool getCurrentScreenMode (Display::ScreenMode &sm)
 
virtual bool getScreenModes (List< Display::ScreenMode * > &sms)
 
virtual bool setScreenMode (Display::ScreenMode sm)
 
size_t getWidth () const
 
size_t getHeight () const
 
Graphics::PixelFormat getFormat () const
 
bool getActive () const
 
void setActive (bool b)
 
void setPalette (uint32_t *palette, size_t nEntries)
 
uint32_t * getPalette () const
 
virtual void * getRawBuffer () const
 
virtual Graphics::BuffercreateBuffer (const void *srcData, Graphics::PixelFormat srcFormat, size_t width, size_t height, uint32_t *pPalette=0)
 
virtual void destroyBuffer (Graphics::Buffer *pBuffer)
 
void redraw (size_t x=~0UL, size_t y=~0UL, size_t w=~0UL, size_t h=~0UL, bool bChild=false)
 
virtual void blit (Graphics::Buffer *pBuffer, size_t srcx, size_t srcy, size_t destx, size_t desty, size_t width, size_t height, bool bLowestCall=true)
 
virtual void draw (void *pBuffer, size_t srcx, size_t srcy, size_t destx, size_t desty, size_t width, size_t height, Graphics::PixelFormat format=Graphics::Bits32_Argb, bool bLowestCall=true)
 
virtual void rect (size_t x, size_t y, size_t width, size_t height, uint32_t colour, Graphics::PixelFormat format=Graphics::Bits32_Argb, bool bLowestCall=true)
 
virtual void copy (size_t srcx, size_t srcy, size_t destx, size_t desty, size_t w, size_t h, bool bLowestCall=true)
 
virtual void line (size_t x1, size_t y1, size_t x2, size_t y2, uint32_t colour, Graphics::PixelFormat format=Graphics::Bits32_Argb, bool bLowestCall=true)
 
void setPixel (size_t x, size_t y, uint32_t colour, Graphics::PixelFormat format=Graphics::Bits32_Argb, bool bLowestCall=true)
 
void setXPos (size_t x)
 
void setYPos (size_t y)
 
void setWidth (size_t w)
 
void setHeight (size_t h)
 
void setFormat (Graphics::PixelFormat pf)
 
void setBytesPerPixel (size_t b)
 
uint32_t getBytesPerPixel () const
 
void setBytesPerLine (size_t b)
 
uint32_t getBytesPerLine () const
 
void setParent (Framebuffer *p)
 
FramebuffergetParent () const
 
virtual void setFramebuffer (uintptr_t p)
 
bool initialise ()
 
void storeMode ()
 
void restoreMode ()
 
int enterMode (size_t desiredW, size_t desiredH, size_t desiredBpp)
 
void * getFramebuffer () const
 
void flush (size_t x, size_t y, size_t w, size_t h)
 
cairo_format_t getFormat () const
 
size_t getWidth () const
 
size_t getHeight () const
 
- Public Member Functions inherited from Display
 Display (Device *p)
 
virtual Type getType ()
 
virtual void getName (String &str)
 
virtual void dump (String &str)
 
virtual rgb_tnewBuffer ()
 
virtual void setCurrentBuffer (rgb_t *pBuffer)
 
virtual void updateBuffer (rgb_t *pBuffer, size_t x1=~0UL, size_t y1=~0UL, size_t x2=~0UL, size_t y2=~0UL)
 
virtual void killBuffer (rgb_t *pBuffer)
 
virtual void bitBlit (rgb_t *pBuffer, size_t fromX, size_t fromY, size_t toX, size_t toY, size_t width, size_t height)
 
virtual void fillRectangle (rgb_t *pBuffer, size_t x, size_t y, size_t width, size_t height, rgb_t colour)
 
virtual bool getPixelFormat (PixelFormat &pf)
 
virtual bool setScreenMode (size_t modeId)
 
virtual bool setScreenMode (size_t nWidth, size_t nHeight, size_t nBpp)
 
- Public Member Functions inherited from Device
 Device (Device *p)
 
DevicegetParent () const
 
void setParent (Device *p)
 
virtual String getSpecificType ()
 
virtual void setSpecificType (String str)
 
void setPciPosition (uint32_t bus, uint32_t device, uint32_t func)
 
void setPciIdentifiers (uint8_t classCode, uint8_t subclassCode, uint16_t vendorId, uint16_t deviceId, uint8_t progIf)
 
void setPciConfigHeader (const PciBus::ConfigSpace &space)
 
PciBus::ConfigSpace getPciConfigHeader () const
 
uint8_t getPciClassCode ()
 
uint8_t getPciSubclassCode ()
 
uint16_t getPciVendorId ()
 
uint16_t getPciDeviceId ()
 
uint8_t getPciProgInterface ()
 
uint32_t getPciBusPosition ()
 
uint32_t getPciDevicePosition ()
 
uint32_t getPciFunctionNumber ()
 
virtual Vector< Address * > & addresses ()
 
virtual uintptr_t getInterruptNumber ()
 
virtual void setInterruptNumber (uintptr_t n)
 
void addChild (Device *pDevice)
 
DevicegetChild (size_t n)
 
size_t getNumChildren ()
 
void removeChild (size_t n)
 
void removeChild (Device *d)
 
void replaceChild (Device *src, Device *dest)
 

Public Attributes

size_t m_XPos
 X position on our parent's framebuffer. More...
 
size_t m_YPos
 Y position on our parent's framebuffer.
 
size_t m_nWidth
 Width of the framebuffer in pixels.
 
size_t m_nHeight
 Height of the framebuffer in pixels.
 
Graphics::PixelFormat m_PixelFormat
 Framebuffer pixel format.
 
size_t m_nBytesPerPixel
 Bytes per pixel in this framebuffer.
 
size_t m_nBytesPerLine
 Bytes per line in this framebuffer.
 
Framebufferm_pParent
 Parent of this framebuffer.
 
- Public Attributes inherited from Display
struct Display::rgb_t PACKED
 

Protected Member Functions

Graphics::Buffer bufferFromSelf ()
 
virtual void draw (Graphics::Buffer *pBuffer, size_t srcx, size_t srcy, size_t destx, size_t desty, size_t width, size_t height, bool bLowestCall=true)
 
void swBlit (Graphics::Buffer *pBuffer, size_t srcx, size_t srcy, size_t destx, size_t desty, size_t width, size_t height)
 
void swRect (size_t x, size_t y, size_t width, size_t height, uint32_t colour, Graphics::PixelFormat format)
 
void swCopy (size_t srcx, size_t srcy, size_t destx, size_t desty, size_t w, size_t h)
 
void swLine (size_t x1, size_t y1, size_t x2, size_t y2, uint32_t colour, Graphics::PixelFormat format)
 
void swDraw (void *pBuffer, size_t srcx, size_t srcy, size_t destx, size_t desty, size_t width, size_t height, Graphics::PixelFormat format=Graphics::Bits32_Argb, bool bLowestCall=true)
 
void swDraw (Graphics::Buffer *pBuffer, size_t srcx, size_t srcy, size_t destx, size_t desty, size_t width, size_t height, bool bLowestCall=true)
 
Graphics::BufferswCreateBuffer (const void *srcData, Graphics::PixelFormat srcFormat, size_t width, size_t height, uint32_t *pPalette)
 
void swDestroyBuffer (Graphics::Buffer *pBuffer)
 
virtual void hwRedraw (size_t x=~0UL, size_t y=~0UL, size_t w=~0UL, size_t h=~0UL)
 Inherited by drivers that provide a hardware redraw function.
 
- Protected Member Functions inherited from Device
 NOT_COPYABLE_OR_ASSIGNABLE (Device)
 

Protected Attributes

uintptr_t m_FramebufferBase
 
uint32_t * m_Palette
 Current graphics palette - an array of 256 32-bit RGBA entries.
 
bool m_bActive
 Whether this framebuffer is active or not.
 
- Protected Attributes inherited from Device
Vector< Address * > m_Addresses
 
Vector< Device * > m_Children
 
Devicem_pParent
 
uintptr_t m_InterruptNumber
 
String m_SpecificType
 
PciBus::ConfigSpace m_ConfigHeader
 
uint8_t m_ClassCode
 
uint8_t m_SubclassCode
 
uint16_t m_VendorId
 
uint16_t m_DeviceId
 
uint8_t m_ProgInterface
 
uint32_t m_PciBusPos
 
uint32_t m_PciDevicePos
 
uint32_t m_PciFunctionNum
 

Private Member Functions

void swSetPixel (size_t x, size_t y, uint32_t colour, Graphics::PixelFormat format=Graphics::Bits32_Argb)
 

Private Attributes

Display::ScreenMode m_Mode
 
void * m_pFramebuffer
 
size_t m_FramebufferSize
 
cairo_format_t m_Format
 
size_t m_Width
 
size_t m_Height
 
int m_Fb
 
bool m_bStoredMode
 
pedigree_fb_mode m_StoredMode
 

Additional Inherited Members

- Public Types inherited from Device
enum  Type {
  Generic, Root, Disk, Bus,
  Display, Network, Sound, Console,
  Mouse, Controller, UsbController, UsbGeneric,
  UsbContainer
}
 
typedef Device *(* Callback) (Device *)
 
- Static Public Member Functions inherited from Device
static void foreach (Callback callback, Device *root=0)
 
template<class F , class... Args>
static void foreach (pedigree_std::Callable< F > &callback, Device *root, Args...args)
 
static void addToRoot (Device *device)
 
static void searchByVendorId (uint16_t vendorId, void(*callback)(Device *), Device *root=0)
 
static void searchByVendorIdAndDeviceId (uint16_t vendorId, uint16_t deviceId, void(*callback)(Device *), Device *root=0)
 
static void searchByClass (uint16_t classCode, void(*callback)(Device *), Device *root=0)
 
static void searchByClassAndSubclass (uint16_t classCode, uint16_t subclassCode, void(*callback)(Device *), Device *root=0)
 
static void searchByClassSubclassAndProgInterface (uint16_t classCode, uint16_t subclassCode, uint8_t progInterface, void(*callback)(Device *), Device *root=0)
 
- Static Protected Member Functions inherited from Device
static Deviceroot ()
 
- Static Protected Attributes inherited from Device
static Device m_Root
 
static Mutex m_TreeLock
 

Detailed Description

Abstracts the system's framebuffer offering.

This class is a wrapper around the standard PPC Vga driver, to provide access to it as a device tree node.

This class provides a generic interface for interfacing with a framebuffer. Each display driver specialises this class to define the "base address" of the framebuffer in its own way (eg, allocate memory, or use a DMA region). There are a variety of default software-only operations, which are used by default if the main operational methods are not overridden.

This is needed to abstract out the Pedigree-specific framebuffer parts so the window manager can be run under SDL on Linux for rapid development.

Definition at line 29 of file modules/drivers/ppc/framebuffer/Framebuffer.h.

Member Function Documentation

void Framebuffer::blit ( Graphics::Buffer pBuffer,
size_t  srcx,
size_t  srcy,
size_t  destx,
size_t  desty,
size_t  width,
size_t  height,
bool  bLowestCall = true 
)
virtual

Blits a given buffer to the screen. See createBuffer.

Parameters
bLowestCallwhether this is the lowest level call for the chain or a call being passed up from a child somewhere in the chain.

Definition at line 156 of file Framebuffer.cc.

void Framebuffer::copy ( size_t  srcx,
size_t  srcy,
size_t  destx,
size_t  desty,
size_t  w,
size_t  h,
bool  bLowestCall = true 
)
virtual

Copies a rectangle already on the framebuffer to a new location

Reimplemented in VmwareGraphics::VmwareFramebuffer.

Definition at line 190 of file Framebuffer.cc.

Graphics::Buffer * Framebuffer::createBuffer ( const void *  srcData,
Graphics::PixelFormat  srcFormat,
size_t  width,
size_t  height,
uint32_t *  pPalette = 0 
)
virtual

Creates a new buffer to be used for blits from the given raw pixel data. Performs automatic conversion of the pixel format to the pixel format of the current display mode. Do not modify any of the members of the buffer structure, or attempt to inject your own pixels into the buffer. Once a buffer is created, it is only used for blitting to the screen and cannot be modified. It is expected that the buffer has been packed to its bit depth, and does not have any padding on each scanline at all. Do not delete the returned buffer yourself, pass it to destroyBuffer which performs a proper cleanup of all resources related to the buffer. The buffer should be padded to finish on a DWORD boundary. This is not padding per scanline but rather padding per buffer.

Definition at line 94 of file Framebuffer.cc.

Referenced by StreamingScreenLogger::callback().

+ Here is the caller graph for this function:

void Framebuffer::destroyBuffer ( Graphics::Buffer pBuffer)
virtual

Destroys a created buffer. Frees its memory in both the system RAM and any references still in VRAM.

Definition at line 104 of file Framebuffer.cc.

Referenced by StreamingScreenLogger::callback().

+ Here is the caller graph for this function:

void Framebuffer::draw ( void *  pBuffer,
size_t  srcx,
size_t  srcy,
size_t  destx,
size_t  desty,
size_t  width,
size_t  height,
Graphics::PixelFormat  format = Graphics::Bits32_Argb,
bool  bLowestCall = true 
)
virtual

Draws given raw pixel data to the screen. Used for framebuffer chains and applications which need to render constantly changing pixel buffers.

Definition at line 168 of file Framebuffer.cc.

Referenced by StreamingScreenLogger::callback().

+ Here is the caller graph for this function:

void Framebuffer::draw ( Graphics::Buffer pBuffer,
size_t  srcx,
size_t  srcy,
size_t  destx,
size_t  desty,
size_t  width,
size_t  height,
bool  bLowestCall = true 
)
protectedvirtual

Special implementation of draw() where a Graphics::Buffer is already available. For use in redraw, and similar.

Definition at line 297 of file Framebuffer.cc.

int Framebuffer::enterMode ( size_t  desiredW,
size_t  desiredH,
size_t  desiredBpp 
)

Create framebuffer, enter desired mode.

Note
Mode set logic will try and find a mode in a lower colour depth if the desired one cannot be set.

Definition at line 98 of file fb.cc.

void Framebuffer::flush ( size_t  x,
size_t  y,
size_t  w,
size_t  h 
)

Flush framebuffer in the given region.

Definition at line 186 of file fb.cc.

Referenced by getFramebuffer().

+ Here is the caller graph for this function:

virtual bool Framebuffer::getCurrentScreenMode ( Display::ScreenMode sm)
virtual

Returns the current screen mode.

Returns
True if operation succeeded, false otherwise.

Reimplemented from Display.

cairo_format_t Framebuffer::getFormat ( ) const
inline

Get framebuffer colour format.

Definition at line 65 of file pedigree_fb.h.

virtual void* Framebuffer::getFramebuffer ( )
virtual

Returns a pointer to a linear framebuffer. Returns 0 if none available.

Warning
Not intended to be used - use the buffer functions instead.

Reimplemented from Display.

Referenced by VbeDisplay::fillRectangle(), and VbeDisplay::newBuffer().

+ Here is the caller graph for this function:

void* Framebuffer::getFramebuffer ( ) const
inline

Retrieve base address of the framebuffer.

Definition at line 56 of file pedigree_fb.h.

References flush().

void * Framebuffer::getRawBuffer ( ) const
virtual

Gets a raw pointer to the framebuffer itself. There is no way to know if this pointer points to an MMIO region or real RAM, so it cannot be guaranteed to be safe.

Definition at line 87 of file Framebuffer.cc.

virtual bool Framebuffer::getScreenModes ( List< Display::ScreenMode * > &  sms)
virtual

Fills the given List with all of the available screen modes.

Returns
True if operation succeeded, false otherwise.

Reimplemented from Display.

size_t Framebuffer::getWidth ( ) const
inline

Get framebuffer dimensions.

Definition at line 71 of file pedigree_fb.h.

bool Framebuffer::initialise ( )

General system-specific initialisation.

Definition at line 56 of file fb.cc.

References File::open().

void Framebuffer::line ( size_t  x1,
size_t  y1,
size_t  x2,
size_t  y2,
uint32_t  colour,
Graphics::PixelFormat  format = Graphics::Bits32_Argb,
bool  bLowestCall = true 
)
virtual

Draws a line one pixel wide between two points on the screen

Definition at line 202 of file Framebuffer.cc.

void Framebuffer::rect ( size_t  x,
size_t  y,
size_t  width,
size_t  height,
uint32_t  colour,
Graphics::PixelFormat  format = Graphics::Bits32_Argb,
bool  bLowestCall = true 
)
virtual

Draws a single rectangle to the screen with the given colour.

Definition at line 179 of file Framebuffer.cc.

Referenced by StreamingScreenLogger::callback().

+ Here is the caller graph for this function:

void Framebuffer::redraw ( size_t  x = ~0UL,
size_t  y = ~0UL,
size_t  w = ~0UL,
size_t  h = ~0UL,
bool  bChild = false 
)

Performs an update of a region of this framebuffer. This function can be used by drivers to request an area of the framebuffer be redrawn, but is useless for non-hardware-accelerated devices.

Parameters
xleftmost x co-ordinate of the redraw area, ~0 for "invalid"
ytopmost y co-ordinate of the redraw area, ~0 for "invalid"
wwidth of the redraw area, ~0 for "invalid"
hheight of the redraw area, ~0 for "invalid"
bChildnon-zero if a child began the redraw, zero otherwise
Note
Because every redraw ends up redrawing a large region of the "root" framebuffer, it's not necessary to do framebuffer copies at any point. The only reason a framebuffer copy is done in this function is in the one case where a parent needs to override a child's framebuffer.
Note
If none of the above makes sense, you need to read the Pedigree graphics design doc: http://pedigree-project.org/issues/114
Todo:
nChildren parameter - this is not necessary if no children!

Definition at line 112 of file Framebuffer.cc.

References ERROR.

Referenced by StreamingScreenLogger::callback(), and FramebufferFile::command().

+ Here is the caller graph for this function:

void Framebuffer::restoreMode ( )

Restore saved mode.

Definition at line 85 of file fb.cc.

void Framebuffer::setPalette ( uint32_t *  palette,
size_t  nEntries 
)

Sets the palette used for palette-based colour formats. Takes an array of pixels in Bits32_Argb format.

Definition at line 71 of file Framebuffer.cc.

References Dec, Hex, and NOTICE.

void Framebuffer::setPixel ( size_t  x,
size_t  y,
uint32_t  colour,
Graphics::PixelFormat  format = Graphics::Bits32_Argb,
bool  bLowestCall = true 
)
virtual bool Framebuffer::setScreenMode ( Display::ScreenMode  sm)
virtual

Sets the current screen mode.

Returns
True if operation succeeded, false otherwise.

Reimplemented from Display.

Referenced by VbeDisplay::setScreenMode().

+ Here is the caller graph for this function:

void Framebuffer::storeMode ( )

Store current mode (before switching).

Definition at line 70 of file fb.cc.

void Framebuffer::swBlit ( Graphics::Buffer pBuffer,
size_t  srcx,
size_t  srcy,
size_t  destx,
size_t  desty,
size_t  width,
size_t  height 
)
protected
Todo:
This code is broken for the case where srcx/srcy are not zero. :(

Definition at line 436 of file Framebuffer.cc.

References Graphics::Buffer::base, Graphics::Buffer::bytesPerPixel, Graphics::Buffer::height, UNLIKELY, and Graphics::Buffer::width.

void Framebuffer::swCopy ( size_t  srcx,
size_t  srcy,
size_t  destx,
size_t  desty,
size_t  w,
size_t  h 
)
protected
Todo:
consider source bytes per line?

Definition at line 646 of file Framebuffer.cc.

References UNLIKELY.

Graphics::Buffer * Framebuffer::swCreateBuffer ( const void *  srcData,
Graphics::PixelFormat  srcFormat,
size_t  width,
size_t  height,
uint32_t *  pPalette 
)
protected
void Framebuffer::swRect ( size_t  x,
size_t  y,
size_t  width,
size_t  height,
uint32_t  colour,
Graphics::PixelFormat  format 
)
protected
Todo:
Handle 24-bit properly
Todo:
Handle 24-bit properly

Definition at line 502 of file Framebuffer.cc.

References UNLIKELY.

void Framebuffer::swSetPixel ( size_t  x,
size_t  y,
uint32_t  colour,
Graphics::PixelFormat  format = Graphics::Bits32_Argb 
)
private

Sets an individual pixel on the framebuffer. Not inheritable.

Todo:
8-bit

Definition at line 804 of file Framebuffer.cc.

References UNLIKELY.

Member Data Documentation

Display::ScreenMode Framebuffer::m_Mode
private

Copy constructor is private. Current mode.

Definition at line 50 of file modules/drivers/ppc/framebuffer/Framebuffer.h.

size_t Framebuffer::m_XPos

X position on our parent's framebuffer.

Class friendship isn't inheritable, so these have to be public for graphics drivers to use. They shouldn't be touched by anything that isn't a graphics driver.

Definition at line 144 of file system/include/pedigree/kernel/machine/Framebuffer.h.


The documentation for this class was generated from the following files: