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:
@@ -1,13 +1,16 @@
|
|||||||
|
#include "DrawingEngine.h"
|
||||||
#include "ServerBitmap.h"
|
#include "ServerBitmap.h"
|
||||||
#include "ServerPicture.h"
|
#include "ServerPicture.h"
|
||||||
#include "ServerTokenSpace.h"
|
#include "ServerTokenSpace.h"
|
||||||
#include "ViewLayer.h"
|
#include "ViewLayer.h"
|
||||||
|
#include "WindowLayer.h"
|
||||||
|
|
||||||
#include <ServerProtocol.h>
|
#include <ServerProtocol.h>
|
||||||
#include <TPicture.h>
|
#include <TPicture.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nop()
|
nop()
|
||||||
{
|
{
|
||||||
@@ -26,30 +29,25 @@ move_pen_by(ViewLayer *view, BPoint delta)
|
|||||||
static void
|
static void
|
||||||
stroke_line(ViewLayer *view, BPoint start, BPoint end)
|
stroke_line(ViewLayer *view, BPoint start, BPoint end)
|
||||||
{
|
{
|
||||||
//view->MovePenTo(start);
|
view->ConvertToScreenForDrawing(&start);
|
||||||
//view->StrokeLine(end);
|
view->ConvertToScreenForDrawing(&end);
|
||||||
printf("StrokeLine(BPoint(%.2f, %.2f), BPoint(%.2f, %.2f))\n", start.x, start.y,
|
view->Window()->GetDrawingEngine()->StrokeLine(start, end, view->CurrentState()->HighColor());
|
||||||
end.x, end.y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
stroke_rect(ViewLayer *view, BRect rect)
|
stroke_rect(ViewLayer *view, BRect rect)
|
||||||
{
|
{
|
||||||
//view->StrokeRect(rect);
|
view->ConvertToScreenForDrawing(&rect);
|
||||||
|
view->Window()->GetDrawingEngine()->StrokeRect(rect, view->CurrentState()->HighColor());
|
||||||
printf("StrokeRect(BRect(%.2f, %.2f, %.2f, %.2f))\n", rect.left, rect.top,
|
|
||||||
rect.right, rect.bottom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fill_rect(ViewLayer *view, BRect rect)
|
fill_rect(ViewLayer *view, BRect rect)
|
||||||
{
|
{
|
||||||
//view->FillRect(rect);
|
view->ConvertToScreenForDrawing(&rect);
|
||||||
|
view->Window()->GetDrawingEngine()->FillRect(rect, view->CurrentState()->HighColor());
|
||||||
printf("FillRect(BRect(%.2f, %.2f, %.2f, %.2f))\n", rect.left, rect.top,
|
|
||||||
rect.right, rect.bottom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -297,20 +295,14 @@ set_pen_size(ViewLayer *view, float size)
|
|||||||
static void
|
static void
|
||||||
set_fore_color(ViewLayer *view, rgb_color color)
|
set_fore_color(ViewLayer *view, rgb_color color)
|
||||||
{
|
{
|
||||||
//view->SetHighColor(color);
|
view->CurrentState()->SetHighColor(RGBColor(color));
|
||||||
|
|
||||||
printf("SetForeColor(%d, %d, %d, %d)\n", color.red, color.green,
|
|
||||||
color.blue, color.alpha);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_back_color(ViewLayer *view, rgb_color color)
|
set_back_color(ViewLayer *view, rgb_color color)
|
||||||
{
|
{
|
||||||
//view->SetLowColor(color);
|
view->CurrentState()->SetLowColor(RGBColor(color));
|
||||||
|
|
||||||
printf("SetBackColor(%d, %d, %d, %d)\n", color.red, color.green,
|
|
||||||
color.blue, color.alpha);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2187,6 +2187,7 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
|
|||||||
if (picture != NULL) {
|
if (picture != NULL) {
|
||||||
fCurrentLayer->ConvertToScreenForDrawing(&where);
|
fCurrentLayer->ConvertToScreenForDrawing(&where);
|
||||||
fCurrentLayer->CurrentState()->SetPenLocation(where);
|
fCurrentLayer->CurrentState()->SetPenLocation(where);
|
||||||
|
// TODO: pass the location to the play method and handle it there
|
||||||
picture->Play(fCurrentLayer);
|
picture->Play(fCurrentLayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2218,15 +2219,44 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case AS_FILL_RECT:
|
case AS_FILL_RECT:
|
||||||
|
case AS_STROKE_RECT:
|
||||||
{
|
{
|
||||||
BRect rect;
|
BRect rect;
|
||||||
link.Read<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->AddRect(rect);
|
||||||
picture->EndOp();
|
picture->EndOp();
|
||||||
break;
|
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:
|
case AS_LAYER_DRAW_BITMAP:
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user