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_f)(void*, float);
|
||||||
typedef void (*fnc_Color)(void*, rgb_color);
|
typedef void (*fnc_Color)(void*, rgb_color);
|
||||||
typedef void (*fnc_Pattern)(void*, pattern);
|
typedef void (*fnc_Pattern)(void*, pattern);
|
||||||
|
typedef void (*fnc_ss)(void *, int16, int16);
|
||||||
typedef void (*fnc_PBRecti)(void*, BRect*, int32);
|
typedef void (*fnc_PBRecti)(void*, BRect*, int32);
|
||||||
typedef void (*fnc_DrawPixels)(void *, BRect, BRect, int32, int32, int32,
|
typedef void (*fnc_DrawPixels)(void *, BRect, BRect, int32, int32, int32,
|
||||||
int32, int32, void*);
|
int32, int32, void*);
|
||||||
@ -147,7 +148,7 @@ PicturePlayer::GetData(void *data, int32 size)
|
|||||||
status_t
|
status_t
|
||||||
PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
|
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.
|
// before calling them.
|
||||||
|
|
||||||
// lenght of the stream
|
// lenght of the stream
|
||||||
@ -213,6 +214,44 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
|
|||||||
((fnc_PBPoint)callBackTable[8])(userData, control);
|
((fnc_PBPoint)callBackTable[8])(userData, control);
|
||||||
break;
|
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:
|
case B_PIC_STROKE_POLYGON:
|
||||||
{
|
{
|
||||||
int32 numPoints = GetInt32();
|
int32 numPoints = GetInt32();
|
||||||
@ -267,44 +306,7 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
|
|||||||
{
|
{
|
||||||
break;
|
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:
|
case B_PIC_ENTER_STATE_CHANGE:
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@ -313,6 +315,11 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case B_PIC_CLEAR_CLIPPING_RECTS:
|
||||||
|
{
|
||||||
|
((fnc_PBRecti)callBackTable[20])(userData, NULL, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case B_PIC_CLIP_TO_PICTURE:
|
case B_PIC_CLIP_TO_PICTURE:
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@ -327,9 +334,9 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
|
|||||||
((fnc)callBackTable[23])(userData);
|
((fnc)callBackTable[23])(userData);
|
||||||
break;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case B_PIC_SET_ORIGIN:
|
case B_PIC_SET_ORIGIN:
|
||||||
@ -364,12 +371,6 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
|
|||||||
((fnc_f)callBackTable[32])(userData, size);
|
((fnc_f)callBackTable[32])(userData, size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_PIC_SET_SCALE:
|
|
||||||
{
|
|
||||||
float scale = GetFloat();
|
|
||||||
((fnc_f)callBackTable[36])(userData, scale);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_PIC_SET_FORE_COLOR:
|
case B_PIC_SET_FORE_COLOR:
|
||||||
{
|
{
|
||||||
rgb_color color = GetColor();
|
rgb_color color = GetColor();
|
||||||
@ -389,17 +390,10 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
|
|||||||
((fnc_Pattern)callBackTable[35])(userData, p);
|
((fnc_Pattern)callBackTable[35])(userData, p);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_PIC_ENTER_FONT_STATE:
|
case B_PIC_SET_SCALE:
|
||||||
{
|
{
|
||||||
((fnc)callBackTable[26])(userData);
|
float scale = GetFloat();
|
||||||
break;
|
((fnc_f)callBackTable[36])(userData, scale);
|
||||||
}
|
|
||||||
case B_PIC_SET_BLENDING_MODE:
|
|
||||||
{
|
|
||||||
//int16 alphaSrcMode = GetInt16();
|
|
||||||
//int16 alphaFncMode = GetInt16();
|
|
||||||
//((fnc_Pattern)callBackTable[??])(userData, alphaSrcMode,
|
|
||||||
// alphaFncMode);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_PIC_SET_FONT_FAMILY:
|
case B_PIC_SET_FONT_FAMILY:
|
||||||
@ -428,18 +422,6 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
|
|||||||
((fnc_i)callBackTable[39])(userData, spacing);
|
((fnc_i)callBackTable[39])(userData, spacing);
|
||||||
break;
|
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:
|
case B_PIC_SET_FONT_SIZE:
|
||||||
{
|
{
|
||||||
float size = GetFloat();
|
float size = GetFloat();
|
||||||
@ -452,6 +434,19 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
|
|||||||
((fnc_f)callBackTable[41])(userData, rotation);
|
((fnc_f)callBackTable[41])(userData, rotation);
|
||||||
break;
|
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:
|
case B_PIC_SET_FONT_SHEAR:
|
||||||
{
|
{
|
||||||
float shear = GetFloat();
|
float shear = GetFloat();
|
||||||
@ -464,6 +459,16 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
|
|||||||
((fnc_i)callBackTable[46])(userData, flags);
|
((fnc_i)callBackTable[46])(userData, flags);
|
||||||
break;
|
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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "ViewLayer.h"
|
#include "ViewLayer.h"
|
||||||
#include "WindowLayer.h"
|
#include "WindowLayer.h"
|
||||||
|
|
||||||
|
#include <PictureProtocol.h>
|
||||||
#include <ServerProtocol.h>
|
#include <ServerProtocol.h>
|
||||||
#include <TPicture.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
|
static void
|
||||||
reserved()
|
reserved()
|
||||||
{
|
{
|
||||||
@ -456,7 +464,7 @@ const void *tableEntries[] = {
|
|||||||
(const void *)fill_shape,
|
(const void *)fill_shape,
|
||||||
(const void *)draw_string,
|
(const void *)draw_string,
|
||||||
(const void *)draw_pixels,
|
(const void *)draw_pixels,
|
||||||
(const void *)reserved,
|
(const void *)reserved, // TODO: This is probably "draw_picture". Investigate
|
||||||
(const void *)set_clipping_rects,
|
(const void *)set_clipping_rects,
|
||||||
(const void *)clip_to_picture,
|
(const void *)clip_to_picture,
|
||||||
(const void *)push_state,
|
(const void *)push_state,
|
||||||
@ -482,8 +490,9 @@ const void *tableEntries[] = {
|
|||||||
(const void *)set_font_encoding,
|
(const void *)set_font_encoding,
|
||||||
(const void *)set_font_flags,
|
(const void *)set_font_flags,
|
||||||
(const void *)set_font_shear,
|
(const void *)set_font_shear,
|
||||||
(const void *)reserved,
|
(const void *)reserved, // TODO: Marc Flerackers calls this "set_font_bpp". Investigate
|
||||||
(const void *)set_font_face,
|
(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
|
void
|
||||||
ServerPicture::SyncState(ViewLayer *view)
|
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()));
|
DTRACE(("ServerWindow %s: Message AS_LAYER_BEGIN_PICTURE\n", Title()));
|
||||||
ServerPicture *picture = App()->CreatePicture();
|
ServerPicture *picture = App()->CreatePicture();
|
||||||
|
picture->SyncState(fCurrentLayer);
|
||||||
fCurrentLayer->SetPicture(picture);
|
fCurrentLayer->SetPicture(picture);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1838,8 +1839,10 @@ ServerWindow::_DispatchViewMessage(int32 code,
|
|||||||
|
|
||||||
int32 pictureToken;
|
int32 pictureToken;
|
||||||
link.Read<int32>(&pictureToken);
|
link.Read<int32>(&pictureToken);
|
||||||
|
ServerPicture *picture = App()->FindPicture(pictureToken);
|
||||||
fCurrentLayer->SetPicture(App()->FindPicture(pictureToken));
|
if (picture)
|
||||||
|
picture->SyncState(fCurrentLayer);
|
||||||
|
fCurrentLayer->SetPicture(picture);
|
||||||
// we don't care if it's NULL
|
// we don't care if it's NULL
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2362,6 +2365,9 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
if (lineCount <= 0)
|
if (lineCount <= 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
picture->BeginOp(B_PIC_PUSH_STATE);
|
||||||
|
picture->EndOp();
|
||||||
|
|
||||||
for (int32 i = 0; i < lineCount; i++) {
|
for (int32 i = 0; i < lineCount; i++) {
|
||||||
float x1, y1, x2, y2;
|
float x1, y1, x2, y2;
|
||||||
link.Read<float>(&x1);
|
link.Read<float>(&x1);
|
||||||
@ -2382,9 +2388,7 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
picture->EndOp();
|
picture->EndOp();
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset the color to the previous one
|
picture->BeginOp(B_PIC_POP_STATE);
|
||||||
picture->BeginOp(B_PIC_SET_FORE_COLOR);
|
|
||||||
picture->AddColor(fCurrentLayer->CurrentState()->HighColor().GetColor32());
|
|
||||||
picture->EndOp();
|
picture->EndOp();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2441,7 +2445,7 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
ServerBitmap *bitmap = App()->FindBitmap(token);
|
ServerBitmap *bitmap = App()->FindBitmap(token);
|
||||||
if (bitmap == NULL)
|
if (bitmap == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
picture->BeginOp(B_PIC_DRAW_PIXELS);
|
picture->BeginOp(B_PIC_DRAW_PIXELS);
|
||||||
picture->AddRect(sourceRect);
|
picture->AddRect(sourceRect);
|
||||||
picture->AddRect(destRect);
|
picture->AddRect(destRect);
|
||||||
@ -2452,6 +2456,22 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
picture->AddInt32(/*bitmap->Flags()*/0);
|
picture->AddInt32(/*bitmap->Flags()*/0);
|
||||||
picture->AddData((void *)bitmap->Bits(), bitmap->BitsLength());
|
picture->AddData((void *)bitmap->Bits(), bitmap->BitsLength());
|
||||||
picture->EndOp();
|
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;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user