Ported and added prototype #7's ScreenDriver and ViewDriver

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2593 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm 2003-01-28 23:58:06 +00:00
parent 42941d8728
commit 8ccf453d5e
7 changed files with 4046 additions and 0 deletions

View File

@ -26,6 +26,17 @@
//------------------------------------------------------------------------------
#include "DisplayDriver.h"
#include "Desktop.h"
#ifdef VIEWDRIVER
#include "ViewDriver.h"
#endif
#ifdef SCREENDRIVER
#include "ScreenDriver.h"
#endif
#ifdef HWDRIVER
#include "AccelerantDriver.h"
#endif
//#include "ServerWindow.h"
namespace desktop_private {

View File

@ -38,8 +38,10 @@ Server app_server :
Decorator.cpp
DisplayDriver.cpp
Layer.cpp
ScreenDriver.cpp
ServerBitmap.cpp
ServerCursor.cpp
ViewDriver.cpp
;
LinkSharedOSLibs app_server : be root game translation
<boot!home!config!lib>libfreetype.so ;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,158 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: ScreenDriver.h
// Author: DarkWyrm <bpmagic@columbus.rr.com>
// Description: BWindowScreen graphics module
//
//------------------------------------------------------------------------------
#ifndef _SCREENDRIVER_H_
#define _SCREENDRIVER_H_
#include <Application.h>
#include <WindowScreen.h>
#include <View.h>
#include <GraphicsCard.h>
#include <Message.h>
#include <OS.h>
#include <Locker.h>
#include <Region.h> // for clipping_rect definition
#include <Bitmap.h>
#include "DisplayDriver.h"
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
class VDWindow;
class ServerCursor;
class ServerBitmap;
class RGBColor;
class PortLink;
class FrameBuffer : public BWindowScreen
{
public:
FrameBuffer(const char *title, uint32 space, status_t *st,bool debug);
~FrameBuffer(void);
void ScreenConnected(bool connected);
void MessageReceived(BMessage *msg);
bool IsConnected(void) const { return is_connected; }
bool QuitRequested(void);
graphics_card_info gcinfo;
protected:
bool is_connected;
PortLink *serverlink;
BPoint mousepos;
uint32 buttons;
};
/*
ScreenDriver.cpp
Replacement class for the ViewDriver which utilizes a BWindowScreen for ease
of testing without requiring a second video card for SecondDriver and also
without the limitations (mostly speed) of ViewDriver.
This module also emulates the input server via the keyboard.
Cursor keys move the mouse and the left modifier keys Option and Ctrl, which
operate the first and second mouse buttons, respectively.
The right window key on American keymaps doesn't map to anything, so it is
not used. Consequently, when a right modifier key is pressed, it works normally.
The concept is pretty close to the retooled ViewDriver, where each module
call locks a couple BLockers and draws to the buffer.
Components:
ScreenDriver: actual driver module
FrameBuffer: BWindowScreen derivative which provides the module access
to the video card
Internal functions for doing graphics on the buffer
*/
class ScreenDriver : public DisplayDriver
{
public:
ScreenDriver(void);
~ScreenDriver(void);
bool Initialize(void);
void Shutdown(void);
// Settings functions
// virtual void CopyBits(BRect src, BRect dest);
virtual void DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest, LayerData *d);
// virtual void DrawPicture(SPicture *pic, BPoint pt);
virtual void DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *delta=NULL);
// virtual void FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat);
// virtual void FillBezier(BPoint *pts, LayerData *d, int8 *pat);
virtual void FillEllipse(BRect r, LayerData *d, int8 *pat);
// virtual void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat);
virtual void FillRect(BRect r, LayerData *d, int8 *pat);
virtual void FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat);
// virtual void FillShape(SShape *sh, LayerData *d, int8 *pat);
virtual void FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat);
virtual void HideCursor(void);
virtual void MoveCursorTo(float x, float y);
virtual void InvertRect(BRect r);
virtual void ShowCursor(void);
virtual void ObscureCursor(void);
virtual void SetCursor(ServerCursor *cursor);
virtual void StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat);
virtual void StrokeBezier(BPoint *pts, LayerData *d, int8 *pat);
virtual void StrokeEllipse(BRect r, LayerData *d, int8 *pat);
virtual void StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat);
virtual void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed=true);
virtual void StrokeRect(BRect r, LayerData *d, int8 *pat);
virtual void StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat);
// virtual void StrokeShape(SShape *sh, LayerData *d, int8 *pat);
virtual void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat);
// virtual void StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d);
virtual void SetMode(int32 mode);
float StringWidth(const char *string, int32 length, LayerData *d);
float StringHeight(const char *string, int32 length, LayerData *d);
// virtual bool DumpToFile(const char *path);
protected:
void BlitMono2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d);
void BlitGray2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d);
void BlitBitmap(ServerBitmap *sourcebmp, BRect sourcerect, BRect destrect, drawing_mode mode=B_OP_COPY);
void ExtractToBitmap(ServerBitmap *destbmp, BRect destrect, BRect sourcerect);
void SetPixelPattern(int x, int y, uint8 *pattern, uint8 patternindex);
void Line(BPoint start, BPoint end, LayerData *d, int8 *pat);
void HLine(int32 x1, int32 x2, int32 y, RGBColor color);
rgb_color GetBlitColor(rgb_color src, rgb_color dest, LayerData *d, bool use_high=true);
void SetPixel(int x, int y, RGBColor col);
void SetPixel32(int x, int y, rgb_color col);
void SetPixel16(int x, int y, uint16 col);
void SetPixel8(int x, int y, uint8 col);
void SetThickPixel(int x, int y, int thick, RGBColor col);
void SetThickPixel32(int x, int y, int thick, rgb_color col);
void SetThickPixel16(int x, int y, int thick, uint16 col);
void SetThickPixel8(int x, int y, int thick, uint8 col);
FrameBuffer *fbuffer;
ServerCursor *cursor, *under_cursor;
int32 drawmode;
BRect cursorframe;
};
#endif

View File

@ -23,6 +23,10 @@
// Display driver to be used by the server.
#define DISPLAYDRIVER VIEWDRIVER
// Define this if you want the display driver to emulate the input server.
// Comment this out if DISPLAYDRIVER is defined as HWDRIVER.
#define ENABLE_INPUT_SERVER_EMULATION
// Server port names. The input port is the port which is used to receive
// input messages from the Input Server. The other is the "main" port for
// the server and is utilized mostly by BApplication objects.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,170 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: ViewDriver.h
// Author: DarkWyrm <bpmagic@columbus.rr.com>
// Description: BView/BWindow combination graphics module
//
//------------------------------------------------------------------------------
#ifndef _VIEWDRIVER_H_
#define _VIEWDRIVER_H_
#include <Application.h>
#include <Window.h>
#include <View.h>
#include <GraphicsCard.h>
#include <GraphicsDefs.h> // for pattern struct
#include <Cursor.h>
#include <Message.h>
#include <Region.h>
#include <Font.h>
#include "DisplayDriver.h"
#include <ft2build.h>
#include FT_FREETYPE_H
class BBitmap;
class PortLink;
class VDWindow;
class LayerData;
class VDView : public BView
{
public:
VDView(BRect bounds);
~VDView(void);
void AttachedToWindow(void);
void Draw(BRect rect);
void MouseDown(BPoint pt);
void MouseMoved(BPoint pt, uint32 transit, const BMessage *msg);
void MouseUp(BPoint pt);
BBitmap *viewbmp;
PortLink *serverlink;
int hide_cursor;
BBitmap *cursor;
BRect cursorframe, oldcursorframe;
bool obscure_cursor;
};
class VDWindow : public BWindow
{
public:
VDWindow(void);
~VDWindow(void);
void MessageReceived(BMessage *msg);
bool QuitRequested(void);
void WindowActivated(bool active);
VDView *view;
};
/*!
\brief BView/BWindow combination graphics module
First, slowest, and easiest driver class in the app_server which is designed
to utilize the BeOS graphics functions to cut out a lot of junk in getting the
drawing infrastructure in this server.
The concept is to have VDView::Draw() draw a bitmap, which is a "frame buffer"
of sorts, utilize a second view to write to it. This cuts out
the most problems with having a crapload of code to get just right without
having to write a bunch of unit tests
Components: 3 classes, VDView, VDWindow, and ViewDriver
ViewDriver - a wrapper class which mostly posts messages to the VDWindow
VDWindow - does most of the work.
VDView - doesn't do all that much except display the rendered bitmap
*/
class ViewDriver : public DisplayDriver
{
public:
ViewDriver(void);
~ViewDriver(void);
bool Initialize(void); // Sets the driver
void Shutdown(void); // You never know when you'll need this
// Drawing functions
void CopyBits(BRect src, BRect dest);
void DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest);
void DrawChar(char c, BPoint pt, LayerData *d);
// virtual void DrawPicture(SPicture *pic, BPoint pt);
void DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *delta=NULL);
void FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat);
void FillBezier(BPoint *pts, LayerData *d, int8 *pat);
void FillEllipse(BRect r, LayerData *d, int8 *pat);
void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat);
void FillRect(BRect r, LayerData *d, int8 *pat);
void FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat);
// void FillShape(SShape *sh, LayerData *d, int8 *pat);
void FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat);
void HideCursor(void);
void InvertRect(BRect r);
bool IsCursorHidden(void);
void MoveCursorTo(float x, float y);
// void MovePenTo(BPoint pt);
void ObscureCursor(void);
// BPoint PenPosition(void);
// float PenSize(void);
void SetCursor(ServerCursor *cursor);
// drawing_mode GetDrawingMode(void);
// void SetDrawingMode(drawing_mode mode);
void ShowCursor(void);
void StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat);
void StrokeBezier(BPoint *pts, LayerData *d, int8 *pat);
void StrokeEllipse(BRect r, LayerData *d, int8 *pat);
void StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat);
void StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d);
void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed=true);
void StrokeRect(BRect r, LayerData *d, int8 *pat);
void StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat);
// void StrokeShape(SShape *sh, LayerData *d, int8 *pat);
void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat);
void SetMode(int32 mode);
float StringWidth(const char *string, int32 length, LayerData *d);
float StringHeight(const char *string, int32 length, LayerData *d);
// bool DumpToFile(const char *path);
VDWindow *screenwin;
protected:
void SetLayerData(LayerData *d, bool set_font_data=false);
void BlitMono2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d);
void BlitGray2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d);
rgb_color GetBlitColor(rgb_color src, rgb_color dest, LayerData *d, bool use_high=true);
int hide_cursor;
bool obscure_cursor;
BBitmap *framebuffer;
BView *drawview;
BRegion laregion;
PortLink *serverlink;
// drawing_mode drawmode;
rgb_color highcolor,lowcolor;
bool is_initialized;
};
#endif