Patch by Artur Wyszynski with some changes by myself:
* Resolved TODO: The type of the gradient is no longer encoded twice in the app_server link protocoll. * Moved instantiation of the BGradient into the LinkReceiver::ReadGradient() method. * Check success for (at least) ReadGradient() in ServerWindow. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28150 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
2259002bdb
commit
431dc47dde
@ -13,9 +13,10 @@
|
|||||||
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
|
||||||
|
|
||||||
|
class BGradient;
|
||||||
class BString;
|
class BString;
|
||||||
class BRegion;
|
class BRegion;
|
||||||
class BGradient;
|
|
||||||
|
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
@ -38,7 +39,7 @@ class LinkReceiver {
|
|||||||
status_t ReadString(BString& string, size_t* _length = NULL);
|
status_t ReadString(BString& string, size_t* _length = NULL);
|
||||||
status_t ReadString(char* buffer, size_t bufferSize);
|
status_t ReadString(char* buffer, size_t bufferSize);
|
||||||
status_t ReadRegion(BRegion* region);
|
status_t ReadRegion(BRegion* region);
|
||||||
status_t ReadGradient(BGradient *gradient);
|
status_t ReadGradient(BGradient** gradient);
|
||||||
|
|
||||||
template <class Type> status_t Read(Type *data)
|
template <class Type> status_t Read(Type *data)
|
||||||
{ return Read(data, sizeof(Type)); }
|
{ return Read(data, sizeof(Type)); }
|
||||||
|
@ -66,7 +66,7 @@ class ServerLink {
|
|||||||
status_t ReadString(char** _string, size_t* _length = NULL);
|
status_t ReadString(char** _string, size_t* _length = NULL);
|
||||||
status_t ReadRegion(BRegion *region);
|
status_t ReadRegion(BRegion *region);
|
||||||
status_t ReadShape(BShape *shape);
|
status_t ReadShape(BShape *shape);
|
||||||
status_t ReadGradient(BGradient *gradient);
|
status_t ReadGradient(BGradient **gradient);
|
||||||
template <class Type> status_t Read(Type *data);
|
template <class Type> status_t Read(Type *data);
|
||||||
|
|
||||||
// convenience methods
|
// convenience methods
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2007, Haiku.
|
* Copyright 2001-2008, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Pahtz <pahtz@yahoo.com.au>
|
* Pahtz <pahtz@yahoo.com.au>
|
||||||
* Axel Dörfler
|
* Axel Dörfler
|
||||||
* Stephan Aßmus <superstippi@gmx.de>
|
* Stephan Aßmus <superstippi@gmx.de>
|
||||||
|
* Artur Wyszynski <harakash@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Class for low-overhead port-based messaging */
|
/** Class for low-overhead port-based messaging */
|
||||||
@ -469,79 +470,120 @@ LinkReceiver::ReadRegion(BRegion* region)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static BGradient*
|
||||||
|
gradient_for_type(gradient_type type)
|
||||||
|
{
|
||||||
|
switch (type) {
|
||||||
|
case B_GRADIENT_LINEAR:
|
||||||
|
return new (std::nothrow) BGradientLinear();
|
||||||
|
case B_GRADIENT_RADIAL:
|
||||||
|
return new (std::nothrow) BGradientRadial();
|
||||||
|
case B_GRADIENT_RADIAL_FOCUS:
|
||||||
|
return new (std::nothrow) BGradientRadialFocus();
|
||||||
|
case B_GRADIENT_DIAMOND:
|
||||||
|
return new (std::nothrow) BGradientDiamond();
|
||||||
|
case B_GRADIENT_CONIC:
|
||||||
|
return new (std::nothrow) BGradientConic();
|
||||||
|
case B_GRADIENT_NONE:
|
||||||
|
return new (std::nothrow) BGradient();
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
LinkReceiver::ReadGradient(BGradient *gradient)
|
LinkReceiver::ReadGradient(BGradient** _gradient)
|
||||||
{
|
{
|
||||||
GTRACE(("LinkReceiver::ReadGradient\n"));
|
GTRACE(("LinkReceiver::ReadGradient\n"));
|
||||||
gradient_type gradientType;
|
gradient_type gradientType;
|
||||||
int32 colorsCount;
|
int32 colorsCount;
|
||||||
Read(&gradientType, sizeof(gradient_type));
|
status_t ret;
|
||||||
Read(&colorsCount, sizeof(int32));
|
if ((ret = Read(&gradientType, sizeof(gradient_type))) != B_OK)
|
||||||
|
return ret;
|
||||||
|
if ((ret = Read(&colorsCount, sizeof(int32))) != B_OK)
|
||||||
|
return ret;
|
||||||
|
BGradient* gradient = gradient_for_type(gradientType);
|
||||||
|
if (!gradient)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
*_gradient = gradient;
|
||||||
|
|
||||||
if (colorsCount > 0) {
|
if (colorsCount > 0) {
|
||||||
color_step step;
|
color_step step;
|
||||||
for (int i = 0; i < colorsCount; i++) {
|
for (int i = 0; i < colorsCount; i++) {
|
||||||
Read(&step, sizeof(color_step));
|
if ((ret = Read(&step, sizeof(color_step))) != B_OK)
|
||||||
gradient->AddColor(step, i);
|
return ret;
|
||||||
|
if (!gradient->AddColor(step, i))
|
||||||
|
return B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(gradientType) {
|
switch(gradientType) {
|
||||||
case B_GRADIENT_LINEAR: {
|
case B_GRADIENT_LINEAR: {
|
||||||
GTRACE(("LinkReceiver::ReadGradient> type == B_GRADIENT_LINEAR\n"));
|
GTRACE(("LinkReceiver::ReadGradient> type == B_GRADIENT_LINEAR\n"));
|
||||||
BGradientLinear* linear = (BGradientLinear*) gradient;
|
BGradientLinear* linear = (BGradientLinear*)gradient;
|
||||||
BPoint start;
|
BPoint start;
|
||||||
BPoint end;
|
BPoint end;
|
||||||
Read(&start, sizeof(BPoint));
|
if ((ret = Read(&start, sizeof(BPoint))) != B_OK)
|
||||||
Read(&end, sizeof(BPoint));
|
return ret;
|
||||||
|
if ((ret = Read(&end, sizeof(BPoint))) != B_OK)
|
||||||
|
return ret;
|
||||||
linear->SetStart(start);
|
linear->SetStart(start);
|
||||||
linear->SetEnd(end);
|
linear->SetEnd(end);
|
||||||
break;
|
return B_OK;
|
||||||
}
|
}
|
||||||
case B_GRADIENT_RADIAL: {
|
case B_GRADIENT_RADIAL: {
|
||||||
GTRACE(("LinkReceiver::ReadGradient> type == B_GRADIENT_RADIAL\n"));
|
GTRACE(("LinkReceiver::ReadGradient> type == B_GRADIENT_RADIAL\n"));
|
||||||
BGradientRadial* radial = (BGradientRadial*) gradient;
|
BGradientRadial* radial = (BGradientRadial*)gradient;
|
||||||
BPoint center;
|
BPoint center;
|
||||||
float radius;
|
float radius;
|
||||||
Read(¢er, sizeof(BPoint));
|
if ((ret = Read(¢er, sizeof(BPoint))) != B_OK)
|
||||||
Read(&radius, sizeof(float));
|
return ret;
|
||||||
|
if ((ret = Read(&radius, sizeof(float))) != B_OK)
|
||||||
|
return ret;
|
||||||
radial->SetCenter(center);
|
radial->SetCenter(center);
|
||||||
radial->SetRadius(radius);
|
radial->SetRadius(radius);
|
||||||
break;
|
return B_OK;
|
||||||
}
|
}
|
||||||
case B_GRADIENT_RADIAL_FOCUS: {
|
case B_GRADIENT_RADIAL_FOCUS: {
|
||||||
GTRACE(("LinkReceiver::ReadGradient> type == B_GRADIENT_RADIAL_FOCUS\n"));
|
GTRACE(("LinkReceiver::ReadGradient> type == B_GRADIENT_RADIAL_FOCUS\n"));
|
||||||
BGradientRadialFocus* radialFocus =
|
BGradientRadialFocus* radialFocus =
|
||||||
(BGradientRadialFocus*) gradient;
|
(BGradientRadialFocus*)gradient;
|
||||||
BPoint center;
|
BPoint center;
|
||||||
BPoint focal;
|
BPoint focal;
|
||||||
float radius;
|
float radius;
|
||||||
Read(¢er, sizeof(BPoint));
|
if ((ret = Read(¢er, sizeof(BPoint))) != B_OK)
|
||||||
Read(&focal, sizeof(BPoint));
|
return ret;
|
||||||
Read(&radius, sizeof(float));
|
if ((ret = Read(&focal, sizeof(BPoint))) != B_OK)
|
||||||
|
return ret;
|
||||||
|
if ((ret = Read(&radius, sizeof(float))) != B_OK)
|
||||||
|
return ret;
|
||||||
radialFocus->SetCenter(center);
|
radialFocus->SetCenter(center);
|
||||||
radialFocus->SetFocal(focal);
|
radialFocus->SetFocal(focal);
|
||||||
radialFocus->SetRadius(radius);
|
radialFocus->SetRadius(radius);
|
||||||
break;
|
return B_OK;
|
||||||
}
|
}
|
||||||
case B_GRADIENT_DIAMOND: {
|
case B_GRADIENT_DIAMOND: {
|
||||||
GTRACE(("LinkReceiver::ReadGradient> type == B_GRADIENT_DIAMOND\n"));
|
GTRACE(("LinkReceiver::ReadGradient> type == B_GRADIENT_DIAMOND\n"));
|
||||||
BGradientDiamond* diamond = (BGradientDiamond*) gradient;
|
BGradientDiamond* diamond = (BGradientDiamond*)gradient;
|
||||||
BPoint center;
|
BPoint center;
|
||||||
Read(¢er, sizeof(BPoint));
|
if ((ret = Read(¢er, sizeof(BPoint))) != B_OK)
|
||||||
|
return ret;
|
||||||
diamond->SetCenter(center);
|
diamond->SetCenter(center);
|
||||||
break;
|
return B_OK;
|
||||||
}
|
}
|
||||||
case B_GRADIENT_CONIC: {
|
case B_GRADIENT_CONIC: {
|
||||||
GTRACE(("LinkReceiver::ReadGradient> type == B_GRADIENT_CONIC\n"));
|
GTRACE(("LinkReceiver::ReadGradient> type == B_GRADIENT_CONIC\n"));
|
||||||
BGradientConic* conic = (BGradientConic*) gradient;
|
BGradientConic* conic = (BGradientConic*)gradient;
|
||||||
BPoint center;
|
BPoint center;
|
||||||
float angle;
|
float angle;
|
||||||
Read(¢er, sizeof(BPoint));
|
if ((ret = Read(¢er, sizeof(BPoint))) != B_OK)
|
||||||
Read(&angle, sizeof(float));
|
return ret;
|
||||||
|
if ((ret = Read(&angle, sizeof(float))) != B_OK)
|
||||||
|
return ret;
|
||||||
conic->SetCenter(center);
|
conic->SetCenter(center);
|
||||||
conic->SetAngle(angle);
|
conic->SetAngle(angle);
|
||||||
break;
|
return B_OK;
|
||||||
}
|
}
|
||||||
case B_GRADIENT_NONE: {
|
case B_GRADIENT_NONE: {
|
||||||
GTRACE(("LinkReceiver::ReadGradient> type == B_GRADIENT_NONE\n"));
|
GTRACE(("LinkReceiver::ReadGradient> type == B_GRADIENT_NONE\n"));
|
||||||
@ -549,7 +591,7 @@ LinkReceiver::ReadGradient(BGradient *gradient)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
@ -115,87 +115,10 @@ ServerLink::AttachShape(BShape &shape)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ServerLink::ReadGradient(BGradient *gradient)
|
ServerLink::ReadGradient(BGradient **gradient)
|
||||||
{
|
{
|
||||||
GTRACE(("ServerLink::ReadGradient\n"));
|
GTRACE(("ServerLink::ReadGradient\n"));
|
||||||
fReceiver->ReadGradient(gradient);
|
return fReceiver->ReadGradient(gradient);
|
||||||
/* gradient_type gradientType;
|
|
||||||
int32 colorsCount;
|
|
||||||
fReceiver->Read(&gradientType, sizeof(gradient_type));
|
|
||||||
fReceiver->Read(&colorsCount, sizeof(int32));
|
|
||||||
|
|
||||||
if (colorsCount > 0) {
|
|
||||||
color_step step;
|
|
||||||
for (int i = 0; i < colorsCount; i++) {
|
|
||||||
fReceiver->Read(&step, sizeof(color_step));
|
|
||||||
gradient->AddColor(step, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(gradientType) {
|
|
||||||
case B_GRADIENT_LINEAR: {
|
|
||||||
GTRACE(("ServerLink::ReadGradient> type == B_GRADIENT_LINEAR\n"));
|
|
||||||
BGradientLinear* linear = (BGradientLinear*) gradient;
|
|
||||||
BPoint start;
|
|
||||||
BPoint end;
|
|
||||||
fReceiver->Read(&start, sizeof(BPoint));
|
|
||||||
fReceiver->Read(&end, sizeof(BPoint));
|
|
||||||
linear->SetStart(start);
|
|
||||||
linear->SetEnd(end);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_GRADIENT_RADIAL: {
|
|
||||||
GTRACE(("ServerLink::ReadGradient> type == B_GRADIENT_RADIAL\n"));
|
|
||||||
BGradientRadial* radial = (BGradientRadial*) gradient;
|
|
||||||
BPoint center;
|
|
||||||
float radius;
|
|
||||||
fReceiver->Read(¢er, sizeof(BPoint));
|
|
||||||
fReceiver->Read(&radius, sizeof(float));
|
|
||||||
radial->SetCenter(center);
|
|
||||||
radial->SetRadius(radius);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_GRADIENT_RADIAL_FOCUS: {
|
|
||||||
GTRACE(("ServerLink::ReadGradient> type == B_GRADIENT_RADIAL_FOCUS\n"));
|
|
||||||
BGradientRadialFocus* radialFocus =
|
|
||||||
(BGradientRadialFocus*) gradient;
|
|
||||||
BPoint center;
|
|
||||||
BPoint focal;
|
|
||||||
float radius;
|
|
||||||
fReceiver->Read(¢er, sizeof(BPoint));
|
|
||||||
fReceiver->Read(&focal, sizeof(BPoint));
|
|
||||||
fReceiver->Read(&radius, sizeof(float));
|
|
||||||
radialFocus->SetCenter(center);
|
|
||||||
radialFocus->SetFocal(focal);
|
|
||||||
radialFocus->SetRadius(radius);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_GRADIENT_DIAMOND: {
|
|
||||||
GTRACE(("ServerLink::ReadGradient> type == B_GRADIENT_DIAMOND\n"));
|
|
||||||
BGradientDiamond* diamond = (BGradientDiamond*) gradient;
|
|
||||||
BPoint center;
|
|
||||||
fReceiver->Read(¢er, sizeof(BPoint));
|
|
||||||
diamond->SetCenter(center);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_GRADIENT_CONIC: {
|
|
||||||
GTRACE(("ServerLink::ReadGradient> type == B_GRADIENT_CONIC\n"));
|
|
||||||
BGradientConic* conic = (BGradientConic*) gradient;
|
|
||||||
BPoint center;
|
|
||||||
float angle;
|
|
||||||
fReceiver->Read(¢er, sizeof(BPoint));
|
|
||||||
fReceiver->Read(&angle, sizeof(float));
|
|
||||||
conic->SetCenter(center);
|
|
||||||
conic->SetAngle(angle);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_GRADIENT_NONE: {
|
|
||||||
GTRACE(("ServerLink::ReadGradient> type == B_GRADIENT_NONE\n"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return B_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2629,7 +2629,6 @@ BView::FillEllipse(BRect rect, const BGradient& gradient)
|
|||||||
|
|
||||||
fOwner->fLink->StartMessage(AS_FILL_ELLIPSE_GRADIENT);
|
fOwner->fLink->StartMessage(AS_FILL_ELLIPSE_GRADIENT);
|
||||||
fOwner->fLink->Attach<BRect>(rect);
|
fOwner->fLink->Attach<BRect>(rect);
|
||||||
fOwner->fLink->Attach<gradient_type>(gradient.Type());
|
|
||||||
fOwner->fLink->AttachGradient(gradient);
|
fOwner->fLink->AttachGradient(gradient);
|
||||||
|
|
||||||
_FlushIfNotInTransaction();
|
_FlushIfNotInTransaction();
|
||||||
@ -2714,7 +2713,6 @@ BView::FillArc(BRect rect, float startAngle, float arcAngle,
|
|||||||
fOwner->fLink->Attach<BRect>(rect);
|
fOwner->fLink->Attach<BRect>(rect);
|
||||||
fOwner->fLink->Attach<float>(startAngle);
|
fOwner->fLink->Attach<float>(startAngle);
|
||||||
fOwner->fLink->Attach<float>(arcAngle);
|
fOwner->fLink->Attach<float>(arcAngle);
|
||||||
fOwner->fLink->Attach<gradient_type>(gradient.Type());
|
|
||||||
fOwner->fLink->AttachGradient(gradient);
|
fOwner->fLink->AttachGradient(gradient);
|
||||||
|
|
||||||
_FlushIfNotInTransaction();
|
_FlushIfNotInTransaction();
|
||||||
@ -2772,7 +2770,6 @@ BView::FillBezier(BPoint *controlPoints, const BGradient& gradient)
|
|||||||
fOwner->fLink->Attach<BPoint>(controlPoints[1]);
|
fOwner->fLink->Attach<BPoint>(controlPoints[1]);
|
||||||
fOwner->fLink->Attach<BPoint>(controlPoints[2]);
|
fOwner->fLink->Attach<BPoint>(controlPoints[2]);
|
||||||
fOwner->fLink->Attach<BPoint>(controlPoints[3]);
|
fOwner->fLink->Attach<BPoint>(controlPoints[3]);
|
||||||
fOwner->fLink->Attach<gradient_type>(gradient.Type());
|
|
||||||
fOwner->fLink->AttachGradient(gradient);
|
fOwner->fLink->AttachGradient(gradient);
|
||||||
|
|
||||||
_FlushIfNotInTransaction();
|
_FlushIfNotInTransaction();
|
||||||
@ -2874,7 +2871,6 @@ BView::FillPolygon(const BPolygon *polygon, const BGradient& gradient)
|
|||||||
fOwner->fLink->Attach<int32>(polygon->fCount);
|
fOwner->fLink->Attach<int32>(polygon->fCount);
|
||||||
fOwner->fLink->Attach(polygon->fPoints,
|
fOwner->fLink->Attach(polygon->fPoints,
|
||||||
polygon->fCount * sizeof(BPoint));
|
polygon->fCount * sizeof(BPoint));
|
||||||
fOwner->fLink->Attach<gradient_type>(gradient.Type());
|
|
||||||
fOwner->fLink->AttachGradient(gradient);
|
fOwner->fLink->AttachGradient(gradient);
|
||||||
|
|
||||||
_FlushIfNotInTransaction();
|
_FlushIfNotInTransaction();
|
||||||
@ -2987,7 +2983,6 @@ BView::FillRect(BRect rect, const BGradient& gradient)
|
|||||||
|
|
||||||
fOwner->fLink->StartMessage(AS_FILL_RECT_GRADIENT);
|
fOwner->fLink->StartMessage(AS_FILL_RECT_GRADIENT);
|
||||||
fOwner->fLink->Attach<BRect>(rect);
|
fOwner->fLink->Attach<BRect>(rect);
|
||||||
fOwner->fLink->Attach<gradient_type>(gradient.Type());
|
|
||||||
fOwner->fLink->AttachGradient(gradient);
|
fOwner->fLink->AttachGradient(gradient);
|
||||||
|
|
||||||
_FlushIfNotInTransaction();
|
_FlushIfNotInTransaction();
|
||||||
@ -3046,7 +3041,6 @@ BView::FillRoundRect(BRect rect, float xRadius, float yRadius,
|
|||||||
fOwner->fLink->Attach<BRect>(rect);
|
fOwner->fLink->Attach<BRect>(rect);
|
||||||
fOwner->fLink->Attach<float>(xRadius);
|
fOwner->fLink->Attach<float>(xRadius);
|
||||||
fOwner->fLink->Attach<float>(yRadius);
|
fOwner->fLink->Attach<float>(yRadius);
|
||||||
fOwner->fLink->Attach<gradient_type>(gradient.Type());
|
|
||||||
fOwner->fLink->AttachGradient(gradient);
|
fOwner->fLink->AttachGradient(gradient);
|
||||||
|
|
||||||
_FlushIfNotInTransaction();
|
_FlushIfNotInTransaction();
|
||||||
@ -3080,7 +3074,6 @@ BView::FillRegion(BRegion *region, const BGradient& gradient)
|
|||||||
|
|
||||||
fOwner->fLink->StartMessage(AS_FILL_REGION_GRADIENT);
|
fOwner->fLink->StartMessage(AS_FILL_REGION_GRADIENT);
|
||||||
fOwner->fLink->AttachRegion(*region);
|
fOwner->fLink->AttachRegion(*region);
|
||||||
fOwner->fLink->Attach<gradient_type>(gradient.Type());
|
|
||||||
fOwner->fLink->AttachGradient(gradient);
|
fOwner->fLink->AttachGradient(gradient);
|
||||||
|
|
||||||
_FlushIfNotInTransaction();
|
_FlushIfNotInTransaction();
|
||||||
@ -3259,7 +3252,6 @@ BView::FillTriangle(BPoint pt1, BPoint pt2, BPoint pt3,
|
|||||||
fOwner->fLink->Attach<BPoint>(pt2);
|
fOwner->fLink->Attach<BPoint>(pt2);
|
||||||
fOwner->fLink->Attach<BPoint>(pt3);
|
fOwner->fLink->Attach<BPoint>(pt3);
|
||||||
fOwner->fLink->Attach<BRect>(bounds);
|
fOwner->fLink->Attach<BRect>(bounds);
|
||||||
fOwner->fLink->Attach<gradient_type>(gradient.Type());
|
|
||||||
fOwner->fLink->AttachGradient(gradient);
|
fOwner->fLink->AttachGradient(gradient);
|
||||||
|
|
||||||
_FlushIfNotInTransaction();
|
_FlushIfNotInTransaction();
|
||||||
@ -3359,7 +3351,6 @@ BView::FillShape(BShape *shape, const BGradient& gradient)
|
|||||||
fOwner->fLink->Attach<int32>(sd->ptCount);
|
fOwner->fLink->Attach<int32>(sd->ptCount);
|
||||||
fOwner->fLink->Attach(sd->opList, sd->opCount * sizeof(int32));
|
fOwner->fLink->Attach(sd->opList, sd->opCount * sizeof(int32));
|
||||||
fOwner->fLink->Attach(sd->ptList, sd->ptCount * sizeof(BPoint));
|
fOwner->fLink->Attach(sd->ptList, sd->ptCount * sizeof(BPoint));
|
||||||
fOwner->fLink->Attach<gradient_type>(gradient.Type());
|
|
||||||
fOwner->fLink->AttachGradient(gradient);
|
fOwner->fLink->AttachGradient(gradient);
|
||||||
|
|
||||||
_FlushIfNotInTransaction();
|
_FlushIfNotInTransaction();
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
* Stephan Aßmus <superstippi@gmx.de>
|
* Stephan Aßmus <superstippi@gmx.de>
|
||||||
* Stefano Ceccherini (burton666@libero.it)
|
* Stefano Ceccherini (burton666@libero.it)
|
||||||
* Axel Dörfler, axeld@pinc-software.de
|
* Axel Dörfler, axeld@pinc-software.de
|
||||||
|
* Artur Wyszynski <harakash@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -2139,15 +2140,12 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
|
|||||||
|
|
||||||
BRect rect;
|
BRect rect;
|
||||||
link.Read<BRect>(&rect);
|
link.Read<BRect>(&rect);
|
||||||
gradient_type gradientType;
|
BGradient* gradient;
|
||||||
link.Read<gradient_type>(&gradientType);
|
if (link.ReadGradient(&gradient) != B_OK)
|
||||||
BGradient* gradient = _GetNewGradientForType(gradientType);
|
break;
|
||||||
if (gradient) {
|
|
||||||
link.ReadGradient(gradient);
|
|
||||||
fCurrentView->ConvertToScreenForDrawing(&rect);
|
fCurrentView->ConvertToScreenForDrawing(&rect);
|
||||||
fCurrentView->ConvertToScreenForDrawing(gradient);
|
fCurrentView->ConvertToScreenForDrawing(gradient);
|
||||||
drawingEngine->FillRectGradient(rect, *gradient);
|
drawingEngine->FillRectGradient(rect, *gradient);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AS_VIEW_DRAW_BITMAP:
|
case AS_VIEW_DRAW_BITMAP:
|
||||||
@ -2198,15 +2196,12 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
|
|||||||
link.Read<BRect>(&r);
|
link.Read<BRect>(&r);
|
||||||
link.Read<float>(&angle);
|
link.Read<float>(&angle);
|
||||||
link.Read<float>(&span);
|
link.Read<float>(&span);
|
||||||
gradient_type gradientType;
|
BGradient* gradient;
|
||||||
link.Read<gradient_type>(&gradientType);
|
if (link.ReadGradient(&gradient) != B_OK)
|
||||||
BGradient* gradient = _GetNewGradientForType(gradientType);
|
break;
|
||||||
if (gradient) {
|
|
||||||
link.ReadGradient(gradient);
|
|
||||||
fCurrentView->ConvertToScreenForDrawing(&r);
|
fCurrentView->ConvertToScreenForDrawing(&r);
|
||||||
fCurrentView->ConvertToScreenForDrawing(gradient);
|
fCurrentView->ConvertToScreenForDrawing(gradient);
|
||||||
drawingEngine->FillArcGradient(r, angle, span, *gradient);
|
drawingEngine->FillArcGradient(r, angle, span, *gradient);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AS_STROKE_BEZIER:
|
case AS_STROKE_BEZIER:
|
||||||
@ -2232,14 +2227,11 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
|
|||||||
link.Read<BPoint>(&(pts[i]));
|
link.Read<BPoint>(&(pts[i]));
|
||||||
fCurrentView->ConvertToScreenForDrawing(&pts[i]);
|
fCurrentView->ConvertToScreenForDrawing(&pts[i]);
|
||||||
}
|
}
|
||||||
gradient_type gradientType;
|
BGradient* gradient;
|
||||||
link.Read<gradient_type>(&gradientType);
|
if (link.ReadGradient(&gradient) != B_OK)
|
||||||
BGradient* gradient = _GetNewGradientForType(gradientType);
|
break;
|
||||||
if (gradient) {
|
|
||||||
link.ReadGradient(gradient);
|
|
||||||
fCurrentView->ConvertToScreenForDrawing(gradient);
|
fCurrentView->ConvertToScreenForDrawing(gradient);
|
||||||
drawingEngine->FillBezierGradient(pts, *gradient);
|
drawingEngine->FillBezierGradient(pts, *gradient);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AS_STROKE_ELLIPSE:
|
case AS_STROKE_ELLIPSE:
|
||||||
@ -2260,15 +2252,12 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
|
|||||||
|
|
||||||
BRect rect;
|
BRect rect;
|
||||||
link.Read<BRect>(&rect);
|
link.Read<BRect>(&rect);
|
||||||
gradient_type gradientType;
|
BGradient* gradient;
|
||||||
link.Read<gradient_type>(&gradientType);
|
if (link.ReadGradient(&gradient) != B_OK)
|
||||||
BGradient* gradient = _GetNewGradientForType(gradientType);
|
break;
|
||||||
if (gradient) {
|
|
||||||
link.ReadGradient(gradient);
|
|
||||||
fCurrentView->ConvertToScreenForDrawing(&rect);
|
fCurrentView->ConvertToScreenForDrawing(&rect);
|
||||||
fCurrentView->ConvertToScreenForDrawing(gradient);
|
fCurrentView->ConvertToScreenForDrawing(gradient);
|
||||||
drawingEngine->FillEllipseGradient(rect, *gradient);
|
drawingEngine->FillEllipseGradient(rect, *gradient);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AS_STROKE_ROUNDRECT:
|
case AS_STROKE_ROUNDRECT:
|
||||||
@ -2295,15 +2284,12 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
|
|||||||
link.Read<BRect>(&rect);
|
link.Read<BRect>(&rect);
|
||||||
link.Read<float>(&xrad);
|
link.Read<float>(&xrad);
|
||||||
link.Read<float>(&yrad);
|
link.Read<float>(&yrad);
|
||||||
gradient_type gradientType;
|
BGradient* gradient;
|
||||||
link.Read<gradient_type>(&gradientType);
|
if (link.ReadGradient(&gradient) != B_OK)
|
||||||
BGradient* gradient = _GetNewGradientForType(gradientType);
|
break;
|
||||||
if (gradient) {
|
|
||||||
link.ReadGradient(gradient);
|
|
||||||
fCurrentView->ConvertToScreenForDrawing(&rect);
|
fCurrentView->ConvertToScreenForDrawing(&rect);
|
||||||
fCurrentView->ConvertToScreenForDrawing(gradient);
|
fCurrentView->ConvertToScreenForDrawing(gradient);
|
||||||
drawingEngine->FillRoundRectGradient(rect, xrad, yrad, *gradient);
|
drawingEngine->FillRoundRectGradient(rect, xrad, yrad, *gradient);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AS_STROKE_TRIANGLE:
|
case AS_STROKE_TRIANGLE:
|
||||||
@ -2336,15 +2322,12 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
|
|||||||
fCurrentView->ConvertToScreenForDrawing(&pts[i]);
|
fCurrentView->ConvertToScreenForDrawing(&pts[i]);
|
||||||
}
|
}
|
||||||
link.Read<BRect>(&rect);
|
link.Read<BRect>(&rect);
|
||||||
gradient_type gradientType;
|
BGradient* gradient;
|
||||||
link.Read<gradient_type>(&gradientType);
|
if (link.ReadGradient(&gradient) != B_OK)
|
||||||
BGradient* gradient = _GetNewGradientForType(gradientType);
|
break;
|
||||||
if (gradient) {
|
|
||||||
link.ReadGradient(gradient);
|
|
||||||
fCurrentView->ConvertToScreenForDrawing(&rect);
|
fCurrentView->ConvertToScreenForDrawing(&rect);
|
||||||
fCurrentView->ConvertToScreenForDrawing(gradient);
|
fCurrentView->ConvertToScreenForDrawing(gradient);
|
||||||
drawingEngine->FillTriangleGradient(pts, rect, *gradient);
|
drawingEngine->FillTriangleGradient(pts, rect, *gradient);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AS_STROKE_POLYGON:
|
case AS_STROKE_POLYGON:
|
||||||
@ -2385,11 +2368,9 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
|
|||||||
|
|
||||||
BPoint* pointList = new(nothrow) BPoint[pointCount];
|
BPoint* pointList = new(nothrow) BPoint[pointCount];
|
||||||
if (link.Read(pointList, pointCount * sizeof(BPoint)) >= B_OK) {
|
if (link.Read(pointList, pointCount * sizeof(BPoint)) >= B_OK) {
|
||||||
gradient_type gradientType;
|
BGradient* gradient;
|
||||||
link.Read<gradient_type>(&gradientType);
|
if (link.ReadGradient(&gradient) != B_OK)
|
||||||
BGradient* gradient = _GetNewGradientForType(gradientType);
|
break;
|
||||||
if (gradient) {
|
|
||||||
link.ReadGradient(gradient);
|
|
||||||
for (int32 i = 0; i < pointCount; i++)
|
for (int32 i = 0; i < pointCount; i++)
|
||||||
fCurrentView->ConvertToScreenForDrawing(&pointList[i]);
|
fCurrentView->ConvertToScreenForDrawing(&pointList[i]);
|
||||||
fCurrentView->ConvertToScreenForDrawing(&polyFrame);
|
fCurrentView->ConvertToScreenForDrawing(&polyFrame);
|
||||||
@ -2398,7 +2379,6 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
|
|||||||
drawingEngine->FillPolygonGradient(pointList, pointCount,
|
drawingEngine->FillPolygonGradient(pointList, pointCount,
|
||||||
polyFrame, *gradient, isClosed && pointCount > 2);
|
polyFrame, *gradient, isClosed && pointCount > 2);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
delete[] pointList;
|
delete[] pointList;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2460,16 +2440,13 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
|
|||||||
ptList[i] += penLocation;
|
ptList[i] += penLocation;
|
||||||
fCurrentView->ConvertToScreenForDrawing(&ptList[i]);
|
fCurrentView->ConvertToScreenForDrawing(&ptList[i]);
|
||||||
}
|
}
|
||||||
gradient_type gradientType;
|
BGradient* gradient;
|
||||||
link.Read<gradient_type>(&gradientType);
|
if (link.ReadGradient(&gradient) != B_OK)
|
||||||
BGradient* gradient = _GetNewGradientForType(gradientType);
|
break;
|
||||||
if (gradient) {
|
|
||||||
link.ReadGradient(gradient);
|
|
||||||
fCurrentView->ConvertToScreenForDrawing(gradient);
|
fCurrentView->ConvertToScreenForDrawing(gradient);
|
||||||
drawingEngine->FillShapeGradient(shapeFrame, opCount, opList,
|
drawingEngine->FillShapeGradient(shapeFrame, opCount, opList,
|
||||||
ptCount, ptList, *gradient);
|
ptCount, ptList, *gradient);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
delete[] opList;
|
delete[] opList;
|
||||||
delete[] ptList;
|
delete[] ptList;
|
||||||
@ -2495,15 +2472,12 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
|
|||||||
BRegion region;
|
BRegion region;
|
||||||
if (link.ReadRegion(®ion) < B_OK)
|
if (link.ReadRegion(®ion) < B_OK)
|
||||||
break;
|
break;
|
||||||
gradient_type gradientType;
|
BGradient* gradient;
|
||||||
link.Read<gradient_type>(&gradientType);
|
if (link.ReadGradient(&gradient) != B_OK)
|
||||||
BGradient* gradient = _GetNewGradientForType(gradientType);
|
break;
|
||||||
if (gradient) {
|
|
||||||
link.ReadGradient(gradient);
|
|
||||||
fCurrentView->ConvertToScreenForDrawing(®ion);
|
fCurrentView->ConvertToScreenForDrawing(®ion);
|
||||||
fCurrentView->ConvertToScreenForDrawing(gradient);
|
fCurrentView->ConvertToScreenForDrawing(gradient);
|
||||||
drawingEngine->FillRegionGradient(region, *gradient);
|
drawingEngine->FillRegionGradient(region, *gradient);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AS_STROKE_LINEARRAY:
|
case AS_STROKE_LINEARRAY:
|
||||||
@ -3491,30 +3465,3 @@ ServerWindow::PictureToRegion(ServerPicture *picture, BRegion ®ion,
|
|||||||
region.MakeEmpty();
|
region.MakeEmpty();
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BGradient*
|
|
||||||
ServerWindow::_GetNewGradientForType(gradient_type type)
|
|
||||||
{
|
|
||||||
switch (type) {
|
|
||||||
case B_GRADIENT_LINEAR: {
|
|
||||||
return new (std::nothrow) BGradientLinear();
|
|
||||||
}
|
|
||||||
case B_GRADIENT_RADIAL: {
|
|
||||||
return new (std::nothrow) BGradientRadial();
|
|
||||||
}
|
|
||||||
case B_GRADIENT_RADIAL_FOCUS: {
|
|
||||||
return new (std::nothrow) BGradientRadialFocus();
|
|
||||||
}
|
|
||||||
case B_GRADIENT_DIAMOND: {
|
|
||||||
return new (std::nothrow) BGradientDiamond();
|
|
||||||
}
|
|
||||||
case B_GRADIENT_CONIC: {
|
|
||||||
return new (std::nothrow) BGradientConic();
|
|
||||||
}
|
|
||||||
case B_GRADIENT_NONE: {
|
|
||||||
return new (std::nothrow) BGradient();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
@ -131,8 +131,6 @@ private:
|
|||||||
|
|
||||||
bool _MessageNeedsAllWindowsLocked(uint32 code) const;
|
bool _MessageNeedsAllWindowsLocked(uint32 code) const;
|
||||||
|
|
||||||
BGradient* _GetNewGradientForType(gradient_type type);
|
|
||||||
|
|
||||||
// TODO: Move me elsewhere
|
// TODO: Move me elsewhere
|
||||||
status_t PictureToRegion(ServerPicture *picture,
|
status_t PictureToRegion(ServerPicture *picture,
|
||||||
BRegion& region, bool inverse,
|
BRegion& region, bool inverse,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user