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:
parent
52c415a86c
commit
e742e3e106
@ -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
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
@ -22,82 +22,223 @@
|
||||
// File Name: LayerData.h
|
||||
// Author: DarkWyrm <bpmagic@columbus.rr.com>
|
||||
// Adi Oanca <adioanca@mymail.ro>
|
||||
// Stephan Aßmus <superstippi@gmx.de>
|
||||
// Description: Data classes for working with BView states and draw parameters
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#ifndef LAYERDATA_H_
|
||||
#define LAYERDATA_H_
|
||||
#ifndef LAYER_DATA_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 <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 ServerFont;
|
||||
class ServerPicture;
|
||||
class Layer;
|
||||
|
||||
class DrawData
|
||||
{
|
||||
public:
|
||||
DrawData(void);
|
||||
DrawData(const DrawData &data);
|
||||
virtual ~DrawData(void);
|
||||
DrawData& operator=(const DrawData &from);
|
||||
// TODO: uncomment and implement DrawData::PrintToStream when needed.
|
||||
// virtual void PrintToStream() const;
|
||||
class DrawData {
|
||||
public:
|
||||
DrawData();
|
||||
DrawData(const DrawData& from);
|
||||
virtual ~DrawData();
|
||||
|
||||
BPoint penlocation;
|
||||
DrawData& operator=(const DrawData& from);
|
||||
|
||||
RGBColor highcolor,
|
||||
lowcolor;
|
||||
// coordinate transformation
|
||||
void SetOrigin(const BPoint& origin);
|
||||
inline const BPoint& Origin() const
|
||||
{ return fOrigin; }
|
||||
|
||||
float pensize;
|
||||
Pattern patt;
|
||||
drawing_mode draw_mode;
|
||||
|
||||
cap_mode lineCap;
|
||||
join_mode lineJoin;
|
||||
float miterLimit;
|
||||
|
||||
source_alpha alphaSrcMode;
|
||||
alpha_function alphaFncMode;
|
||||
float scale;
|
||||
bool fontAliasing;
|
||||
ServerFont font;
|
||||
|
||||
BRegion* clipReg;
|
||||
|
||||
escapement_delta edelta;
|
||||
void SetScale(float scale);
|
||||
inline float Scale() const
|
||||
{ return fScale; }
|
||||
|
||||
// additional clipping as requested by client
|
||||
void SetClippingRegion(const BRegion& region);
|
||||
inline const BRegion* ClippingRegion() const
|
||||
{ return fClippingRegion; }
|
||||
/* inline int32 CountClippingRects() const
|
||||
{ return fClippingRegion ? fClippingRegion.CountRects() : 0; }
|
||||
inline BRect ClippingRectAt(int32 index) const;*/
|
||||
|
||||
// color
|
||||
void SetHighColor(const RGBColor& color);
|
||||
inline const RGBColor& HighColor() const
|
||||
{ return fHighColor; }
|
||||
|
||||
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
|
||||
{
|
||||
public:
|
||||
LayerData(void);
|
||||
LayerData(const Layer *layer);
|
||||
class LayerData : public DrawData {
|
||||
public:
|
||||
LayerData();
|
||||
LayerData(const LayerData &data);
|
||||
virtual ~LayerData(void);
|
||||
LayerData &operator=(const LayerData &from);
|
||||
virtual ~LayerData();
|
||||
|
||||
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;
|
||||
|
||||
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
|
||||
// places on us. We can have both. :)
|
||||
ServerBitmap* background;
|
||||
ServerBitmap* overlay;
|
||||
RGBColor fViewColor;
|
||||
|
||||
// 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
|
||||
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_
|
||||
|
@ -46,6 +46,9 @@ class Pattern {
|
||||
Pattern(const Pattern& src)
|
||||
{ fPattern.type64 = src.fPattern.type64; }
|
||||
|
||||
Pattern(const pattern& src)
|
||||
{ fPattern.type64 = *(uint64*)src.data; }
|
||||
|
||||
inline const int8* GetInt8(void) const
|
||||
{ return fPattern.type8; }
|
||||
|
||||
|
@ -180,7 +180,7 @@ void Decorator::SetFont(ServerFont *font)
|
||||
if(!font)
|
||||
return;
|
||||
|
||||
_drawdata.font = *font;
|
||||
_drawdata.SetFont(*font);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -24,18 +24,20 @@
|
||||
// Description: Fallback decorator for the app_server
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Rect.h>
|
||||
#include "DisplayDriver.h"
|
||||
#include <View.h>
|
||||
#include "LayerData.h"
|
||||
|
||||
#include "ColorUtils.h"
|
||||
#include "DefaultDecorator.h"
|
||||
#include "DisplayDriver.h"
|
||||
#include "FontServer.h"
|
||||
#include "LayerData.h"
|
||||
#include "PatternHandler.h"
|
||||
#include "RGBColor.h"
|
||||
#include "RectUtils.h"
|
||||
#include <stdio.h>
|
||||
#include "FontServer.h"
|
||||
|
||||
#include "DefaultDecorator.h"
|
||||
|
||||
//#define USE_VIEW_FILL_HACK
|
||||
|
||||
@ -53,11 +55,12 @@ DefaultDecorator::DefaultDecorator(BRect rect, int32 wlook, int32 wfeel, int32 w
|
||||
|
||||
taboffset=0;
|
||||
titlepixelwidth=0;
|
||||
|
||||
SetFont(fontserver->GetSystemBold());
|
||||
_drawdata.font.SetSize(14);
|
||||
_drawdata.font.SetFlags(B_FORCE_ANTIALIASING);
|
||||
_drawdata.font.SetSpacing(B_STRING_SPACING);
|
||||
|
||||
ServerFont font(*fontserver->GetSystemBold());
|
||||
font.SetSize(font.Size() * 1.1);
|
||||
font.SetFlags(B_FORCE_ANTIALIASING);
|
||||
font.SetSpacing(B_STRING_SPACING);
|
||||
SetFont(&font);
|
||||
|
||||
framecolors=new RGBColor[6];
|
||||
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));
|
||||
// Designed simply to redraw the title when it has changed on
|
||||
// the client side.
|
||||
_drawdata.highcolor=_colors->window_tab_text;
|
||||
_drawdata.lowcolor=(GetFocus())?_colors->window_tab:_colors->inactive_window_tab;
|
||||
_drawdata.SetHighColor(_colors->window_tab_text);
|
||||
_drawdata.SetLowColor(GetFocus() ? _colors->window_tab : _colors->inactive_window_tab);
|
||||
|
||||
int32 titlecount=_ClipTitle((_zoomrect.left-textoffset)-(_closerect.right+textoffset));
|
||||
BString titlestr( GetTitle() );
|
||||
@ -551,8 +554,8 @@ STRACE(("_DrawFrame(%f,%f,%f,%f)\n", invalid.left, invalid.top,
|
||||
invalid.right, invalid.bottom));
|
||||
|
||||
#ifdef USE_VIEW_FILL_HACK
|
||||
_drawdata.highcolor = RGBColor( 192, 192, 192 );
|
||||
_driver->FillRect(_frame,_drawdata.highcolor);
|
||||
_drawdata.SetHighColor(RGBColor(192, 192, 192 ));
|
||||
_driver->FillRect(_frame, _drawdata.HighColor());
|
||||
#endif
|
||||
|
||||
if(_look == B_NO_BORDER_WINDOW_LOOK)
|
||||
|
@ -614,7 +614,7 @@ void Layer::Draw(const BRect &r)
|
||||
r.PrintToStream();
|
||||
#endif
|
||||
|
||||
fDriver->FillRect(r, fLayerData->viewcolor);
|
||||
fDriver->FillRect(r, fLayerData->ViewColor());
|
||||
// RGBColor c(rand()%255,rand()%255,rand()%255);
|
||||
// fDriver->FillRect(r, c);
|
||||
|
||||
@ -736,8 +736,8 @@ void Layer::RebuildFullRegion(void)
|
||||
do
|
||||
{
|
||||
// clip to user region
|
||||
if(ld->clipReg)
|
||||
fFull.IntersectWith( ld->clipReg );
|
||||
if (const BRegion* userClipping = ld->ClippingRegion())
|
||||
fFull.IntersectWith(userClipping);
|
||||
|
||||
} while( (ld = ld->prevState) );
|
||||
|
||||
|
@ -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
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
@ -22,175 +22,534 @@
|
||||
// File Name: LayerData.cpp
|
||||
// Author: DarkWyrm <bpmagic@columbus.rr.com>
|
||||
// Adi Oanca <adioanca@mymail.ro>
|
||||
// Stephan Aßmus <superstippi@gmx.de>
|
||||
// Description: Data classes for working with BView states and draw parameters
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#include "LayerData.h"
|
||||
#include <Layer.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;
|
||||
penlocation.Set(0,0);
|
||||
highcolor.SetColor(0, 0, 0, 255);
|
||||
lowcolor.SetColor(255, 255, 255, 255);
|
||||
|
||||
patt=kSolidHigh;
|
||||
draw_mode=B_OP_COPY;
|
||||
if (fontserver && fontserver->GetSystemPlain())
|
||||
fFont = *(fontserver->GetSystemPlain());
|
||||
|
||||
lineCap =B_BUTT_CAP;
|
||||
lineJoin=B_BEVEL_JOIN;
|
||||
miterLimit=B_DEFAULT_MITER_LIMIT;
|
||||
fEscapementDelta.space = 0;
|
||||
fEscapementDelta.nonspace = 0;
|
||||
|
||||
alphaSrcMode=B_PIXEL_ALPHA;
|
||||
alphaFncMode=B_ALPHA_OVERLAY;
|
||||
|
||||
scale=1.0;
|
||||
fontAliasing=true;
|
||||
|
||||
if(fontserver && fontserver->GetSystemPlain())
|
||||
font=*(fontserver->GetSystemPlain());
|
||||
|
||||
clipReg=NULL;
|
||||
|
||||
edelta.space=0;
|
||||
edelta.nonspace=0;
|
||||
fUnscaledFontSize = fFont.Size();
|
||||
}
|
||||
|
||||
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;
|
||||
*this=data;
|
||||
delete fClippingRegion;
|
||||
}
|
||||
|
||||
DrawData &DrawData::operator=(const DrawData &from)
|
||||
// operator=
|
||||
DrawData&
|
||||
DrawData::operator=(const DrawData& from)
|
||||
{
|
||||
pensize=from.pensize;
|
||||
highcolor=from.highcolor;
|
||||
lowcolor=from.lowcolor;
|
||||
fOrigin = from.fOrigin;
|
||||
fScale = from.fScale;
|
||||
|
||||
patt=from.patt;
|
||||
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;
|
||||
fontAliasing=from.fontAliasing;
|
||||
font=from.font;
|
||||
|
||||
if(from.clipReg)
|
||||
{
|
||||
if(clipReg)
|
||||
*clipReg=*(from.clipReg);
|
||||
else
|
||||
clipReg=new BRegion(*(from.clipReg));
|
||||
if (from.fClippingRegion) {
|
||||
SetClippingRegion(*(from.fClippingRegion));
|
||||
} else {
|
||||
delete fClippingRegion;
|
||||
fClippingRegion = NULL;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
LayerData::LayerData(void)
|
||||
// SetOrigin
|
||||
void
|
||||
DrawData::SetOrigin(const BPoint& origin)
|
||||
{
|
||||
coordOrigin.Set(0.0, 0.0);
|
||||
viewcolor.SetColor(255,255,255,255);
|
||||
|
||||
background=NULL;
|
||||
overlay=NULL;
|
||||
prevState=NULL;
|
||||
fOrigin = origin;
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
clipReg = NULL;
|
||||
*this=data;
|
||||
fClippingRegion = NULL;
|
||||
*this = data;
|
||||
}
|
||||
|
||||
// destructor
|
||||
LayerData::~LayerData(void)
|
||||
{
|
||||
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,
|
||||
// so I'll just make sure the copy happens. :P
|
||||
pensize=from.pensize;
|
||||
highcolor=from.highcolor;
|
||||
lowcolor=from.lowcolor;
|
||||
DrawData::operator=(from);
|
||||
|
||||
patt=from.patt;
|
||||
draw_mode=from.draw_mode;
|
||||
penlocation=from.penlocation;
|
||||
|
||||
lineCap=from.lineCap;
|
||||
lineJoin=from.lineJoin;
|
||||
miterLimit=from.miterLimit;
|
||||
|
||||
alphaSrcMode=from.alphaSrcMode;
|
||||
alphaFncMode=from.alphaFncMode;
|
||||
fViewColor = from.fViewColor;
|
||||
|
||||
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;
|
||||
|
||||
// Stuff specific to LayerData
|
||||
coordOrigin=from.coordOrigin;;
|
||||
viewcolor=from.viewcolor;
|
||||
|
||||
background=from.background;
|
||||
overlay=from.overlay;
|
||||
|
||||
prevState=from.prevState;
|
||||
// TODO: Are we making any sense here?
|
||||
// How is operator= being used?
|
||||
fBackgroundBitmap = from.fBackgroundBitmap;
|
||||
fOverlayBitmap = from.fOverlayBitmap;
|
||||
|
||||
prevState = from.prevState;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void LayerData::PrintToStream() const{
|
||||
printf("\t Pen Location and Size: (%f, %f) - %f\n", penlocation.x, penlocation.y, pensize);
|
||||
printf("\t HighColor: "); highcolor.PrintToStream();
|
||||
printf("\t LowColor: "); lowcolor.PrintToStream();
|
||||
printf("\t ViewColor "); viewcolor.PrintToStream();
|
||||
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);
|
||||
printf("\t AlphaSrcMode: %ld\t AlphaFncMode: %ld\n", (int32)alphaSrcMode, (int32)alphaFncMode);
|
||||
printf("\t Scale: %f\n", scale);
|
||||
if (clipReg)
|
||||
clipReg->PrintToStream();
|
||||
// SetViewColor
|
||||
void
|
||||
LayerData::SetViewColor(const RGBColor& color)
|
||||
{
|
||||
fViewColor = color;
|
||||
}
|
||||
|
||||
// SetBackgroundBitmap
|
||||
void
|
||||
LayerData::SetBackgroundBitmap(const ServerBitmap* bitmap)
|
||||
{
|
||||
// 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 FontStyle: CURRENTLY NOT SET\n");
|
||||
printf("\t FontSize: %f\n", font.Size());
|
||||
printf("\t FontShear: %f\n", font.Shear());
|
||||
printf("\t FontRotation: %f\n", font.Rotation());
|
||||
printf("\t FontSpacing: %ld\n", font.Spacing());
|
||||
printf("\t FontEncoding: %ld\n", font.Encoding());
|
||||
printf("\t FontFace: %d\n", font.Face());
|
||||
printf("\t FontFlags: %lu\n", font.Flags());
|
||||
printf("\t Style: CURRENTLY NOT SET\n"); // ???
|
||||
printf("\t Size: %.1f (%.1f)\n", fFont.Size(), fUnscaledFontSize);
|
||||
printf("\t Shear: %.2f\n", fFont.Shear());
|
||||
printf("\t Rotation: %.2f\n", fFont.Rotation());
|
||||
printf("\t Spacing: %ld\n", fFont.Spacing());
|
||||
printf("\t Encoding: %ld\n", fFont.Encoding());
|
||||
printf("\t Face: %d\n", fFont.Face());
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,12 +26,17 @@
|
||||
// Marc Flerackers' TPicture class
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include "PicturePlayer.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Region.h>
|
||||
|
||||
#include "ServerBitmap.h"
|
||||
|
||||
#include "DisplayDriver.h"
|
||||
#include "PictureProtocol.h"
|
||||
#include "Utils.h"
|
||||
#include "DisplayDriver.h"
|
||||
#include <ServerBitmap.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "PicturePlayer.h"
|
||||
|
||||
PicturePlayer::PicturePlayer(DisplayDriver *d,void *data, int32 size)
|
||||
: fData(data, size)
|
||||
@ -133,6 +138,7 @@ status_t PicturePlayer::Play(int32 tableEntries,void *userData, LayerData *d)
|
||||
fData.Seek(0,SEEK_SET);
|
||||
off_t pos;
|
||||
fldata=*d;
|
||||
ServerFont dummyFont;
|
||||
|
||||
while (fData.Position() < size)
|
||||
{
|
||||
@ -145,8 +151,7 @@ status_t PicturePlayer::Play(int32 tableEntries,void *userData, LayerData *d)
|
||||
case B_PIC_MOVE_PEN_BY:
|
||||
{
|
||||
BPoint where = GetCoord();
|
||||
fldata.penlocation.x+=where.x;
|
||||
fldata.penlocation.y+=where.y;
|
||||
fldata.SetPenLocation(fldata.PenLocation() + where);
|
||||
break;
|
||||
}
|
||||
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
|
||||
// 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.
|
||||
fldata.edelta.nonspace=deltax;
|
||||
fldata.edelta.space=deltay;
|
||||
escapement_delta delta;
|
||||
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;
|
||||
break;
|
||||
}
|
||||
@ -349,44 +356,48 @@ status_t PicturePlayer::Play(int32 tableEntries,void *userData, LayerData *d)
|
||||
case B_PIC_SET_PEN_LOCATION:
|
||||
{
|
||||
BPoint pt = GetCoord();
|
||||
fldata.penlocation=pt;
|
||||
fldata.SetPenLocation(pt);
|
||||
break;
|
||||
}
|
||||
case B_PIC_SET_DRAWING_MODE:
|
||||
{
|
||||
int16 mode = GetInt16();
|
||||
fldata.draw_mode=(drawing_mode)mode;
|
||||
fldata.SetDrawingMode((drawing_mode)mode);
|
||||
break;
|
||||
}
|
||||
case B_PIC_SET_LINE_MODE:
|
||||
{
|
||||
GetData(&fldata.lineCap,sizeof(cap_mode));
|
||||
GetData(&fldata.lineJoin,sizeof(join_mode));
|
||||
fldata.miterLimit = GetFloat();
|
||||
cap_mode lineCapMode;
|
||||
join_mode lineJoinMode;
|
||||
GetData(&lineCapMode, sizeof(cap_mode));
|
||||
GetData(&lineJoinMode, sizeof(join_mode));
|
||||
fldata.SetLineCapMode(lineCapMode);
|
||||
fldata.SetLineJoinMode(lineJoinMode);
|
||||
fldata.SetMiterLimit(GetFloat());
|
||||
break;
|
||||
}
|
||||
case B_PIC_SET_PEN_SIZE:
|
||||
{
|
||||
float size = GetFloat();
|
||||
fldata.pensize=size;
|
||||
fldata.SetPenSize(size);
|
||||
break;
|
||||
}
|
||||
case B_PIC_SET_SCALE:
|
||||
{
|
||||
float scale = GetFloat();
|
||||
fldata.scale=scale;
|
||||
fldata.SetScale(scale);
|
||||
break;
|
||||
}
|
||||
case B_PIC_SET_FORE_COLOR:
|
||||
{
|
||||
rgb_color color = GetColor();
|
||||
fldata.highcolor=color;
|
||||
fldata.SetHighColor(color);
|
||||
break;
|
||||
}
|
||||
case B_PIC_SET_BACK_COLOR:
|
||||
{
|
||||
rgb_color color = GetColor();
|
||||
fldata.lowcolor=color;
|
||||
fldata.SetLowColor(color);
|
||||
break;
|
||||
}
|
||||
case B_PIC_SET_STIPLE_PATTERN:
|
||||
@ -405,8 +416,8 @@ status_t PicturePlayer::Play(int32 tableEntries,void *userData, LayerData *d)
|
||||
{
|
||||
int16 alphaSrcMode = GetInt16();
|
||||
int16 alphaFncMode = GetInt16();
|
||||
fldata.alphaSrcMode = (source_alpha)alphaSrcMode;
|
||||
fldata.alphaFncMode = (alpha_function)alphaFncMode;
|
||||
fldata.SetBlendingMode((source_alpha)alphaSrcMode,
|
||||
(alpha_function)alphaFncMode);
|
||||
break;
|
||||
}
|
||||
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:
|
||||
{
|
||||
fldata.font.SetSpacing(GetInt32());
|
||||
dummyFont.SetSpacing(GetInt32());
|
||||
fldata.SetFont(dummyFont, B_FONT_SPACING);
|
||||
break;
|
||||
}
|
||||
case B_PIC_SET_FONT_ENCODING:
|
||||
{
|
||||
fldata.font.SetEncoding(GetInt32());
|
||||
dummyFont.SetEncoding(GetInt32());
|
||||
fldata.SetFont(dummyFont, B_FONT_ENCODING);
|
||||
break;
|
||||
}
|
||||
case B_PIC_SET_FONT_FLAGS:
|
||||
{
|
||||
fldata.font.SetFlags(GetInt32());
|
||||
dummyFont.SetFlags(GetInt32());
|
||||
fldata.SetFont(dummyFont, B_FONT_FLAGS);
|
||||
break;
|
||||
}
|
||||
case B_PIC_SET_FONT_SIZE:
|
||||
{
|
||||
fldata.font.SetSize(GetFloat());
|
||||
dummyFont.SetSize(GetFloat());
|
||||
fldata.SetFont(dummyFont, B_FONT_SIZE);
|
||||
break;
|
||||
}
|
||||
case B_PIC_SET_FONT_ROTATE:
|
||||
{
|
||||
fldata.font.SetRotation(GetFloat());
|
||||
dummyFont.SetRotation(GetFloat());
|
||||
fldata.SetFont(dummyFont, B_FONT_ROTATION);
|
||||
break;
|
||||
}
|
||||
case B_PIC_SET_FONT_SHEAR:
|
||||
{
|
||||
fldata.font.SetShear(GetFloat());
|
||||
dummyFont.SetShear(GetFloat());
|
||||
fldata.SetFont(dummyFont, B_FONT_SHEAR);
|
||||
break;
|
||||
}
|
||||
case B_PIC_SET_FONT_FACE:
|
||||
{
|
||||
fldata.font.SetFace(GetInt32());
|
||||
dummyFont.SetFace(GetInt32());
|
||||
fldata.SetFont(dummyFont, B_FONT_FACE);
|
||||
break;
|
||||
}
|
||||
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
|
||||
// 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;
|
||||
clipreg=NULL;
|
||||
|
@ -1218,7 +1218,6 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
||||
float size,width=0;
|
||||
uint8 spacing;
|
||||
port_id replyport;
|
||||
DrawData drawdata;
|
||||
|
||||
msg.ReadString(&string);
|
||||
msg.Read<int32>(&length);
|
||||
@ -1229,22 +1228,27 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
||||
msg.Read<port_id>(&replyport);
|
||||
|
||||
replylink.SetSendPort(replyport);
|
||||
|
||||
if(length>0 && drawdata.font.SetFamilyAndStyle(family,style)==B_OK &&
|
||||
size>0 && string)
|
||||
{
|
||||
drawdata.font.SetSize(size);
|
||||
drawdata.font.SetSpacing(spacing);
|
||||
width=desktop->GetDisplayDriver()->StringWidth(string,length,&drawdata);
|
||||
|
||||
ServerFont font;
|
||||
|
||||
if (length > 0 && font.SetFamilyAndStyle(family, style) == B_OK &&
|
||||
size > 0 && string) {
|
||||
|
||||
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.Attach<float>(width);
|
||||
replylink.Flush();
|
||||
|
||||
free(string);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
replylink.StartMessage(SERVER_FALSE);
|
||||
replylink.Flush();
|
||||
}
|
||||
|
@ -348,65 +348,8 @@ void ServerWindow::SetLayerFontState(Layer *layer, LinkMsgReader &link)
|
||||
STRACE(("ServerWindow %s: SetLayerFontStateMessage for layer %s\n",
|
||||
fName, layer->fName->String()));
|
||||
// NOTE: no need to check for a lock. This is a private method.
|
||||
uint16 mask;
|
||||
|
||||
link.Read<uint16>(&mask);
|
||||
|
||||
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);
|
||||
}
|
||||
layer->fLayerData->ReadFontFromLink(link);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
inline
|
||||
@ -415,55 +358,9 @@ void ServerWindow::SetLayerState(Layer *layer, LinkMsgReader &link)
|
||||
STRACE(("ServerWindow %s: SetLayerState for layer %s\n",fName,
|
||||
layer->fName->String()));
|
||||
// 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));
|
||||
link.Read<float>( &(layer->fLayerData->pensize));
|
||||
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;
|
||||
}
|
||||
}
|
||||
layer->fLayerData->ReadFromLink(link);
|
||||
// TODO: Rebuild clipping here?
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
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()));
|
||||
// SetLayerState(cl);
|
||||
SetLayerState(cl,link);
|
||||
// TODO: should this be moved into SetLayerState?
|
||||
// If it _always_ needs to be done afterwards, then yes!
|
||||
cl->RebuildFullRegion();
|
||||
break;
|
||||
}
|
||||
@ -746,61 +645,16 @@ void ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link)
|
||||
case AS_LAYER_GET_STATE:
|
||||
{
|
||||
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);
|
||||
|
||||
// Attach font state
|
||||
fMsgSender->Attach<uint32>(ld->font.GetFamilyAndStyle());
|
||||
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));
|
||||
|
||||
|
||||
// attach state data
|
||||
cl->fLayerData->WriteToLink(*fMsgSender);
|
||||
|
||||
fMsgSender->Attach<float>(cl->fFrame.left);
|
||||
fMsgSender->Attach<float>(cl->fFrame.top);
|
||||
fMsgSender->Attach<BRect>(cl->fFrame.OffsetToCopy(cl->fBoundsLeftTop));
|
||||
|
||||
fMsgSender->Flush();
|
||||
|
||||
break;
|
||||
@ -857,7 +711,7 @@ cl->fBoundsLeftTop.PrintToStream();
|
||||
link.Read<float>(&x);
|
||||
link.Read<float>(&y);
|
||||
|
||||
cl->fLayerData->coordOrigin.Set(x, y);
|
||||
cl->fLayerData->SetOrigin(BPoint(x, y));
|
||||
|
||||
break;
|
||||
}
|
||||
@ -865,7 +719,7 @@ cl->fBoundsLeftTop.PrintToStream();
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_GET_ORIGIN: Layer: %s\n",fName, cl->fName->String()));
|
||||
fMsgSender->StartMessage(SERVER_TRUE);
|
||||
fMsgSender->Attach<BPoint>(cl->fLayerData->coordOrigin);
|
||||
fMsgSender->Attach<BPoint>(cl->fLayerData->Origin());
|
||||
fMsgSender->Flush();
|
||||
|
||||
break;
|
||||
@ -912,15 +766,17 @@ cl->fBoundsLeftTop.PrintToStream();
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_LINE_MODE: Layer: %s\n",fName, cl->fName->String()));
|
||||
int8 lineCap, lineJoin;
|
||||
float miterLimit;
|
||||
|
||||
// TODO: Look into locking scheme relating to Layers and modifying redraw-related members
|
||||
|
||||
link.Read<int8>(&lineCap);
|
||||
link.Read<int8>(&lineJoin);
|
||||
link.Read<float>(&(cl->fLayerData->miterLimit));
|
||||
link.Read<float>(&miterLimit);
|
||||
|
||||
cl->fLayerData->lineCap = (cap_mode)lineCap;
|
||||
cl->fLayerData->lineJoin = (join_mode)lineJoin;
|
||||
cl->fLayerData->SetLineCapMode((cap_mode)lineCap);
|
||||
cl->fLayerData->SetLineJoinMode((join_mode)lineJoin);
|
||||
cl->fLayerData->SetMiterLimit(miterLimit);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -928,9 +784,9 @@ cl->fBoundsLeftTop.PrintToStream();
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_LINE_MODE: Layer: %s\n",fName, cl->fName->String()));
|
||||
fMsgSender->StartMessage(SERVER_TRUE);
|
||||
fMsgSender->Attach<int8>((int8)(cl->fLayerData->lineCap));
|
||||
fMsgSender->Attach<int8>((int8)(cl->fLayerData->lineJoin));
|
||||
fMsgSender->Attach<float>(cl->fLayerData->miterLimit);
|
||||
fMsgSender->Attach<int8>((int8)(cl->fLayerData->LineCapMode()));
|
||||
fMsgSender->Attach<int8>((int8)(cl->fLayerData->LineJoinMode()));
|
||||
fMsgSender->Attach<float>(cl->fLayerData->MiterLimit());
|
||||
fMsgSender->Flush();
|
||||
|
||||
break;
|
||||
@ -938,6 +794,7 @@ cl->fBoundsLeftTop.PrintToStream();
|
||||
case AS_LAYER_PUSH_STATE:
|
||||
{
|
||||
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();
|
||||
ld->prevState = cl->fLayerData;
|
||||
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()));
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: refactor, put this in Layer
|
||||
LayerData *ld = cl->fLayerData;
|
||||
cl->fLayerData = cl->fLayerData->prevState;
|
||||
ld->prevState = NULL;
|
||||
@ -966,8 +823,12 @@ cl->fBoundsLeftTop.PrintToStream();
|
||||
}
|
||||
case AS_LAYER_SET_SCALE:
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",fName, cl->fName->String()));
|
||||
link.Read<float>(&(cl->fLayerData->scale));
|
||||
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",fName, cl->fName->String()));
|
||||
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;
|
||||
}
|
||||
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()));
|
||||
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))
|
||||
scale *= ld->scale;
|
||||
while ((ld = ld->prevState))
|
||||
scale *= ld->Scale();
|
||||
|
||||
fMsgSender->StartMessage(SERVER_TRUE);
|
||||
fMsgSender->Attach<float>(scale);
|
||||
@ -994,7 +859,7 @@ cl->fBoundsLeftTop.PrintToStream();
|
||||
link.Read<float>(&x);
|
||||
link.Read<float>(&y);
|
||||
|
||||
cl->fLayerData->penlocation.Set(x, y);
|
||||
cl->fLayerData->SetPenLocation(BPoint(x, y));
|
||||
|
||||
break;
|
||||
}
|
||||
@ -1002,7 +867,7 @@ cl->fBoundsLeftTop.PrintToStream();
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_LOC: Layer: %s\n",fName, cl->fName->String()));
|
||||
fMsgSender->StartMessage(SERVER_TRUE);
|
||||
fMsgSender->Attach<BPoint>(cl->fLayerData->penlocation);
|
||||
fMsgSender->Attach<BPoint>(cl->fLayerData->PenLocation());
|
||||
fMsgSender->Flush();
|
||||
|
||||
break;
|
||||
@ -1010,7 +875,9 @@ cl->fBoundsLeftTop.PrintToStream();
|
||||
case AS_LAYER_SET_PEN_SIZE:
|
||||
{
|
||||
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;
|
||||
}
|
||||
@ -1018,7 +885,7 @@ cl->fBoundsLeftTop.PrintToStream();
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_SIZE: Layer: %s\n",fName, cl->fName->String()));
|
||||
fMsgSender->StartMessage(SERVER_TRUE);
|
||||
fMsgSender->Attach<float>(cl->fLayerData->pensize);
|
||||
fMsgSender->Attach<float>(cl->fLayerData->PenSize());
|
||||
fMsgSender->Flush();
|
||||
|
||||
break;
|
||||
@ -1030,8 +897,9 @@ cl->fBoundsLeftTop.PrintToStream();
|
||||
|
||||
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);
|
||||
|
||||
break;
|
||||
@ -1041,9 +909,9 @@ cl->fBoundsLeftTop.PrintToStream();
|
||||
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_COLORS: Layer: %s\n",fName, cl->fName->String()));
|
||||
rgb_color highColor, lowColor, viewColor;
|
||||
|
||||
highColor = cl->fLayerData->highcolor.GetColor32();
|
||||
lowColor = cl->fLayerData->lowcolor.GetColor32();
|
||||
viewColor = cl->fLayerData->viewcolor.GetColor32();
|
||||
highColor = cl->fLayerData->HighColor().GetColor32();
|
||||
lowColor = cl->fLayerData->LowColor().GetColor32();
|
||||
viewColor = cl->fLayerData->ViewColor().GetColor32();
|
||||
|
||||
fMsgSender->StartMessage(SERVER_TRUE);
|
||||
fMsgSender->Attach(&highColor, sizeof(rgb_color));
|
||||
@ -1061,8 +929,8 @@ cl->fBoundsLeftTop.PrintToStream();
|
||||
link.Read<int8>(&srcAlpha);
|
||||
link.Read<int8>(&alphaFunc);
|
||||
|
||||
cl->fLayerData->alphaSrcMode = (source_alpha)srcAlpha;
|
||||
cl->fLayerData->alphaFncMode = (alpha_function)alphaFunc;
|
||||
cl->fLayerData->SetBlendingMode((source_alpha)srcAlpha,
|
||||
(alpha_function)alphaFunc);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -1070,8 +938,8 @@ cl->fBoundsLeftTop.PrintToStream();
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_BLEND_MODE: Layer: %s\n",fName, cl->fName->String()));
|
||||
fMsgSender->StartMessage(SERVER_TRUE);
|
||||
fMsgSender->Attach<int8>((int8)(cl->fLayerData->alphaSrcMode));
|
||||
fMsgSender->Attach<int8>((int8)(cl->fLayerData->alphaFncMode));
|
||||
fMsgSender->Attach<int8>((int8)(cl->fLayerData->AlphaSrcMode()));
|
||||
fMsgSender->Attach<int8>((int8)(cl->fLayerData->AlphaFncMode()));
|
||||
fMsgSender->Flush();
|
||||
|
||||
break;
|
||||
@ -1083,7 +951,7 @@ cl->fBoundsLeftTop.PrintToStream();
|
||||
|
||||
link.Read<int8>(&drawingMode);
|
||||
|
||||
cl->fLayerData->draw_mode = (drawing_mode)drawingMode;
|
||||
cl->fLayerData->SetDrawingMode((drawing_mode)drawingMode);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -1091,7 +959,7 @@ cl->fBoundsLeftTop.PrintToStream();
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_DRAW_MODE: Layer: %s\n",fName, cl->fName->String()));
|
||||
fMsgSender->StartMessage(SERVER_TRUE);
|
||||
fMsgSender->Attach<int8>((int8)(cl->fLayerData->draw_mode));
|
||||
fMsgSender->Attach<int8>((int8)(cl->fLayerData->GetDrawingMode()));
|
||||
fMsgSender->Flush();
|
||||
|
||||
break;
|
||||
@ -1099,7 +967,9 @@ cl->fBoundsLeftTop.PrintToStream();
|
||||
case AS_LAYER_PRINT_ALIASING:
|
||||
{
|
||||
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;
|
||||
}
|
||||
@ -1176,6 +1046,7 @@ cl->fBoundsLeftTop.PrintToStream();
|
||||
}
|
||||
|
||||
// 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)
|
||||
myRootLayer->GoRedraw(cl, reg);
|
||||
|
||||
@ -1242,13 +1113,16 @@ cl->fBoundsLeftTop.PrintToStream();
|
||||
ld = cl->fLayerData;
|
||||
reg = cl->ConvertFromParent(&(cl->fVisible));
|
||||
|
||||
if(ld->clipReg)
|
||||
reg.IntersectWith(ld->clipReg);
|
||||
if (ld->ClippingRegion())
|
||||
reg.IntersectWith(ld->ClippingRegion());
|
||||
|
||||
while((ld = ld->prevState))
|
||||
{
|
||||
if(ld->clipReg)
|
||||
reg.IntersectWith(ld->clipReg);
|
||||
// TODO: This could also be done more reliably in the Layer,
|
||||
// when the State stack is implemented there. There should be
|
||||
// DrawData::fCulmulatedClippingRegion...
|
||||
// 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();
|
||||
@ -1268,18 +1142,15 @@ cl->fBoundsLeftTop.PrintToStream();
|
||||
int32 noOfRects;
|
||||
BRect r;
|
||||
|
||||
if(cl->fLayerData->clipReg)
|
||||
cl->fLayerData->clipReg->MakeEmpty();
|
||||
else
|
||||
cl->fLayerData->clipReg = new BRegion();
|
||||
|
||||
link.Read<int32>(&noOfRects);
|
||||
|
||||
|
||||
BRegion region;
|
||||
for(int i = 0; i < noOfRects; i++)
|
||||
{
|
||||
link.Read<BRect>(&r);
|
||||
cl->fLayerData->clipReg->Include(r);
|
||||
region.Include(r);
|
||||
}
|
||||
cl->fLayerData->SetClippingRegion(region);
|
||||
|
||||
cl->RebuildFullRegion();
|
||||
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()));
|
||||
|
||||
// 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;
|
||||
int32 noOfRects;
|
||||
BRect rect;
|
||||
@ -1597,7 +1469,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
|
||||
|
||||
link.Read(&c, sizeof(rgb_color));
|
||||
|
||||
cl->fLayerData->highcolor.SetColor(c);
|
||||
cl->fLayerData->SetHighColor(RGBColor(c));
|
||||
|
||||
break;
|
||||
}
|
||||
@ -1608,7 +1480,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
|
||||
|
||||
link.Read(&c, sizeof(rgb_color));
|
||||
|
||||
cl->fLayerData->lowcolor.SetColor(c);
|
||||
cl->fLayerData->SetLowColor(RGBColor(c));
|
||||
|
||||
break;
|
||||
}
|
||||
@ -1619,7 +1491,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
|
||||
|
||||
link.Read(&pat, sizeof(pattern));
|
||||
|
||||
cl->fLayerData->patt = pat;
|
||||
cl->fLayerData->SetPattern(Pattern(pat));
|
||||
|
||||
break;
|
||||
}
|
||||
@ -1627,7 +1499,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_STROKE_LINE\n",fName));
|
||||
|
||||
// TODO: Add clipping TO AS_STROKE_LINE
|
||||
float x1, y1, x2, y2;
|
||||
|
||||
link.Read<float>(&x1);
|
||||
@ -1639,12 +1510,17 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
|
||||
{
|
||||
BPoint p1(x1,y1);
|
||||
BPoint p2(x2,y2);
|
||||
desktop->GetDisplayDriver()->StrokeLine(cl->ConvertToTop(p1),cl->ConvertToTop(p2),
|
||||
cl->fLayerData);
|
||||
desktop->GetDisplayDriver()->StrokeLine(cl->ConvertToTop(p1),
|
||||
cl->ConvertToTop(p2),
|
||||
cl->fLayerData);
|
||||
|
||||
// We update the pen here because many DisplayDriver calls which do not update the
|
||||
// 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;
|
||||
}
|
||||
@ -1652,7 +1528,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_INVERT_RECT\n",fName));
|
||||
|
||||
// TODO: Add clipping TO AS_INVERT_RECT
|
||||
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));
|
||||
|
||||
// TODO: Add clipping TO AS_STROKE_RECT
|
||||
float left, top, right, bottom;
|
||||
link.Read<float>(&left);
|
||||
link.Read<float>(&top);
|
||||
@ -1680,7 +1554,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_FILL_RECT\n",fName));
|
||||
|
||||
// TODO: Add clipping TO AS_FILL_RECT
|
||||
BRect rect;
|
||||
link.Read<BRect>(&rect);
|
||||
if (cl && cl->fLayerData)
|
||||
@ -1691,7 +1564,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_STROKE_ARC\n",fName));
|
||||
|
||||
// TODO: Add clipping to AS_STROKE_ARC
|
||||
float angle, span;
|
||||
BRect r;
|
||||
|
||||
@ -1706,7 +1578,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_FILL_ARC\n",fName));
|
||||
|
||||
// TODO: Add clipping to AS_FILL_ARC
|
||||
float angle, span;
|
||||
BRect r;
|
||||
|
||||
@ -1721,7 +1592,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_STROKE_BEZIER\n",fName));
|
||||
|
||||
// TODO: Add clipping to AS_STROKE_BEZIER
|
||||
BPoint *pts;
|
||||
int i;
|
||||
pts = new BPoint[4];
|
||||
@ -1743,7 +1613,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_FILL_BEZIER\n",fName));
|
||||
|
||||
// TODO: Add clipping to AS_STROKE_BEZIER
|
||||
BPoint *pts;
|
||||
int i;
|
||||
pts = new BPoint[4];
|
||||
@ -1765,7 +1634,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_STROKE_ELLIPSE\n",fName));
|
||||
|
||||
// TODO: Add clipping AS_STROKE_ELLIPSE
|
||||
BRect rect;
|
||||
link.Read<BRect>(&rect);
|
||||
if (cl && cl->fLayerData)
|
||||
@ -1776,7 +1644,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_FILL_ELLIPSE\n",fName));
|
||||
|
||||
// TODO: Add clipping AS_STROKE_ELLIPSE
|
||||
BRect rect;
|
||||
link.Read<BRect>(&rect);
|
||||
if (cl && cl->fLayerData)
|
||||
@ -1787,7 +1654,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_STROKE_ROUNDRECT\n",fName));
|
||||
|
||||
// TODO: Add clipping AS_STROKE_ROUNDRECT
|
||||
BRect rect;
|
||||
float xrad,yrad;
|
||||
link.Read<BRect>(&rect);
|
||||
@ -1802,7 +1668,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_FILL_ROUNDRECT\n",fName));
|
||||
|
||||
// TODO: Add clipping AS_STROKE_ROUNDRECT
|
||||
BRect rect;
|
||||
float xrad,yrad;
|
||||
link.Read<BRect>(&rect);
|
||||
@ -1817,7 +1682,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_STROKE_TRIANGLE\n",fName));
|
||||
|
||||
// TODO:: Add clipping to AS_STROKE_TRIANGLE
|
||||
BPoint pts[3];
|
||||
BRect rect;
|
||||
|
||||
@ -1839,7 +1703,6 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_FILL_TRIANGLE\n",fName));
|
||||
|
||||
// TODO:: Add clipping to AS_FILL_TRIANGLE
|
||||
BPoint pts[3];
|
||||
BRect rect;
|
||||
|
||||
@ -1857,6 +1720,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
|
||||
}
|
||||
break;
|
||||
}
|
||||
// TODO: get rid of all this code duplication!!
|
||||
case AS_STROKE_POLYGON:
|
||||
{
|
||||
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>(&y);
|
||||
if(cl && cl->fLayerData)
|
||||
cl->fLayerData->penlocation.Set(x,y);
|
||||
cl->fLayerData->SetPenLocation(BPoint(x, y));
|
||||
|
||||
break;
|
||||
}
|
||||
@ -2066,7 +1930,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
|
||||
|
||||
link.Read<float>(&size);
|
||||
if(cl && cl->fLayerData)
|
||||
cl->fLayerData->pensize=size;
|
||||
cl->fLayerData->SetPenSize(size);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -2074,6 +1938,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_SET_FONT\n",fName));
|
||||
// TODO: Implement AS_SET_FONT?
|
||||
// Confusing!! But it works already!
|
||||
break;
|
||||
}
|
||||
case AS_SET_FONT_SIZE:
|
||||
|
@ -712,8 +712,8 @@ DisplayDriverPainter::StrokeLine(const BPoint &start, const BPoint &end, const R
|
||||
if (Lock()) {
|
||||
if (!fPainter->StraightLine(start, end, color.GetColor32())) {
|
||||
DrawData context;
|
||||
context.highcolor = color;
|
||||
context.draw_mode = B_OP_COPY;
|
||||
context.SetHighColor(color);
|
||||
context.SetDrawingMode(B_OP_COPY);
|
||||
StrokeLine(start, end, &context);
|
||||
} else {
|
||||
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,
|
||||
escapement_delta *delta)
|
||||
{
|
||||
// what - without any clipping?!?
|
||||
DrawData d;
|
||||
d.highcolor=color;
|
||||
d.SetHighColor(color);
|
||||
|
||||
if(delta)
|
||||
d.edelta=*delta;
|
||||
DrawString(string,length,pt,&d);
|
||||
if (delta)
|
||||
d.SetEscapementDelta(*delta);
|
||||
|
||||
DrawString(string, length, pt, &d);
|
||||
}
|
||||
|
||||
// DrawString
|
||||
@ -1144,16 +1144,16 @@ DisplayDriverPainter::StrokeLineArray(const int32 &numlines,
|
||||
|
||||
if (Lock()) {
|
||||
DrawData context;
|
||||
context.draw_mode = B_OP_COPY;
|
||||
context.SetDrawingMode(B_OP_COPY);
|
||||
const LineArrayData *data;
|
||||
|
||||
data = (const LineArrayData *)&(linedata[0]);
|
||||
context.highcolor = data->color;
|
||||
context.SetHighColor(data->color);
|
||||
BRect touched = fPainter->StrokeLine(data->pt1, data->pt2, &context);
|
||||
|
||||
for (int32 i = 1; i < numlines; i++) {
|
||||
data = (const LineArrayData *)&(linedata[i]);
|
||||
context.highcolor = data->color;
|
||||
context.SetHighColor(data->color);
|
||||
touched = touched | fPainter->StrokeLine(data->pt1, data->pt2, &context);
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,8 @@ HWInterface::HWInterface()
|
||||
fCursor(NULL),
|
||||
fCursorVisible(true),
|
||||
fCursorLocation(0, 0),
|
||||
fUpdateExecutor(new UpdateQueue(this))
|
||||
// fUpdateExecutor(NULL)
|
||||
// fUpdateExecutor(new UpdateQueue(this))
|
||||
fUpdateExecutor(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@ -105,18 +105,18 @@ HWInterface::GetCursorPosition()
|
||||
status_t
|
||||
HWInterface::Invalidate(const BRect& frame)
|
||||
{
|
||||
// return CopyBackToFront(frame);
|
||||
return CopyBackToFront(frame);
|
||||
|
||||
// TODO: the remaining problem is the immediate wake up of the
|
||||
// thread carrying out the updates, when I enable it, there
|
||||
// seems to be a deadlock, but I didn't figure it out yet.
|
||||
// Maybe the same bug is there without the wakeup, only, triggered
|
||||
// less often.... scarry, huh?
|
||||
if (frame.IsValid()) {
|
||||
/* if (frame.IsValid()) {
|
||||
fUpdateExecutor->AddRect(frame);
|
||||
return B_OK;
|
||||
}
|
||||
return B_BAD_VALUE;
|
||||
return B_BAD_VALUE;*/
|
||||
}
|
||||
|
||||
// CopyBackToFront
|
||||
|
@ -152,29 +152,29 @@ void
|
||||
Painter::SetDrawData(const DrawData* data)
|
||||
{
|
||||
// for now...
|
||||
SetPenSize(data->pensize);
|
||||
SetPenLocation(data->penlocation);
|
||||
SetFont(data->font);
|
||||
SetPenSize(data->PenSize());
|
||||
SetPenLocation(data->PenLocation());
|
||||
SetFont(data->Font());
|
||||
// if (data->clipReg) {
|
||||
// ConstrainClipping(*data->clipReg);
|
||||
// }
|
||||
// any of these conditions means we need to use a different drawing
|
||||
// mode instance
|
||||
bool updateDrawingMode = !(data->patt == fPatternHandler->GetPattern()) ||
|
||||
data->draw_mode != fDrawingMode ||
|
||||
(data->draw_mode == B_OP_ALPHA && (data->alphaSrcMode != fAlphaSrcMode ||
|
||||
data->alphaFncMode != fAlphaFncMode));
|
||||
bool updateDrawingMode = !(data->GetPattern() == fPatternHandler->GetPattern()) ||
|
||||
data->GetDrawingMode() != fDrawingMode ||
|
||||
(data->GetDrawingMode() == B_OP_ALPHA && (data->AlphaSrcMode() != fAlphaSrcMode ||
|
||||
data->AlphaFncMode() != fAlphaFncMode));
|
||||
|
||||
fDrawingMode = data->draw_mode;
|
||||
fAlphaSrcMode = data->alphaSrcMode;
|
||||
fAlphaFncMode = data->alphaFncMode;
|
||||
fPatternHandler->SetPattern(data->patt);
|
||||
fDrawingMode = data->GetDrawingMode();
|
||||
fAlphaSrcMode = data->AlphaSrcMode();
|
||||
fAlphaFncMode = data->AlphaFncMode();
|
||||
fPatternHandler->SetPattern(data->GetPattern());
|
||||
|
||||
if (updateDrawingMode)
|
||||
_UpdateDrawingMode();
|
||||
|
||||
SetHighColor(data->highcolor.GetColor32());
|
||||
SetLowColor(data->lowcolor.GetColor32());
|
||||
SetHighColor(data->HighColor().GetColor32());
|
||||
SetLowColor(data->LowColor().GetColor32());
|
||||
}
|
||||
|
||||
// #pragma mark -
|
||||
@ -292,7 +292,7 @@ BRect
|
||||
Painter::StrokeLine(BPoint a, BPoint b, DrawData* context)
|
||||
{
|
||||
// this happens independent of wether we actually draw something
|
||||
context->penlocation = b;
|
||||
context->SetPenLocation(b);
|
||||
// NOTE: penlocation should be converted to the local
|
||||
// coordinate of the view for which we draw here, after
|
||||
// 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(&b, false);
|
||||
|
||||
SetPenSize(context->pensize);
|
||||
SetPenSize(context->PenSize());
|
||||
|
||||
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));
|
||||
@ -360,7 +360,7 @@ BRect
|
||||
Painter::StrokeLine(BPoint b, DrawData* context)
|
||||
{
|
||||
// TODO: move this function elsewhere
|
||||
return StrokeLine(context->penlocation, b, context);
|
||||
return StrokeLine(context->PenLocation(), b, context);
|
||||
}
|
||||
|
||||
typedef union {
|
||||
|
Loading…
Reference in New Issue
Block a user