Initial support for recording (some, for now) drawing events into a BPicture

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15838 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2006-01-04 07:30:38 +00:00
parent e55e1a0e66
commit ee6bcb7d78
2 changed files with 65 additions and 0 deletions

View File

@ -37,6 +37,7 @@
#include <DirectWindowPrivate.h>
#include <MessagePrivate.h>
#include <PictureProtocol.h>
#include "AppServer.h"
#include "BGet++.h"
@ -1023,6 +1024,9 @@ void
ServerWindow::_DispatchViewMessage(int32 code,
BPrivate::LinkReceiver &link)
{
if (_DispatchPictureMessage(code, link))
return;
switch (code) {
case AS_LAYER_SCROLL:
{
@ -2225,6 +2229,65 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
}
bool
ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver &link)
{
ServerPicture *picture = fCurrentLayer->Picture();
if (picture == NULL)
return false;
switch (code) {
case AS_FILL_RECT:
{
BRect rect;
link.Read<BRect>(&rect);
picture->BeginOp(B_PIC_FILL_RECT);
picture->AddRect(rect);
picture->EndOp();
break;
}
case AS_LAYER_DRAW_BITMAP_SYNC_IN_RECT:
case AS_LAYER_DRAW_BITMAP_ASYNC_IN_RECT:
{
int32 token;
link.Read<int32>(&token);
BRect destRect;
link.Read<BRect>(&destRect);
BRect sourceRect;
link.Read<BRect>(&sourceRect);
ServerBitmap *bitmap = App()->FindBitmap(token);
if (bitmap == NULL)
break;
picture->BeginOp(B_PIC_DRAW_PIXELS);
picture->AddRect(sourceRect);
picture->AddRect(destRect);
picture->AddInt32(bitmap->Width());
picture->AddInt32(bitmap->Height());
picture->AddInt32(bitmap->BytesPerRow());
picture->AddInt32(bitmap->ColorSpace());
picture->AddInt32(/*bitmap->Flags()*/0);
picture->AddData((void *)bitmap->Bits(), bitmap->BitsLength());
picture->EndOp();
break;
}
default:
return false;
}
if (link.NeedsReply()) {
fLink.StartMessage(B_ERROR);
fLink.Flush();
}
return true;
}
/*!
\brief Message-dispatching loop for the ServerWindow

View File

@ -121,6 +121,8 @@ private:
BPrivate::LinkReceiver &link);
void _DispatchViewDrawingMessage(int32 code,
BPrivate::LinkReceiver &link);
bool _DispatchPictureMessage(int32 code,
BPrivate::LinkReceiver &link);
void _MessageLooper();
virtual void _PrepareQuit();
virtual void _GetLooperName(char* name, size_t size);