(Theoretically) fixed the build

Replaced ServerCursor class with ServerBitmap use
DisplayDriver updated
ScreenDriver now does DrawString and DrawChar (!) and looks good
Fixed stupid jamfile mistakes


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1894 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2002-11-09 21:26:34 +00:00
parent 6cdadea727
commit ab225173d8
27 changed files with 705 additions and 229 deletions
+1
View File
@@ -2,6 +2,7 @@
#include <View.h>
#include "LayerData.h"
#include "ColorUtils.h"
#include "ColorSet.h"
#include "BeDecorator.h"
#include "RGBColor.h"
#include "Desktop.h"
+14 -5
View File
@@ -48,7 +48,7 @@ int8 default_cursor[]={
//--------------------GLOBALS-------------------------
uint32 workspace_count, active_workspace;
BList *desktop;
ServerCursor *startup_cursor;
ServerBitmap *startup_cursor;
Workspace *pactive_workspace;
DisplayDriver *gfxdriver;
int32 token_count=-1;
@@ -145,9 +145,9 @@ printf("init_desktop(%d)\n",workspaces);
workspace_count++;
// Instantiate and initialize display driver
// gfxdriver=new ViewDriver();
gfxdriver=new ViewDriver();
// gfxdriver=new SecondDriver();
gfxdriver=new ScreenDriver();
// gfxdriver=new ScreenDriver();
gfxdriver->Initialize();
workspacelock=new BLocker();
@@ -194,8 +194,17 @@ printf("Driver %s\n", (gfxdriver->IsInitialized()==true)?"initialized":"NOT init
// Clear the screen
pactive_workspace->toplayer->SetColor(RGBColor(80,85,152));
// gfxdriver->Clear(pactive_workspace->toplayer->GetColor());
startup_cursor=new ServerCursor(default_cursor);
gfxdriver->SetCursor(startup_cursor);
// CURSOR_ARROW
startup_cursor=new ServerBitmap('CURS',"CURSOR_DEFAULT");
if(!startup_cursor->InitCheck())
{
// Apparently, something is screwed up beyond recognition in loading the cursor,
// so we'll put in one just so we have something usable.
delete startup_cursor;
startup_cursor=new ServerBitmap(default_cursor);
}
gfxdriver->SetCursor(startup_cursor, BPoint(0,0));
gfxdriver->ShowCursor();
pactive_workspace->toplayer->SetVisible(true);
+13 -3
View File
@@ -5,7 +5,6 @@
*/
#include "DisplayDriver.h"
#include "LayerData.h"
#include "ServerCursor.h"
DisplayDriver::DisplayDriver(void)
{
@@ -71,8 +70,19 @@ void DisplayDriver::ObscureCursor(void)
SetCursorObscured(true);
}
void DisplayDriver::SetCursor(ServerCursor *cursor)
void DisplayDriver::SetCursor(ServerBitmap *cursor, const BPoint &hotspot)
{
SetHotSpot(hotspot);
}
void DisplayDriver::SetHotSpot(const BPoint &pt)
{
cursor_hotspot=pt;
}
BPoint DisplayDriver::GetHotSpot(void)
{
return cursor_hotspot;
}
//---------------------------------------------------------
@@ -147,7 +157,7 @@ void DisplayDriver::SetCursorObscured(bool state)
void DisplayDriver::Shutdown(void) {}
void DisplayDriver::CopyBits(BRect src, BRect dest) {}
void DisplayDriver::DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest) {}
void DisplayDriver::DrawChar(char c, BPoint pt) {}
void DisplayDriver::DrawChar(char c, BPoint pt, LayerData *d) {}
//void DisplayDriver::DrawPicture(SPicture *pic, BPoint pt) {}
void DisplayDriver::DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *delta=NULL) {}
+5 -2
View File
@@ -66,7 +66,7 @@ public:
virtual void Shutdown(void);
virtual void CopyBits(BRect src, BRect dest);
virtual void DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest);
virtual void DrawChar(char c, BPoint pt);
virtual void DrawChar(char c, BPoint pt, 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);
@@ -85,7 +85,7 @@ public:
virtual void InvertRect(BRect r);
virtual void ShowCursor(void);
virtual void ObscureCursor(void);
virtual void SetCursor(ServerCursor *cursor);
virtual void SetCursor(ServerBitmap *cursor, const BPoint &hotspot);
virtual void StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat);
virtual void StrokeBezier(BPoint *pts, LayerData *d, int8 *pat);
@@ -104,6 +104,8 @@ public:
uint16 GetHeight(void);
uint16 GetWidth(void);
int32 GetMode(void);
void SetHotSpot(const BPoint &pt);
BPoint GetHotSpot(void);
protected:
void Lock(void);
@@ -126,6 +128,7 @@ private:
drawing_mode drawmode;
int32 is_cursor_hidden;
bool is_cursor_obscured, cursor_state_changed;
BPoint cursor_hotspot;
};
#endif
+9 -1
View File
@@ -17,11 +17,14 @@ FontStyle::FontStyle(const char *filepath, FT_Face face)
has_kerning=(face->face_flags & FT_FACE_FLAG_KERNING)?true:false;
glyphcount=face->num_glyphs;
charmapcount=face->num_charmaps;
path=new BString(filepath);
fbounds.Set(0,0,0,0);
}
FontStyle::~FontStyle(void)
{
delete name;
delete path;
delete cachedface;
// Mark all instances as Free here
@@ -42,7 +45,7 @@ FontStyle::~FontStyle(void)
const char *FontStyle::Style(void)
{
return name->String();
return path->String();
}
FT_Face FontStyle::GetFace(void)
@@ -51,6 +54,11 @@ FT_Face FontStyle::GetFace(void)
return (FTC_Manager_Lookup_Face(ftmanager,cachedface,&f)!=0)?f:NULL;
}
const char *FontStyle::GetPath(void)
{
return path->String();
}
int16 FontStyle::ConvertToUnicode(uint16 c)
{
FT_Face f;
+3
View File
@@ -2,6 +2,7 @@
#define FONT_FAMILY_H_
#include <String.h>
#include <Rect.h>
#include <Font.h>
#include <List.h>
#include <ft2build.h>
@@ -49,6 +50,7 @@ public:
const char *Style(void);
FontFamily *Family(void) { return family; }
FT_Face GetFace(void);
const char *GetPath(void);
int16 ConvertToUnicode(uint16 c);
protected:
friend FontFamily;
@@ -59,6 +61,7 @@ protected:
bool is_fixedwidth, is_scalable, has_kerning, has_bitmaps;
CachedFace cachedface;
uint8 format;
BRect fbounds;
};
class FontFamily : public SharedObject
-53
View File
@@ -1,53 +0,0 @@
#ifndef FONTINSTANCE_H_
#define FONTINSTANCE_H_
class FontStyle;
#include <Font.h>
class FontInstance
{
public:
FontInstance(void);
FontInstance(float size, float rotation, float shear);
~FontInstance(void);
void SetProperties(float size=12.0, float rotation=0.0, float shear=90.0);
void SetSpacing(uint8 spacing);
void SetFlags(int32 flags);
void SetFace(int32 face);
void SetSize(float size);
void SetRotation(float rotation);
void SetShear(float shear);
void SetEncoding(uint8 encoding);
unicode_block Blocks(void);
BRect BoundingBox(void);
float Rotation(void) { return fRotation; }
float Shear(void) { return fShear; }
float Size(void) { return fSize; }
uint8 Spacing(void) { return fSpacing; }
uint8 Encoding(void) { return fEncoding; }
font_direction Direction(void) { return fDirection; }
FontStyle *Style(void) { return fStyle; }
void Height(font_height *height) { *height=fHeight; }
float fSize,
fRotation,
fShear;
int32 fToken,
fFlags,
fFace;
uint8 fEncoding,
fSpacing;
font_height fHeight;
font_direction fDirection;
FontStyle *fStyle;
};
#endif
+3
View File
@@ -366,6 +366,9 @@ void FontServer::SaveList(void)
// Check to see if it has prerendered strikes (has "tuned" fonts)
sty=fam->GetStyle(styname.String());
if(!sty)
continue;
if(sty->HasTuned() && sty->IsScalable())
tuned=true;
+3 -2
View File
@@ -5,8 +5,9 @@
#include <List.h>
#include <SupportDefs.h>
#include <Font.h>
#include <freetype.h>
#include <ftcache.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_CACHE_H
class FontFamily;
class FontStyle;
+2 -1
View File
@@ -4,8 +4,10 @@ UseFreeTypeHeaders ;
Server OBAppServer :
# Misc. Sources
Angle.cpp
BeDecorator.cpp
ColorUtils.cc
ColorSet.cpp
DebugTools.cpp
Decorator.cpp
PortLink.cpp
@@ -18,7 +20,6 @@ Server OBAppServer :
Layer.cpp
ServerApp.cpp
ServerBitmap.cpp
ServerCursor.cpp
ServerWindow.cpp
WindowBorder.cpp
+8
View File
@@ -2,6 +2,7 @@
#define LAYERDATA_H_
#include <Point.h>
#include <Font.h>
#include "RGBColor.h"
#include "ServerFont.h"
#include "FontServer.h"
@@ -16,12 +17,16 @@ LayerData(void)
pensize=1.0;
penlocation.Set(0,0);
draw_mode=B_OP_COPY;
blending_mode=B_ALPHA_OVERLAY;
alpha_mode=B_CONSTANT_ALPHA;
bitmap_background=NULL;
bitmap_overlay=NULL;
highcolor.SetColor(0,0,0,255);
lowcolor.SetColor(255,255,255,255);
font=fontserver->GetSystemPlain();
scale=1.0;
edelta.space=0;
edelta.nonspace=0;
}
~LayerData(void)
{
@@ -34,11 +39,14 @@ LayerData(void)
float pensize;
BPoint penlocation;
drawing_mode draw_mode;
source_alpha alpha_mode;
alpha_function blending_mode;
ServerBitmap *bitmap_background;
ServerBitmap *bitmap_overlay;
RGBColor highcolor, lowcolor;
ServerFont *font;
float scale;
escapement_delta edelta;
};
extern int8 *solidhigh;
+12
View File
@@ -174,3 +174,15 @@ void RGBColor::PrintToStream(void)
{
printf("RGBColor (%u,%u,%u,%u)\n", color32.red,color32.green,color32.blue,color32.alpha);
}
bool RGBColor::operator==(const rgb_color &col)
{
return (color32.red==col.red && color32.green==col.green
&& color32.blue==col.blue)?true:false;
}
bool RGBColor::operator==(const RGBColor &col)
{
return (color32.red==col.color32.red && color32.green==col.color32.green
&& color32.blue==col.color32.blue)?true:false;
}
+2
View File
@@ -26,6 +26,8 @@ public:
RGBColor MakeBlendColor(RGBColor color, float position);
RGBColor & operator=(const RGBColor &col);
RGBColor & operator=(rgb_color col);
bool operator==(const rgb_color &col);
bool operator==(const RGBColor &col);
protected:
rgb_color color32;
uint16 color16;
+458 -3
View File
@@ -16,12 +16,15 @@
to the video card
Internal functions for doing graphics on the buffer
*/
#include "Angle.h"
#include "ScreenDriver.h"
#include "ServerProtocol.h"
#include "ServerBitmap.h"
#include "ServerCursor.h"
#include "SystemPalette.h"
#include "ColorUtils.h"
#include "PortLink.h"
#include "FontFamily.h"
#include "RGBColor.h"
#include "DebugTools.h"
#include "LayerData.h"
@@ -30,6 +33,7 @@
#include <stdio.h>
#include <string.h>
#include <String.h>
#include <math.h>
//#define DEBUG_DRIVER
#define DEBUG_SERVER_EMU
@@ -1051,8 +1055,8 @@ printf("ScreenDriver::ObscureCursor\n");
BlitBitmap(under_cursor,under_cursor->Bounds(),oldcursorframe);
Unlock();
}
/*
void ScreenDriver::SetCursor(ServerBitmap *csr)
void ScreenDriver::SetCursor(ServerBitmap *csr, const BPoint &spot)
{
#ifdef DEBUG_DRIVER
printf("ScreenDriver::SetCursor\n");
@@ -1074,6 +1078,11 @@ printf("ScreenDriver::SetCursor\n");
cursor=new ServerBitmap(csr);
under_cursor=new ServerBitmap(csr);
if(cursor->Bounds().Contains(spot))
SetHotSpot(spot);
else
SetHotSpot(BPoint(0,0));
cursorframe.right=cursorframe.left+csr->Bounds().Width();
cursorframe.bottom=cursorframe.top+csr->Bounds().Height();
oldcursorframe=cursorframe;
@@ -1085,7 +1094,7 @@ printf("ScreenDriver::SetCursor\n");
Unlock();
}
*/
void ScreenDriver::HLine(int32 x1, int32 x2, int32 y, RGBColor color)
{
// Internal function called from others in the driver
@@ -1293,3 +1302,449 @@ void ScreenDriver::InvertRect(BRect r)
}
Unlock();
}
void ScreenDriver::DrawChar(char c, BPoint pt, LayerData *d)
{
char st[2];
st[0]=c;
st[1]='\0';
DrawString(st,1,pt,d);
}
void ScreenDriver::DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *edelta=NULL)
{
if(!string || !d || !d->font)
return;
pt.y--; // because of Be's backward compatibility hack
ServerFont *font=d->font;
FontStyle *style=font->Style();
if(!style)
return;
FT_Face face;
FT_GlyphSlot slot;
FT_Matrix rmatrix,smatrix;
FT_UInt glyph_index, previous=0;
FT_Vector pen,delta,space,nonspace;
int16 error=0;
int32 strlength,i;
Angle rotation(font->Rotation()), shear(font->Shear());
bool antialias=( (font->Size()<18 && font->Flags()& B_DISABLE_ANTIALIASING==0)
|| font->Flags()& B_FORCE_ANTIALIASING)?true:false;
// Originally, I thought to do this shear checking here, but it really should be
// done in BFont::SetShear()
float shearangle=shear.Value();
if(shearangle>135)
shearangle=135;
if(shearangle<45)
shearangle=45;
if(shearangle>90)
shear=90+((180-shearangle)*2);
else
shear=90-(90-shearangle)*2;
error=FT_New_Face(ftlib, style->GetPath(), 0, &face);
if(error)
{
printf("Couldn't create face object\n");
return;
}
slot=face->glyph;
bool use_kerning=FT_HAS_KERNING(face) && font->Spacing()==B_STRING_SPACING;
error=FT_Set_Char_Size(face, 0,int32(font->Size())*64,72,72);
if(error)
{
printf("Couldn't set character size - error 0x%x\n",error);
return;
}
// if we do any transformation, we do a call to FT_Set_Transform() here
// First, rotate
rmatrix.xx = (FT_Fixed)( rotation.Cosine()*0x10000);
rmatrix.xy = (FT_Fixed)(-rotation.Sine()*0x10000);
rmatrix.yx = (FT_Fixed)( rotation.Sine()*0x10000);
rmatrix.yy = (FT_Fixed)( rotation.Cosine()*0x10000);
// Next, shear
smatrix.xx = (FT_Fixed)(0x10000);
smatrix.xy = (FT_Fixed)(-shear.Cosine()*0x10000);
smatrix.yx = (FT_Fixed)(0);
smatrix.yy = (FT_Fixed)(0x10000);
FT_Matrix_Multiply(&rmatrix,&smatrix);
// Set up the increment value for escapement padding
space.x=int32(d->edelta.space * rotation.Cosine()*64);
space.y=int32(d->edelta.space * rotation.Sine()*64);
nonspace.x=int32(d->edelta.nonspace * rotation.Cosine()*64);
nonspace.y=int32(d->edelta.nonspace * rotation.Sine()*64);
// set the pen position in 26.6 cartesian space coordinates
pen.x=(int32)pt.x * 64;
pen.y=(int32)pt.y * 64;
slot=face->glyph;
strlength=strlen(string);
if(length<strlength)
strlength=length;
for(i=0;i<strlength;i++)
{
FT_Set_Transform(face,&smatrix,&pen);
// Handle escapement padding option
if((uint8)string[i]<=0x20)
{
pen.x+=space.x;
pen.y+=space.y;
}
else
{
pen.x+=nonspace.x;
pen.y+=nonspace.y;
}
// get kerning and move pen
if(use_kerning && previous && glyph_index)
{
FT_Get_Kerning(face, previous, glyph_index,ft_kerning_default, &delta);
pen.x+=delta.x;
pen.y+=delta.y;
}
error=FT_Load_Char(face,string[i],
((antialias)?FT_LOAD_RENDER:FT_LOAD_RENDER | FT_LOAD_MONOCHROME) );
if(!error)
{
if(antialias)
BlitGray2RGB32(&slot->bitmap,
BPoint(slot->bitmap_left,pt.y-(slot->bitmap_top-pt.y)), d);
else
BlitMono2RGB32(&slot->bitmap,
BPoint(slot->bitmap_left,pt.y-(slot->bitmap_top-pt.y)), d);
}
else
printf("Couldn't load character %c\n", string[i]);
// increment pen position
pen.x+=slot->advance.x;
pen.y+=slot->advance.y;
previous=glyph_index;
}
FT_Done_Face(face);
}
void ScreenDriver::BlitMono2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d)
{
rgb_color color=d->highcolor.GetColor32();
// pointers to the top left corner of the area to be copied in each bitmap
uint8 *srcbuffer, *destbuffer;
// index pointers which are incremented during the course of the blit
uint8 *srcindex, *destindex, *rowptr, value;
// increment values for the index pointers
int32 srcinc=src->pitch, destinc=fbuffer->gcinfo.bytes_per_row;
int16 i,j,k, srcwidth=src->pitch, srcheight=src->rows;
int32 x=(int32)pt.x,y=(int32)pt.y;
// starting point in source bitmap
srcbuffer=(uint8*)src->buffer;
if(y<0)
{
if(y<pt.y)
y++;
srcbuffer+=srcinc * (0-y);
srcheight-=srcinc;
destbuffer+=destinc * (0-y);
}
if(y+srcheight>fbuffer->gcinfo.height)
{
if(y>pt.y)
y--;
srcheight-=(y+srcheight-1)-fbuffer->gcinfo.height;
}
if(x+srcwidth>fbuffer->gcinfo.width)
{
if(x>pt.x)
x--;
srcwidth-=(x+srcwidth-1)-fbuffer->gcinfo.width;
}
if(x<0)
{
if(x<pt.x)
x++;
srcbuffer+=(0-x)>>3;
srcwidth-=0-x;
destbuffer+=(0-x)*4;
}
// starting point in destination bitmap
destbuffer=(uint8*)fbuffer->gcinfo.frame_buffer+int32( (pt.y*fbuffer->gcinfo.bytes_per_row)+(pt.x*4) );
srcindex=srcbuffer;
destindex=destbuffer;
for(i=0; i<srcheight; i++)
{
rowptr=destindex;
for(j=0;j<srcwidth;j++)
{
for(k=0; k<8; k++)
{
value=*(srcindex+j) & (1 << (7-k));
if(value)
{
rowptr[0]=color.blue;
rowptr[1]=color.green;
rowptr[2]=color.red;
rowptr[3]=color.alpha;
}
rowptr+=4;
}
}
srcindex+=srcinc;
destindex+=destinc;
}
}
void ScreenDriver::BlitGray2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d)
{
// pointers to the top left corner of the area to be copied in each bitmap
uint8 *srcbuffer=NULL, *destbuffer=NULL;
// index pointers which are incremented during the course of the blit
uint8 *srcindex=NULL, *destindex=NULL, *rowptr=NULL;
rgb_color highcolor=d->highcolor.GetColor32(), lowcolor=d->lowcolor.GetColor32(); float rstep,gstep,bstep,astep;
rstep=float(highcolor.red-lowcolor.red)/255.0;
gstep=float(highcolor.green-lowcolor.green)/255.0;
bstep=float(highcolor.blue-lowcolor.blue)/255.0;
astep=float(highcolor.alpha-lowcolor.alpha)/255.0;
// increment values for the index pointers
int32 x=(int32)pt.x,
y=(int32)pt.y,
srcinc=src->pitch,
// destinc=dest->BytesPerRow(),
destinc=fbuffer->gcinfo.bytes_per_row,
srcwidth=src->width,
srcheight=src->rows,
incval=0;
int16 i,j;
// starting point in source bitmap
srcbuffer=(uint8*)src->buffer;
// starting point in destination bitmap
// destbuffer=(uint8*)dest->Bits()+(y*dest->BytesPerRow()+(x*4));
destbuffer=(uint8*)fbuffer->gcinfo.frame_buffer+(y*fbuffer->gcinfo.bytes_per_row+(x*4));
if(y<0)
{
if(y<pt.y)
y++;
incval=0-y;
srcbuffer+=incval * srcinc;
srcheight-=incval;
destbuffer+=incval * destinc;
}
if(y+srcheight>fbuffer->gcinfo.height)
{
if(y>pt.y)
y--;
srcheight-=(y+srcheight-1)-fbuffer->gcinfo.height;
}
if(x+srcwidth>fbuffer->gcinfo.width)
{
if(x>pt.x)
x--;
srcwidth-=(x+srcwidth-1)-fbuffer->gcinfo.width;
}
if(x<0)
{
if(x<pt.x)
x++;
incval=0-x;
srcbuffer+=incval;
srcwidth-=incval;
destbuffer+=incval*4;
}
int32 value;
srcindex=srcbuffer;
destindex=destbuffer;
for(i=0; i<srcheight; i++)
{
rowptr=destindex;
for(j=0;j<srcwidth;j++)
{
value=*(srcindex+j) ^ 255;
if(value!=255)
{
if(d->draw_mode==B_OP_COPY)
{
rowptr[0]=uint8(highcolor.blue-(value*bstep));
rowptr[1]=uint8(highcolor.green-(value*gstep));
rowptr[2]=uint8(highcolor.red-(value*rstep));
rowptr[3]=255;
}
else
if(d->draw_mode==B_OP_OVER)
{
if(highcolor.alpha>127)
{
rowptr[0]=uint8(highcolor.blue-(value*(float(highcolor.blue-rowptr[0])/255.0)));
rowptr[1]=uint8(highcolor.green-(value*(float(highcolor.green-rowptr[1])/255.0)));
rowptr[2]=uint8(highcolor.red-(value*(float(highcolor.red-rowptr[2])/255.0)));
rowptr[3]=255;
}
}
}
rowptr+=4;
}
srcindex+=srcinc;
destindex+=destinc;
}
}
rgb_color ScreenDriver::GetBlitColor(rgb_color src, rgb_color dest, LayerData *d, bool use_high=true)
{
rgb_color returncolor={0,0,0,0};
int16 value;
if(!d)
return returncolor;
switch(d->draw_mode)
{
case B_OP_COPY:
{
return src;
}
case B_OP_ADD:
{
value=src.red+dest.red;
returncolor.red=(value>255)?255:value;
value=src.green+dest.green;
returncolor.green=(value>255)?255:value;
value=src.blue+dest.blue;
returncolor.blue=(value>255)?255:value;
return returncolor;
}
case B_OP_SUBTRACT:
{
value=src.red-dest.red;
returncolor.red=(value<0)?0:value;
value=src.green-dest.green;
returncolor.green=(value<0)?0:value;
value=src.blue-dest.blue;
returncolor.blue=(value<0)?0:value;
return returncolor;
}
case B_OP_BLEND:
{
value=int16(src.red+dest.red)>>1;
returncolor.red=value;
value=int16(src.green+dest.green)>>1;
returncolor.green=value;
value=int16(src.blue+dest.blue)>>1;
returncolor.blue=value;
return returncolor;
}
case B_OP_MIN:
{
return ( uint16(src.red+src.blue+src.green) >
uint16(dest.red+dest.blue+dest.green) )?dest:src;
}
case B_OP_MAX:
{
return ( uint16(src.red+src.blue+src.green) <
uint16(dest.red+dest.blue+dest.green) )?dest:src;
}
case B_OP_OVER:
{
return (use_high && src.alpha>127)?src:dest;
}
case B_OP_INVERT:
{
returncolor.red=dest.red ^ 255;
returncolor.green=dest.green ^ 255;
returncolor.blue=dest.blue ^ 255;
return (use_high && src.alpha>127)?returncolor:dest;
}
// This is a pain in the arse to implement, so I'm saving it for the real
// server
case B_OP_ALPHA:
{
return src;
}
case B_OP_ERASE:
{
// This one's tricky.
return (use_high && src.alpha>127)?d->lowcolor.GetColor32():dest;
}
case B_OP_SELECT:
{
// This one's tricky, too. We are passed a color in src. If it's the layer's
// high color or low color, we check for a swap.
if(d->highcolor==src)
return (use_high && d->highcolor==dest)?d->lowcolor.GetColor32():dest;
if(d->lowcolor==src)
return (use_high && d->lowcolor==dest)?d->highcolor.GetColor32():dest;
return dest;
}
default:
{
break;
}
}
return returncolor;
}
+9 -3
View File
@@ -11,6 +11,9 @@
#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;
@@ -49,9 +52,9 @@ public:
// Settings functions
// virtual void CopyBits(BRect src, BRect dest);
virtual void DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest);
// virtual void DrawChar(char c, BPoint pt);
// 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 DrawChar(char c, BPoint pt, LayerData *d);
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);
@@ -67,7 +70,7 @@ public:
virtual void InvertRect(BRect r);
virtual void ShowCursor(void);
virtual void ObscureCursor(void);
// virtual void SetCursor(ServerBitmap *cursor);
virtual void SetCursor(ServerBitmap *cursor, const BPoint &spot);
// virtual void StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat);
// virtual void StrokeBezier(BPoint *pts, LayerData *d, int8 *pat);
@@ -82,10 +85,13 @@ public:
virtual void SetMode(int32 mode);
// 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);
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);
+2 -2
View File
@@ -411,8 +411,8 @@ printf("ServerApp: ActivateWorkspace(%ld)\n",*((int32*)index));
memcpy(cdata, buffer, 68);
if(cursor)
delete cursor;
cursor=new ServerCursor(cdata);
driver->SetCursor(cursor);
cursor=new ServerBitmap(cdata);
driver->SetCursor(cursor,BPoint(cdata[2],cdata[3]));
#ifdef DEBUG_SERVERAPP_CURSOR
printf("ServerApp: SetCursor(%d,%d,%d,%d)\n",r,g,b,a);
#endif
+1 -1
View File
@@ -28,7 +28,7 @@ public:
thread_id monitor_thread;
PortLink *applink;
BList *winlist, *bmplist;
ServerCursor *cursor;
ServerBitmap *cursor;
DisplayDriver *driver;
rgb_color high, low; // just for testing until layers are implemented
+126 -5
View File
@@ -12,7 +12,6 @@
#include <string.h>
#include <Bitmap.h>
#include <assert.h>
#include "ServerBitmap.h"
#include "Desktop.h"
#include "DisplayDriver.h"
@@ -23,8 +22,16 @@
#include <stdio.h>
#endif
long pow2(int power)
{
if(power==0)
return 1;
return long(2 << (power-1));
}
ServerBitmap::ServerBitmap(BRect rect,color_space space,int32 BytesPerLine=0)
{
is_initialized=true;
width=rect.IntegerWidth()+1;
height=rect.IntegerHeight()+1;
cspace=space;
@@ -36,6 +43,7 @@ ServerBitmap::ServerBitmap(BRect rect,color_space space,int32 BytesPerLine=0)
ServerBitmap::ServerBitmap(int32 w,int32 h,color_space space,int32 BytesPerLine=0)
{
is_initialized=true;
width=w;
height=h;
cspace=space;
@@ -45,22 +53,22 @@ ServerBitmap::ServerBitmap(int32 w,int32 h,color_space space,int32 BytesPerLine=
buffer=new uint8[bytesperline*height];
}
// This particular version is not intended for use except for testing purposes.
// It loads a BBitmap and copies it to the ServerBitmap. Probably will disappear
// when the *real* server is written
// This loads a bitmap from disk, given a path
ServerBitmap::ServerBitmap(const char *path)
{
is_initialized=true;
if(!path)
{
width=0;
height=0;
cspace=B_NO_COLOR_SPACE;
bytesperline=0;
is_initialized=false;
buffer=NULL;
return;
}
BBitmap *bmp=BTranslationUtils::GetBitmap(path);
assert(bmp!=NULL);
if(bmp==NULL)
{
@@ -68,6 +76,59 @@ ServerBitmap::ServerBitmap(const char *path)
height=0;
cspace=B_NO_COLOR_SPACE;
bytesperline=0;
is_initialized=false;
buffer=NULL;
}
else
{
width=bmp->Bounds().IntegerWidth();
height=bmp->Bounds().IntegerHeight();
cspace=bmp->ColorSpace();
bytesperline=bmp->BytesPerRow();
buffer=new uint8[bmp->BitsLength()];
memcpy(buffer,(void *)bmp->Bits(),bmp->BitsLength());
}
}
// Load a bitmap from a resource file
ServerBitmap::ServerBitmap(uint32 type,int32 id)
{
is_initialized=true;
BBitmap *bmp=BTranslationUtils::GetBitmap(type,id);
if(bmp==NULL)
{
width=0;
height=0;
cspace=B_NO_COLOR_SPACE;
bytesperline=0;
is_initialized=false;
buffer=NULL;
}
else
{
width=bmp->Bounds().IntegerWidth();
height=bmp->Bounds().IntegerHeight();
cspace=bmp->ColorSpace();
bytesperline=bmp->BytesPerRow();
buffer=new uint8[bmp->BitsLength()];
memcpy(buffer,(void *)bmp->Bits(),bmp->BitsLength());
}
}
ServerBitmap::ServerBitmap(uint32 type, const char *name)
{
is_initialized=true;
BBitmap *bmp=BTranslationUtils::GetBitmap(type,name);
if(bmp==NULL)
{
width=0;
height=0;
cspace=B_NO_COLOR_SPACE;
bytesperline=0;
is_initialized=false;
buffer=NULL;
}
else
{
@@ -82,6 +143,7 @@ ServerBitmap::ServerBitmap(const char *path)
ServerBitmap::ServerBitmap(ServerBitmap *bitmap)
{
is_initialized=true;
width=bitmap->width;
height=bitmap->height;
cspace=bitmap->cspace;
@@ -92,6 +154,65 @@ ServerBitmap::ServerBitmap(ServerBitmap *bitmap)
memcpy(buffer, bitmap->buffer, bytesperline * height);
}
ServerBitmap::ServerBitmap(int8 *data)
{
// 68-byte array used in R5 for holding cursors.
// This API has serious problems and should be deprecated(but supported) in R2
// Now that we have all the setup, we're going to map (for now) the cursor
// to RGBA32. Eventually, there will be support for 16 and 8-bit depths
is_initialized=true;
if(data)
{
uint32 black=0xFF000000,
white=0xFFFFFFFF,
*bmppos;
uint16 *cursorpos, *maskpos,cursorflip, maskflip,
cursorval, maskval;
uint8 i,j;
cursorpos=(uint16*)(data+4);
maskpos=(uint16*)(data+36);
buffer=new uint8[1024]; // 16x16x4 - RGBA32 space
width=16;
height=16;
bytesperline=64;
// for each row in the cursor data
for(j=0;j<16;j++)
{
bmppos=(uint32*)(buffer+ (j*64) );
// On intel, our bytes end up swapped, so we must swap them back
cursorflip=(cursorpos[j] & 0xFF) << 8;
cursorflip |= (cursorpos[j] & 0xFF00) >> 8;
maskflip=(maskpos[j] & 0xFF) << 8;
maskflip |= (maskpos[j] & 0xFF00) >> 8;
// for each column in each row of cursor data
for(i=0;i<16;i++)
{
// Get the values and dump them to the bitmap
cursorval=cursorflip & pow2(15-i);
maskval=maskflip & pow2(15-i);
bmppos[i]=((cursorval!=0)?black:white) & ((maskval>0)?0xFFFFFFFF:0x00FFFFFF);
}
}
}
else
{
buffer=NULL;
width=0;
height=0;
bytesperline=0;
}
#ifdef DEBUG_SERVER_CURSOR
PrintToStream();
#endif
}
ServerBitmap::~ServerBitmap(void)
{
if(buffer)
+5
View File
@@ -14,6 +14,9 @@ public:
ServerBitmap(int32 w,int32 h,color_space space,int32 BytesPerLine=0);
ServerBitmap(const char *path);
ServerBitmap(ServerBitmap *bitmap);
ServerBitmap(uint32 type, int32 id);
ServerBitmap(int8 *data);
ServerBitmap(uint32 type, const char *name);
~ServerBitmap(void);
void UpdateSettings(void);
void SetBuffer(void *ptr) { buffer=(uint8*)ptr; }
@@ -26,6 +29,7 @@ public:
int32 BytesPerRow(void) { return bytesperline; };
uint8 BitsPerPixel(void) { return bpp; }
color_space ColorSpace(void) { return cspace; }
const bool &InitCheck(void) { return is_initialized; }
int32 width,height;
int32 bytesperline;
@@ -33,6 +37,7 @@ public:
int bpp;
protected:
bool is_initialized;
void HandleSpace(color_space space, int32 BytesPerLine);
DisplayDriver *driver;
area_id areaid;
-113
View File
@@ -1,113 +0,0 @@
/*
ServerCursor.cpp
This is the server-side class used to handle cursors. Note that it
will handle the R5 cursor API, but it will also handle taking a bitmap.
ServerCursors are 32-bit. Eventually, we will be mapping colors to fit
when the set is called.
This is new code, and there may be changes to the API before it settles
in.
*/
#include "ServerCursor.h"
#include <stdio.h>
#include <math.h>
long pow2(int power)
{
if(power==0)
return 1;
return long(2 << (power-1));
}
//#define DEBUG_SERVER_CURSOR
/*
ServerCursor::ServerCursor(ServerBitmap *bmp, ServerBitmap *cmask=NULL)
{
// The OpenBeOS R1 API can use Bitmaps to create cursors - more flexibility that way.
}
*/
ServerCursor::ServerCursor(int8 *data)
{
// 68-byte array used in R5 for holding cursors.
// This API has serious problems and should be deprecated(but supported) in R2
// Now that we have all the setup, we're going to map (for now) the cursor
// to RGBA32. Eventually, there will be support for 16 and 8-bit depths
if(data)
{
uint32 black=0xFF000000,
white=0xFFFFFFFF,
*bmppos;
uint16 *cursorpos, *maskpos,cursorflip, maskflip,
cursorval, maskval;
uint8 i,j;
cursorpos=(uint16*)(data+4);
maskpos=(uint16*)(data+36);
buffer=new uint8[1024]; // 16x16x4 - RGBA32 space
width=16;
height=16;
bytesperline=64;
// for each row in the cursor data
for(j=0;j<16;j++)
{
bmppos=(uint32*)(buffer+ (j*64) );
// On intel, our bytes end up swapped, so we must swap them back
cursorflip=(cursorpos[j] & 0xFF) << 8;
cursorflip |= (cursorpos[j] & 0xFF00) >> 8;
maskflip=(maskpos[j] & 0xFF) << 8;
maskflip |= (maskpos[j] & 0xFF00) >> 8;
// for each column in each row of cursor data
for(i=0;i<16;i++)
{
// Get the values and dump them to the bitmap
cursorval=cursorflip & pow2(15-i);
maskval=maskflip & pow2(15-i);
bmppos[i]=((cursorval!=0)?black:white) & ((maskval>0)?0xFFFFFFFF:0x00FFFFFF);
}
}
}
else
{
buffer=NULL;
width=0;
height=0;
bytesperline=0;
}
#ifdef DEBUG_SERVER_CURSOR
PrintToStream();
#endif
}
ServerCursor::~ServerCursor(void)
{
if(buffer)
delete buffer;
}
void ServerCursor::PrintToStream(void)
{
if(!buffer)
{
printf("ServerCursor with NULL buffer\n");
return;
}
rgb_color *color=(rgb_color*)buffer;
printf("Server Cursor\n");
for(int32 i=0; i<height; i++)
{
for(int32 j=0; j<width; j++)
printf("%c ", (color[(i*height)+j].alpha>0)?'*':'.');
printf("\n");
}
}
-26
View File
@@ -1,26 +0,0 @@
#ifndef _SERVER_CURSOR_H
#define _SERVER_CURSOR_H
#include <GraphicsDefs.h>
#include <Rect.h>
#include "ServerBitmap.h"
class ServerCursor
{
public:
// ServerCursor(ServerBitmap *bmp,ServerBitmap *cmask=NULL);
ServerCursor(int8 *data);
~ServerCursor(void);
BRect Bounds() { return BRect(0,0,width-1,height-1); };
uint8 *Buffer(void) const { return buffer;}
int32 Width(void) const { return width; }
int32 Height(void) const { return height; }
int32 BytesPerLine(void) const { return bytesperline; };
void PrintToStream(void);
protected:
uint8 *buffer;
int32 width,height;
int32 bytesperline;
};
#endif
+13
View File
@@ -21,6 +21,7 @@ ServerFont::ServerFont(FontStyle *style, float size=12.0, float rotation=0.0, fl
fface=B_REGULAR_FACE;
ftruncate=B_TRUNCATE_END;
fencoding=B_UNICODE_UTF8;
fbounds.Set(0,0,0,0);
if(fstyle)
fstyle->AddDependent();
}
@@ -37,6 +38,7 @@ ServerFont::ServerFont(const ServerFont &font)
fface=font.fface;
ftruncate=font.ftruncate;
fencoding=font.fencoding;
fbounds.Set(0,0,0,0);
if(fstyle)
fstyle->AddDependent();
}
@@ -56,6 +58,17 @@ escapement_delta Escapements(char c)
{
}
*/
const BRect &ServerFont::BoundingBox(void)
{
return fbounds;
}
BRect ServerFont::StringBounds(const char *string)
{
return BRect(0,0,0,0);
}
void ServerFont::Height(font_height *fh)
{
fh->ascent=fheight.ascent;
+3 -2
View File
@@ -35,16 +35,17 @@ public:
void SetRotation(const float &value) { frotation=value; }
void SetFace(const uint16 &value) { fface=value; }
// BRect BoundingBox(void);
const BRect &BoundingBox(void);
BRect StringBounds(const char *string);
// escapement_delta Escapements(char c);
void Height(font_height *fh);
protected:
friend FontStyle;
FontStyle *fstyle;
font_height fheight;
escapement_delta fescapements;
edge_info fedges;
float fsize, frotation, fshear;
BRect fbounds;
uint32 fflags;
uint8 fspacing;
uint16 fface;
+9 -4
View File
@@ -732,7 +732,7 @@ void ViewDriver::MoveCursorTo(float x, float y)
screenwin->Unlock();
}
void ViewDriver::SetCursor(ServerCursor *cursor)
void ViewDriver::SetCursor(ServerBitmap *cursor, const BPoint &spot)
{
#ifdef DEBUG_DRIVER_MODULE
printf("ViewDriver:: SetCursor(%p)\n",cursor);
@@ -743,14 +743,19 @@ printf("ViewDriver:: SetCursor(%p)\n",cursor);
BBitmap *bmp=new BBitmap(cursor->Bounds(),B_RGBA32);
// Copy the server bitmap in the cursor to a BBitmap
uint8 *sbmppos=(uint8*)cursor->Buffer(),
uint8 *sbmppos=(uint8*)cursor->Bits(),
*bbmppos=(uint8*)bmp->Bits();
int32 bytes=cursor->BytesPerLine(),
int32 bytes=cursor->BytesPerRow(),
bbytes=bmp->BytesPerRow();
for(int i=0;i<cursor->Height();i++)
for(int i=0;i<=cursor->Bounds().IntegerHeight();i++)
memcpy(bbmppos+(i*bbytes), sbmppos+(i*bytes), bytes);
if(cursor->Bounds().Contains(spot))
SetHotSpot(spot);
else
SetHotSpot(BPoint(0,0));
// Replace the bitmap
delete screenwin->view->cursor;
+1 -1
View File
@@ -84,7 +84,7 @@ public:
void ObscureCursor(void);
// BPoint PenPosition(void);
// float PenSize(void);
void SetCursor(ServerCursor *cursor);
void SetCursor(ServerBitmap *cursor, const BPoint &spot);
// drawing_mode GetDrawingMode(void);
// void SetDrawingMode(drawing_mode mode);
void ShowCursor(void);
@@ -4,14 +4,15 @@
kept on the client side.
*/
#include "ClientFontList.h"
#include <File.h>
#include <Message.h>
#include <String.h>
#include <stdio.h>
#include <string.h>
#include <String.h>
#include "PortLink.h"
#include "ServerProtocol.h"
#include "ClientFontList.h"
#define DEBUG_CLIENT_FONT_LIST
+1 -1
View File
@@ -10,4 +10,4 @@ App proto7_test_app :
<$(SOURCE_GRIST)>OBWindow.cpp
<$(SOURCE_GRIST)>PortLink.cpp
;
LinkSharedOSLibs OBApplication : be stdc++.r4 ;
LinkSharedOSLibs proto7_test_app : be stdc++.r4 ;