Begun to use structs for the BView<->app_server communication. This makes

the protocoll less prone to errors, reduces possible points of failure and
most importantly, reduces the number of function calls to the link API.
I only know the numbers for StrokeLine(), which I tested via the Benchmark
test app. With this change, drawing random colored and positioned lines
actually doubled in speed. On the BView side, the calls to
ServerLink::Attach() only halfed, while on the app_server side, the number
of calls to ServerLink::Read() is now 1/4th. It will also be worth
investigating why the link stuff is so slow at all. I also optimized
BView::DrawString() a lot in this change, but I don't have any numbers
yet. Some other commands which used multiple Attach()/Read() calls were
also optimized, at least the most important ones. Begin/EndLineArray() was
also pretty bad on the app_server side. 


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29937 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2009-04-05 14:59:43 +00:00
parent a6354157ca
commit 12349c7d3d
7 changed files with 360 additions and 369 deletions

View File

@ -15,6 +15,7 @@
#include <Point.h> #include <Point.h>
#include <Rect.h> #include <Rect.h>
#include <Region.h> #include <Region.h>
#include <ServerProtocolStructs.h>
const static uint32 kDeleteReplicant = 'JAHA'; const static uint32 kDeleteReplicant = 'JAHA';
@ -121,21 +122,13 @@ ViewState::IsAllValid() const
} // namespace BPrivate } // namespace BPrivate
struct _array_hdr_{
float startX;
float startY;
float endX;
float endY;
rgb_color color;
};
struct _array_data_{ struct _array_data_{
// the max number of points in the array // the max number of points in the array
uint32 maxCount; uint32 maxCount;
// the current number of points in the array // the current number of points in the array
uint32 count; uint32 count;
// the array of points // the array of points
_array_hdr_* array; ViewLineArrayInfo* array;
}; };
#endif /* VIEW_PRIVATE_H */ #endif /* VIEW_PRIVATE_H */

View File

@ -51,6 +51,7 @@
#include <MessageUtils.h> #include <MessageUtils.h>
#include <PortLink.h> #include <PortLink.h>
#include <ServerProtocol.h> #include <ServerProtocol.h>
#include <ServerProtocolStructs.h>
#include <ShapePrivate.h> #include <ShapePrivate.h>
#include <TokenSpace.h> #include <TokenSpace.h>
#include <ViewPrivate.h> #include <ViewPrivate.h>
@ -216,22 +217,27 @@ ViewState::UpdateServerState(BPrivate::PortLink &link)
UpdateServerFontState(link); UpdateServerFontState(link);
link.StartMessage(AS_VIEW_SET_STATE); link.StartMessage(AS_VIEW_SET_STATE);
link.Attach<BPoint>(pen_location);
link.Attach<float>(pen_size); ViewSetStateInfo info;
link.Attach<rgb_color>(high_color); info.penLocation = pen_location;
link.Attach<rgb_color>(low_color); info.penSize = pen_size;
link.Attach< ::pattern>(pattern); info.highColor = high_color;
link.Attach<int8>((int8)drawing_mode); info.lowColor = low_color;
link.Attach<BPoint>(origin); info.pattern = pattern;
link.Attach<int8>((int8)line_join); info.drawingMode = drawing_mode;
link.Attach<int8>((int8)line_cap); info.origin = origin;
link.Attach<float>(miter_limit); info.scale = scale;
link.Attach<int8>((int8)alpha_source_mode); info.lineJoin = line_join;
link.Attach<int8>((int8)alpha_function_mode); info.lineCap = line_cap;
link.Attach<float>(scale); info.miterLimit = miter_limit;
link.Attach<bool>(font_aliasing); info.alphaSourceMode = alpha_source_mode;
info.alphaFunctionMode = alpha_function_mode;
info.fontAntialiasing = font_aliasing;
link.Attach<ViewSetStateInfo>(info);
// we send the 'local' clipping region... if we have one... // we send the 'local' clipping region... if we have one...
// TODO: Could be optimized, but is low prio, since most views won't
// have a custom clipping region.
if (clipping_region_used) { if (clipping_region_used) {
int32 count = clipping_region.CountRects(); int32 count = clipping_region.CountRects();
link.Attach<int32>(count); link.Attach<int32>(count);
@ -260,57 +266,36 @@ ViewState::UpdateFrom(BPrivate::PortLink &link)
|| code != B_OK) || code != B_OK)
return; return;
uint32 fontID; ViewGetStateInfo info;
float size; link.Read<ViewGetStateInfo>(&info);
float shear;
float rotation;
float falseBoldeWidth;
uint8 spacing;
uint8 encoding;
uint16 face;
uint32 flags;
// read and set the font state
link.Read<int32>((int32 *)&fontID);
link.Read<float>(&size);
link.Read<float>(&shear);
link.Read<float>(&rotation);
link.Read<float>(&falseBoldeWidth);
link.Read<int8>((int8 *)&spacing);
link.Read<int8>((int8 *)&encoding);
link.Read<int16>((int16 *)&face);
link.Read<int32>((int32 *)&flags);
// set view's font state
font_flags = B_FONT_ALL; font_flags = B_FONT_ALL;
font.SetFamilyAndStyle(fontID); font.SetFamilyAndStyle(info.fontID);
font.SetSize(size); font.SetSize(info.fontSize);
font.SetShear(shear); font.SetShear(info.fontShear);
font.SetRotation(rotation); font.SetRotation(info.fontRotation);
font.SetFalseBoldWidth(falseBoldeWidth); font.SetFalseBoldWidth(info.fontFalseBoldWidth);
font.SetSpacing(spacing); font.SetSpacing(info.fontSpacing);
font.SetEncoding(encoding); font.SetEncoding(info.fontEncoding);
font.SetFace(face); font.SetFace(info.fontFace);
font.SetFlags(flags); font.SetFlags(info.fontFlags);
// read and set view's state // set view's state
link.Read<BPoint>(&pen_location); pen_location = info.viewStateInfo.penLocation;
link.Read<float>(&pen_size); pen_size = info.viewStateInfo.penSize;
link.Read<rgb_color>(&high_color); high_color = info.viewStateInfo.highColor;
link.Read<rgb_color>(&low_color); low_color = info.viewStateInfo.lowColor;
link.Read< ::pattern>(&pattern); pattern = info.viewStateInfo.pattern;
link.Read<BPoint>(&origin); drawing_mode = info.viewStateInfo.drawingMode;
origin = info.viewStateInfo.origin;
int8 drawingMode; scale = info.viewStateInfo.scale;
link.Read<int8>((int8 *)&drawingMode); line_join = info.viewStateInfo.lineJoin;
drawing_mode = (::drawing_mode)drawingMode; line_cap = info.viewStateInfo.lineCap;
miter_limit = info.viewStateInfo.miterLimit;
link.Read<int8>((int8 *)&line_cap); alpha_source_mode = info.viewStateInfo.alphaSourceMode;
link.Read<int8>((int8 *)&line_join); alpha_function_mode = info.viewStateInfo.alphaFunctionMode;
link.Read<float>(&miter_limit); font_aliasing = info.viewStateInfo.fontAntialiasing;
link.Read<int8>((int8 *)&alpha_source_mode);
link.Read<int8>((int8 *)&alpha_function_mode);
link.Read<float>(&scale);
link.Read<bool>(&font_aliasing);
// read the user clipping // read the user clipping
// (that's NOT the current View visible clipping but the additional // (that's NOT the current View visible clipping but the additional
@ -796,6 +781,7 @@ BView::_ConvertFromScreen(BPoint *pt, bool checkLock) const
fParent->_ConvertFromScreen(pt, false); fParent->_ConvertFromScreen(pt, false);
} }
void void
BView::ConvertFromScreen(BPoint *pt) const BView::ConvertFromScreen(BPoint *pt) const
{ {
@ -1017,8 +1003,10 @@ BView::SetViewCursor(const BCursor *cursor, bool sync)
_CheckLockAndSwitchCurrent(); _CheckLockAndSwitchCurrent();
fOwner->fLink->StartMessage(AS_VIEW_SET_CURSOR); fOwner->fLink->StartMessage(AS_VIEW_SET_CURSOR);
fOwner->fLink->Attach<int32>(cursor->fServerToken); ViewSetViewCursorInfo info;
fOwner->fLink->Attach<bool>(sync); info.cursorToken = cursor->fServerToken;
info.sync = sync;
fOwner->fLink->Attach<ViewSetViewCursorInfo>(info);
if (!sync) { if (!sync) {
cursor->fPendingViewCursor = true; cursor->fPendingViewCursor = true;
@ -1781,10 +1769,13 @@ BView::SetLineMode(cap_mode lineCap, join_mode lineJoin, float miterLimit)
if (fOwner) { if (fOwner) {
_CheckLockAndSwitchCurrent(); _CheckLockAndSwitchCurrent();
ViewSetLineModeInfo info;
info.lineJoin = lineJoin;
info.lineCap = lineCap;
info.miterLimit = miterLimit;
fOwner->fLink->StartMessage(AS_VIEW_SET_LINE_MODE); fOwner->fLink->StartMessage(AS_VIEW_SET_LINE_MODE);
fOwner->fLink->Attach<int8>((int8)lineCap); fOwner->fLink->Attach<ViewSetLineModeInfo>(info);
fOwner->fLink->Attach<int8>((int8)lineJoin);
fOwner->fLink->Attach<float>(miterLimit);
fState->valid_flags |= B_VIEW_LINE_MODES_BIT; fState->valid_flags |= B_VIEW_LINE_MODES_BIT;
} }
@ -1830,13 +1821,13 @@ BView::LineMiterLimit() const
int32 code; int32 code;
if (fOwner->fLink->FlushWithReply(code) == B_OK if (fOwner->fLink->FlushWithReply(code) == B_OK
&& code == B_OK) { && code == B_OK) {
int8 cap, join;
fOwner->fLink->Read<int8>((int8 *)&cap);
fOwner->fLink->Read<int8>((int8 *)&join);
fOwner->fLink->Read<float>(&fState->miter_limit);
fState->line_cap = (cap_mode)cap; ViewSetLineModeInfo info;
fState->line_join = (join_mode)join; fOwner->fLink->Read<ViewSetLineModeInfo>(&info);
fState->line_cap = info.lineCap;
fState->line_join = info.lineJoin;
fState->miter_limit = info.miterLimit;
} }
fState->valid_flags |= B_VIEW_LINE_MODES_BIT; fState->valid_flags |= B_VIEW_LINE_MODES_BIT;
@ -1901,9 +1892,12 @@ BView::SetBlendingMode(source_alpha sourceAlpha, alpha_function alphaFunction)
if (fOwner) { if (fOwner) {
_CheckLockAndSwitchCurrent(); _CheckLockAndSwitchCurrent();
ViewBlendingModeInfo info;
info.sourceAlpha = sourceAlpha;
info.alphaFunction = alphaFunction;
fOwner->fLink->StartMessage(AS_VIEW_SET_BLENDING_MODE); fOwner->fLink->StartMessage(AS_VIEW_SET_BLENDING_MODE);
fOwner->fLink->Attach<int8>((int8)sourceAlpha); fOwner->fLink->Attach<ViewBlendingModeInfo>(info);
fOwner->fLink->Attach<int8>((int8)alphaFunction);
fState->valid_flags |= B_VIEW_BLENDING_BIT; fState->valid_flags |= B_VIEW_BLENDING_BIT;
} }
@ -1926,12 +1920,11 @@ BView::GetBlendingMode(source_alpha *_sourceAlpha,
int32 code; int32 code;
if (fOwner->fLink->FlushWithReply(code) == B_OK && code == B_OK) { if (fOwner->fLink->FlushWithReply(code) == B_OK && code == B_OK) {
int8 alphaSourceMode, alphaFunctionMode; ViewBlendingModeInfo info;
fOwner->fLink->Read<int8>(&alphaSourceMode); fOwner->fLink->Read<ViewBlendingModeInfo>(&info);
fOwner->fLink->Read<int8>(&alphaFunctionMode);
fState->alpha_source_mode = (source_alpha)alphaSourceMode; fState->alpha_source_mode = info.sourceAlpha;
fState->alpha_function_mode = (alpha_function)alphaFunctionMode; fState->alpha_function_mode = info.alphaFunction;
fState->valid_flags |= B_VIEW_BLENDING_BIT; fState->valid_flags |= B_VIEW_BLENDING_BIT;
} }
@ -1963,8 +1956,7 @@ BView::MovePenTo(float x, float y)
_CheckLockAndSwitchCurrent(); _CheckLockAndSwitchCurrent();
fOwner->fLink->StartMessage(AS_VIEW_SET_PEN_LOC); fOwner->fLink->StartMessage(AS_VIEW_SET_PEN_LOC);
fOwner->fLink->Attach<float>(x); fOwner->fLink->Attach<BPoint>(BPoint(x, y));
fOwner->fLink->Attach<float>(y);
fState->valid_flags |= B_VIEW_PEN_LOCATION_BIT; fState->valid_flags |= B_VIEW_PEN_LOCATION_BIT;
} }
@ -2387,11 +2379,14 @@ BView::DrawBitmapAsync(const BBitmap* bitmap, BRect bitmapRect, BRect viewRect,
_CheckLockAndSwitchCurrent(); _CheckLockAndSwitchCurrent();
ViewDrawBitmapInfo info;
info.bitmapToken = bitmap->_ServerToken();
info.options = options;
info.viewRect = viewRect;
info.bitmapRect = bitmapRect;
fOwner->fLink->StartMessage(AS_VIEW_DRAW_BITMAP); fOwner->fLink->StartMessage(AS_VIEW_DRAW_BITMAP);
fOwner->fLink->Attach<int32>(bitmap->_ServerToken()); fOwner->fLink->Attach<ViewDrawBitmapInfo>(info);
fOwner->fLink->Attach<uint32>(options);
fOwner->fLink->Attach<BRect>(viewRect);
fOwner->fLink->Attach<BRect>(bitmapRect);
_FlushIfNotInTransaction(); _FlushIfNotInTransaction();
} }
@ -2422,15 +2417,14 @@ BView::DrawBitmapAsync(const BBitmap* bitmap, BPoint where)
_CheckLockAndSwitchCurrent(); _CheckLockAndSwitchCurrent();
BRect bitmapRect = bitmap->Bounds().OffsetToCopy(B_ORIGIN); ViewDrawBitmapInfo info;
BRect viewRect = bitmapRect.OffsetToCopy(where); info.bitmapToken = bitmap->_ServerToken();
uint32 options = 0; info.options = 0;
info.bitmapRect = bitmap->Bounds().OffsetToCopy(B_ORIGIN);
info.viewRect = info.bitmapRect.OffsetToCopy(where);
fOwner->fLink->StartMessage(AS_VIEW_DRAW_BITMAP); fOwner->fLink->StartMessage(AS_VIEW_DRAW_BITMAP);
fOwner->fLink->Attach<int32>(bitmap->_ServerToken()); fOwner->fLink->Attach<ViewDrawBitmapInfo>(info);
fOwner->fLink->Attach<uint32>(options);
fOwner->fLink->Attach<BRect>(viewRect);
fOwner->fLink->Attach<BRect>(bitmapRect);
_FlushIfNotInTransaction(); _FlushIfNotInTransaction();
} }
@ -2533,33 +2527,33 @@ BView::DrawString(const char *string, int32 length, escapement_delta *delta)
void void
BView::DrawString(const char *string, int32 length, BPoint location, BView::DrawString(const char* string, int32 length, BPoint location,
escapement_delta *delta) escapement_delta* delta)
{ {
if (string == NULL || length < 1) if (fOwner == NULL || string == NULL || length < 1)
return; return;
if (fOwner) { _CheckLockAndSwitchCurrent();
_CheckLockAndSwitchCurrent();
// quite often delta will be NULL ViewDrawStringInfo info;
if (delta) info.stringLength = length;
fOwner->fLink->StartMessage(AS_DRAW_STRING_WITH_DELTA); info.location = location;
else if (delta != NULL)
fOwner->fLink->StartMessage(AS_DRAW_STRING); info.delta = *delta;
fOwner->fLink->Attach<int32>(length);
fOwner->fLink->Attach<BPoint>(location);
if (delta) // quite often delta will be NULL
fOwner->fLink->Attach<escapement_delta>(*delta); if (delta)
fOwner->fLink->StartMessage(AS_DRAW_STRING_WITH_DELTA);
else
fOwner->fLink->StartMessage(AS_DRAW_STRING);
fOwner->fLink->AttachString(string, length); fOwner->fLink->Attach<ViewDrawStringInfo>(info);
fOwner->fLink->Attach(string, length);
_FlushIfNotInTransaction(); _FlushIfNotInTransaction();
// this modifies our pen location, so we invalidate the flag. // this modifies our pen location, so we invalidate the flag.
fState->valid_flags &= ~B_VIEW_PEN_LOCATION_BIT; fState->valid_flags &= ~B_VIEW_PEN_LOCATION_BIT;
}
} }
@ -3277,9 +3271,12 @@ BView::StrokeLine(BPoint pt0, BPoint pt1, ::pattern pattern)
_CheckLockAndSwitchCurrent(); _CheckLockAndSwitchCurrent();
_UpdatePattern(pattern); _UpdatePattern(pattern);
ViewStrokeLineInfo info;
info.startPoint = pt0;
info.endPoint = pt1;
fOwner->fLink->StartMessage(AS_STROKE_LINE); fOwner->fLink->StartMessage(AS_STROKE_LINE);
fOwner->fLink->Attach<BPoint>(pt0); fOwner->fLink->Attach<ViewStrokeLineInfo>(info);
fOwner->fLink->Attach<BPoint>(pt1);
_FlushIfNotInTransaction(); _FlushIfNotInTransaction();
@ -3386,7 +3383,7 @@ BView::BeginLineArray(int32 count)
fCommArray = new _array_data_; fCommArray = new _array_data_;
fCommArray->maxCount = count; fCommArray->maxCount = count;
fCommArray->count = 0; fCommArray->count = 0;
fCommArray->array = new _array_hdr_[count]; fCommArray->array = new ViewLineArrayInfo[count];
} }
@ -3403,10 +3400,8 @@ BView::AddLine(BPoint pt0, BPoint pt1, rgb_color col)
const uint32 &arrayCount = fCommArray->count; const uint32 &arrayCount = fCommArray->count;
if (arrayCount < fCommArray->maxCount) { if (arrayCount < fCommArray->maxCount) {
fCommArray->array[arrayCount].startX = pt0.x; fCommArray->array[arrayCount].startPoint = pt0;
fCommArray->array[arrayCount].startY = pt0.y; fCommArray->array[arrayCount].endPoint = pt1;
fCommArray->array[arrayCount].endX = pt1.x;
fCommArray->array[arrayCount].endY = pt1.y;
fCommArray->array[arrayCount].color = col; fCommArray->array[arrayCount].color = col;
fCommArray->count++; fCommArray->count++;
@ -3420,7 +3415,7 @@ BView::EndLineArray()
if (fOwner == NULL) if (fOwner == NULL)
return; return;
if (!fCommArray) if (fCommArray == NULL)
debugger("Can't call EndLineArray before BeginLineArray"); debugger("Can't call EndLineArray before BeginLineArray");
_CheckLockAndSwitchCurrent(); _CheckLockAndSwitchCurrent();
@ -3428,7 +3423,7 @@ BView::EndLineArray()
fOwner->fLink->StartMessage(AS_STROKE_LINEARRAY); fOwner->fLink->StartMessage(AS_STROKE_LINEARRAY);
fOwner->fLink->Attach<int32>(fCommArray->count); fOwner->fLink->Attach<int32>(fCommArray->count);
fOwner->fLink->Attach(fCommArray->array, fOwner->fLink->Attach(fCommArray->array,
fCommArray->count * sizeof(_array_hdr_)); fCommArray->count * sizeof(ViewLineArrayInfo));
_FlushIfNotInTransaction(); _FlushIfNotInTransaction();

View File

@ -12,6 +12,7 @@
//! Data classes for working with BView states and draw parameters //! Data classes for working with BView states and draw parameters
#include "DrawState.h"
#include <new> #include <new>
#include <stdio.h> #include <stdio.h>
@ -20,8 +21,8 @@
#include "LinkReceiver.h" #include "LinkReceiver.h"
#include "LinkSender.h" #include "LinkSender.h"
#include "ServerProtocolStructs.h"
#include "DrawState.h"
using std::nothrow; using std::nothrow;
@ -183,24 +184,24 @@ DrawState::ReadFontFromLink(BPrivate::LinkReceiver& link)
void void
DrawState::ReadFromLink(BPrivate::LinkReceiver& link) DrawState::ReadFromLink(BPrivate::LinkReceiver& link)
{ {
rgb_color highColor; ViewSetStateInfo info;
rgb_color lowColor;
pattern patt;
link.Read<BPoint>(&fPenLocation); link.Read<ViewSetStateInfo>(&info);
link.Read<float>(&fPenSize);
link.Read(&highColor, sizeof(rgb_color)); fPenLocation = info.penLocation;
link.Read(&lowColor, sizeof(rgb_color)); fPenSize = info.penSize;
link.Read(&patt, sizeof(pattern)); fHighColor = info.highColor;
link.Read<int8>((int8*)&fDrawingMode); fLowColor = info.lowColor;
link.Read<BPoint>(&fOrigin); fPattern = info.pattern;
link.Read<int8>((int8*)&fLineJoinMode); fDrawingMode = info.drawingMode;
link.Read<int8>((int8*)&fLineCapMode); fOrigin = info.origin;
link.Read<float>(&fMiterLimit); fScale = info.scale;
link.Read<int8>((int8*)&fAlphaSrcMode); fLineJoinMode = info.lineJoin;
link.Read<int8>((int8*)&fAlphaFncMode); fLineCapMode = info.lineCap;
link.Read<float>(&fScale); fMiterLimit = info.miterLimit;
link.Read<bool>(&fFontAliasing); fAlphaSrcMode = info.alphaSourceMode;
fAlphaFncMode = info.alphaFunctionMode;
fFontAliasing = info.fontAntialiasing;
if (fPreviousState) { if (fPreviousState) {
fCombinedOrigin = fPreviousState->fCombinedOrigin + fOrigin; fCombinedOrigin = fPreviousState->fCombinedOrigin + fOrigin;
@ -210,11 +211,10 @@ DrawState::ReadFromLink(BPrivate::LinkReceiver& link)
fCombinedScale = fScale; fCombinedScale = fScale;
} }
fHighColor = highColor;
fLowColor = lowColor;
fPattern = patt;
// read clipping // read clipping
// TODO: This could be optimized, but the user clipping regions are rarely
// used, so it's low priority...
int32 clipRectCount; int32 clipRectCount;
link.Read<int32>(&clipRectCount); link.Read<int32>(&clipRectCount);
@ -237,33 +237,39 @@ void
DrawState::WriteToLink(BPrivate::LinkSender& link) const DrawState::WriteToLink(BPrivate::LinkSender& link) const
{ {
// Attach font state // Attach font state
link.Attach<uint32>(fFont.GetFamilyAndStyle()); ViewGetStateInfo info;
link.Attach<float>(fFont.Size()); info.fontID = fFont.GetFamilyAndStyle();
link.Attach<float>(fFont.Shear()); info.fontSize = fFont.Size();
link.Attach<float>(fFont.Rotation()); info.fontShear = fFont.Shear();
link.Attach<float>(fFont.FalseBoldWidth()); info.fontRotation = fFont.Rotation();
link.Attach<uint8>(fFont.Spacing()); info.fontFalseBoldWidth = fFont.FalseBoldWidth();
link.Attach<uint8>(fFont.Encoding()); info.fontSpacing = fFont.Spacing();
link.Attach<uint16>(fFont.Face()); info.fontEncoding = fFont.Encoding();
link.Attach<uint32>(fFont.Flags()); info.fontFace = fFont.Face();
info.fontFlags = fFont.Flags();
// Attach view state // Attach view state
link.Attach<BPoint>(fPenLocation); info.viewStateInfo.penLocation = fPenLocation;
link.Attach<float>(fPenSize); info.viewStateInfo.penSize = fPenSize;
link.Attach<rgb_color>(fHighColor); info.viewStateInfo.highColor = fHighColor;
link.Attach<rgb_color>(fLowColor); info.viewStateInfo.lowColor = fLowColor;
link.Attach<uint64>(fPattern.GetInt64()); info.viewStateInfo.pattern = (::pattern)fPattern.GetPattern();
link.Attach<BPoint>(fOrigin); info.viewStateInfo.drawingMode = fDrawingMode;
link.Attach<uint8>((uint8)fDrawingMode); info.viewStateInfo.origin = fOrigin;
link.Attach<uint8>((uint8)fLineCapMode); info.viewStateInfo.scale = fScale;
link.Attach<uint8>((uint8)fLineJoinMode); info.viewStateInfo.lineJoin = fLineJoinMode;
link.Attach<float>(fMiterLimit); info.viewStateInfo.lineCap = fLineCapMode;
link.Attach<uint8>((uint8)fAlphaSrcMode); info.viewStateInfo.miterLimit = fMiterLimit;
link.Attach<uint8>((uint8)fAlphaFncMode); info.viewStateInfo.alphaSourceMode = fAlphaSrcMode;
link.Attach<float>(fScale); info.viewStateInfo.alphaFunctionMode = fAlphaFncMode;
link.Attach<bool>(fFontAliasing); info.viewStateInfo.fontAntialiasing = fFontAliasing;
link.Attach<ViewGetStateInfo>(info);
// TODO: Could be optimized, but is low prio, since most views do not
// use a custom clipping region...
if (fClippingRegion) { if (fClippingRegion) {
int32 clippingRectCount = fClippingRegion->CountRects(); int32 clippingRectCount = fClippingRegion->CountRects();
link.Attach<int32>(clippingRectCount); link.Attach<int32>(clippingRectCount);

View File

@ -43,6 +43,7 @@
#include <DirectWindowPrivate.h> #include <DirectWindowPrivate.h>
#include <MessagePrivate.h> #include <MessagePrivate.h>
#include <PortLink.h> #include <PortLink.h>
#include <ServerProtocolStructs.h>
#include <ViewPrivate.h> #include <ViewPrivate.h>
#include <WindowInfo.h> #include <WindowInfo.h>
#include <WindowPrivate.h> #include <WindowPrivate.h>
@ -1545,17 +1546,15 @@ fDesktop->LockSingleWindow();
DTRACE(("ServerWindow %s: Message AS_VIEW_CURSOR: View: %s\n", DTRACE(("ServerWindow %s: Message AS_VIEW_CURSOR: View: %s\n",
Title(), fCurrentView->Name())); Title(), fCurrentView->Name()));
int32 token; ViewSetViewCursorInfo info;
bool sync; if (link.Read<ViewSetViewCursorInfo>(&info) != B_OK)
link.Read<int32>(&token);
if (link.Read<bool>(&sync) != B_OK)
break; break;
if (!fDesktop->GetCursorManager().Lock()) if (!fDesktop->GetCursorManager().Lock())
break; break;
ServerCursor* cursor ServerCursor* cursor
= fDesktop->GetCursorManager().FindCursor(token); = fDesktop->GetCursorManager().FindCursor(info.cursorToken);
fCurrentView->SetCursor(cursor); fCurrentView->SetCursor(cursor);
fDesktop->GetCursorManager().Unlock(); fDesktop->GetCursorManager().Unlock();
@ -1565,7 +1564,7 @@ fDesktop->LockSingleWindow();
if (fDesktop->ViewUnderMouse(fWindow) == fCurrentView->Token()) if (fDesktop->ViewUnderMouse(fWindow) == fCurrentView->Token())
fServerApp->SetCurrentCursor(cursor); fServerApp->SetCurrentCursor(cursor);
} }
if (sync) { if (info.sync) {
// sync the client (it can now delete the cursor) // sync the client (it can now delete the cursor)
fLink.StartMessage(B_OK); fLink.StartMessage(B_OK);
fLink.Flush(); fLink.Flush();
@ -1612,21 +1611,16 @@ fDesktop->LockSingleWindow();
{ {
DTRACE(("ServerWindow %s: Message AS_VIEW_SET_LINE_MODE: " DTRACE(("ServerWindow %s: Message AS_VIEW_SET_LINE_MODE: "
"View: %s\n", Title(), fCurrentView->Name())); "View: %s\n", Title(), fCurrentView->Name()));
int8 lineCap, lineJoin; ViewSetLineModeInfo info;
float miterLimit; if (link.Read<ViewSetLineModeInfo>(&info) != B_OK)
link.Read<int8>(&lineCap);
link.Read<int8>(&lineJoin);
if (link.Read<float>(&miterLimit) != B_OK)
break; break;
fCurrentView->CurrentState()->SetLineCapMode((cap_mode)lineCap); fCurrentView->CurrentState()->SetLineCapMode(info.lineCap);
fCurrentView->CurrentState()->SetLineJoinMode((join_mode)lineJoin); fCurrentView->CurrentState()->SetLineJoinMode(info.lineJoin);
fCurrentView->CurrentState()->SetMiterLimit(miterLimit); fCurrentView->CurrentState()->SetMiterLimit(info.miterLimit);
fWindow->GetDrawingEngine()->SetStrokeMode((cap_mode)lineCap, fWindow->GetDrawingEngine()->SetStrokeMode(info.lineCap,
(join_mode)lineJoin, miterLimit); info.lineJoin, info.miterLimit);
// _UpdateDrawState(fCurrentView);
break; break;
} }
@ -1634,10 +1628,13 @@ fDesktop->LockSingleWindow();
{ {
DTRACE(("ServerWindow %s: Message AS_VIEW_GET_LINE_MODE: " DTRACE(("ServerWindow %s: Message AS_VIEW_GET_LINE_MODE: "
"View: %s\n", Title(), fCurrentView->Name())); "View: %s\n", Title(), fCurrentView->Name()));
ViewSetLineModeInfo info;
info.lineJoin = fCurrentView->CurrentState()->LineJoinMode();
info.lineCap = fCurrentView->CurrentState()->LineCapMode();
info.miterLimit = fCurrentView->CurrentState()->MiterLimit();
fLink.StartMessage(B_OK); fLink.StartMessage(B_OK);
fLink.Attach<int8>((int8)(fCurrentView->CurrentState()->LineCapMode())); fLink.Attach<ViewSetLineModeInfo>(info);
fLink.Attach<int8>((int8)(fCurrentView->CurrentState()->LineJoinMode()));
fLink.Attach<float>(fCurrentView->CurrentState()->MiterLimit());
fLink.Flush(); fLink.Flush();
break; break;
@ -1690,16 +1687,15 @@ fDesktop->LockSingleWindow();
} }
case AS_VIEW_SET_PEN_LOC: case AS_VIEW_SET_PEN_LOC:
{ {
float x, y; BPoint location;
link.Read<float>(&x); if (link.Read<BPoint>(&location) != B_OK)
if (link.Read<float>(&y) != B_OK)
break; break;
DTRACE(("ServerWindow %s: Message AS_VIEW_SET_PEN_LOC: " DTRACE(("ServerWindow %s: Message AS_VIEW_SET_PEN_LOC: "
"View: %s -> BPoint(%.1f, %.1f)\n", Title(), "View: %s -> BPoint(%.1f, %.1f)\n", Title(),
fCurrentView->Name(), x, y)); fCurrentView->Name(), location.x, location.y));
fCurrentView->CurrentState()->SetPenLocation(BPoint(x, y)); fCurrentView->CurrentState()->SetPenLocation(location);
break; break;
} }
case AS_VIEW_GET_PEN_LOC: case AS_VIEW_GET_PEN_LOC:
@ -1847,27 +1843,28 @@ fDesktop->LockSingleWindow();
{ {
DTRACE(("ServerWindow %s: Message AS_VIEW_SET_BLEND_MODE: " DTRACE(("ServerWindow %s: Message AS_VIEW_SET_BLEND_MODE: "
"View: %s\n", Title(), fCurrentView->Name())); "View: %s\n", Title(), fCurrentView->Name()));
int8 srcAlpha, alphaFunc;
link.Read<int8>(&srcAlpha); ViewBlendingModeInfo info;
if (link.Read<int8>(&alphaFunc) != B_OK) if (link.Read<ViewBlendingModeInfo>(&info) != B_OK)
break; break;
fCurrentView->CurrentState()->SetBlendingMode( fCurrentView->CurrentState()->SetBlendingMode(
(source_alpha)srcAlpha, (alpha_function)alphaFunc); info.sourceAlpha, info.alphaFunction);
fWindow->GetDrawingEngine()->SetBlendingMode( fWindow->GetDrawingEngine()->SetBlendingMode(
(source_alpha)srcAlpha, (alpha_function)alphaFunc); info.sourceAlpha, info.alphaFunction);
break; break;
} }
case AS_VIEW_GET_BLENDING_MODE: case AS_VIEW_GET_BLENDING_MODE:
{ {
DTRACE(("ServerWindow %s: Message AS_VIEW_GET_BLEND_MODE: " DTRACE(("ServerWindow %s: Message AS_VIEW_GET_BLEND_MODE: "
"View: %s\n", Title(), fCurrentView->Name())); "View: %s\n", Title(), fCurrentView->Name()));
ViewBlendingModeInfo info;
info.sourceAlpha = fCurrentView->CurrentState()->AlphaSrcMode();
info.alphaFunction = fCurrentView->CurrentState()->AlphaFncMode();
fLink.StartMessage(B_OK); fLink.StartMessage(B_OK);
fLink.Attach<int8>((int8)( fLink.Attach<ViewBlendingModeInfo>(info);
fCurrentView->CurrentState()->AlphaSrcMode()));
fLink.Attach<int8>((int8)(
fCurrentView->CurrentState()->AlphaFncMode()));
fLink.Flush(); fLink.Flush();
break; break;
@ -2286,27 +2283,23 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code,
switch (code) { switch (code) {
case AS_STROKE_LINE: case AS_STROKE_LINE:
{ {
float x1, y1, x2, y2; ViewStrokeLineInfo info;
if (link.Read<ViewStrokeLineInfo>(&info) != B_OK)
link.Read<float>(&x1);
link.Read<float>(&y1);
link.Read<float>(&x2);
if (link.Read<float>(&y2) != B_OK)
break; break;
DTRACE(("ServerWindow %s: Message AS_STROKE_LINE: View: %s -> " DTRACE(("ServerWindow %s: Message AS_STROKE_LINE: View: %s -> "
"BPoint(%.1f, %.1f) - BPoint(%.1f, %.1f)\n", Title(), "BPoint(%.1f, %.1f) - BPoint(%.1f, %.1f)\n", Title(),
fCurrentView->Name(), x1, y1, x2, y2)); fCurrentView->Name(),
info.startPoint.x, info.startPoint.y,
info.endPoint.x, info.endPoint.y));
BPoint p1(x1, y1); BPoint penPos = info.endPoint;
BPoint p2(x2, y2); fCurrentView->ConvertToScreenForDrawing(&info.startPoint);
BPoint penPos = p2; fCurrentView->ConvertToScreenForDrawing(&info.endPoint);
fCurrentView->ConvertToScreenForDrawing(&p1); drawingEngine->StrokeLine(info.startPoint, info.endPoint);
fCurrentView->ConvertToScreenForDrawing(&p2);
drawingEngine->StrokeLine(p1, p2);
// We update the pen here because many DrawingEngine calls which do not update the // We update the pen here because many DrawingEngine calls which
// pen position actually call StrokeLine // do not update the pen position actually call StrokeLine
// TODO: Decide where to put this, for example, it cannot be done // TODO: Decide where to put this, for example, it cannot be done
// for DrawString(), also there needs to be a decision, if penlocation // for DrawString(), also there needs to be a decision, if penlocation
@ -2379,15 +2372,8 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code,
} }
case AS_VIEW_DRAW_BITMAP: case AS_VIEW_DRAW_BITMAP:
{ {
int32 bitmapToken; ViewDrawBitmapInfo info;
uint32 options; if (link.Read<ViewDrawBitmapInfo>(&info) != B_OK)
BRect bitmapRect;
BRect viewRect;
link.Read<int32>(&bitmapToken);
link.Read<uint32>(&options);
link.Read<BRect>(&viewRect);
if (link.Read<BRect>(&bitmapRect) != B_OK)
break; break;
#if 0 #if 0
@ -2395,23 +2381,24 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code,
options |= B_FILTER_BITMAP_BILINEAR; options |= B_FILTER_BITMAP_BILINEAR;
#endif #endif
ServerBitmap* bitmap = fServerApp->FindBitmap(bitmapToken); ServerBitmap* bitmap = fServerApp->FindBitmap(info.bitmapToken);
if (bitmap) { if (bitmap) {
DTRACE(("ServerWindow %s: Message AS_VIEW_DRAW_BITMAP: " DTRACE(("ServerWindow %s: Message AS_VIEW_DRAW_BITMAP: "
"View: %s, bitmap: %ld (size %ld x %ld), " "View: %s, bitmap: %ld (size %ld x %ld), "
"BRect(%.1f, %.1f, %.1f, %.1f) -> " "BRect(%.1f, %.1f, %.1f, %.1f) -> "
"BRect(%.1f, %.1f, %.1f, %.1f)\n", "BRect(%.1f, %.1f, %.1f, %.1f)\n",
fTitle, fCurrentView->Name(), bitmapToken, fTitle, fCurrentView->Name(), info.bitmapToken,
bitmap->Width(), bitmap->Height(), bitmap->Width(), bitmap->Height(),
bitmapRect.left, bitmapRect.top, bitmapRect.right, info.bitmapRect.left, info.bitmapRect.top,
bitmapRect.bottom, viewRect.left, viewRect.top, info.bitmapRect.right, info.bitmapRect.bottom,
viewRect.right, viewRect.bottom)); info.viewRect.left, info.viewRect.top,
info.viewRect.right, info.viewRect.bottom));
fCurrentView->ConvertToScreenForDrawing(&viewRect); fCurrentView->ConvertToScreenForDrawing(&info.viewRect);
drawingEngine->DrawBitmap(bitmap, bitmapRect, viewRect, drawingEngine->DrawBitmap(bitmap, info.bitmapRect,
options); info.viewRect, info.options);
} }
break; break;
@ -2758,52 +2745,73 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code,
// 2) LineArrayData // 2) LineArrayData
int32 lineCount; int32 lineCount;
if (link.Read<int32>(&lineCount) != B_OK || lineCount <= 0)
break;
link.Read<int32>(&lineCount); // To speed things up, try to use a stack allocation and only
if (lineCount > 0) { // fall back to the heap if there are enough lines...
LineArrayData lineData[lineCount]; ViewLineArrayInfo* lineData;
static const int32 kStackBufferLineDataCount = 64;
ViewLineArrayInfo lineDataStackBuffer[kStackBufferLineDataCount];
if (lineCount > kStackBufferLineDataCount) {
lineData = new(std::nothrow) ViewLineArrayInfo[lineCount];
if (lineData == NULL)
break;
} else
lineData = lineDataStackBuffer;
for (int32 i = 0; i < lineCount; i++) { // Read them all in one go
LineArrayData* index = &lineData[i]; size_t dataSize = lineCount * sizeof(ViewLineArrayInfo);
if (link.Read(lineData, dataSize) != B_OK) {
link.Read<float>(&(index->pt1.x)); if (lineData != lineDataStackBuffer)
link.Read<float>(&(index->pt1.y)); delete[] lineData;
link.Read<float>(&(index->pt2.x)); break;
link.Read<float>(&(index->pt2.y));
link.Read<rgb_color>(&(index->color));
fCurrentView->ConvertToScreenForDrawing(&index->pt1);
fCurrentView->ConvertToScreenForDrawing(&index->pt2);
}
drawingEngine->StrokeLineArray(lineCount, lineData);
} }
// Convert to screen coords and draw
for (int32 i = 0; i < lineCount; i++) {
ViewLineArrayInfo* index = &lineData[i];
fCurrentView->ConvertToScreenForDrawing(&index->startPoint);
fCurrentView->ConvertToScreenForDrawing(&index->endPoint);
}
drawingEngine->StrokeLineArray(lineCount, lineData);
if (lineData != lineDataStackBuffer)
delete[] lineData;
break; break;
} }
case AS_DRAW_STRING: case AS_DRAW_STRING:
case AS_DRAW_STRING_WITH_DELTA: case AS_DRAW_STRING_WITH_DELTA:
{ {
char* string; ViewDrawStringInfo info;
int32 length; if (link.Read<ViewDrawStringInfo>(&info) != B_OK)
BPoint location;
escapement_delta _delta;
escapement_delta* delta = NULL;
link.Read<int32>(&length);
link.Read<BPoint>(&location);
if (code == AS_DRAW_STRING_WITH_DELTA) {
link.Read<escapement_delta>(&_delta);
if (_delta.nonspace != 0.0 || _delta.space != 0.0)
delta = &_delta;
}
if (link.ReadString(&string) != B_OK)
break; break;
char* string = (char*)malloc(info.stringLength + 1);
if (string == NULL)
break;
escapement_delta* delta = NULL;
if (code == AS_DRAW_STRING_WITH_DELTA) {
// In this case, info.delta will contain valid values.
delta = &info.delta;
}
if (link.Read(string, info.stringLength) != B_OK) {
free(string);
break;
}
// Terminate the string, if nothing else, it's important
// for the DTRACE call below...
string[info.stringLength] = '\0';
DTRACE(("ServerWindow %s: Message AS_DRAW_STRING, View: %s " DTRACE(("ServerWindow %s: Message AS_DRAW_STRING, View: %s "
"-> %s\n", Title(), fCurrentView->Name(), string)); "-> %s\n", Title(), fCurrentView->Name(), string));
fCurrentView->ConvertToScreenForDrawing(&location); fCurrentView->ConvertToScreenForDrawing(&info.location);
BPoint penLocation = drawingEngine->DrawString(string, length, BPoint penLocation = drawingEngine->DrawString(string,
location, delta); info.stringLength, info.location, delta);
fCurrentView->ConvertFromScreenForDrawing(&penLocation); fCurrentView->ConvertFromScreenForDrawing(&penLocation);
fCurrentView->CurrentState()->SetPenLocation(penLocation); fCurrentView->CurrentState()->SetPenLocation(penLocation);
@ -2903,12 +2911,11 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver &link)
case AS_VIEW_SET_PEN_LOC: case AS_VIEW_SET_PEN_LOC:
{ {
float x, y; BPoint location;
link.Read<float>(&x); link.Read<BPoint>(&location);
link.Read<float>(&y); picture->WriteSetPenLocation(location);
picture->WriteSetPenLocation(BPoint(x, y));
fCurrentView->CurrentState()->SetPenLocation(BPoint(x, y)); fCurrentView->CurrentState()->SetPenLocation(location);
break; break;
} }
case AS_VIEW_SET_PEN_SIZE: case AS_VIEW_SET_PEN_SIZE:
@ -2925,21 +2932,19 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver &link)
case AS_VIEW_SET_LINE_MODE: case AS_VIEW_SET_LINE_MODE:
{ {
int8 lineCap, lineJoin;
float miterLimit;
link.Read<int8>(&lineCap); ViewSetLineModeInfo info;
link.Read<int8>(&lineJoin); link.Read<ViewSetLineModeInfo>(&info);
link.Read<float>(&miterLimit);
picture->WriteSetLineMode((cap_mode)lineCap, (join_mode)lineJoin, miterLimit); picture->WriteSetLineMode(info.lineCap, info.lineJoin,
info.miterLimit);
fCurrentView->CurrentState()->SetLineCapMode((cap_mode)lineCap); fCurrentView->CurrentState()->SetLineCapMode(info.lineCap);
fCurrentView->CurrentState()->SetLineJoinMode((join_mode)lineJoin); fCurrentView->CurrentState()->SetLineJoinMode(info.lineJoin);
fCurrentView->CurrentState()->SetMiterLimit(miterLimit); fCurrentView->CurrentState()->SetMiterLimit(info.miterLimit);
fWindow->GetDrawingEngine()->SetStrokeMode((cap_mode)lineCap, fWindow->GetDrawingEngine()->SetStrokeMode(info.lineCap,
(join_mode)lineJoin, miterLimit); info.lineJoin, info.miterLimit);
break; break;
} }
case AS_VIEW_SET_SCALE: case AS_VIEW_SET_SCALE:
@ -3081,14 +3086,10 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver &link)
case AS_STROKE_LINE: case AS_STROKE_LINE:
{ {
float x1, y1, x2, y2; ViewStrokeLineInfo info;
link.Read<ViewStrokeLineInfo>(&info);
link.Read<float>(&x1); picture->WriteStrokeLine(info.startPoint, info.endPoint);
link.Read<float>(&y1);
link.Read<float>(&x2);
link.Read<float>(&y2);
picture->WriteStrokeLine(BPoint(x1, y1), BPoint(x2, y2));
break; break;
} }
@ -3102,17 +3103,13 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver &link)
picture->WritePushState(); picture->WritePushState();
for (int32 i = 0; i < lineCount; i++) { for (int32 i = 0; i < lineCount; i++) {
float x1, y1, x2, y2; ViewLineArrayInfo lineData;
link.Read<float>(&x1); if (link.Read<ViewLineArrayInfo >(&lineData) != B_OK)
link.Read<float>(&y1); break;
link.Read<float>(&x2);
link.Read<float>(&y2);
rgb_color color; picture->WriteSetHighColor(lineData.color);
link.Read<rgb_color>(&color); picture->WriteStrokeLine(lineData.startPoint,
lineData.endPoint);
picture->WriteSetHighColor(color);
picture->WriteStrokeLine(BPoint(x1, y1), BPoint(x2, y2));
} }
picture->WritePopState(); picture->WritePopState();
@ -3139,18 +3136,29 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver &link)
case AS_DRAW_STRING: case AS_DRAW_STRING:
case AS_DRAW_STRING_WITH_DELTA: case AS_DRAW_STRING_WITH_DELTA:
{ {
char* string = NULL; ViewDrawStringInfo info;
int32 length; if (link.Read<ViewDrawStringInfo>(&info) != B_OK)
BPoint location; break;
link.Read<int32>(&length); char* string = (char*)malloc(info.stringLength + 1);
link.Read<BPoint>(&location); if (string == NULL)
escapement_delta delta = { 0, 0 }; break;
if (code == AS_DRAW_STRING_WITH_DELTA)
link.Read<escapement_delta>(&delta);
link.ReadString(&string);
picture->WriteDrawString(location, string, length, delta); if (code != AS_DRAW_STRING_WITH_DELTA) {
// In this case, info.delta will NOT contain valid values.
info.delta = (escapement_delta){ 0, 0 };
}
if (link.Read(string, info.stringLength) != B_OK) {
free(string);
break;
}
// Terminate the string, if nothing else, it's important
// for the DTRACE call below...
string[info.stringLength] = '\0';
picture->WriteDrawString(info.location, string, info.stringLength,
info.delta);
free(string); free(string);
break; break;
@ -3190,25 +3198,17 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver &link)
case AS_VIEW_DRAW_BITMAP: case AS_VIEW_DRAW_BITMAP:
{ {
int32 token; ViewDrawBitmapInfo info;
link.Read<int32>(&token); link.Read<ViewDrawBitmapInfo>(&info);
uint32 options; ServerBitmap *bitmap = App()->FindBitmap(info.bitmapToken);
link.Read<uint32>(&options);
BRect viewRect;
link.Read<BRect>(&viewRect);
BRect bitmapRect;
link.Read<BRect>(&bitmapRect);
ServerBitmap *bitmap = App()->FindBitmap(token);
if (bitmap == NULL) if (bitmap == NULL)
break; break;
picture->WriteDrawBitmap(bitmapRect, viewRect, bitmap->Width(), picture->WriteDrawBitmap(info.bitmapRect, info.viewRect,
bitmap->Height(), bitmap->BytesPerRow(), bitmap->ColorSpace(), bitmap->Width(), bitmap->Height(), bitmap->BytesPerRow(),
options, bitmap->Bits(), bitmap->BitsLength()); bitmap->ColorSpace(), info.options, bitmap->Bits(),
bitmap->BitsLength());
break; break;
} }
@ -3293,20 +3293,18 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver &link)
/* /*
case AS_VIEW_SET_BLENDING_MODE: case AS_VIEW_SET_BLENDING_MODE:
{ {
int8 srcAlpha, alphaFunc; ViewBlendingModeInfo info;
link.Read<ViewBlendingModeInfo>(&info);
link.Read<int8>(&srcAlpha);
link.Read<int8>(&alphaFunc);
picture->BeginOp(B_PIC_SET_BLENDING_MODE); picture->BeginOp(B_PIC_SET_BLENDING_MODE);
picture->AddInt16((int16)srcAlpha); picture->AddInt16((int16)info.sourceAlpha);
picture->AddInt16((int16)alphaFunc); picture->AddInt16((int16)info.alphaFunction);
picture->EndOp(); picture->EndOp();
fCurrentView->CurrentState()->SetBlendingMode((source_alpha)srcAlpha, fCurrentView->CurrentState()->SetBlendingMode(info.sourceAlpha,
(alpha_function)alphaFunc); info.alphaFunction);
fWindow->GetDrawingEngine()->SetBlendingMode((source_alpha)srcAlpha, fWindow->GetDrawingEngine()->SetBlendingMode(info.sourceAlpha,
(alpha_function)alphaFunc); info.alphaFunction);
break; break;
}*/ }*/
default: default:

View File

@ -1207,26 +1207,26 @@ DrawingEngine::StrokeLine(const BPoint &start, const BPoint &end)
// StrokeLineArray // StrokeLineArray
void void
DrawingEngine::StrokeLineArray(int32 numLines, DrawingEngine::StrokeLineArray(int32 numLines,
const LineArrayData *linedata) const ViewLineArrayInfo *lineData)
{ {
CRASH_IF_NOT_LOCKED CRASH_IF_NOT_LOCKED
if (!linedata || numLines <= 0) if (!lineData || numLines <= 0)
return; return;
// figure out bounding box for line array // figure out bounding box for line array
const LineArrayData *data = (const LineArrayData *)&(linedata[0]); const ViewLineArrayInfo* data = (const ViewLineArrayInfo*)&(lineData[0]);
BRect touched(min_c(data->pt1.x, data->pt2.x), BRect touched(min_c(data->startPoint.x, data->endPoint.x),
min_c(data->pt1.y, data->pt2.y), min_c(data->startPoint.y, data->endPoint.y),
max_c(data->pt1.x, data->pt2.x), max_c(data->startPoint.x, data->endPoint.x),
max_c(data->pt1.y, data->pt2.y)); max_c(data->startPoint.y, data->endPoint.y));
for (int32 i = 1; i < numLines; i++) { for (int32 i = 1; i < numLines; i++) {
data = (const LineArrayData *)&(linedata[i]); data = (const ViewLineArrayInfo*)&(lineData[i]);
BRect box(min_c(data->pt1.x, data->pt2.x), BRect box(min_c(data->startPoint.x, data->endPoint.x),
min_c(data->pt1.y, data->pt2.y), min_c(data->startPoint.y, data->endPoint.y),
max_c(data->pt1.x, data->pt2.x), max_c(data->startPoint.x, data->endPoint.x),
max_c(data->pt1.y, data->pt2.y)); max_c(data->startPoint.y, data->endPoint.y));
touched = touched | box; touched = touched | box;
} }
extend_by_stroke_width(touched, fPainter->PenSize()); extend_by_stroke_width(touched, fPainter->PenSize());
@ -1234,7 +1234,7 @@ DrawingEngine::StrokeLineArray(int32 numLines,
if (touched.IsValid()) { if (touched.IsValid()) {
AutoFloatingOverlaysHider _(fGraphicsCard, touched); AutoFloatingOverlaysHider _(fGraphicsCard, touched);
data = (const LineArrayData *)&(linedata[0]); data = (const ViewLineArrayInfo*)&(lineData[0]);
// store current graphics state, we mess with the // store current graphics state, we mess with the
// high color and pattern... // high color and pattern...
@ -1243,12 +1243,12 @@ DrawingEngine::StrokeLineArray(int32 numLines,
fPainter->SetHighColor(data->color); fPainter->SetHighColor(data->color);
fPainter->SetPattern(B_SOLID_HIGH); fPainter->SetPattern(B_SOLID_HIGH);
fPainter->StrokeLine(data->pt1, data->pt2); fPainter->StrokeLine(data->startPoint, data->endPoint);
for (int32 i = 1; i < numLines; i++) { for (int32 i = 1; i < numLines; i++) {
data = (const LineArrayData *)&(linedata[i]); data = (const ViewLineArrayInfo*)&(lineData[i]);
fPainter->SetHighColor(data->color); fPainter->SetHighColor(data->color);
fPainter->StrokeLine(data->pt1, data->pt2); fPainter->StrokeLine(data->startPoint, data->endPoint);
} }
// restore correct drawing state highcolor and pattern // restore correct drawing state highcolor and pattern

View File

@ -16,6 +16,7 @@
#include <Locker.h> #include <Locker.h>
#include <Point.h> #include <Point.h>
#include <Gradient.h> #include <Gradient.h>
#include <ServerProtocolStructs.h>
#include "HWInterface.h" #include "HWInterface.h"
@ -29,11 +30,6 @@ class ServerBitmap;
class ServerCursor; class ServerCursor;
class ServerFont; class ServerFont;
typedef struct {
BPoint pt1;
BPoint pt2;
rgb_color color;
} LineArrayData;
class DrawingEngine : public HWInterfaceListener { class DrawingEngine : public HWInterfaceListener {
public: public:
@ -158,7 +154,7 @@ public:
const BPoint& end); const BPoint& end);
void StrokeLineArray(int32 numlines, void StrokeLineArray(int32 numlines,
const LineArrayData* data); const ViewLineArrayInfo* data);
// -------- text related calls // -------- text related calls

View File

@ -20,7 +20,7 @@ class BPoint;
class Pattern { class Pattern {
public: public:
Pattern(void) {} Pattern() {}
Pattern(const uint64& p) Pattern(const uint64& p)
{ fPattern.type64 = p; } { fPattern.type64 = p; }
@ -34,12 +34,15 @@ class Pattern {
Pattern(const pattern& src) Pattern(const pattern& src)
{ fPattern.type64 = *(uint64*)src.data; } { fPattern.type64 = *(uint64*)src.data; }
inline const int8* GetInt8(void) const inline const int8* GetInt8() const
{ return fPattern.type8; } { return fPattern.type8; }
inline uint64 GetInt64(void) const inline uint64 GetInt64() const
{ return fPattern.type64; } { return fPattern.type64; }
inline const ::pattern& GetPattern() const
{ return *(const ::pattern*)&fPattern.type64; }
inline void Set(const int8* p) inline void Set(const int8* p)
{ fPattern.type64 = *((const uint64*)p); } { fPattern.type64 = *((const uint64*)p); }