implemented some more stuff for bpicture support. In theory StrokeLine, Stroke/FillRect should work but in practice they don't.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16005 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2006-01-18 20:49:29 +00:00
parent 678d2b34a4
commit af675e2c03
2 changed files with 43 additions and 21 deletions

View File

@ -1,13 +1,16 @@
#include "DrawingEngine.h"
#include "ServerBitmap.h"
#include "ServerPicture.h"
#include "ServerTokenSpace.h"
#include "ViewLayer.h"
#include "WindowLayer.h"
#include <ServerProtocol.h>
#include <TPicture.h>
#include <stdio.h>
static void
nop()
{
@ -26,30 +29,25 @@ move_pen_by(ViewLayer *view, BPoint delta)
static void
stroke_line(ViewLayer *view, BPoint start, BPoint end)
{
//view->MovePenTo(start);
//view->StrokeLine(end);
printf("StrokeLine(BPoint(%.2f, %.2f), BPoint(%.2f, %.2f))\n", start.x, start.y,
end.x, end.y);
view->ConvertToScreenForDrawing(&start);
view->ConvertToScreenForDrawing(&end);
view->Window()->GetDrawingEngine()->StrokeLine(start, end, view->CurrentState()->HighColor());
}
static void
stroke_rect(ViewLayer *view, BRect rect)
{
//view->StrokeRect(rect);
printf("StrokeRect(BRect(%.2f, %.2f, %.2f, %.2f))\n", rect.left, rect.top,
rect.right, rect.bottom);
view->ConvertToScreenForDrawing(&rect);
view->Window()->GetDrawingEngine()->StrokeRect(rect, view->CurrentState()->HighColor());
}
static void
fill_rect(ViewLayer *view, BRect rect)
{
//view->FillRect(rect);
printf("FillRect(BRect(%.2f, %.2f, %.2f, %.2f))\n", rect.left, rect.top,
rect.right, rect.bottom);
view->ConvertToScreenForDrawing(&rect);
view->Window()->GetDrawingEngine()->FillRect(rect, view->CurrentState()->HighColor());
}
@ -297,20 +295,14 @@ set_pen_size(ViewLayer *view, float size)
static void
set_fore_color(ViewLayer *view, rgb_color color)
{
//view->SetHighColor(color);
printf("SetForeColor(%d, %d, %d, %d)\n", color.red, color.green,
color.blue, color.alpha);
view->CurrentState()->SetHighColor(RGBColor(color));
}
static void
set_back_color(ViewLayer *view, rgb_color color)
{
//view->SetLowColor(color);
printf("SetBackColor(%d, %d, %d, %d)\n", color.red, color.green,
color.blue, color.alpha);
view->CurrentState()->SetLowColor(RGBColor(color));
}

View File

@ -2187,6 +2187,7 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
if (picture != NULL) {
fCurrentLayer->ConvertToScreenForDrawing(&where);
fCurrentLayer->CurrentState()->SetPenLocation(where);
// TODO: pass the location to the play method and handle it there
picture->Play(fCurrentLayer);
}
}
@ -2218,15 +2219,44 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver &link)
switch (code) {
case AS_FILL_RECT:
case AS_STROKE_RECT:
{
BRect rect;
link.Read<BRect>(&rect);
picture->BeginOp(B_PIC_FILL_RECT);
picture->BeginOp(code == AS_FILL_RECT ? B_PIC_FILL_RECT : B_PIC_STROKE_RECT);
picture->AddRect(rect);
picture->EndOp();
break;
}
case AS_STROKE_LINE:
{
float x1, y1, x2, y2;
link.Read<float>(&x1);
link.Read<float>(&y1);
link.Read<float>(&x2);
link.Read<float>(&y2);
picture->BeginOp(B_PIC_STROKE_LINE);
picture->AddCoord(BPoint(x1, y1));
picture->AddCoord(BPoint(x2, y2));
picture->EndOp();
break;
}
case AS_LAYER_SET_LOW_COLOR:
case AS_LAYER_SET_HIGH_COLOR:
{
rgb_color color;
link.Read(&color, sizeof(rgb_color));
picture->BeginOp(code == AS_LAYER_SET_HIGH_COLOR ? B_PIC_SET_FORE_COLOR : B_PIC_SET_BACK_COLOR);
picture->AddColor(color);
picture->EndOp();
break;
}
case AS_LAYER_DRAW_BITMAP:
{