refactoring and cleanup in LayerData and friends, it shows what I mean by "forced code paths" for example in coupled font size and view scale, added a couple TODOs, disabled decoupled frame buffer transfers, it is buggy and deadlocks for some reason...

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12441 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2005-04-19 00:42:42 +00:00
parent 52c415a86c
commit e742e3e106
12 changed files with 890 additions and 497 deletions

View File

@ -1,5 +1,5 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Copyright (c) 2001-2002, Haiku, Inc. // Copyright (c) 2001-2005, Haiku, Inc.
// //
// Permission is hereby granted, free of charge, to any person obtaining a // Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"), // copy of this software and associated documentation files (the "Software"),
@ -22,82 +22,223 @@
// File Name: LayerData.h // File Name: LayerData.h
// Author: DarkWyrm <bpmagic@columbus.rr.com> // Author: DarkWyrm <bpmagic@columbus.rr.com>
// Adi Oanca <adioanca@mymail.ro> // Adi Oanca <adioanca@mymail.ro>
// Stephan Aßmus <superstippi@gmx.de>
// Description: Data classes for working with BView states and draw parameters // Description: Data classes for working with BView states and draw parameters
// //
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#ifndef LAYERDATA_H_ #ifndef LAYER_DATA_H_
#define LAYERDATA_H_ #define LAYER_DATA_H_
#include <Point.h>
#include <Font.h>
#include <Region.h>
#include <RGBColor.h>
#include <FontServer.h>
#include <ServerFont.h>
#include <PatternHandler.h>
#include <GraphicsDefs.h> #include <GraphicsDefs.h>
#include <InterfaceDefs.h> #include <InterfaceDefs.h>
#include <Point.h>
#include <View.h> // for B_FONT_ALL
#include "RGBColor.h"
#include "FontServer.h"
#include "ServerFont.h"
#include "PatternHandler.h"
class BRegion;
class LinkMsgReader;
class LinkMsgSender;
class ServerBitmap; class ServerBitmap;
class ServerFont;
class ServerPicture;
class Layer;
class DrawData class DrawData {
{ public:
public: DrawData();
DrawData(void); DrawData(const DrawData& from);
DrawData(const DrawData &data); virtual ~DrawData();
virtual ~DrawData(void);
DrawData& operator=(const DrawData &from);
// TODO: uncomment and implement DrawData::PrintToStream when needed.
// virtual void PrintToStream() const;
BPoint penlocation; DrawData& operator=(const DrawData& from);
RGBColor highcolor, // coordinate transformation
lowcolor; void SetOrigin(const BPoint& origin);
inline const BPoint& Origin() const
{ return fOrigin; }
float pensize; void SetScale(float scale);
Pattern patt; inline float Scale() const
drawing_mode draw_mode; { return fScale; }
cap_mode lineCap; // additional clipping as requested by client
join_mode lineJoin; void SetClippingRegion(const BRegion& region);
float miterLimit; inline const BRegion* ClippingRegion() const
{ return fClippingRegion; }
source_alpha alphaSrcMode; /* inline int32 CountClippingRects() const
alpha_function alphaFncMode; { return fClippingRegion ? fClippingRegion.CountRects() : 0; }
float scale; inline BRect ClippingRectAt(int32 index) const;*/
bool fontAliasing;
ServerFont font; // color
void SetHighColor(const RGBColor& color);
BRegion* clipReg; inline const RGBColor& HighColor() const
{ return fHighColor; }
escapement_delta edelta;
void SetLowColor(const RGBColor& color);
inline const RGBColor& LowColor() const
{ return fLowColor; }
void SetPattern(const Pattern& pattern);
inline const Pattern& GetPattern() const
{ return fPattern; }
// drawing/blending mode
void SetDrawingMode(drawing_mode mode);
inline drawing_mode GetDrawingMode() const
{ return fDrawingMode; }
void SetBlendingMode(source_alpha srcMode,
alpha_function fncMode);
inline source_alpha AlphaSrcMode() const
{ return fAlphaSrcMode; }
inline alpha_function AlphaFncMode() const
{ return fAlphaFncMode; }
// pen
void SetPenLocation(const BPoint& location);
const BPoint& PenLocation() const;
void SetPenSize(float size);
float PenSize() const;
// font
void SetFont(const ServerFont& font,
uint32 flags = B_FONT_ALL);
inline const ServerFont& Font() const
{ return fFont; }
void SetFontAntiAliasing(bool antiAliasing);
inline bool FontAntiAliasing() const
{ return fFontAntiAliasing; }
void SetEscapementDelta(escapement_delta delta);
inline escapement_delta EscapementDelta() const
{ return fEscapementDelta; }
// postscript style settings
void SetLineCapMode(cap_mode mode);
inline cap_mode LineCapMode() const
{ return fLineCapMode; }
void SetLineJoinMode(join_mode mode);
inline join_mode LineJoinMode() const
{ return fLineJoinMode; }
void SetMiterLimit(float limit);
inline float MiterLimit() const
{ return fMiterLimit; }
// convenience functions
inline BPoint Transform(const BPoint& point) const;
inline BRect Transform(const BRect& rect) const;
protected:
BPoint fOrigin;
float fScale;
BRegion* fClippingRegion;
RGBColor fHighColor;
RGBColor fLowColor;
Pattern fPattern;
drawing_mode fDrawingMode;
source_alpha fAlphaSrcMode;
alpha_function fAlphaFncMode;
BPoint fPenLocation;
float fPenSize;
ServerFont fFont;
bool fFontAntiAliasing;
escapement_delta fEscapementDelta;
cap_mode fLineCapMode;
join_mode fLineJoinMode;
float fMiterLimit;
float fUnscaledFontSize;
}; };
class LayerData : public DrawData class LayerData : public DrawData {
{ public:
public: LayerData();
LayerData(void);
LayerData(const Layer *layer);
LayerData(const LayerData &data); LayerData(const LayerData &data);
virtual ~LayerData(void); virtual ~LayerData();
LayerData &operator=(const LayerData &from);
LayerData& operator=(const LayerData &from);
// automatic background blanking by app_server
void SetViewColor(const RGBColor& color);
inline const RGBColor& ViewColor() const
{ return fViewColor; }
void SetBackgroundBitmap(const ServerBitmap* bitmap);
inline const ServerBitmap* BackgroundBitmap() const
{ return fBackgroundBitmap; }
// overlay support
// TODO: This can't be all, what about color key?
void SetOverlayBitmap(const ServerBitmap* bitmap);
inline const ServerBitmap* OverlayBitmap() const
{ return fOverlayBitmap; }
// convenience functions
virtual void PrintToStream() const; virtual void PrintToStream() const;
BPoint coordOrigin; void ReadFontFromLink(LinkMsgReader& link);
// NOTE: ReadFromLink() does not read Font state!!
// It was separate in ServerWindow, and I didn't
// want to change it without knowing implications.
void ReadFromLink(LinkMsgReader& link);
void WriteToLink(LinkMsgSender& link) const;
RGBColor viewcolor; protected:
// We have both because we are not going to suffer from the limitation that R5 RGBColor fViewColor;
// places on us. We can have both. :)
ServerBitmap* background;
ServerBitmap* overlay;
// We have both because we are not going to suffer
// from the limitation that R5 places on us.
// We can have both. :)
const ServerBitmap* fBackgroundBitmap;
const ServerBitmap* fOverlayBitmap;
public:
// used for the state stack // used for the state stack
LayerData* prevState; LayerData* prevState;
}; };
#endif
// inline implementations
// Transform
BPoint
DrawData::Transform(const BPoint& point) const
{
BPoint p(point);
p += fOrigin;
p.x *= fScale;
p.y *= fScale;
return p;
}
// Transform
BRect
DrawData::Transform(const BRect& rect) const
{
return BRect(Transform(rect.LeftTop()),
Transform(rect.LeftBottom()));
}
/*
// ClippingRectAt
BRect
DrawData::ClippingRectAt(int32 index) const
{
BRect r;
if (fClippingRegion) {
r = fClippingRegion.RectAt(index);
}
return r;
}*/
#endif // LAYER_DATA_H_

View File

@ -46,6 +46,9 @@ class Pattern {
Pattern(const Pattern& src) Pattern(const Pattern& src)
{ fPattern.type64 = src.fPattern.type64; } { fPattern.type64 = src.fPattern.type64; }
Pattern(const pattern& src)
{ fPattern.type64 = *(uint64*)src.data; }
inline const int8* GetInt8(void) const inline const int8* GetInt8(void) const
{ return fPattern.type8; } { return fPattern.type8; }

View File

@ -180,7 +180,7 @@ void Decorator::SetFont(ServerFont *font)
if(!font) if(!font)
return; return;
_drawdata.font = *font; _drawdata.SetFont(*font);
} }
/*! /*!

View File

@ -24,18 +24,20 @@
// Description: Fallback decorator for the app_server // Description: Fallback decorator for the app_server
// //
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include <stdio.h>
#include <Rect.h> #include <Rect.h>
#include "DisplayDriver.h"
#include <View.h> #include <View.h>
#include "LayerData.h"
#include "ColorUtils.h" #include "ColorUtils.h"
#include "DefaultDecorator.h" #include "DisplayDriver.h"
#include "FontServer.h"
#include "LayerData.h"
#include "PatternHandler.h" #include "PatternHandler.h"
#include "RGBColor.h" #include "RGBColor.h"
#include "RectUtils.h"
#include <stdio.h>
#include "FontServer.h"
#include "DefaultDecorator.h"
//#define USE_VIEW_FILL_HACK //#define USE_VIEW_FILL_HACK
@ -53,11 +55,12 @@ DefaultDecorator::DefaultDecorator(BRect rect, int32 wlook, int32 wfeel, int32 w
taboffset=0; taboffset=0;
titlepixelwidth=0; titlepixelwidth=0;
SetFont(fontserver->GetSystemBold()); ServerFont font(*fontserver->GetSystemBold());
_drawdata.font.SetSize(14); font.SetSize(font.Size() * 1.1);
_drawdata.font.SetFlags(B_FORCE_ANTIALIASING); font.SetFlags(B_FORCE_ANTIALIASING);
_drawdata.font.SetSpacing(B_STRING_SPACING); font.SetSpacing(B_STRING_SPACING);
SetFont(&font);
framecolors=new RGBColor[6]; framecolors=new RGBColor[6];
framecolors[0].SetColor(152,152,152); framecolors[0].SetColor(152,152,152);
@ -361,8 +364,8 @@ void DefaultDecorator::_DrawTitle(BRect r)
STRACE(("_DrawTitle(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom)); STRACE(("_DrawTitle(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom));
// Designed simply to redraw the title when it has changed on // Designed simply to redraw the title when it has changed on
// the client side. // the client side.
_drawdata.highcolor=_colors->window_tab_text; _drawdata.SetHighColor(_colors->window_tab_text);
_drawdata.lowcolor=(GetFocus())?_colors->window_tab:_colors->inactive_window_tab; _drawdata.SetLowColor(GetFocus() ? _colors->window_tab : _colors->inactive_window_tab);
int32 titlecount=_ClipTitle((_zoomrect.left-textoffset)-(_closerect.right+textoffset)); int32 titlecount=_ClipTitle((_zoomrect.left-textoffset)-(_closerect.right+textoffset));
BString titlestr( GetTitle() ); BString titlestr( GetTitle() );
@ -551,8 +554,8 @@ STRACE(("_DrawFrame(%f,%f,%f,%f)\n", invalid.left, invalid.top,
invalid.right, invalid.bottom)); invalid.right, invalid.bottom));
#ifdef USE_VIEW_FILL_HACK #ifdef USE_VIEW_FILL_HACK
_drawdata.highcolor = RGBColor( 192, 192, 192 ); _drawdata.SetHighColor(RGBColor(192, 192, 192 ));
_driver->FillRect(_frame,_drawdata.highcolor); _driver->FillRect(_frame, _drawdata.HighColor());
#endif #endif
if(_look == B_NO_BORDER_WINDOW_LOOK) if(_look == B_NO_BORDER_WINDOW_LOOK)

View File

@ -614,7 +614,7 @@ void Layer::Draw(const BRect &r)
r.PrintToStream(); r.PrintToStream();
#endif #endif
fDriver->FillRect(r, fLayerData->viewcolor); fDriver->FillRect(r, fLayerData->ViewColor());
// RGBColor c(rand()%255,rand()%255,rand()%255); // RGBColor c(rand()%255,rand()%255,rand()%255);
// fDriver->FillRect(r, c); // fDriver->FillRect(r, c);
@ -736,8 +736,8 @@ void Layer::RebuildFullRegion(void)
do do
{ {
// clip to user region // clip to user region
if(ld->clipReg) if (const BRegion* userClipping = ld->ClippingRegion())
fFull.IntersectWith( ld->clipReg ); fFull.IntersectWith(userClipping);
} while( (ld = ld->prevState) ); } while( (ld = ld->prevState) );

View File

@ -1,5 +1,5 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Copyright (c) 2001-2002, Haiku, Inc. // Copyright (c) 2001-2005, Haiku, Inc.
// //
// Permission is hereby granted, free of charge, to any person obtaining a // Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"), // copy of this software and associated documentation files (the "Software"),
@ -22,175 +22,534 @@
// File Name: LayerData.cpp // File Name: LayerData.cpp
// Author: DarkWyrm <bpmagic@columbus.rr.com> // Author: DarkWyrm <bpmagic@columbus.rr.com>
// Adi Oanca <adioanca@mymail.ro> // Adi Oanca <adioanca@mymail.ro>
// Stephan Aßmus <superstippi@gmx.de>
// Description: Data classes for working with BView states and draw parameters // Description: Data classes for working with BView states and draw parameters
// //
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include "LayerData.h"
#include <Layer.h>
#include <stdio.h> #include <stdio.h>
DrawData::DrawData(void) #include <Region.h>
#include "LinkMsgReader.h"
#include "LinkMsgSender.h"
#include "LayerData.h"
// constructor
DrawData::DrawData()
: fOrigin(0.0, 0.0),
fScale(1.0),
fClippingRegion(NULL),
fHighColor(0, 0, 0, 255),
fLowColor(255, 255, 255, 255),
fPattern(kSolidHigh),
fDrawingMode(B_OP_COPY),
fAlphaSrcMode(B_PIXEL_ALPHA),
fAlphaFncMode(B_ALPHA_OVERLAY),
fPenLocation(0.0, 0.0),
fPenSize(1.0),
fFont(),
fFontAntiAliasing(true),
fLineCapMode(B_BUTT_CAP),
fLineJoinMode(B_BEVEL_JOIN),
fMiterLimit(B_DEFAULT_MITER_LIMIT)
{ {
pensize=1.0; if (fontserver && fontserver->GetSystemPlain())
penlocation.Set(0,0); fFont = *(fontserver->GetSystemPlain());
highcolor.SetColor(0, 0, 0, 255);
lowcolor.SetColor(255, 255, 255, 255);
patt=kSolidHigh;
draw_mode=B_OP_COPY;
lineCap =B_BUTT_CAP; fEscapementDelta.space = 0;
lineJoin=B_BEVEL_JOIN; fEscapementDelta.nonspace = 0;
miterLimit=B_DEFAULT_MITER_LIMIT;
alphaSrcMode=B_PIXEL_ALPHA; fUnscaledFontSize = fFont.Size();
alphaFncMode=B_ALPHA_OVERLAY;
scale=1.0;
fontAliasing=true;
if(fontserver && fontserver->GetSystemPlain())
font=*(fontserver->GetSystemPlain());
clipReg=NULL;
edelta.space=0;
edelta.nonspace=0;
} }
DrawData::~DrawData(void) // copy constructor
DrawData::DrawData(const DrawData& from)
: fClippingRegion(NULL)
{ {
delete clipReg; *this = from;
} }
DrawData::DrawData(const DrawData &data) // destructor
DrawData::~DrawData()
{ {
clipReg = NULL; delete fClippingRegion;
*this=data;
} }
DrawData &DrawData::operator=(const DrawData &from) // operator=
DrawData&
DrawData::operator=(const DrawData& from)
{ {
pensize=from.pensize; fOrigin = from.fOrigin;
highcolor=from.highcolor; fScale = from.fScale;
lowcolor=from.lowcolor;
patt=from.patt; if (from.fClippingRegion) {
draw_mode=from.draw_mode; SetClippingRegion(*(from.fClippingRegion));
penlocation=from.penlocation; } else {
delete fClippingRegion;
lineCap=from.lineCap; fClippingRegion = NULL;
lineJoin=from.lineJoin;
miterLimit=from.miterLimit;
alphaSrcMode=from.alphaSrcMode;
alphaFncMode=from.alphaFncMode;
scale=from.scale;
fontAliasing=from.fontAliasing;
font=from.font;
if(from.clipReg)
{
if(clipReg)
*clipReg=*(from.clipReg);
else
clipReg=new BRegion(*(from.clipReg));
} }
edelta=from.edelta; fHighColor = from.fHighColor;
fLowColor = from.fLowColor;
fPattern = from.fPattern;
fDrawingMode = from.fDrawingMode;
fAlphaSrcMode = from.fAlphaSrcMode;
fAlphaFncMode = from.fAlphaFncMode;
fPenLocation = from.fPenLocation;
fPenSize = from.fPenSize;
fFont = from.fFont;
fFontAntiAliasing = from.fFontAntiAliasing;
fEscapementDelta = from.fEscapementDelta;
fLineCapMode = from.fLineCapMode;
fLineJoinMode = from.fLineJoinMode;
fMiterLimit = from.fMiterLimit;
fUnscaledFontSize = from.fUnscaledFontSize;
return *this; return *this;
} }
LayerData::LayerData(void) // SetOrigin
void
DrawData::SetOrigin(const BPoint& origin)
{ {
coordOrigin.Set(0.0, 0.0); fOrigin = origin;
viewcolor.SetColor(255,255,255,255);
background=NULL;
overlay=NULL;
prevState=NULL;
} }
// SetScale
void
DrawData::SetScale(float scale)
{
if (fScale != scale) {
fScale = scale;
// update font size
// (pen size is currently calulated on the fly)
fFont.SetSize(fUnscaledFontSize * fScale);
}
}
// SetClippingRegion
void
DrawData::SetClippingRegion(const BRegion& region)
{
if (region.Frame().IsValid()) {
if (fClippingRegion)
*fClippingRegion = region;
else
fClippingRegion = new BRegion(region);
} else {
delete fClippingRegion;
fClippingRegion = NULL;
}
}
// SetHighColor
void
DrawData::SetHighColor(const RGBColor& color)
{
fHighColor = color;
}
// SetLowColor
void
DrawData::SetLowColor(const RGBColor& color)
{
fLowColor = color;
}
// SetPattern
void
DrawData::SetPattern(const Pattern& pattern)
{
fPattern = pattern;
}
// SetDrawingMode
void
DrawData::SetDrawingMode(drawing_mode mode)
{
fDrawingMode = mode;
}
// SetBlendingMode
void
DrawData::SetBlendingMode(source_alpha srcMode, alpha_function fncMode)
{
fAlphaSrcMode = srcMode;
fAlphaFncMode = fncMode;
}
// SetPenLocation
void
DrawData::SetPenLocation(const BPoint& location)
{
// TODO: Needs to be in local coordinate system!
// There is going to be some work involved in
// other parts of app_server...
fPenLocation = location;
}
// PenLocation
const BPoint&
DrawData::PenLocation() const
{
// TODO: See above
return fPenLocation;
}
// SetPenSize
void
DrawData::SetPenSize(float size)
{
fPenSize = size;
}
// PenSize
// * returns the scaled pen size
float
DrawData::PenSize() const
{
float penSize = fPenSize * fScale;
// NOTE: As documented in the BeBook,
// pen size is never smaller than 1.0.
// This is supposed to be the smallest
// possible device size.
if (penSize < 1.0)
penSize = 1.0;
return penSize;
}
// SetFont
// * sets the font to be already scaled by fScale
void
DrawData::SetFont(const ServerFont& font, uint32 flags)
{
if (flags == B_FONT_ALL) {
fFont = font;
fUnscaledFontSize = font.Size();
fFont.SetSize(fUnscaledFontSize * fScale);
} else {
// family & style
if (flags & B_FONT_FAMILY_AND_STYLE)
fFont.SetFamilyAndStyle(font.GetFamilyAndStyle());
// size
if (flags & B_FONT_SIZE) {
fUnscaledFontSize = font.Size();
fFont.SetSize(fUnscaledFontSize * fScale);
}
// shear
if (flags & B_FONT_SHEAR)
fFont.SetShear(font.Shear());
// rotation
if (flags & B_FONT_ROTATION)
fFont.SetRotation(font.Rotation());
// spacing
if (flags & B_FONT_SPACING)
fFont.SetSpacing(font.Spacing());
// encoding
if (flags & B_FONT_ENCODING)
fFont.SetEncoding(font.Encoding());
// face
if (flags & B_FONT_FACE)
fFont.SetFace(font.Face());
// face
if (flags & B_FONT_FLAGS)
fFont.SetFlags(font.Flags());
}
}
// SetFontAntiAliasing
void
DrawData::SetFontAntiAliasing(bool antiAliasing)
{
fFontAntiAliasing = antiAliasing;
}
// SetEscapementDelta
void
DrawData::SetEscapementDelta(escapement_delta delta)
{
fEscapementDelta = delta;
}
// SetLineCapMode
void
DrawData::SetLineCapMode(cap_mode mode)
{
fLineCapMode = mode;
}
// SetLineJoinMode
void
DrawData::SetLineJoinMode(join_mode mode)
{
fLineJoinMode = mode;
}
// SetMiterLimit
void
DrawData::SetMiterLimit(float limit)
{
fMiterLimit = limit;
}
//----------------------------LayerData----------------------
// #pragmamark -
// constructpr
LayerData::LayerData()
: DrawData(),
fViewColor(255, 255, 255, 255),
fBackgroundBitmap(NULL),
fOverlayBitmap(NULL),
prevState(NULL)
{
}
// LayerData
LayerData::LayerData(const LayerData &data) LayerData::LayerData(const LayerData &data)
{ {
clipReg = NULL; fClippingRegion = NULL;
*this=data; *this = data;
} }
// destructor
LayerData::~LayerData(void) LayerData::~LayerData(void)
{ {
delete prevState; delete prevState;
// NOTE: we're in the destructor here. why the assignment?
prevState=NULL;
} }
LayerData &LayerData::operator=(const LayerData &from) // operator=
LayerData&
LayerData::operator=(const LayerData& from)
{ {
// I'm not sure if the DrawData copy constructor will get called before this one is, DrawData::operator=(from);
// so I'll just make sure the copy happens. :P
pensize=from.pensize;
highcolor=from.highcolor;
lowcolor=from.lowcolor;
patt=from.patt; fViewColor = from.fViewColor;
draw_mode=from.draw_mode;
penlocation=from.penlocation;
lineCap=from.lineCap;
lineJoin=from.lineJoin;
miterLimit=from.miterLimit;
alphaSrcMode=from.alphaSrcMode;
alphaFncMode=from.alphaFncMode;
scale=from.scale; // TODO: Are we making any sense here?
fontAliasing=from.fontAliasing; // How is operator= being used?
font=from.font; fBackgroundBitmap = from.fBackgroundBitmap;
fOverlayBitmap = from.fOverlayBitmap;
if(from.clipReg)
{ prevState = from.prevState;
if(clipReg)
*clipReg=*(from.clipReg);
else
clipReg=new BRegion(*(from.clipReg));
}
edelta=from.edelta;
// Stuff specific to LayerData
coordOrigin=from.coordOrigin;;
viewcolor=from.viewcolor;
background=from.background;
overlay=from.overlay;
prevState=from.prevState;
return *this; return *this;
} }
void LayerData::PrintToStream() const{ // SetViewColor
printf("\t Pen Location and Size: (%f, %f) - %f\n", penlocation.x, penlocation.y, pensize); void
printf("\t HighColor: "); highcolor.PrintToStream(); LayerData::SetViewColor(const RGBColor& color)
printf("\t LowColor: "); lowcolor.PrintToStream(); {
printf("\t ViewColor "); viewcolor.PrintToStream(); fViewColor = color;
printf("\t Pattern: %llu\n", patt.GetInt64()); }
printf("\t DrawMode: %lu\n", (uint32)draw_mode);
printf("\t LineCap: %d\t LineJoin: %d\t MiterLimit: %f\n", (int16)lineCap, (int16)lineJoin, miterLimit); // SetBackgroundBitmap
printf("\t AlphaSrcMode: %ld\t AlphaFncMode: %ld\n", (int32)alphaSrcMode, (int32)alphaFncMode); void
printf("\t Scale: %f\n", scale); LayerData::SetBackgroundBitmap(const ServerBitmap* bitmap)
if (clipReg) {
clipReg->PrintToStream(); // TODO: What about reference counting?
// "Release" old fBackgroundBitmap and "Aquire" new one?
fBackgroundBitmap = bitmap;
}
// SetOverlayBitmap
void
LayerData::SetOverlayBitmap(const ServerBitmap* bitmap)
{
// TODO: What about reference counting?
// "Release" old fOverlayBitmap and "Aquire" new one?
fOverlayBitmap = bitmap;
}
// PrintToStream
void
LayerData::PrintToStream() const
{
printf("\t Origin: (%.1f, %.1f)\n", fOrigin.x, fOrigin.y);
printf("\t Scale: %.2f\n", fScale);
printf("\t Pen Location and Size: (%.1f, %.1f) - %.2f (%.2f)\n",
fPenLocation.x, fPenLocation.y, PenSize(), fPenSize);
printf("\t HighColor: "); fHighColor.PrintToStream();
printf("\t LowColor: "); fLowColor.PrintToStream();
printf("\t ViewColor "); fViewColor.PrintToStream();
printf("\t Pattern: %llu\n", fPattern.GetInt64());
printf("\t DrawMode: %lu\n", (uint32)fDrawingMode);
printf("\t AlphaSrcMode: %ld\t AlphaFncMode: %ld\n",
(int32)fAlphaSrcMode, (int32)fAlphaFncMode);
printf("\t LineCap: %d\t LineJoin: %d\t MiterLimit: %.2f\n",
(int16)fLineCapMode, (int16)fLineJoinMode, fMiterLimit);
if (fClippingRegion)
fClippingRegion->PrintToStream();
printf("\t ===== Font Data =====\n"); printf("\t ===== Font Data =====\n");
printf("\t FontStyle: CURRENTLY NOT SET\n"); printf("\t Style: CURRENTLY NOT SET\n"); // ???
printf("\t FontSize: %f\n", font.Size()); printf("\t Size: %.1f (%.1f)\n", fFont.Size(), fUnscaledFontSize);
printf("\t FontShear: %f\n", font.Shear()); printf("\t Shear: %.2f\n", fFont.Shear());
printf("\t FontRotation: %f\n", font.Rotation()); printf("\t Rotation: %.2f\n", fFont.Rotation());
printf("\t FontSpacing: %ld\n", font.Spacing()); printf("\t Spacing: %ld\n", fFont.Spacing());
printf("\t FontEncoding: %ld\n", font.Encoding()); printf("\t Encoding: %ld\n", fFont.Encoding());
printf("\t FontFace: %d\n", font.Face()); printf("\t Face: %d\n", fFont.Face());
printf("\t FontFlags: %lu\n", font.Flags()); printf("\t Flags: %lu\n", fFont.Flags());
} }
// ReadFromLink
void
LayerData::ReadFontFromLink(LinkMsgReader& link)
{
uint16 mask;
link.Read<uint16>(&mask);
if (mask & B_FONT_FAMILY_AND_STYLE) {
uint32 fontID;
link.Read<int32>((int32*)&fontID);
fFont.SetFamilyAndStyle(fontID);
}
if (mask & B_FONT_SIZE) {
float size;
link.Read<float>(&size);
fFont.SetSize(size);
}
if (mask & B_FONT_SHEAR) {
float shear;
link.Read<float>(&shear);
fFont.SetShear(shear);
}
if (mask & B_FONT_ROTATION) {
float rotation;
link.Read<float>(&rotation);
fFont.SetRotation(rotation);
}
if (mask & B_FONT_SPACING) {
uint8 spacing;
link.Read<uint8>(&spacing);
fFont.SetSpacing(spacing);
}
if (mask & B_FONT_ENCODING) {
uint8 encoding;
link.Read<uint8>((uint8*)&encoding);
fFont.SetEncoding(encoding);
}
if (mask & B_FONT_FACE) {
uint16 face;
link.Read<uint16>(&face);
fFont.SetFace(face);
}
if (mask & B_FONT_FLAGS) {
uint32 flags;
link.Read<uint32>(&flags);
fFont.SetFlags(flags);
}
}
// ReadFromLink
void
LayerData::ReadFromLink(LinkMsgReader& link)
{
rgb_color highColor;
rgb_color lowColor;
rgb_color viewColor;
pattern patt;
link.Read<BPoint>(&fPenLocation);
link.Read<float>(&fPenSize);
link.Read(&highColor, sizeof(rgb_color));
link.Read(&lowColor, sizeof(rgb_color));
link.Read(&viewColor, sizeof(rgb_color));
link.Read(&patt, sizeof(pattern));
link.Read<int8>((int8*)&fDrawingMode);
link.Read<BPoint>(&fOrigin);
link.Read<int8>((int8*)&fLineJoinMode);
link.Read<int8>((int8*)&fLineCapMode);
link.Read<float>(&fMiterLimit);
link.Read<int8>((int8*)&fAlphaSrcMode);
link.Read<int8>((int8*)&fAlphaFncMode);
link.Read<float>(&fScale);
link.Read<bool>(&fFontAntiAliasing);
// TODO: ahm... which way arround?
fFontAntiAliasing = !fFontAntiAliasing;
fHighColor = highColor;
fLowColor = lowColor;
fViewColor = viewColor;
fPattern = patt;
// read clipping
int32 clipRectCount;
link.Read<int32>(&clipRectCount);
BRegion region;
if (clipRectCount > 0) {
BRect rect;
for (int32 i = 0; i < clipRectCount; i++) {
link.Read<BRect>(&rect);
region.Include(rect);
}
}
SetClippingRegion(region);
}
// WriteToLink
void
LayerData::WriteToLink(LinkMsgSender& link) const
{
rgb_color hc = fHighColor.GetColor32();
rgb_color lc = fLowColor.GetColor32();
rgb_color vc = fViewColor.GetColor32();
// Attach font state
link.Attach<uint32>(fFont.GetFamilyAndStyle());
link.Attach<float>(fFont.Size());
link.Attach<float>(fFont.Shear());
link.Attach<float>(fFont.Rotation());
link.Attach<uint8>(fFont.Spacing());
link.Attach<uint8>(fFont.Encoding());
link.Attach<uint16>(fFont.Face());
link.Attach<uint32>(fFont.Flags());
// Attach view state
link.Attach<BPoint>(fPenLocation);
link.Attach<float>(fPenSize);
link.Attach(&hc, sizeof(rgb_color));
link.Attach(&lc, sizeof(rgb_color));
link.Attach(&vc, sizeof(rgb_color));
link.Attach<uint64>(fPattern.GetInt64());
link.Attach<BPoint>(fOrigin);
link.Attach<uint8>((uint8)fDrawingMode);
link.Attach<uint8>((uint8)fLineCapMode);
link.Attach<uint8>((uint8)fLineJoinMode);
link.Attach<float>(fMiterLimit);
link.Attach<uint8>((uint8)fAlphaSrcMode);
link.Attach<uint8>((uint8)fAlphaFncMode);
link.Attach<float>(fScale);
// TODO: bool, no?
link.Attach<float>(!fFontAntiAliasing);
int32 clippingRectCount = fClippingRegion ? fClippingRegion->CountRects() : 0;
link.Attach<int32>(clippingRectCount);
if (fClippingRegion) {
for (int i = 0; i < clippingRectCount; i++)
link.Attach<BRect>(fClippingRegion->RectAt(i));
}
}

View File

@ -26,12 +26,17 @@
// Marc Flerackers' TPicture class // Marc Flerackers' TPicture class
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include "PicturePlayer.h" #include <stdio.h>
#include <Region.h>
#include "ServerBitmap.h"
#include "DisplayDriver.h"
#include "PictureProtocol.h" #include "PictureProtocol.h"
#include "Utils.h" #include "Utils.h"
#include "DisplayDriver.h"
#include <ServerBitmap.h> #include "PicturePlayer.h"
#include <stdio.h>
PicturePlayer::PicturePlayer(DisplayDriver *d,void *data, int32 size) PicturePlayer::PicturePlayer(DisplayDriver *d,void *data, int32 size)
: fData(data, size) : fData(data, size)
@ -133,6 +138,7 @@ status_t PicturePlayer::Play(int32 tableEntries,void *userData, LayerData *d)
fData.Seek(0,SEEK_SET); fData.Seek(0,SEEK_SET);
off_t pos; off_t pos;
fldata=*d; fldata=*d;
ServerFont dummyFont;
while (fData.Position() < size) while (fData.Position() < size)
{ {
@ -145,8 +151,7 @@ status_t PicturePlayer::Play(int32 tableEntries,void *userData, LayerData *d)
case B_PIC_MOVE_PEN_BY: case B_PIC_MOVE_PEN_BY:
{ {
BPoint where = GetCoord(); BPoint where = GetCoord();
fldata.penlocation.x+=where.x; fldata.SetPenLocation(fldata.PenLocation() + where);
fldata.penlocation.y+=where.y;
break; break;
} }
case B_PIC_STROKE_LINE: case B_PIC_STROKE_LINE:
@ -230,10 +235,12 @@ status_t PicturePlayer::Play(int32 tableEntries,void *userData, LayerData *d)
// TODO: The deltas given are escapements. They seem to be called deltax and deltay // TODO: The deltas given are escapements. They seem to be called deltax and deltay
// despite the fact that they are space and non-space escapements. Find out which is which when possible. // despite the fact that they are space and non-space escapements. Find out which is which when possible.
// My best guess is that deltax corresponds to escapement_delta.nonspace. // My best guess is that deltax corresponds to escapement_delta.nonspace.
fldata.edelta.nonspace=deltax; escapement_delta delta;
fldata.edelta.space=deltay; delta.nonspace = deltax;
delta.space = deltay;
fldata.SetEscapementDelta(delta);
fdriver->DrawString(string,len,fldata.penlocation,&fldata); fdriver->DrawString(string, len, fldata.PenLocation(), &fldata);
delete string; delete string;
break; break;
} }
@ -349,44 +356,48 @@ status_t PicturePlayer::Play(int32 tableEntries,void *userData, LayerData *d)
case B_PIC_SET_PEN_LOCATION: case B_PIC_SET_PEN_LOCATION:
{ {
BPoint pt = GetCoord(); BPoint pt = GetCoord();
fldata.penlocation=pt; fldata.SetPenLocation(pt);
break; break;
} }
case B_PIC_SET_DRAWING_MODE: case B_PIC_SET_DRAWING_MODE:
{ {
int16 mode = GetInt16(); int16 mode = GetInt16();
fldata.draw_mode=(drawing_mode)mode; fldata.SetDrawingMode((drawing_mode)mode);
break; break;
} }
case B_PIC_SET_LINE_MODE: case B_PIC_SET_LINE_MODE:
{ {
GetData(&fldata.lineCap,sizeof(cap_mode)); cap_mode lineCapMode;
GetData(&fldata.lineJoin,sizeof(join_mode)); join_mode lineJoinMode;
fldata.miterLimit = GetFloat(); GetData(&lineCapMode, sizeof(cap_mode));
GetData(&lineJoinMode, sizeof(join_mode));
fldata.SetLineCapMode(lineCapMode);
fldata.SetLineJoinMode(lineJoinMode);
fldata.SetMiterLimit(GetFloat());
break; break;
} }
case B_PIC_SET_PEN_SIZE: case B_PIC_SET_PEN_SIZE:
{ {
float size = GetFloat(); float size = GetFloat();
fldata.pensize=size; fldata.SetPenSize(size);
break; break;
} }
case B_PIC_SET_SCALE: case B_PIC_SET_SCALE:
{ {
float scale = GetFloat(); float scale = GetFloat();
fldata.scale=scale; fldata.SetScale(scale);
break; break;
} }
case B_PIC_SET_FORE_COLOR: case B_PIC_SET_FORE_COLOR:
{ {
rgb_color color = GetColor(); rgb_color color = GetColor();
fldata.highcolor=color; fldata.SetHighColor(color);
break; break;
} }
case B_PIC_SET_BACK_COLOR: case B_PIC_SET_BACK_COLOR:
{ {
rgb_color color = GetColor(); rgb_color color = GetColor();
fldata.lowcolor=color; fldata.SetLowColor(color);
break; break;
} }
case B_PIC_SET_STIPLE_PATTERN: case B_PIC_SET_STIPLE_PATTERN:
@ -405,8 +416,8 @@ status_t PicturePlayer::Play(int32 tableEntries,void *userData, LayerData *d)
{ {
int16 alphaSrcMode = GetInt16(); int16 alphaSrcMode = GetInt16();
int16 alphaFncMode = GetInt16(); int16 alphaFncMode = GetInt16();
fldata.alphaSrcMode = (source_alpha)alphaSrcMode; fldata.SetBlendingMode((source_alpha)alphaSrcMode,
fldata.alphaFncMode = (alpha_function)alphaFncMode; (alpha_function)alphaFncMode);
break; break;
} }
case B_PIC_SET_FONT_FAMILY: case B_PIC_SET_FONT_FAMILY:
@ -433,37 +444,44 @@ status_t PicturePlayer::Play(int32 tableEntries,void *userData, LayerData *d)
} }
case B_PIC_SET_FONT_SPACING: case B_PIC_SET_FONT_SPACING:
{ {
fldata.font.SetSpacing(GetInt32()); dummyFont.SetSpacing(GetInt32());
fldata.SetFont(dummyFont, B_FONT_SPACING);
break; break;
} }
case B_PIC_SET_FONT_ENCODING: case B_PIC_SET_FONT_ENCODING:
{ {
fldata.font.SetEncoding(GetInt32()); dummyFont.SetEncoding(GetInt32());
fldata.SetFont(dummyFont, B_FONT_ENCODING);
break; break;
} }
case B_PIC_SET_FONT_FLAGS: case B_PIC_SET_FONT_FLAGS:
{ {
fldata.font.SetFlags(GetInt32()); dummyFont.SetFlags(GetInt32());
fldata.SetFont(dummyFont, B_FONT_FLAGS);
break; break;
} }
case B_PIC_SET_FONT_SIZE: case B_PIC_SET_FONT_SIZE:
{ {
fldata.font.SetSize(GetFloat()); dummyFont.SetSize(GetFloat());
fldata.SetFont(dummyFont, B_FONT_SIZE);
break; break;
} }
case B_PIC_SET_FONT_ROTATE: case B_PIC_SET_FONT_ROTATE:
{ {
fldata.font.SetRotation(GetFloat()); dummyFont.SetRotation(GetFloat());
fldata.SetFont(dummyFont, B_FONT_ROTATION);
break; break;
} }
case B_PIC_SET_FONT_SHEAR: case B_PIC_SET_FONT_SHEAR:
{ {
fldata.font.SetShear(GetFloat()); dummyFont.SetShear(GetFloat());
fldata.SetFont(dummyFont, B_FONT_SHEAR);
break; break;
} }
case B_PIC_SET_FONT_FACE: case B_PIC_SET_FONT_FACE:
{ {
fldata.font.SetFace(GetInt32()); dummyFont.SetFace(GetInt32());
fldata.SetFont(dummyFont, B_FONT_FACE);
break; break;
} }
default: default:
@ -485,7 +503,7 @@ void PicturePlayer::SetClippingRegion(BRect *rects, int32 numrects)
// Passing NULL or 0 rectangles to the function empties the clipping region. The clipping // Passing NULL or 0 rectangles to the function empties the clipping region. The clipping
// region is also emptied if there is no union of all rectangles passed to the function. // region is also emptied if there is no union of all rectangles passed to the function.
if(!rects || numrects) if(!rects || numrects == 0)
{ {
delete clipreg; delete clipreg;
clipreg=NULL; clipreg=NULL;

View File

@ -1218,7 +1218,6 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
float size,width=0; float size,width=0;
uint8 spacing; uint8 spacing;
port_id replyport; port_id replyport;
DrawData drawdata;
msg.ReadString(&string); msg.ReadString(&string);
msg.Read<int32>(&length); msg.Read<int32>(&length);
@ -1229,22 +1228,27 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
msg.Read<port_id>(&replyport); msg.Read<port_id>(&replyport);
replylink.SetSendPort(replyport); replylink.SetSendPort(replyport);
if(length>0 && drawdata.font.SetFamilyAndStyle(family,style)==B_OK && ServerFont font;
size>0 && string)
{ if (length > 0 && font.SetFamilyAndStyle(family, style) == B_OK &&
drawdata.font.SetSize(size); size > 0 && string) {
drawdata.font.SetSpacing(spacing);
width=desktop->GetDisplayDriver()->StringWidth(string,length,&drawdata); font.SetSize(size);
font.SetSpacing(spacing);
DrawData drawdata;
drawdata.SetFont(font);
// TODO: make a DisplayDriver::StringWidth() function that takes
// just a ServerFont
width = desktop->GetDisplayDriver()->StringWidth(string, length, &drawdata);
replylink.StartMessage(SERVER_TRUE); replylink.StartMessage(SERVER_TRUE);
replylink.Attach<float>(width); replylink.Attach<float>(width);
replylink.Flush(); replylink.Flush();
free(string); free(string);
} } else {
else
{
replylink.StartMessage(SERVER_FALSE); replylink.StartMessage(SERVER_FALSE);
replylink.Flush(); replylink.Flush();
} }

View File

@ -348,65 +348,8 @@ void ServerWindow::SetLayerFontState(Layer *layer, LinkMsgReader &link)
STRACE(("ServerWindow %s: SetLayerFontStateMessage for layer %s\n", STRACE(("ServerWindow %s: SetLayerFontStateMessage for layer %s\n",
fName, layer->fName->String())); fName, layer->fName->String()));
// NOTE: no need to check for a lock. This is a private method. // NOTE: no need to check for a lock. This is a private method.
uint16 mask;
link.Read<uint16>(&mask); layer->fLayerData->ReadFontFromLink(link);
if (mask & B_FONT_FAMILY_AND_STYLE)
{
uint32 fontID;
link.Read<int32>((int32*)&fontID);
layer->fLayerData->font.SetFamilyAndStyle(fontID);
}
if (mask & B_FONT_SIZE)
{
float size;
link.Read<float>(&size);
layer->fLayerData->font.SetSize(size);
}
if (mask & B_FONT_SHEAR)
{
float shear;
link.Read<float>(&shear);
layer->fLayerData->font.SetShear(shear);
}
if (mask & B_FONT_ROTATION)
{
float rotation;
link.Read<float>(&rotation);
layer->fLayerData->font.SetRotation(rotation);
}
if (mask & B_FONT_SPACING)
{
uint8 spacing;
link.Read<uint8>(&spacing);
layer->fLayerData->font.SetSpacing(spacing);
}
if (mask & B_FONT_ENCODING)
{
uint8 encoding;
link.Read<uint8>((uint8*)&encoding);
layer->fLayerData->font.SetEncoding(encoding);
}
if (mask & B_FONT_FACE)
{
uint16 face;
link.Read<uint16>(&face);
layer->fLayerData->font.SetFace(face);
}
if (mask & B_FONT_FLAGS)
{
uint32 flags;
link.Read<uint32>(&flags);
layer->fLayerData->font.SetFlags(flags);
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
inline inline
@ -415,55 +358,9 @@ void ServerWindow::SetLayerState(Layer *layer, LinkMsgReader &link)
STRACE(("ServerWindow %s: SetLayerState for layer %s\n",fName, STRACE(("ServerWindow %s: SetLayerState for layer %s\n",fName,
layer->fName->String())); layer->fName->String()));
// NOTE: no need to check for a lock. This is a private method. // NOTE: no need to check for a lock. This is a private method.
rgb_color highColor, lowColor, viewColor;
pattern patt;
int32 clipRegRects;
link.Read<BPoint>( &(layer->fLayerData->penlocation)); layer->fLayerData->ReadFromLink(link);
link.Read<float>( &(layer->fLayerData->pensize)); // TODO: Rebuild clipping here?
link.Read( &highColor, sizeof(rgb_color));
link.Read( &lowColor, sizeof(rgb_color));
link.Read( &viewColor, sizeof(rgb_color));
link.Read( &patt, sizeof(pattern));
link.Read<int8>((int8*) &(layer->fLayerData->draw_mode));
link.Read<BPoint>( &(layer->fLayerData->coordOrigin));
link.Read<int8>((int8*) &(layer->fLayerData->lineJoin));
link.Read<int8>((int8*) &(layer->fLayerData->lineCap));
link.Read<float>( &(layer->fLayerData->miterLimit));
link.Read<int8>((int8*) &(layer->fLayerData->alphaSrcMode));
link.Read<int8>((int8*) &(layer->fLayerData->alphaFncMode));
link.Read<float>( &(layer->fLayerData->scale));
link.Read<bool>( &(layer->fLayerData->fontAliasing));
link.Read<int32>( &clipRegRects);
layer->fLayerData->patt.Set(*((uint64*)&patt));
layer->fLayerData->highcolor.SetColor(highColor);
layer->fLayerData->lowcolor.SetColor(lowColor);
layer->fLayerData->viewcolor.SetColor(viewColor);
if(clipRegRects != 0)
{
if(layer->fLayerData->clipReg == NULL)
layer->fLayerData->clipReg = new BRegion();
else
layer->fLayerData->clipReg->MakeEmpty();
BRect rect;
for(int32 i = 0; i < clipRegRects; i++)
{
link.Read<BRect>(&rect);
layer->fLayerData->clipReg->Include(rect);
}
}
else
{
if (layer->fLayerData->clipReg)
{
delete layer->fLayerData->clipReg;
layer->fLayerData->clipReg = NULL;
}
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
inline inline
@ -732,6 +629,8 @@ void ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link)
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_STATE: Layer name: %s\n", fName, cl->fName->String())); DTRACE(("ServerWindow %s: Message AS_LAYER_SET_STATE: Layer name: %s\n", fName, cl->fName->String()));
// SetLayerState(cl); // SetLayerState(cl);
SetLayerState(cl,link); SetLayerState(cl,link);
// TODO: should this be moved into SetLayerState?
// If it _always_ needs to be done afterwards, then yes!
cl->RebuildFullRegion(); cl->RebuildFullRegion();
break; break;
} }
@ -746,61 +645,16 @@ void ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link)
case AS_LAYER_GET_STATE: case AS_LAYER_GET_STATE:
{ {
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_STATE: Layer name: %s\n", fName, cl->fName->String())); DTRACE(("ServerWindow %s: Message AS_LAYER_GET_STATE: Layer name: %s\n", fName, cl->fName->String()));
LayerData *ld;
// these 4 are here because of a compiler warning. Maybe he's right... :-)
rgb_color hc, lc, vc; // high, low and view colors
uint64 patt;
ld = cl->fLayerData; // now we write fewer characters. :-)
hc = ld->highcolor.GetColor32();
lc = ld->lowcolor.GetColor32();
vc = ld->viewcolor.GetColor32();
patt = ld->patt.GetInt64();
// TODO: Implement when ServerFont::SetfamilyAndStyle(int32) exists
// TODO: Implement *what*? SetFamilyAndStyle exists. :)
fMsgSender->StartMessage(SERVER_TRUE); fMsgSender->StartMessage(SERVER_TRUE);
// Attach font state // attach state data
fMsgSender->Attach<uint32>(ld->font.GetFamilyAndStyle()); cl->fLayerData->WriteToLink(*fMsgSender);
fMsgSender->Attach<float>(ld->font.Size());
fMsgSender->Attach<float>(ld->font.Shear());
fMsgSender->Attach<float>(ld->font.Rotation());
fMsgSender->Attach<uint8>(ld->font.Spacing());
fMsgSender->Attach<uint8>(ld->font.Encoding());
fMsgSender->Attach<uint16>(ld->font.Face());
fMsgSender->Attach<uint32>(ld->font.Flags());
// Attach view state
fMsgSender->Attach<BPoint>(ld->penlocation);
fMsgSender->Attach<float>(ld->pensize);
fMsgSender->Attach(&hc, sizeof(rgb_color));
fMsgSender->Attach(&lc, sizeof(rgb_color));
fMsgSender->Attach(&vc, sizeof(rgb_color));
fMsgSender->Attach<uint64>(patt);
fMsgSender->Attach<BPoint>(ld->coordOrigin);
fMsgSender->Attach<uint8>((uint8)(ld->draw_mode));
fMsgSender->Attach<uint8>((uint8)(ld->lineCap));
fMsgSender->Attach<uint8>((uint8)(ld->lineJoin));
fMsgSender->Attach<float>(ld->miterLimit);
fMsgSender->Attach<uint8>((uint8)(ld->alphaSrcMode));
fMsgSender->Attach<uint8>((uint8)(ld->alphaFncMode));
fMsgSender->Attach<float>(ld->scale);
fMsgSender->Attach<float>(ld->fontAliasing);
int32 noOfRects = 0;
if (ld->clipReg)
noOfRects = ld->clipReg->CountRects();
fMsgSender->Attach<int32>(noOfRects);
for(int i = 0; i < noOfRects; i++)
fMsgSender->Attach<BRect>(ld->clipReg->RectAt(i));
fMsgSender->Attach<float>(cl->fFrame.left); fMsgSender->Attach<float>(cl->fFrame.left);
fMsgSender->Attach<float>(cl->fFrame.top); fMsgSender->Attach<float>(cl->fFrame.top);
fMsgSender->Attach<BRect>(cl->fFrame.OffsetToCopy(cl->fBoundsLeftTop)); fMsgSender->Attach<BRect>(cl->fFrame.OffsetToCopy(cl->fBoundsLeftTop));
fMsgSender->Flush(); fMsgSender->Flush();
break; break;
@ -857,7 +711,7 @@ cl->fBoundsLeftTop.PrintToStream();
link.Read<float>(&x); link.Read<float>(&x);
link.Read<float>(&y); link.Read<float>(&y);
cl->fLayerData->coordOrigin.Set(x, y); cl->fLayerData->SetOrigin(BPoint(x, y));
break; break;
} }
@ -865,7 +719,7 @@ cl->fBoundsLeftTop.PrintToStream();
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_GET_ORIGIN: Layer: %s\n",fName, cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_GET_ORIGIN: Layer: %s\n",fName, cl->fName->String()));
fMsgSender->StartMessage(SERVER_TRUE); fMsgSender->StartMessage(SERVER_TRUE);
fMsgSender->Attach<BPoint>(cl->fLayerData->coordOrigin); fMsgSender->Attach<BPoint>(cl->fLayerData->Origin());
fMsgSender->Flush(); fMsgSender->Flush();
break; break;
@ -912,15 +766,17 @@ cl->fBoundsLeftTop.PrintToStream();
{ {
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_LINE_MODE: Layer: %s\n",fName, cl->fName->String())); DTRACE(("ServerWindow %s: Message AS_LAYER_SET_LINE_MODE: Layer: %s\n",fName, cl->fName->String()));
int8 lineCap, lineJoin; int8 lineCap, lineJoin;
float miterLimit;
// TODO: Look into locking scheme relating to Layers and modifying redraw-related members // TODO: Look into locking scheme relating to Layers and modifying redraw-related members
link.Read<int8>(&lineCap); link.Read<int8>(&lineCap);
link.Read<int8>(&lineJoin); link.Read<int8>(&lineJoin);
link.Read<float>(&(cl->fLayerData->miterLimit)); link.Read<float>(&miterLimit);
cl->fLayerData->lineCap = (cap_mode)lineCap; cl->fLayerData->SetLineCapMode((cap_mode)lineCap);
cl->fLayerData->lineJoin = (join_mode)lineJoin; cl->fLayerData->SetLineJoinMode((join_mode)lineJoin);
cl->fLayerData->SetMiterLimit(miterLimit);
break; break;
} }
@ -928,9 +784,9 @@ cl->fBoundsLeftTop.PrintToStream();
{ {
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_LINE_MODE: Layer: %s\n",fName, cl->fName->String())); DTRACE(("ServerWindow %s: Message AS_LAYER_GET_LINE_MODE: Layer: %s\n",fName, cl->fName->String()));
fMsgSender->StartMessage(SERVER_TRUE); fMsgSender->StartMessage(SERVER_TRUE);
fMsgSender->Attach<int8>((int8)(cl->fLayerData->lineCap)); fMsgSender->Attach<int8>((int8)(cl->fLayerData->LineCapMode()));
fMsgSender->Attach<int8>((int8)(cl->fLayerData->lineJoin)); fMsgSender->Attach<int8>((int8)(cl->fLayerData->LineJoinMode()));
fMsgSender->Attach<float>(cl->fLayerData->miterLimit); fMsgSender->Attach<float>(cl->fLayerData->MiterLimit());
fMsgSender->Flush(); fMsgSender->Flush();
break; break;
@ -938,6 +794,7 @@ cl->fBoundsLeftTop.PrintToStream();
case AS_LAYER_PUSH_STATE: case AS_LAYER_PUSH_STATE:
{ {
DTRACE(("ServerWindow %s: Message AS_LAYER_PUSH_STATE: Layer: %s\n",fName, cl->fName->String())); DTRACE(("ServerWindow %s: Message AS_LAYER_PUSH_STATE: Layer: %s\n",fName, cl->fName->String()));
// TODO: refactor, put this in Layer
LayerData *ld = new LayerData(); LayerData *ld = new LayerData();
ld->prevState = cl->fLayerData; ld->prevState = cl->fLayerData;
cl->fLayerData = ld; cl->fLayerData = ld;
@ -954,7 +811,7 @@ cl->fBoundsLeftTop.PrintToStream();
DTRACE(("WARNING: SW(%s): User called BView(%s)::PopState(), but there is NO state on stack!\n", fName, cl->fName->String())); DTRACE(("WARNING: SW(%s): User called BView(%s)::PopState(), but there is NO state on stack!\n", fName, cl->fName->String()));
break; break;
} }
// TODO: refactor, put this in Layer
LayerData *ld = cl->fLayerData; LayerData *ld = cl->fLayerData;
cl->fLayerData = cl->fLayerData->prevState; cl->fLayerData = cl->fLayerData->prevState;
ld->prevState = NULL; ld->prevState = NULL;
@ -966,8 +823,12 @@ cl->fBoundsLeftTop.PrintToStream();
} }
case AS_LAYER_SET_SCALE: case AS_LAYER_SET_SCALE:
{ {
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",fName, cl->fName->String())); DTRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",fName, cl->fName->String()));
link.Read<float>(&(cl->fLayerData->scale)); float scale;
link.Read<float>(&scale);
// TODO: The BeBook says, if you call SetScale() it will be
// multiplied with the scale from all previous states on the stack
cl->fLayerData->SetScale(scale);
break; break;
} }
case AS_LAYER_GET_SCALE: case AS_LAYER_GET_SCALE:
@ -975,10 +836,14 @@ cl->fBoundsLeftTop.PrintToStream();
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_SCALE: Layer: %s\n",fName, cl->fName->String())); DTRACE(("ServerWindow %s: Message AS_LAYER_GET_SCALE: Layer: %s\n",fName, cl->fName->String()));
LayerData *ld = cl->fLayerData; LayerData *ld = cl->fLayerData;
float scale = ld->scale; // TODO: And here, we're taking that into account, but not above
// -> refactor put scale into Layer, or better yet, when the
// state stack is within Layer, PushState() should multiply
// by the previous last states scale. Would fix the problem above too.
float scale = ld->Scale();
while((ld = ld->prevState)) while ((ld = ld->prevState))
scale *= ld->scale; scale *= ld->Scale();
fMsgSender->StartMessage(SERVER_TRUE); fMsgSender->StartMessage(SERVER_TRUE);
fMsgSender->Attach<float>(scale); fMsgSender->Attach<float>(scale);
@ -994,7 +859,7 @@ cl->fBoundsLeftTop.PrintToStream();
link.Read<float>(&x); link.Read<float>(&x);
link.Read<float>(&y); link.Read<float>(&y);
cl->fLayerData->penlocation.Set(x, y); cl->fLayerData->SetPenLocation(BPoint(x, y));
break; break;
} }
@ -1002,7 +867,7 @@ cl->fBoundsLeftTop.PrintToStream();
{ {
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_LOC: Layer: %s\n",fName, cl->fName->String())); DTRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_LOC: Layer: %s\n",fName, cl->fName->String()));
fMsgSender->StartMessage(SERVER_TRUE); fMsgSender->StartMessage(SERVER_TRUE);
fMsgSender->Attach<BPoint>(cl->fLayerData->penlocation); fMsgSender->Attach<BPoint>(cl->fLayerData->PenLocation());
fMsgSender->Flush(); fMsgSender->Flush();
break; break;
@ -1010,7 +875,9 @@ cl->fBoundsLeftTop.PrintToStream();
case AS_LAYER_SET_PEN_SIZE: case AS_LAYER_SET_PEN_SIZE:
{ {
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_SIZE: Layer: %s\n",fName, cl->fName->String())); DTRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_SIZE: Layer: %s\n",fName, cl->fName->String()));
link.Read<float>(&(cl->fLayerData->pensize)); float penSize;
link.Read<float>(&penSize);
cl->fLayerData->SetPenSize(penSize);
break; break;
} }
@ -1018,7 +885,7 @@ cl->fBoundsLeftTop.PrintToStream();
{ {
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_SIZE: Layer: %s\n",fName, cl->fName->String())); DTRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_SIZE: Layer: %s\n",fName, cl->fName->String()));
fMsgSender->StartMessage(SERVER_TRUE); fMsgSender->StartMessage(SERVER_TRUE);
fMsgSender->Attach<float>(cl->fLayerData->pensize); fMsgSender->Attach<float>(cl->fLayerData->PenSize());
fMsgSender->Flush(); fMsgSender->Flush();
break; break;
@ -1030,8 +897,9 @@ cl->fBoundsLeftTop.PrintToStream();
link.Read(&c, sizeof(rgb_color)); link.Read(&c, sizeof(rgb_color));
cl->fLayerData->viewcolor.SetColor(c); cl->fLayerData->SetViewColor(RGBColor(c));
// TODO: this should not trigger redraw, no?!?
myRootLayer->GoRedraw(cl, cl->fVisible); myRootLayer->GoRedraw(cl, cl->fVisible);
break; break;
@ -1041,9 +909,9 @@ cl->fBoundsLeftTop.PrintToStream();
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_COLORS: Layer: %s\n",fName, cl->fName->String())); DTRACE(("ServerWindow %s: Message AS_LAYER_GET_COLORS: Layer: %s\n",fName, cl->fName->String()));
rgb_color highColor, lowColor, viewColor; rgb_color highColor, lowColor, viewColor;
highColor = cl->fLayerData->highcolor.GetColor32(); highColor = cl->fLayerData->HighColor().GetColor32();
lowColor = cl->fLayerData->lowcolor.GetColor32(); lowColor = cl->fLayerData->LowColor().GetColor32();
viewColor = cl->fLayerData->viewcolor.GetColor32(); viewColor = cl->fLayerData->ViewColor().GetColor32();
fMsgSender->StartMessage(SERVER_TRUE); fMsgSender->StartMessage(SERVER_TRUE);
fMsgSender->Attach(&highColor, sizeof(rgb_color)); fMsgSender->Attach(&highColor, sizeof(rgb_color));
@ -1061,8 +929,8 @@ cl->fBoundsLeftTop.PrintToStream();
link.Read<int8>(&srcAlpha); link.Read<int8>(&srcAlpha);
link.Read<int8>(&alphaFunc); link.Read<int8>(&alphaFunc);
cl->fLayerData->alphaSrcMode = (source_alpha)srcAlpha; cl->fLayerData->SetBlendingMode((source_alpha)srcAlpha,
cl->fLayerData->alphaFncMode = (alpha_function)alphaFunc; (alpha_function)alphaFunc);
break; break;
} }
@ -1070,8 +938,8 @@ cl->fBoundsLeftTop.PrintToStream();
{ {
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_BLEND_MODE: Layer: %s\n",fName, cl->fName->String())); DTRACE(("ServerWindow %s: Message AS_LAYER_GET_BLEND_MODE: Layer: %s\n",fName, cl->fName->String()));
fMsgSender->StartMessage(SERVER_TRUE); fMsgSender->StartMessage(SERVER_TRUE);
fMsgSender->Attach<int8>((int8)(cl->fLayerData->alphaSrcMode)); fMsgSender->Attach<int8>((int8)(cl->fLayerData->AlphaSrcMode()));
fMsgSender->Attach<int8>((int8)(cl->fLayerData->alphaFncMode)); fMsgSender->Attach<int8>((int8)(cl->fLayerData->AlphaFncMode()));
fMsgSender->Flush(); fMsgSender->Flush();
break; break;
@ -1083,7 +951,7 @@ cl->fBoundsLeftTop.PrintToStream();
link.Read<int8>(&drawingMode); link.Read<int8>(&drawingMode);
cl->fLayerData->draw_mode = (drawing_mode)drawingMode; cl->fLayerData->SetDrawingMode((drawing_mode)drawingMode);
break; break;
} }
@ -1091,7 +959,7 @@ cl->fBoundsLeftTop.PrintToStream();
{ {
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_DRAW_MODE: Layer: %s\n",fName, cl->fName->String())); DTRACE(("ServerWindow %s: Message AS_LAYER_GET_DRAW_MODE: Layer: %s\n",fName, cl->fName->String()));
fMsgSender->StartMessage(SERVER_TRUE); fMsgSender->StartMessage(SERVER_TRUE);
fMsgSender->Attach<int8>((int8)(cl->fLayerData->draw_mode)); fMsgSender->Attach<int8>((int8)(cl->fLayerData->GetDrawingMode()));
fMsgSender->Flush(); fMsgSender->Flush();
break; break;
@ -1099,7 +967,9 @@ cl->fBoundsLeftTop.PrintToStream();
case AS_LAYER_PRINT_ALIASING: case AS_LAYER_PRINT_ALIASING:
{ {
DTRACE(("ServerWindow %s: Message AS_LAYER_PRINT_ALIASING: Layer: %s\n",fName, cl->fName->String())); DTRACE(("ServerWindow %s: Message AS_LAYER_PRINT_ALIASING: Layer: %s\n",fName, cl->fName->String()));
link.Read<bool>(&(cl->fLayerData->fontAliasing)); bool fontAliasing;
link.Read<bool>(&fontAliasing);
cl->fLayerData->SetFontAntiAliasing(!fontAliasing);
break; break;
} }
@ -1176,6 +1046,7 @@ cl->fBoundsLeftTop.PrintToStream();
} }
// redraw if we previously had or if we have acquired a picture to clip to. // redraw if we previously had or if we have acquired a picture to clip to.
// TODO: Are you sure about triggering a redraw?
if (redraw) if (redraw)
myRootLayer->GoRedraw(cl, reg); myRootLayer->GoRedraw(cl, reg);
@ -1242,13 +1113,16 @@ cl->fBoundsLeftTop.PrintToStream();
ld = cl->fLayerData; ld = cl->fLayerData;
reg = cl->ConvertFromParent(&(cl->fVisible)); reg = cl->ConvertFromParent(&(cl->fVisible));
if(ld->clipReg) if (ld->ClippingRegion())
reg.IntersectWith(ld->clipReg); reg.IntersectWith(ld->ClippingRegion());
while((ld = ld->prevState)) // TODO: This could also be done more reliably in the Layer,
{ // when the State stack is implemented there. There should be
if(ld->clipReg) // DrawData::fCulmulatedClippingRegion...
reg.IntersectWith(ld->clipReg); // TODO: the DrawData clipping region should be in local view coords.
while ((ld = ld->prevState)) {
if (ld->ClippingRegion())
reg.IntersectWith(ld->ClippingRegion());
} }
noOfRects = reg.CountRects(); noOfRects = reg.CountRects();
@ -1268,18 +1142,15 @@ cl->fBoundsLeftTop.PrintToStream();
int32 noOfRects; int32 noOfRects;
BRect r; BRect r;
if(cl->fLayerData->clipReg)
cl->fLayerData->clipReg->MakeEmpty();
else
cl->fLayerData->clipReg = new BRegion();
link.Read<int32>(&noOfRects); link.Read<int32>(&noOfRects);
BRegion region;
for(int i = 0; i < noOfRects; i++) for(int i = 0; i < noOfRects; i++)
{ {
link.Read<BRect>(&r); link.Read<BRect>(&r);
cl->fLayerData->clipReg->Include(r); region.Include(r);
} }
cl->fLayerData->SetClippingRegion(region);
cl->RebuildFullRegion(); cl->RebuildFullRegion();
if (!(cl->IsHidden())) if (!(cl->IsHidden()))
@ -1305,7 +1176,8 @@ cl->fBoundsLeftTop.PrintToStream();
{ {
DTRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",fName, cl->fName->String())); DTRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",fName, cl->fName->String()));
// TODO: Watch out for the coordinate system AS_LAYER_INVAL_REGION // TODO: handle transformation (origin and scale) prior to converting to top
// TODO: Handle conversion to top
BRegion invalReg; BRegion invalReg;
int32 noOfRects; int32 noOfRects;
BRect rect; BRect rect;
@ -1597,7 +1469,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
link.Read(&c, sizeof(rgb_color)); link.Read(&c, sizeof(rgb_color));
cl->fLayerData->highcolor.SetColor(c); cl->fLayerData->SetHighColor(RGBColor(c));
break; break;
} }
@ -1608,7 +1480,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
link.Read(&c, sizeof(rgb_color)); link.Read(&c, sizeof(rgb_color));
cl->fLayerData->lowcolor.SetColor(c); cl->fLayerData->SetLowColor(RGBColor(c));
break; break;
} }
@ -1619,7 +1491,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
link.Read(&pat, sizeof(pattern)); link.Read(&pat, sizeof(pattern));
cl->fLayerData->patt = pat; cl->fLayerData->SetPattern(Pattern(pat));
break; break;
} }
@ -1627,7 +1499,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
{ {
DTRACE(("ServerWindow %s: Message AS_STROKE_LINE\n",fName)); DTRACE(("ServerWindow %s: Message AS_STROKE_LINE\n",fName));
// TODO: Add clipping TO AS_STROKE_LINE
float x1, y1, x2, y2; float x1, y1, x2, y2;
link.Read<float>(&x1); link.Read<float>(&x1);
@ -1639,12 +1510,17 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
{ {
BPoint p1(x1,y1); BPoint p1(x1,y1);
BPoint p2(x2,y2); BPoint p2(x2,y2);
desktop->GetDisplayDriver()->StrokeLine(cl->ConvertToTop(p1),cl->ConvertToTop(p2), desktop->GetDisplayDriver()->StrokeLine(cl->ConvertToTop(p1),
cl->fLayerData); cl->ConvertToTop(p2),
cl->fLayerData);
// We update the pen here because many DisplayDriver calls which do not update the // We update the pen here because many DisplayDriver calls which do not update the
// pen position actually call StrokeLine // pen position actually call StrokeLine
cl->fLayerData->penlocation=p2;
// TODO: Decide where to put this, for example, it cannot be done
// for DrawString(), also there needs to be a decision, if penlocation
// is in View coordinates (I think it should be) or in screen coordinates.
cl->fLayerData->SetPenLocation(p2);
} }
break; break;
} }
@ -1652,7 +1528,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
{ {
DTRACE(("ServerWindow %s: Message AS_INVERT_RECT\n",fName)); DTRACE(("ServerWindow %s: Message AS_INVERT_RECT\n",fName));
// TODO: Add clipping TO AS_INVERT_RECT
BRect rect; BRect rect;
link.Read<BRect>(&rect); link.Read<BRect>(&rect);
@ -1664,7 +1539,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
{ {
DTRACE(("ServerWindow %s: Message AS_STROKE_RECT\n",fName)); DTRACE(("ServerWindow %s: Message AS_STROKE_RECT\n",fName));
// TODO: Add clipping TO AS_STROKE_RECT
float left, top, right, bottom; float left, top, right, bottom;
link.Read<float>(&left); link.Read<float>(&left);
link.Read<float>(&top); link.Read<float>(&top);
@ -1680,7 +1554,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
{ {
DTRACE(("ServerWindow %s: Message AS_FILL_RECT\n",fName)); DTRACE(("ServerWindow %s: Message AS_FILL_RECT\n",fName));
// TODO: Add clipping TO AS_FILL_RECT
BRect rect; BRect rect;
link.Read<BRect>(&rect); link.Read<BRect>(&rect);
if (cl && cl->fLayerData) if (cl && cl->fLayerData)
@ -1691,7 +1564,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
{ {
DTRACE(("ServerWindow %s: Message AS_STROKE_ARC\n",fName)); DTRACE(("ServerWindow %s: Message AS_STROKE_ARC\n",fName));
// TODO: Add clipping to AS_STROKE_ARC
float angle, span; float angle, span;
BRect r; BRect r;
@ -1706,7 +1578,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
{ {
DTRACE(("ServerWindow %s: Message AS_FILL_ARC\n",fName)); DTRACE(("ServerWindow %s: Message AS_FILL_ARC\n",fName));
// TODO: Add clipping to AS_FILL_ARC
float angle, span; float angle, span;
BRect r; BRect r;
@ -1721,7 +1592,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
{ {
DTRACE(("ServerWindow %s: Message AS_STROKE_BEZIER\n",fName)); DTRACE(("ServerWindow %s: Message AS_STROKE_BEZIER\n",fName));
// TODO: Add clipping to AS_STROKE_BEZIER
BPoint *pts; BPoint *pts;
int i; int i;
pts = new BPoint[4]; pts = new BPoint[4];
@ -1743,7 +1613,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
{ {
DTRACE(("ServerWindow %s: Message AS_FILL_BEZIER\n",fName)); DTRACE(("ServerWindow %s: Message AS_FILL_BEZIER\n",fName));
// TODO: Add clipping to AS_STROKE_BEZIER
BPoint *pts; BPoint *pts;
int i; int i;
pts = new BPoint[4]; pts = new BPoint[4];
@ -1765,7 +1634,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
{ {
DTRACE(("ServerWindow %s: Message AS_STROKE_ELLIPSE\n",fName)); DTRACE(("ServerWindow %s: Message AS_STROKE_ELLIPSE\n",fName));
// TODO: Add clipping AS_STROKE_ELLIPSE
BRect rect; BRect rect;
link.Read<BRect>(&rect); link.Read<BRect>(&rect);
if (cl && cl->fLayerData) if (cl && cl->fLayerData)
@ -1776,7 +1644,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
{ {
DTRACE(("ServerWindow %s: Message AS_FILL_ELLIPSE\n",fName)); DTRACE(("ServerWindow %s: Message AS_FILL_ELLIPSE\n",fName));
// TODO: Add clipping AS_STROKE_ELLIPSE
BRect rect; BRect rect;
link.Read<BRect>(&rect); link.Read<BRect>(&rect);
if (cl && cl->fLayerData) if (cl && cl->fLayerData)
@ -1787,7 +1654,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
{ {
DTRACE(("ServerWindow %s: Message AS_STROKE_ROUNDRECT\n",fName)); DTRACE(("ServerWindow %s: Message AS_STROKE_ROUNDRECT\n",fName));
// TODO: Add clipping AS_STROKE_ROUNDRECT
BRect rect; BRect rect;
float xrad,yrad; float xrad,yrad;
link.Read<BRect>(&rect); link.Read<BRect>(&rect);
@ -1802,7 +1668,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
{ {
DTRACE(("ServerWindow %s: Message AS_FILL_ROUNDRECT\n",fName)); DTRACE(("ServerWindow %s: Message AS_FILL_ROUNDRECT\n",fName));
// TODO: Add clipping AS_STROKE_ROUNDRECT
BRect rect; BRect rect;
float xrad,yrad; float xrad,yrad;
link.Read<BRect>(&rect); link.Read<BRect>(&rect);
@ -1817,7 +1682,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
{ {
DTRACE(("ServerWindow %s: Message AS_STROKE_TRIANGLE\n",fName)); DTRACE(("ServerWindow %s: Message AS_STROKE_TRIANGLE\n",fName));
// TODO:: Add clipping to AS_STROKE_TRIANGLE
BPoint pts[3]; BPoint pts[3];
BRect rect; BRect rect;
@ -1839,7 +1703,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
{ {
DTRACE(("ServerWindow %s: Message AS_FILL_TRIANGLE\n",fName)); DTRACE(("ServerWindow %s: Message AS_FILL_TRIANGLE\n",fName));
// TODO:: Add clipping to AS_FILL_TRIANGLE
BPoint pts[3]; BPoint pts[3];
BRect rect; BRect rect;
@ -1857,6 +1720,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
} }
break; break;
} }
// TODO: get rid of all this code duplication!!
case AS_STROKE_POLYGON: case AS_STROKE_POLYGON:
{ {
DTRACE(("ServerWindow %s: Message AS_STROKE_POLYGON\n",fName)); DTRACE(("ServerWindow %s: Message AS_STROKE_POLYGON\n",fName));
@ -2055,7 +1919,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
link.Read<float>(&x); link.Read<float>(&x);
link.Read<float>(&y); link.Read<float>(&y);
if(cl && cl->fLayerData) if(cl && cl->fLayerData)
cl->fLayerData->penlocation.Set(x,y); cl->fLayerData->SetPenLocation(BPoint(x, y));
break; break;
} }
@ -2066,7 +1930,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
link.Read<float>(&size); link.Read<float>(&size);
if(cl && cl->fLayerData) if(cl && cl->fLayerData)
cl->fLayerData->pensize=size; cl->fLayerData->SetPenSize(size);
break; break;
} }
@ -2074,6 +1938,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
{ {
DTRACE(("ServerWindow %s: Message AS_SET_FONT\n",fName)); DTRACE(("ServerWindow %s: Message AS_SET_FONT\n",fName));
// TODO: Implement AS_SET_FONT? // TODO: Implement AS_SET_FONT?
// Confusing!! But it works already!
break; break;
} }
case AS_SET_FONT_SIZE: case AS_SET_FONT_SIZE:

View File

@ -712,8 +712,8 @@ DisplayDriverPainter::StrokeLine(const BPoint &start, const BPoint &end, const R
if (Lock()) { if (Lock()) {
if (!fPainter->StraightLine(start, end, color.GetColor32())) { if (!fPainter->StraightLine(start, end, color.GetColor32())) {
DrawData context; DrawData context;
context.highcolor = color; context.SetHighColor(color);
context.draw_mode = B_OP_COPY; context.SetDrawingMode(B_OP_COPY);
StrokeLine(start, end, &context); StrokeLine(start, end, &context);
} else { } else {
BRect touched(min_c(start.x, end.x), BRect touched(min_c(start.x, end.x),
@ -886,13 +886,13 @@ DisplayDriverPainter::DrawString(const char *string, const int32 &length,
const BPoint &pt, const RGBColor &color, const BPoint &pt, const RGBColor &color,
escapement_delta *delta) escapement_delta *delta)
{ {
// what - without any clipping?!?
DrawData d; DrawData d;
d.highcolor=color; d.SetHighColor(color);
if(delta) if (delta)
d.edelta=*delta; d.SetEscapementDelta(*delta);
DrawString(string,length,pt,&d);
DrawString(string, length, pt, &d);
} }
// DrawString // DrawString
@ -1144,16 +1144,16 @@ DisplayDriverPainter::StrokeLineArray(const int32 &numlines,
if (Lock()) { if (Lock()) {
DrawData context; DrawData context;
context.draw_mode = B_OP_COPY; context.SetDrawingMode(B_OP_COPY);
const LineArrayData *data; const LineArrayData *data;
data = (const LineArrayData *)&(linedata[0]); data = (const LineArrayData *)&(linedata[0]);
context.highcolor = data->color; context.SetHighColor(data->color);
BRect touched = fPainter->StrokeLine(data->pt1, data->pt2, &context); BRect touched = fPainter->StrokeLine(data->pt1, data->pt2, &context);
for (int32 i = 1; i < numlines; i++) { for (int32 i = 1; i < numlines; i++) {
data = (const LineArrayData *)&(linedata[i]); data = (const LineArrayData *)&(linedata[i]);
context.highcolor = data->color; context.SetHighColor(data->color);
touched = touched | fPainter->StrokeLine(data->pt1, data->pt2, &context); touched = touched | fPainter->StrokeLine(data->pt1, data->pt2, &context);
} }

View File

@ -19,8 +19,8 @@ HWInterface::HWInterface()
fCursor(NULL), fCursor(NULL),
fCursorVisible(true), fCursorVisible(true),
fCursorLocation(0, 0), fCursorLocation(0, 0),
fUpdateExecutor(new UpdateQueue(this)) // fUpdateExecutor(new UpdateQueue(this))
// fUpdateExecutor(NULL) fUpdateExecutor(NULL)
{ {
} }
@ -105,18 +105,18 @@ HWInterface::GetCursorPosition()
status_t status_t
HWInterface::Invalidate(const BRect& frame) HWInterface::Invalidate(const BRect& frame)
{ {
// return CopyBackToFront(frame); return CopyBackToFront(frame);
// TODO: the remaining problem is the immediate wake up of the // TODO: the remaining problem is the immediate wake up of the
// thread carrying out the updates, when I enable it, there // thread carrying out the updates, when I enable it, there
// seems to be a deadlock, but I didn't figure it out yet. // seems to be a deadlock, but I didn't figure it out yet.
// Maybe the same bug is there without the wakeup, only, triggered // Maybe the same bug is there without the wakeup, only, triggered
// less often.... scarry, huh? // less often.... scarry, huh?
if (frame.IsValid()) { /* if (frame.IsValid()) {
fUpdateExecutor->AddRect(frame); fUpdateExecutor->AddRect(frame);
return B_OK; return B_OK;
} }
return B_BAD_VALUE; return B_BAD_VALUE;*/
} }
// CopyBackToFront // CopyBackToFront

View File

@ -152,29 +152,29 @@ void
Painter::SetDrawData(const DrawData* data) Painter::SetDrawData(const DrawData* data)
{ {
// for now... // for now...
SetPenSize(data->pensize); SetPenSize(data->PenSize());
SetPenLocation(data->penlocation); SetPenLocation(data->PenLocation());
SetFont(data->font); SetFont(data->Font());
// if (data->clipReg) { // if (data->clipReg) {
// ConstrainClipping(*data->clipReg); // ConstrainClipping(*data->clipReg);
// } // }
// any of these conditions means we need to use a different drawing // any of these conditions means we need to use a different drawing
// mode instance // mode instance
bool updateDrawingMode = !(data->patt == fPatternHandler->GetPattern()) || bool updateDrawingMode = !(data->GetPattern() == fPatternHandler->GetPattern()) ||
data->draw_mode != fDrawingMode || data->GetDrawingMode() != fDrawingMode ||
(data->draw_mode == B_OP_ALPHA && (data->alphaSrcMode != fAlphaSrcMode || (data->GetDrawingMode() == B_OP_ALPHA && (data->AlphaSrcMode() != fAlphaSrcMode ||
data->alphaFncMode != fAlphaFncMode)); data->AlphaFncMode() != fAlphaFncMode));
fDrawingMode = data->draw_mode; fDrawingMode = data->GetDrawingMode();
fAlphaSrcMode = data->alphaSrcMode; fAlphaSrcMode = data->AlphaSrcMode();
fAlphaFncMode = data->alphaFncMode; fAlphaFncMode = data->AlphaFncMode();
fPatternHandler->SetPattern(data->patt); fPatternHandler->SetPattern(data->GetPattern());
if (updateDrawingMode) if (updateDrawingMode)
_UpdateDrawingMode(); _UpdateDrawingMode();
SetHighColor(data->highcolor.GetColor32()); SetHighColor(data->HighColor().GetColor32());
SetLowColor(data->lowcolor.GetColor32()); SetLowColor(data->LowColor().GetColor32());
} }
// #pragma mark - // #pragma mark -
@ -292,7 +292,7 @@ BRect
Painter::StrokeLine(BPoint a, BPoint b, DrawData* context) Painter::StrokeLine(BPoint a, BPoint b, DrawData* context)
{ {
// this happens independent of wether we actually draw something // this happens independent of wether we actually draw something
context->penlocation = b; context->SetPenLocation(b);
// NOTE: penlocation should be converted to the local // NOTE: penlocation should be converted to the local
// coordinate of the view for which we draw here, after // coordinate of the view for which we draw here, after
// we have been used. Updating it could also be done somewhere // we have been used. Updating it could also be done somewhere
@ -305,7 +305,7 @@ Painter::StrokeLine(BPoint a, BPoint b, DrawData* context)
_Transform(&a, false); _Transform(&a, false);
_Transform(&b, false); _Transform(&b, false);
SetPenSize(context->pensize); SetPenSize(context->PenSize());
BRect touched(min_c(a.x, b.x), min_c(a.y, b.y), BRect touched(min_c(a.x, b.x), min_c(a.y, b.y),
max_c(a.x, b.x), max_c(a.y, b.y)); max_c(a.x, b.x), max_c(a.y, b.y));
@ -360,7 +360,7 @@ BRect
Painter::StrokeLine(BPoint b, DrawData* context) Painter::StrokeLine(BPoint b, DrawData* context)
{ {
// TODO: move this function elsewhere // TODO: move this function elsewhere
return StrokeLine(context->penlocation, b, context); return StrokeLine(context->PenLocation(), b, context);
} }
typedef union { typedef union {