The drawstate is now synched when the recording of a BPicture starts. Some reordering of the function calls, implemented B_PIC_SET_BLENDING_MODE, some other cleanups
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17580 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
e0da42a8fa
commit
a7dc54697c
@ -32,6 +32,7 @@ typedef void (*fnc_ssf)(void*, int16, int16, float);
|
||||
typedef void (*fnc_f)(void*, float);
|
||||
typedef void (*fnc_Color)(void*, rgb_color);
|
||||
typedef void (*fnc_Pattern)(void*, pattern);
|
||||
typedef void (*fnc_ss)(void *, int16, int16);
|
||||
typedef void (*fnc_PBRecti)(void*, BRect*, int32);
|
||||
typedef void (*fnc_DrawPixels)(void *, BRect, BRect, int32, int32, int32,
|
||||
int32, int32, void*);
|
||||
@ -147,7 +148,7 @@ PicturePlayer::GetData(void *data, int32 size)
|
||||
status_t
|
||||
PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
|
||||
{
|
||||
// TODO: we should probably check if the functions in the table are not 0
|
||||
// TODO: we should probably check if the functions in the table are not NULL
|
||||
// before calling them.
|
||||
|
||||
// lenght of the stream
|
||||
@ -213,6 +214,44 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
|
||||
((fnc_PBPoint)callBackTable[8])(userData, control);
|
||||
break;
|
||||
}
|
||||
case B_PIC_STROKE_ARC:
|
||||
{
|
||||
BPoint center = GetCoord();
|
||||
BPoint radii = GetCoord();
|
||||
float startTheta = GetFloat();
|
||||
float arcTheta = GetFloat();
|
||||
((fnc_BPointBPointff)callBackTable[9])(userData, center, radii,
|
||||
startTheta, arcTheta);
|
||||
break;
|
||||
}
|
||||
case B_PIC_FILL_ARC:
|
||||
{
|
||||
BPoint center = GetCoord();
|
||||
BPoint radii = GetCoord();
|
||||
float startTheta = GetFloat();
|
||||
float arcTheta = GetFloat();
|
||||
((fnc_BPointBPointff)callBackTable[10])(userData, center, radii,
|
||||
startTheta, arcTheta);
|
||||
break;
|
||||
}
|
||||
case B_PIC_STROKE_ELLIPSE:
|
||||
{
|
||||
BRect rect = GetRect();
|
||||
BPoint center;
|
||||
BPoint radii((rect.Width() + 1) / 2.0f, (rect.Height() + 1) / 2.0f);
|
||||
center = rect.LeftTop() + radii;
|
||||
((fnc_BPointBPoint)callBackTable[11])(userData, center, radii);
|
||||
break;
|
||||
}
|
||||
case B_PIC_FILL_ELLIPSE:
|
||||
{
|
||||
BRect rect = GetRect();
|
||||
BPoint center;
|
||||
BPoint radii((rect.Width() + 1) / 2.0f, (rect.Height() + 1) / 2.0f);
|
||||
center = rect.LeftTop() + radii;
|
||||
((fnc_BPointBPoint)callBackTable[12])(userData, center, radii);
|
||||
break;
|
||||
}
|
||||
case B_PIC_STROKE_POLYGON:
|
||||
{
|
||||
int32 numPoints = GetInt32();
|
||||
@ -267,44 +306,7 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
|
||||
{
|
||||
break;
|
||||
}
|
||||
case B_PIC_STROKE_ARC:
|
||||
{
|
||||
BPoint center = GetCoord();
|
||||
BPoint radii = GetCoord();
|
||||
float startTheta = GetFloat();
|
||||
float arcTheta = GetFloat();
|
||||
((fnc_BPointBPointff)callBackTable[9])(userData, center, radii,
|
||||
startTheta, arcTheta);
|
||||
break;
|
||||
}
|
||||
case B_PIC_FILL_ARC:
|
||||
{
|
||||
BPoint center = GetCoord();
|
||||
BPoint radii = GetCoord();
|
||||
float startTheta = GetFloat();
|
||||
float arcTheta = GetFloat();
|
||||
((fnc_BPointBPointff)callBackTable[10])(userData, center, radii,
|
||||
startTheta, arcTheta);
|
||||
break;
|
||||
}
|
||||
case B_PIC_STROKE_ELLIPSE:
|
||||
{
|
||||
BRect rect = GetRect();
|
||||
BPoint center;
|
||||
BPoint radii((rect.Width() + 1) / 2.0f, (rect.Height() + 1) / 2.0f);
|
||||
center = rect.LeftTop() + radii;
|
||||
((fnc_BPointBPoint)callBackTable[11])(userData, center, radii);
|
||||
break;
|
||||
}
|
||||
case B_PIC_FILL_ELLIPSE:
|
||||
{
|
||||
BRect rect = GetRect();
|
||||
BPoint center;
|
||||
BPoint radii((rect.Width() + 1) / 2.0f, (rect.Height() + 1) / 2.0f);
|
||||
center = rect.LeftTop() + radii;
|
||||
((fnc_BPointBPoint)callBackTable[12])(userData, center, radii);
|
||||
break;
|
||||
}
|
||||
|
||||
case B_PIC_ENTER_STATE_CHANGE:
|
||||
{
|
||||
break;
|
||||
@ -313,6 +315,11 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
|
||||
{
|
||||
break;
|
||||
}
|
||||
case B_PIC_CLEAR_CLIPPING_RECTS:
|
||||
{
|
||||
((fnc_PBRecti)callBackTable[20])(userData, NULL, 0);
|
||||
break;
|
||||
}
|
||||
case B_PIC_CLIP_TO_PICTURE:
|
||||
{
|
||||
break;
|
||||
@ -327,9 +334,9 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
|
||||
((fnc)callBackTable[23])(userData);
|
||||
break;
|
||||
}
|
||||
case B_PIC_CLEAR_CLIPPING_RECTS:
|
||||
case B_PIC_ENTER_FONT_STATE:
|
||||
{
|
||||
((fnc_PBRecti)callBackTable[20])(userData, NULL, 0);
|
||||
((fnc)callBackTable[26])(userData);
|
||||
break;
|
||||
}
|
||||
case B_PIC_SET_ORIGIN:
|
||||
@ -364,12 +371,6 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
|
||||
((fnc_f)callBackTable[32])(userData, size);
|
||||
break;
|
||||
}
|
||||
case B_PIC_SET_SCALE:
|
||||
{
|
||||
float scale = GetFloat();
|
||||
((fnc_f)callBackTable[36])(userData, scale);
|
||||
break;
|
||||
}
|
||||
case B_PIC_SET_FORE_COLOR:
|
||||
{
|
||||
rgb_color color = GetColor();
|
||||
@ -389,17 +390,10 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
|
||||
((fnc_Pattern)callBackTable[35])(userData, p);
|
||||
break;
|
||||
}
|
||||
case B_PIC_ENTER_FONT_STATE:
|
||||
case B_PIC_SET_SCALE:
|
||||
{
|
||||
((fnc)callBackTable[26])(userData);
|
||||
break;
|
||||
}
|
||||
case B_PIC_SET_BLENDING_MODE:
|
||||
{
|
||||
//int16 alphaSrcMode = GetInt16();
|
||||
//int16 alphaFncMode = GetInt16();
|
||||
//((fnc_Pattern)callBackTable[??])(userData, alphaSrcMode,
|
||||
// alphaFncMode);
|
||||
float scale = GetFloat();
|
||||
((fnc_f)callBackTable[36])(userData, scale);
|
||||
break;
|
||||
}
|
||||
case B_PIC_SET_FONT_FAMILY:
|
||||
@ -428,18 +422,6 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
|
||||
((fnc_i)callBackTable[39])(userData, spacing);
|
||||
break;
|
||||
}
|
||||
case B_PIC_SET_FONT_ENCODING:
|
||||
{
|
||||
int32 encoding = GetInt32();
|
||||
((fnc_i)callBackTable[42])(userData, encoding);
|
||||
break;
|
||||
}
|
||||
case B_PIC_SET_FONT_FLAGS:
|
||||
{
|
||||
int32 flags = GetInt32();
|
||||
((fnc_i)callBackTable[43])(userData, flags);
|
||||
break;
|
||||
}
|
||||
case B_PIC_SET_FONT_SIZE:
|
||||
{
|
||||
float size = GetFloat();
|
||||
@ -452,6 +434,19 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
|
||||
((fnc_f)callBackTable[41])(userData, rotation);
|
||||
break;
|
||||
}
|
||||
case B_PIC_SET_FONT_ENCODING:
|
||||
{
|
||||
int32 encoding = GetInt32();
|
||||
((fnc_i)callBackTable[42])(userData, encoding);
|
||||
break;
|
||||
}
|
||||
case B_PIC_SET_FONT_FLAGS:
|
||||
{
|
||||
int32 flags = GetInt32();
|
||||
((fnc_i)callBackTable[43])(userData, flags);
|
||||
break;
|
||||
}
|
||||
|
||||
case B_PIC_SET_FONT_SHEAR:
|
||||
{
|
||||
float shear = GetFloat();
|
||||
@ -464,6 +459,16 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
|
||||
((fnc_i)callBackTable[46])(userData, flags);
|
||||
break;
|
||||
}
|
||||
// TODO: Looks like R5 function table only exports 47 functions...
|
||||
// I added this here as a temporary workaround, because there seems to be
|
||||
// no room for this op, although it's obviously implemented in some way...
|
||||
case B_PIC_SET_BLENDING_MODE:
|
||||
{
|
||||
int16 alphaSrcMode = GetInt16();
|
||||
int16 alphaFncMode = GetInt16();
|
||||
((fnc_ss)callBackTable[47])(userData, alphaSrcMode, alphaFncMode);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "ViewLayer.h"
|
||||
#include "WindowLayer.h"
|
||||
|
||||
#include <PictureProtocol.h>
|
||||
#include <ServerProtocol.h>
|
||||
#include <TPicture.h>
|
||||
|
||||
@ -430,6 +431,13 @@ set_font_face(ViewLayer *view, int32 flags)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
set_blending_mode(ViewLayer *view, int16 alphaSrcMode, int16 alphaFncMode)
|
||||
{
|
||||
view->CurrentState()->SetBlendingMode((source_alpha)alphaSrcMode, (alpha_function)alphaFncMode);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
reserved()
|
||||
{
|
||||
@ -456,7 +464,7 @@ const void *tableEntries[] = {
|
||||
(const void *)fill_shape,
|
||||
(const void *)draw_string,
|
||||
(const void *)draw_pixels,
|
||||
(const void *)reserved,
|
||||
(const void *)reserved, // TODO: This is probably "draw_picture". Investigate
|
||||
(const void *)set_clipping_rects,
|
||||
(const void *)clip_to_picture,
|
||||
(const void *)push_state,
|
||||
@ -482,8 +490,9 @@ const void *tableEntries[] = {
|
||||
(const void *)set_font_encoding,
|
||||
(const void *)set_font_flags,
|
||||
(const void *)set_font_shear,
|
||||
(const void *)reserved,
|
||||
(const void *)set_font_face,
|
||||
(const void *)reserved, // TODO: Marc Flerackers calls this "set_font_bpp". Investigate
|
||||
(const void *)set_font_face, // TODO: R5 function table ends here... how is set blending mode implemented there ?
|
||||
(const void *)set_blending_mode
|
||||
};
|
||||
|
||||
|
||||
@ -642,7 +651,44 @@ ServerPicture::AddData(const void *data, int32 size)
|
||||
void
|
||||
ServerPicture::SyncState(ViewLayer *view)
|
||||
{
|
||||
// TODO:
|
||||
BeginOp(B_PIC_ENTER_STATE_CHANGE);
|
||||
|
||||
BeginOp(B_PIC_SET_PEN_LOCATION);
|
||||
AddCoord(view->CurrentState()->PenLocation());
|
||||
EndOp();
|
||||
|
||||
BeginOp(B_PIC_SET_PEN_SIZE);
|
||||
AddFloat(view->CurrentState()->PenSize());
|
||||
EndOp();
|
||||
|
||||
BeginOp(B_PIC_SET_LINE_MODE);
|
||||
AddInt16((int16)view->CurrentState()->LineCapMode());
|
||||
AddInt16((int16)view->CurrentState()->LineJoinMode());
|
||||
AddFloat(view->CurrentState()->MiterLimit());
|
||||
EndOp();
|
||||
|
||||
BeginOp(B_PIC_SET_STIPLE_PATTERN);
|
||||
AddData(view->CurrentState()->GetPattern().GetInt8(), sizeof(pattern));
|
||||
EndOp();
|
||||
|
||||
BeginOp(B_PIC_SET_DRAWING_MODE);
|
||||
AddInt16((int16)view->CurrentState()->GetDrawingMode());
|
||||
EndOp();
|
||||
|
||||
BeginOp(B_PIC_SET_BLENDING_MODE);
|
||||
AddInt16((int16)view->CurrentState()->AlphaSrcMode());
|
||||
AddInt16((int16)view->CurrentState()->AlphaFncMode());
|
||||
EndOp();
|
||||
|
||||
BeginOp(B_PIC_SET_FORE_COLOR);
|
||||
AddColor(view->CurrentState()->HighColor().GetColor32());
|
||||
EndOp();
|
||||
|
||||
BeginOp(B_PIC_SET_BACK_COLOR);
|
||||
AddColor(view->CurrentState()->LowColor().GetColor32());
|
||||
EndOp();
|
||||
|
||||
EndOp();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1828,6 +1828,7 @@ ServerWindow::_DispatchViewMessage(int32 code,
|
||||
{
|
||||
DTRACE(("ServerWindow %s: Message AS_LAYER_BEGIN_PICTURE\n", Title()));
|
||||
ServerPicture *picture = App()->CreatePicture();
|
||||
picture->SyncState(fCurrentLayer);
|
||||
fCurrentLayer->SetPicture(picture);
|
||||
break;
|
||||
}
|
||||
@ -1838,8 +1839,10 @@ ServerWindow::_DispatchViewMessage(int32 code,
|
||||
|
||||
int32 pictureToken;
|
||||
link.Read<int32>(&pictureToken);
|
||||
|
||||
fCurrentLayer->SetPicture(App()->FindPicture(pictureToken));
|
||||
ServerPicture *picture = App()->FindPicture(pictureToken);
|
||||
if (picture)
|
||||
picture->SyncState(fCurrentLayer);
|
||||
fCurrentLayer->SetPicture(picture);
|
||||
// we don't care if it's NULL
|
||||
break;
|
||||
}
|
||||
@ -2362,6 +2365,9 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
if (lineCount <= 0)
|
||||
break;
|
||||
|
||||
picture->BeginOp(B_PIC_PUSH_STATE);
|
||||
picture->EndOp();
|
||||
|
||||
for (int32 i = 0; i < lineCount; i++) {
|
||||
float x1, y1, x2, y2;
|
||||
link.Read<float>(&x1);
|
||||
@ -2382,9 +2388,7 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
picture->EndOp();
|
||||
}
|
||||
|
||||
// reset the color to the previous one
|
||||
picture->BeginOp(B_PIC_SET_FORE_COLOR);
|
||||
picture->AddColor(fCurrentLayer->CurrentState()->HighColor().GetColor32());
|
||||
picture->BeginOp(B_PIC_POP_STATE);
|
||||
picture->EndOp();
|
||||
break;
|
||||
}
|
||||
@ -2441,7 +2445,7 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
ServerBitmap *bitmap = App()->FindBitmap(token);
|
||||
if (bitmap == NULL)
|
||||
break;
|
||||
|
||||
|
||||
picture->BeginOp(B_PIC_DRAW_PIXELS);
|
||||
picture->AddRect(sourceRect);
|
||||
picture->AddRect(destRect);
|
||||
@ -2452,6 +2456,22 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
picture->AddInt32(/*bitmap->Flags()*/0);
|
||||
picture->AddData((void *)bitmap->Bits(), bitmap->BitsLength());
|
||||
picture->EndOp();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case AS_LAYER_SET_BLENDING_MODE:
|
||||
{
|
||||
int8 srcAlpha, alphaFunc;
|
||||
|
||||
link.Read<int8>(&srcAlpha);
|
||||
link.Read<int8>(&alphaFunc);
|
||||
|
||||
picture->BeginOp(B_PIC_SET_BLENDING_MODE);
|
||||
picture->AddInt16((int16)srcAlpha);
|
||||
picture->AddInt16((int16)alphaFunc);
|
||||
picture->EndOp();
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user