* Cleanup in the Gradient department. No fuctional change.
Renamed BGradient::color_step to BGradient::ColorStop as it's called everywhere else. Also renamed BGradient::gradient_type to just BGradient::Type. Renamed BGradient::Type() to GetType(). * Simplification of method names in Painter.cpp. Some not yet complete and yet inactive code to accelerate vertical gradients (bypassing AGG for this special case). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29214 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
c88313977f
commit
64eb49fd24
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2008, Haiku.
|
||||
* Copyright 2006-2009, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -21,7 +21,7 @@ class BRect;
|
||||
|
||||
class BGradient : public BArchivable {
|
||||
public:
|
||||
enum gradient_type {
|
||||
enum Type {
|
||||
TYPE_LINEAR = 0,
|
||||
TYPE_RADIAL,
|
||||
TYPE_RADIAL_FOCUS,
|
||||
@ -30,13 +30,13 @@ public:
|
||||
TYPE_NONE
|
||||
};
|
||||
|
||||
struct color_step {
|
||||
color_step(const rgb_color c, float o);
|
||||
color_step(uint8 r, uint8 g, uint8 b, uint8 a, float o);
|
||||
color_step(const color_step& other);
|
||||
color_step();
|
||||
struct ColorStop {
|
||||
ColorStop(const rgb_color c, float o);
|
||||
ColorStop(uint8 r, uint8 g, uint8 b, uint8 a, float o);
|
||||
ColorStop(const ColorStop& other);
|
||||
ColorStop();
|
||||
|
||||
bool operator!=(const color_step& other) const;
|
||||
bool operator!=(const ColorStop& other) const;
|
||||
|
||||
rgb_color color;
|
||||
float offset;
|
||||
@ -53,26 +53,26 @@ public:
|
||||
|
||||
bool operator==(const BGradient& other) const;
|
||||
bool operator!=(const BGradient& other) const;
|
||||
bool ColorStepsAreEqual(const BGradient& other) const;
|
||||
bool ColorStopsAreEqual(const BGradient& other) const;
|
||||
|
||||
void SetColors(const BGradient& other);
|
||||
void SetColorStops(const BGradient& other);
|
||||
|
||||
int32 AddColor(const rgb_color& color, float offset);
|
||||
bool AddColor(const color_step& color, int32 index);
|
||||
bool AddColorStop(const ColorStop& colorStop, int32 index);
|
||||
|
||||
bool RemoveColor(int32 index);
|
||||
|
||||
bool SetColor(int32 index, const color_step& step);
|
||||
bool SetColorStop(int32 index, const ColorStop& colorStop);
|
||||
bool SetColor(int32 index, const rgb_color& color);
|
||||
bool SetOffset(int32 index, float offset);
|
||||
|
||||
int32 CountColors() const;
|
||||
color_step* ColorAt(int32 index) const;
|
||||
color_step* ColorAtFast(int32 index) const;
|
||||
color_step* Colors() const;
|
||||
void SortColorStepsByOffset();
|
||||
int32 CountColorStops() const;
|
||||
ColorStop* ColorStopAt(int32 index) const;
|
||||
ColorStop* ColorStopAtFast(int32 index) const;
|
||||
ColorStop* ColorStops() const;
|
||||
void SortColorStopsByOffset();
|
||||
|
||||
gradient_type Type() const
|
||||
Type GetType() const
|
||||
{ return fType; }
|
||||
|
||||
void MakeEmpty();
|
||||
@ -102,8 +102,8 @@ private:
|
||||
} conic;
|
||||
} fData;
|
||||
|
||||
BList fColors;
|
||||
gradient_type fType;
|
||||
BList fColorStops;
|
||||
Type fType;
|
||||
};
|
||||
|
||||
#endif // _GRADIENT_H
|
||||
|
@ -36,17 +36,17 @@ class GradientsView : public BView {
|
||||
public:
|
||||
GradientsView(const BRect &r);
|
||||
virtual ~GradientsView(void);
|
||||
|
||||
|
||||
virtual void Draw(BRect update);
|
||||
void DrawLinear(BRect update);
|
||||
void DrawRadial(BRect update);
|
||||
void DrawRadialFocus(BRect update);
|
||||
void DrawDiamond(BRect update);
|
||||
void DrawConic(BRect update);
|
||||
void SetType(BGradient::gradient_type type);
|
||||
|
||||
void SetType(BGradient::Type type);
|
||||
|
||||
private:
|
||||
BGradient::gradient_type fType;
|
||||
BGradient::Type fType;
|
||||
};
|
||||
|
||||
|
||||
@ -110,7 +110,7 @@ GradientsWindow::GradientsWindow()
|
||||
fGradientsTypeField->SetViewColor(255, 255, 255);
|
||||
fGradientsTypeField->SetDivider(110);
|
||||
AddChild(fGradientsTypeField);
|
||||
|
||||
|
||||
BRect bounds = Bounds();
|
||||
bounds.top = 40;
|
||||
fGradientsView = new GradientsView(bounds);
|
||||
@ -218,7 +218,7 @@ GradientsView::DrawLinear(BRect update)
|
||||
c.green = 0;
|
||||
c.blue = 255;
|
||||
gradient.AddColor(c, 255);
|
||||
|
||||
|
||||
// RoundRect
|
||||
SetHighColor(0, 0, 0);
|
||||
FillRoundRect(BRect(10, 10, 110, 110), 5, 5);
|
||||
@ -232,7 +232,7 @@ GradientsView::DrawLinear(BRect update)
|
||||
gradient.SetStart(BPoint(120, 120));
|
||||
gradient.SetEnd(BPoint(220, 220));
|
||||
FillRect(BRect(120, 120, 220, 220), gradient);
|
||||
|
||||
|
||||
// Triangle
|
||||
SetHighColor(0, 0, 0);
|
||||
FillTriangle(BPoint(60, 230), BPoint(10, 330), BPoint(110, 330));
|
||||
@ -266,25 +266,25 @@ GradientsView::DrawRadial(BRect update)
|
||||
c.green = 0;
|
||||
c.blue = 255;
|
||||
gradient.AddColor(c, 255);
|
||||
|
||||
|
||||
// RoundRect
|
||||
SetHighColor(0, 0, 0);
|
||||
FillRoundRect(BRect(10, 10, 110, 110), 5, 5);
|
||||
gradient.SetCenter(BPoint(170, 60));
|
||||
FillRoundRect(BRect(120, 10, 220, 110), 5, 5, gradient);
|
||||
|
||||
|
||||
// Rect
|
||||
SetHighColor(0, 0, 0);
|
||||
FillRect(BRect(10, 120, 110, 220));
|
||||
gradient.SetCenter(BPoint(170, 170));
|
||||
FillRect(BRect(120, 120, 220, 220), gradient);
|
||||
|
||||
|
||||
// Triangle
|
||||
SetHighColor(0, 0, 0);
|
||||
FillTriangle(BPoint(60, 230), BPoint(10, 330), BPoint(110, 330));
|
||||
gradient.SetCenter(BPoint(170, 280));
|
||||
FillTriangle(BPoint(170, 230), BPoint(120, 330), BPoint(220, 330), gradient);
|
||||
|
||||
|
||||
// Ellipse
|
||||
SetHighColor(0, 0, 0);
|
||||
FillEllipse(BPoint(60, 390), 50, 50);
|
||||
@ -310,25 +310,25 @@ GradientsView::DrawRadialFocus(BRect update)
|
||||
c.green = 0;
|
||||
c.blue = 255;
|
||||
gradient.AddColor(c, 255);
|
||||
|
||||
|
||||
// RoundRect
|
||||
SetHighColor(0, 0, 0);
|
||||
FillRoundRect(BRect(10, 10, 110, 110), 5, 5);
|
||||
gradient.SetCenter(BPoint(170, 60));
|
||||
FillRoundRect(BRect(120, 10, 220, 110), 5, 5, gradient);
|
||||
|
||||
|
||||
// Rect
|
||||
SetHighColor(0, 0, 0);
|
||||
FillRect(BRect(10, 120, 110, 220));
|
||||
gradient.SetCenter(BPoint(170, 170));
|
||||
FillRect(BRect(120, 120, 220, 220), gradient);
|
||||
|
||||
|
||||
// Triangle
|
||||
SetHighColor(0, 0, 0);
|
||||
FillTriangle(BPoint(60, 230), BPoint(10, 330), BPoint(110, 330));
|
||||
gradient.SetCenter(BPoint(170, 280));
|
||||
FillTriangle(BPoint(170, 230), BPoint(120, 330), BPoint(220, 330), gradient);
|
||||
|
||||
|
||||
// Ellipse
|
||||
SetHighColor(0, 0, 0);
|
||||
FillEllipse(BPoint(60, 390), 50, 50);
|
||||
@ -354,25 +354,25 @@ GradientsView::DrawDiamond(BRect update)
|
||||
c.green = 0;
|
||||
c.blue = 255;
|
||||
gradient.AddColor(c, 255);
|
||||
|
||||
|
||||
// RoundRect
|
||||
SetHighColor(0, 0, 0);
|
||||
FillRoundRect(BRect(10, 10, 110, 110), 5, 5);
|
||||
gradient.SetCenter(BPoint(170, 60));
|
||||
FillRoundRect(BRect(120, 10, 220, 110), 5, 5, gradient);
|
||||
|
||||
|
||||
// Rect
|
||||
SetHighColor(0, 0, 0);
|
||||
FillRect(BRect(10, 120, 110, 220));
|
||||
gradient.SetCenter(BPoint(170, 170));
|
||||
FillRect(BRect(120, 120, 220, 220), gradient);
|
||||
|
||||
|
||||
// Triangle
|
||||
SetHighColor(0, 0, 0);
|
||||
FillTriangle(BPoint(60, 230), BPoint(10, 330), BPoint(110, 330));
|
||||
gradient.SetCenter(BPoint(170, 280));
|
||||
FillTriangle(BPoint(170, 230), BPoint(120, 330), BPoint(220, 330), gradient);
|
||||
|
||||
|
||||
// Ellipse
|
||||
SetHighColor(0, 0, 0);
|
||||
FillEllipse(BPoint(60, 390), 50, 50);
|
||||
@ -398,25 +398,25 @@ GradientsView::DrawConic(BRect update)
|
||||
c.green = 0;
|
||||
c.blue = 255;
|
||||
gradient.AddColor(c, 255);
|
||||
|
||||
|
||||
// RoundRect
|
||||
SetHighColor(0, 0, 0);
|
||||
FillRoundRect(BRect(10, 10, 110, 110), 5, 5);
|
||||
gradient.SetCenter(BPoint(170, 60));
|
||||
FillRoundRect(BRect(120, 10, 220, 110), 5, 5, gradient);
|
||||
|
||||
|
||||
// Rect
|
||||
SetHighColor(0, 0, 0);
|
||||
FillRect(BRect(10, 120, 110, 220));
|
||||
gradient.SetCenter(BPoint(170, 170));
|
||||
FillRect(BRect(120, 120, 220, 220), gradient);
|
||||
|
||||
|
||||
// Triangle
|
||||
SetHighColor(0, 0, 0);
|
||||
FillTriangle(BPoint(60, 230), BPoint(10, 330), BPoint(110, 330));
|
||||
gradient.SetCenter(BPoint(170, 280));
|
||||
FillTriangle(BPoint(170, 230), BPoint(120, 330), BPoint(220, 330), gradient);
|
||||
|
||||
|
||||
// Ellipse
|
||||
SetHighColor(0, 0, 0);
|
||||
FillEllipse(BPoint(60, 390), 50, 50);
|
||||
@ -426,7 +426,7 @@ GradientsView::DrawConic(BRect update)
|
||||
|
||||
|
||||
void
|
||||
GradientsView::SetType(BGradient::gradient_type type)
|
||||
GradientsView::SetType(BGradient::Type type)
|
||||
{
|
||||
fType = type;
|
||||
Invalidate();
|
||||
|
@ -164,7 +164,7 @@ GradientControl::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMe
|
||||
float offset = _OffsetFor(where);
|
||||
|
||||
if (fDraggingStepIndex >= 0) {
|
||||
BGradient::color_step* step = fGradient->ColorAt(fDraggingStepIndex);
|
||||
BGradient::ColorStop* step = fGradient->ColorAt(fDraggingStepIndex);
|
||||
if (step) {
|
||||
if (fGradient->SetOffset(fDraggingStepIndex, offset)) {
|
||||
_UpdateColors();
|
||||
@ -201,7 +201,7 @@ GradientControl::MessageReceived(BMessage* message)
|
||||
if (restore_color_from_message(message, color, 0) >= B_OK) {
|
||||
bool update = false;
|
||||
if (fDropIndex >= 0) {
|
||||
if (BGradient::color_step* step
|
||||
if (BGradient::ColorStop* step
|
||||
= fGradient->ColorAt(fDropIndex)) {
|
||||
color.alpha = step->color.alpha;
|
||||
}
|
||||
@ -250,12 +250,12 @@ GradientControl::KeyDown(const char* bytes, int32 numBytes)
|
||||
_UpdateCurrentColor();
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case B_HOME:
|
||||
case B_END:
|
||||
case B_LEFT_ARROW:
|
||||
case B_RIGHT_ARROW: {
|
||||
if (BGradient::color_step* step
|
||||
if (BGradient::ColorStop* step
|
||||
= fGradient->ColorAt(fCurrentStepIndex)) {
|
||||
BRect r = _GradientBitmapRect();
|
||||
float x = r.left + r.Width() * step->offset;
|
||||
@ -282,7 +282,7 @@ GradientControl::KeyDown(const char* bytes, int32 numBytes)
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case B_UP_ARROW:
|
||||
// previous step
|
||||
fCurrentStepIndex--;
|
||||
@ -299,7 +299,7 @@ GradientControl::KeyDown(const char* bytes, int32 numBytes)
|
||||
}
|
||||
_UpdateCurrentColor();
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
handled = false;
|
||||
break;
|
||||
@ -381,7 +381,7 @@ GradientControl::Draw(BRect updateRect)
|
||||
markerPos.y = b.bottom + 4.0;
|
||||
BPoint leftBottom(-6.0, 6.0);
|
||||
BPoint rightBottom(6.0, 6.0);
|
||||
for (int32 i = 0; BGradient::color_step* step = fGradient->ColorAt(i);
|
||||
for (int32 i = 0; BGradient::ColorStop* step = fGradient->ColorAt(i);
|
||||
i++) {
|
||||
markerPos.x = b.left + (b.Width() * step->offset);
|
||||
|
||||
@ -426,7 +426,7 @@ GradientControl::FrameResized(float width, float height)
|
||||
_AllocBitmap(r.IntegerWidth() + 1, r.IntegerHeight() + 1);
|
||||
_UpdateColors();
|
||||
Invalidate();
|
||||
|
||||
|
||||
}
|
||||
|
||||
// SetGradient
|
||||
@ -463,7 +463,7 @@ GradientControl::SetCurrentStop(const rgb_color& color)
|
||||
bool
|
||||
GradientControl::GetCurrentStop(rgb_color* color) const
|
||||
{
|
||||
BGradient::color_step* stop
|
||||
BGradient::ColorStop* stop
|
||||
= fGradient->ColorAt(fCurrentStepIndex);
|
||||
if (stop && color) {
|
||||
*color = stop->color;
|
||||
@ -617,7 +617,7 @@ GradientControl::_StepIndexFor(BPoint where) const
|
||||
int32 index = -1;
|
||||
BRect r = _GradientBitmapRect();
|
||||
BRect markerFrame(Bounds());
|
||||
for (int32 i = 0; BGradient::color_step* step
|
||||
for (int32 i = 0; BGradient::ColorStop* step
|
||||
= fGradient->ColorAt(i); i++) {
|
||||
markerFrame.left = markerFrame.right = r.left
|
||||
+ (r.Width() * step->offset);
|
||||
@ -648,7 +648,7 @@ GradientControl::_UpdateCurrentColor() const
|
||||
if (!fMessage || !fTarget || !fTarget->Looper())
|
||||
return;
|
||||
// set the CanvasView current color
|
||||
if (BGradient::color_step* step = fGradient->ColorAt(fCurrentStepIndex)) {
|
||||
if (BGradient::ColorStop* step = fGradient->ColorAt(fCurrentStepIndex)) {
|
||||
BMessage message(*fMessage);
|
||||
store_color_in_message(&message, step->color);
|
||||
fTarget->Looper()->PostMessage(&message, fTarget);
|
||||
|
@ -241,7 +241,7 @@ FlatIconExporter::_WriteStyles(LittleEndianBuffer& buffer,
|
||||
styleType = STYLE_TYPE_SOLID_COLOR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!buffer.Write(styleType))
|
||||
return B_NO_MEMORY;
|
||||
|
||||
@ -527,7 +527,7 @@ _WritePathSourceShape(LittleEndianBuffer& buffer, Shape* shape,
|
||||
shapeFlags |= SHAPE_FLAG_LOD_SCALE;
|
||||
if (transformerCount > 0)
|
||||
shapeFlags |= SHAPE_FLAG_HAS_TRANSFORMERS;
|
||||
|
||||
|
||||
if (!buffer.Write((uint8)shapeFlags))
|
||||
return false;
|
||||
|
||||
@ -555,7 +555,7 @@ _WritePathSourceShape(LittleEndianBuffer& buffer, Shape* shape,
|
||||
// transformers
|
||||
if (!buffer.Write(transformerCount))
|
||||
return false;
|
||||
|
||||
|
||||
for (uint32 i = 0; i < transformerCount; i++) {
|
||||
Transformer* transformer = shape->TransformerAtFast(i);
|
||||
if (!_WriteTransformer(buffer, transformer))
|
||||
@ -606,7 +606,7 @@ FlatIconExporter::_WriteGradient(LittleEndianBuffer& buffer,
|
||||
bool alpha = false;
|
||||
bool gray = true;
|
||||
for (int32 i = 0; i < gradientStopCount; i++) {
|
||||
BGradient::color_step* step = gradient->ColorAtFast(i);
|
||||
BGradient::ColorStop* step = gradient->ColorAtFast(i);
|
||||
if (step->color.alpha < 255)
|
||||
alpha = true;
|
||||
if (step->color.red != step->color.green
|
||||
@ -632,7 +632,7 @@ FlatIconExporter::_WriteGradient(LittleEndianBuffer& buffer,
|
||||
}
|
||||
|
||||
for (int32 i = 0; i < gradientStopCount; i++) {
|
||||
BGradient::color_step* step = gradient->ColorAtFast(i);
|
||||
BGradient::ColorStop* step = gradient->ColorAtFast(i);
|
||||
uint8 stopOffset = (uint8)(step->offset * 255.0);
|
||||
uint32 color = (uint32&)step->color;
|
||||
if (!buffer.Write(stopOffset))
|
||||
|
@ -10,8 +10,8 @@
|
||||
// Anti-Grain Geometry - Version 2.2
|
||||
// Copyright (C) 2002-2004 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
@ -157,7 +157,7 @@ DocumentBuilder::curve3(double x, double y, bool rel) // T, t
|
||||
// curve4
|
||||
void
|
||||
DocumentBuilder::curve4(double x1, double y1, // C, c
|
||||
double x2, double y2,
|
||||
double x2, double y2,
|
||||
double x, double y, bool rel)
|
||||
{
|
||||
if (rel) {
|
||||
@ -392,7 +392,7 @@ DocumentBuilder::parse_path(PathTokenizer& tok)
|
||||
case 'H': case 'h':
|
||||
hline_to(tok.last_number(), cmd == 'h');
|
||||
break;
|
||||
|
||||
|
||||
case 'Q': case 'q':
|
||||
arg[0] = tok.last_number();
|
||||
for(i = 1; i < 4; i++) {
|
||||
@ -697,12 +697,12 @@ AddPathsFromVertexSource(Icon* icon, Shape* shape,
|
||||
int32 start = path->CountPoints() - 1;
|
||||
BPoint from;
|
||||
path->GetPointAt(start, from);
|
||||
|
||||
|
||||
double cx2 = (1.0/3.0) * from.x + (2.0/3.0) * x1;
|
||||
double cy2 = (1.0/3.0) * from.y + (2.0/3.0) * y1;
|
||||
double cx3 = (2.0/3.0) * x1 + (1.0/3.0) * x2;
|
||||
double cy3 = (2.0/3.0) * y1 + (1.0/3.0) * y2;
|
||||
|
||||
|
||||
path->SetPointOut(start, BPoint(cx2, cy2));
|
||||
|
||||
if (!path->AddPoint(BPoint(x2, y2)))
|
||||
@ -778,7 +778,7 @@ DocumentBuilder::_AddShape(path_attributes& attributes, bool outline,
|
||||
stroke->line_cap(attributes.line_cap);
|
||||
stroke->line_join(attributes.line_join);
|
||||
}
|
||||
|
||||
|
||||
if (!shape->AddTransformer(stroke)) {
|
||||
delete stroke;
|
||||
stroke = NULL;
|
||||
@ -802,8 +802,8 @@ DocumentBuilder::_AddShape(path_attributes& attributes, bool outline,
|
||||
ObjectDeleter<Gradient> gradientDeleter(gradient);
|
||||
|
||||
rgb_color color;
|
||||
|
||||
BGradient::color_step* step;
|
||||
|
||||
BGradient::ColorStop* step;
|
||||
if (gradient && (step = gradient->ColorAt(0))) {
|
||||
color.red = step->color.red;
|
||||
color.green = step->color.green;
|
||||
|
@ -295,7 +295,7 @@ SVGExporter::_ExportShape(const Shape* shape, BPositionIO* stream)
|
||||
|
||||
int32 pointCount = path->CountPoints();
|
||||
for (int32 j = 0; j < pointCount; j++) {
|
||||
|
||||
|
||||
if (!path->GetPointsAt(j, a, aIn, aOut))
|
||||
break;
|
||||
|
||||
@ -412,7 +412,7 @@ SVGExporter::_ExportGradient(const Gradient* gradient, BPositionIO* stream)
|
||||
|
||||
// write stop tags
|
||||
char color[16];
|
||||
for (int32 i = 0; BGradient::color_step* stop = gradient->ColorAt(i); i++) {
|
||||
for (int32 i = 0; BGradient::ColorStop* stop = gradient->ColorAt(i); i++) {
|
||||
|
||||
sprintf(color, "%.2x%.2x%.2x", stop->color.red,
|
||||
stop->color.green,
|
||||
|
@ -471,7 +471,7 @@ LinkReceiver::ReadRegion(BRegion* region)
|
||||
|
||||
|
||||
static BGradient*
|
||||
gradient_for_type(BGradient::gradient_type type)
|
||||
gradient_for_type(BGradient::Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case BGradient::TYPE_LINEAR:
|
||||
@ -495,10 +495,10 @@ status_t
|
||||
LinkReceiver::ReadGradient(BGradient** _gradient)
|
||||
{
|
||||
GTRACE(("LinkReceiver::ReadGradient\n"));
|
||||
BGradient::gradient_type gradientType;
|
||||
BGradient::Type gradientType;
|
||||
int32 colorsCount;
|
||||
status_t ret;
|
||||
if ((ret = Read(&gradientType, sizeof(BGradient::gradient_type))) != B_OK)
|
||||
if ((ret = Read(&gradientType, sizeof(BGradient::Type))) != B_OK)
|
||||
return ret;
|
||||
if ((ret = Read(&colorsCount, sizeof(int32))) != B_OK)
|
||||
return ret;
|
||||
@ -509,11 +509,11 @@ LinkReceiver::ReadGradient(BGradient** _gradient)
|
||||
*_gradient = gradient;
|
||||
|
||||
if (colorsCount > 0) {
|
||||
BGradient::color_step step;
|
||||
BGradient::ColorStop stop;
|
||||
for (int i = 0; i < colorsCount; i++) {
|
||||
if ((ret = Read(&step, sizeof(BGradient::color_step))) != B_OK)
|
||||
if ((ret = Read(&stop, sizeof(BGradient::ColorStop))) != B_OK)
|
||||
return ret;
|
||||
if (!gradient->AddColor(step, i))
|
||||
if (!gradient->AddColorStop(stop, i))
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
}
|
||||
|
@ -126,15 +126,16 @@ status_t
|
||||
ServerLink::AttachGradient(const BGradient &gradient)
|
||||
{
|
||||
GTRACE(("ServerLink::AttachGradient\n"));
|
||||
BGradient::gradient_type gradientType = gradient.Type();
|
||||
int32 colorsCount = gradient.CountColors();
|
||||
GTRACE(("ServerLink::AttachGradient> colors count == %d\n", (int)colorsCount));
|
||||
fSender->Attach(&gradientType, sizeof(BGradient::gradient_type));
|
||||
fSender->Attach(&colorsCount, sizeof(int32));
|
||||
if (colorsCount > 0) {
|
||||
for (int i = 0; i < colorsCount; i++) {
|
||||
fSender->Attach(gradient.ColorAtFast(i),
|
||||
sizeof(BGradient::color_step));
|
||||
BGradient::Type gradientType = gradient.GetType();
|
||||
int32 stopCount = gradient.CountColorStops();
|
||||
GTRACE(("ServerLink::AttachGradient> color stop count == %d\n",
|
||||
(int)stopCount));
|
||||
fSender->Attach(&gradientType, sizeof(BGradient::Type));
|
||||
fSender->Attach(&stopCount, sizeof(int32));
|
||||
if (stopCount > 0) {
|
||||
for (int i = 0; i < stopCount; i++) {
|
||||
fSender->Attach(gradient.ColorStopAtFast(i),
|
||||
sizeof(BGradient::ColorStop));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2008, Haiku.
|
||||
* Copyright 2006-2009, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
|
||||
// constructor
|
||||
BGradient::color_step::color_step(const rgb_color c, float o)
|
||||
BGradient::ColorStop::ColorStop(const rgb_color c, float o)
|
||||
{
|
||||
color.red = c.red;
|
||||
color.green = c.green;
|
||||
@ -27,7 +27,7 @@ BGradient::color_step::color_step(const rgb_color c, float o)
|
||||
|
||||
|
||||
// constructor
|
||||
BGradient::color_step::color_step(uint8 r, uint8 g, uint8 b, uint8 a, float o)
|
||||
BGradient::ColorStop::ColorStop(uint8 r, uint8 g, uint8 b, uint8 a, float o)
|
||||
{
|
||||
color.red = r;
|
||||
color.green = g;
|
||||
@ -38,7 +38,7 @@ BGradient::color_step::color_step(uint8 r, uint8 g, uint8 b, uint8 a, float o)
|
||||
|
||||
|
||||
// constructor
|
||||
BGradient::color_step::color_step(const color_step& other)
|
||||
BGradient::ColorStop::ColorStop(const ColorStop& other)
|
||||
{
|
||||
color.red = other.color.red;
|
||||
color.green = other.color.green;
|
||||
@ -49,7 +49,7 @@ BGradient::color_step::color_step(const color_step& other)
|
||||
|
||||
|
||||
// constructor
|
||||
BGradient::color_step::color_step()
|
||||
BGradient::ColorStop::ColorStop()
|
||||
{
|
||||
color.red = 0;
|
||||
color.green = 0;
|
||||
@ -61,7 +61,7 @@ BGradient::color_step::color_step()
|
||||
|
||||
// operator!=
|
||||
bool
|
||||
BGradient::color_step::operator!=(const color_step& other) const
|
||||
BGradient::ColorStop::operator!=(const ColorStop& other) const
|
||||
{
|
||||
return color.red != other.color.red ||
|
||||
color.green != other.color.green ||
|
||||
@ -72,10 +72,10 @@ BGradient::color_step::operator!=(const color_step& other) const
|
||||
|
||||
|
||||
static int
|
||||
sort_color_steps_by_offset(const void* _left, const void* _right)
|
||||
sort_color_stops_by_offset(const void* _left, const void* _right)
|
||||
{
|
||||
const BGradient::color_step** left = (const BGradient::color_step**)_left;
|
||||
const BGradient::color_step** right = (const BGradient::color_step**)_right;
|
||||
const BGradient::ColorStop** left = (const BGradient::ColorStop**)_left;
|
||||
const BGradient::ColorStop** right = (const BGradient::ColorStop**)_right;
|
||||
if ((*left)->offset > (*right)->offset)
|
||||
return 1;
|
||||
else if ((*left)->offset < (*right)->offset)
|
||||
@ -90,7 +90,7 @@ sort_color_steps_by_offset(const void* _left, const void* _right)
|
||||
// constructor
|
||||
BGradient::BGradient()
|
||||
: BArchivable(),
|
||||
fColors(4),
|
||||
fColorStops(4),
|
||||
fType(TYPE_NONE)
|
||||
{
|
||||
}
|
||||
@ -99,17 +99,17 @@ BGradient::BGradient()
|
||||
// constructor
|
||||
BGradient::BGradient(BMessage* archive)
|
||||
: BArchivable(archive),
|
||||
fColors(4),
|
||||
fColorStops(4),
|
||||
fType(TYPE_NONE)
|
||||
{
|
||||
if (!archive)
|
||||
return;
|
||||
|
||||
// color steps
|
||||
color_step step;
|
||||
for (int32 i = 0; archive->FindFloat("offset", i, &step.offset) >= B_OK; i++) {
|
||||
if (archive->FindInt32("color", i, (int32*)&step.color) >= B_OK)
|
||||
AddColor(step, i);
|
||||
// color stops
|
||||
ColorStop stop;
|
||||
for (int32 i = 0; archive->FindFloat("offset", i, &stop.offset) >= B_OK; i++) {
|
||||
if (archive->FindInt32("color", i, (int32*)&stop.color) >= B_OK)
|
||||
AddColorStop(stop, i);
|
||||
else
|
||||
break;
|
||||
}
|
||||
@ -177,11 +177,11 @@ BGradient::Archive(BMessage* into, bool deep) const
|
||||
|
||||
// color steps
|
||||
if (ret >= B_OK) {
|
||||
for (int32 i = 0; color_step* step = ColorAt(i); i++) {
|
||||
ret = into->AddInt32("color", (const uint32&)step->color);
|
||||
for (int32 i = 0; ColorStop* stop = ColorStopAt(i); i++) {
|
||||
ret = into->AddInt32("color", (const uint32&)stop->color);
|
||||
if (ret < B_OK)
|
||||
break;
|
||||
ret = into->AddFloat("offset", step->offset);
|
||||
ret = into->AddFloat("offset", stop->offset);
|
||||
if (ret < B_OK)
|
||||
break;
|
||||
}
|
||||
@ -246,7 +246,7 @@ BGradient::Archive(BMessage* into, bool deep) const
|
||||
BGradient&
|
||||
BGradient::operator=(const BGradient& other)
|
||||
{
|
||||
SetColors(other);
|
||||
SetColorStops(other);
|
||||
fType = other.fType;
|
||||
return *this;
|
||||
}
|
||||
@ -256,7 +256,7 @@ BGradient::operator=(const BGradient& other)
|
||||
bool
|
||||
BGradient::operator==(const BGradient& other) const
|
||||
{
|
||||
return ((other.Type() == Type()) && ColorStepsAreEqual(other));
|
||||
return ((other.GetType() == GetType()) && ColorStopsAreEqual(other));
|
||||
}
|
||||
|
||||
|
||||
@ -268,19 +268,19 @@ BGradient::operator!=(const BGradient& other) const
|
||||
}
|
||||
|
||||
|
||||
// ColorStepsAreEqual
|
||||
// ColorStopsAreEqual
|
||||
bool
|
||||
BGradient::ColorStepsAreEqual(const BGradient& other) const
|
||||
BGradient::ColorStopsAreEqual(const BGradient& other) const
|
||||
{
|
||||
int32 count = CountColors();
|
||||
if (count == other.CountColors() &&
|
||||
int32 count = CountColorStops();
|
||||
if (count == other.CountColorStops() &&
|
||||
fType == other.fType) {
|
||||
|
||||
bool equal = true;
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
color_step* ourStep = ColorAtFast(i);
|
||||
color_step* otherStep = other.ColorAtFast(i);
|
||||
if (*ourStep != *otherStep) {
|
||||
ColorStop* ourStop = ColorStopAtFast(i);
|
||||
ColorStop* otherStop = other.ColorStopAtFast(i);
|
||||
if (*ourStop != *otherStop) {
|
||||
equal = false;
|
||||
break;
|
||||
}
|
||||
@ -291,13 +291,13 @@ BGradient::ColorStepsAreEqual(const BGradient& other) const
|
||||
}
|
||||
|
||||
|
||||
// SetColors
|
||||
// SetColorStops
|
||||
void
|
||||
BGradient::SetColors(const BGradient& other)
|
||||
BGradient::SetColorStops(const BGradient& other)
|
||||
{
|
||||
MakeEmpty();
|
||||
for (int32 i = 0; color_step* step = other.ColorAt(i); i++)
|
||||
AddColor(*step, i);
|
||||
for (int32 i = 0; ColorStop* stop = other.ColorStopAt(i); i++)
|
||||
AddColorStop(*stop, i);
|
||||
}
|
||||
|
||||
|
||||
@ -306,29 +306,29 @@ int32
|
||||
BGradient::AddColor(const rgb_color& color, float offset)
|
||||
{
|
||||
// find the correct index (sorted by offset)
|
||||
color_step* step = new color_step(color, offset);
|
||||
ColorStop* stop = new ColorStop(color, offset);
|
||||
int32 index = 0;
|
||||
int32 count = CountColors();
|
||||
int32 count = CountColorStops();
|
||||
for (; index < count; index++) {
|
||||
color_step* s = ColorAtFast(index);
|
||||
if (s->offset > step->offset)
|
||||
ColorStop* s = ColorStopAtFast(index);
|
||||
if (s->offset > stop->offset)
|
||||
break;
|
||||
}
|
||||
if (!fColors.AddItem((void*)step, index)) {
|
||||
delete step;
|
||||
if (!fColorStops.AddItem((void*)stop, index)) {
|
||||
delete stop;
|
||||
return -1;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
// AddColor
|
||||
// AddColorStop
|
||||
bool
|
||||
BGradient::AddColor(const color_step& color, int32 index)
|
||||
BGradient::AddColorStop(const ColorStop& colorStop, int32 index)
|
||||
{
|
||||
color_step* step = new color_step(color);
|
||||
if (!fColors.AddItem((void*)step, index)) {
|
||||
delete step;
|
||||
ColorStop* stop = new ColorStop(colorStop);
|
||||
if (!fColorStops.AddItem((void*)stop, index)) {
|
||||
delete stop;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -339,23 +339,23 @@ BGradient::AddColor(const color_step& color, int32 index)
|
||||
bool
|
||||
BGradient::RemoveColor(int32 index)
|
||||
{
|
||||
color_step* step = (color_step*)fColors.RemoveItem(index);
|
||||
if (!step) {
|
||||
ColorStop* stop = (ColorStop*)fColorStops.RemoveItem(index);
|
||||
if (!stop) {
|
||||
return false;
|
||||
}
|
||||
delete step;
|
||||
delete stop;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// SetColor
|
||||
// SetColorStop
|
||||
bool
|
||||
BGradient::SetColor(int32 index, const color_step& color)
|
||||
BGradient::SetColorStop(int32 index, const ColorStop& color)
|
||||
{
|
||||
if (color_step* step = ColorAt(index)) {
|
||||
if (*step != color) {
|
||||
step->color = color.color;
|
||||
step->offset = color.offset;
|
||||
if (ColorStop* stop = ColorStopAt(index)) {
|
||||
if (*stop != color) {
|
||||
stop->color = color.color;
|
||||
stop->offset = color.offset;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -367,11 +367,10 @@ BGradient::SetColor(int32 index, const color_step& color)
|
||||
bool
|
||||
BGradient::SetColor(int32 index, const rgb_color& color)
|
||||
{
|
||||
if (color_step* step = ColorAt(index)) {
|
||||
if ((uint32&)step->color != (uint32&)color) {
|
||||
step->color = color;
|
||||
return true;
|
||||
}
|
||||
ColorStop* stop = ColorStopAt(index);
|
||||
if (stop && stop->color != color) {
|
||||
stop->color = color;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -381,55 +380,55 @@ BGradient::SetColor(int32 index, const rgb_color& color)
|
||||
bool
|
||||
BGradient::SetOffset(int32 index, float offset)
|
||||
{
|
||||
color_step* step = ColorAt(index);
|
||||
if (step && step->offset != offset) {
|
||||
step->offset = offset;
|
||||
ColorStop* stop = ColorStopAt(index);
|
||||
if (stop && stop->offset != offset) {
|
||||
stop->offset = offset;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// CountColors
|
||||
// CountColorStops
|
||||
int32
|
||||
BGradient::CountColors() const
|
||||
BGradient::CountColorStops() const
|
||||
{
|
||||
return fColors.CountItems();
|
||||
return fColorStops.CountItems();
|
||||
}
|
||||
|
||||
|
||||
// ColorAt
|
||||
BGradient::color_step*
|
||||
BGradient::ColorAt(int32 index) const
|
||||
// ColorStopAt
|
||||
BGradient::ColorStop*
|
||||
BGradient::ColorStopAt(int32 index) const
|
||||
{
|
||||
return (color_step*)fColors.ItemAt(index);
|
||||
return (ColorStop*)fColorStops.ItemAt(index);
|
||||
}
|
||||
|
||||
|
||||
// ColorAtFast
|
||||
BGradient::color_step*
|
||||
BGradient::ColorAtFast(int32 index) const
|
||||
// ColorStopAtFast
|
||||
BGradient::ColorStop*
|
||||
BGradient::ColorStopAtFast(int32 index) const
|
||||
{
|
||||
return (color_step*)fColors.ItemAtFast(index);
|
||||
return (ColorStop*)fColorStops.ItemAtFast(index);
|
||||
}
|
||||
|
||||
|
||||
// Colors
|
||||
BGradient::color_step*
|
||||
BGradient::Colors() const
|
||||
// ColorStops
|
||||
BGradient::ColorStop*
|
||||
BGradient::ColorStops() const
|
||||
{
|
||||
if (CountColors() > 0) {
|
||||
return (color_step*) fColors.Items();
|
||||
if (CountColorStops() > 0) {
|
||||
return (ColorStop*) fColorStops.Items();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// SortColorStepsByOffset
|
||||
// SortColorStopsByOffset
|
||||
void
|
||||
BGradient::SortColorStepsByOffset()
|
||||
BGradient::SortColorStopsByOffset()
|
||||
{
|
||||
fColors.SortItems(sort_color_steps_by_offset);
|
||||
fColorStops.SortItems(sort_color_stops_by_offset);
|
||||
}
|
||||
|
||||
|
||||
@ -437,8 +436,8 @@ BGradient::SortColorStepsByOffset()
|
||||
void
|
||||
BGradient::MakeEmpty()
|
||||
{
|
||||
int32 count = CountColors();
|
||||
int32 count = CountColorStops();
|
||||
for (int32 i = 0; i < count; i++)
|
||||
delete ColorAtFast(i);
|
||||
fColors.MakeEmpty();
|
||||
delete ColorStopAtFast(i);
|
||||
fColorStops.MakeEmpty();
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ Gradient::Gradient(bool empty)
|
||||
fInheritTransformation(true)
|
||||
{
|
||||
if (!empty) {
|
||||
AddColor(BGradient::color_step(0, 0, 0, 255, 0.0), 0);
|
||||
AddColor(BGradient::color_step(255, 255, 255, 255, 1.0), 1);
|
||||
AddColor(BGradient::ColorStop(0, 0, 0, 255, 0.0), 0);
|
||||
AddColor(BGradient::ColorStop(255, 255, 255, 255, 1.0), 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ Gradient::Gradient(BMessage* archive)
|
||||
LoadFrom((const double*)matrix);
|
||||
|
||||
// color steps
|
||||
BGradient::color_step step;
|
||||
BGradient::ColorStop step;
|
||||
for (int32 i = 0; archive->FindFloat("offset", i, &step.offset) >= B_OK; i++) {
|
||||
if (archive->FindInt32("color", i, (int32*)&step.color) >= B_OK)
|
||||
AddColor(step, i);
|
||||
@ -97,7 +97,7 @@ Gradient::Gradient(const Gradient& other)
|
||||
fInterpolation(other.fInterpolation),
|
||||
fInheritTransformation(other.fInheritTransformation)
|
||||
{
|
||||
for (int32 i = 0; BGradient::color_step* step = other.ColorAt(i); i++) {
|
||||
for (int32 i = 0; BGradient::ColorStop* step = other.ColorAt(i); i++) {
|
||||
AddColor(*step, i);
|
||||
}
|
||||
}
|
||||
@ -126,7 +126,7 @@ Gradient::Archive(BMessage* into, bool deep) const
|
||||
|
||||
// color steps
|
||||
if (ret >= B_OK) {
|
||||
for (int32 i = 0; BGradient::color_step* step = ColorAt(i); i++) {
|
||||
for (int32 i = 0; BGradient::ColorStop* step = ColorAt(i); i++) {
|
||||
ret = into->AddInt32("color", (const uint32&)step->color);
|
||||
if (ret < B_OK)
|
||||
break;
|
||||
@ -198,8 +198,8 @@ Gradient::ColorStepsAreEqual(const Gradient& other) const
|
||||
|
||||
bool equal = true;
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
BGradient::color_step* ourStep = ColorAtFast(i);
|
||||
BGradient::color_step* otherStep = other.ColorAtFast(i);
|
||||
BGradient::ColorStop* ourStep = ColorAtFast(i);
|
||||
BGradient::ColorStop* otherStep = other.ColorAtFast(i);
|
||||
if (*ourStep != *otherStep) {
|
||||
equal = false;
|
||||
break;
|
||||
@ -219,7 +219,7 @@ Gradient::SetColors(const Gradient& other)
|
||||
#endif
|
||||
|
||||
_MakeEmpty();
|
||||
for (int32 i = 0; BGradient::color_step* step = other.ColorAt(i); i++)
|
||||
for (int32 i = 0; BGradient::ColorStop* step = other.ColorAt(i); i++)
|
||||
AddColor(*step, i);
|
||||
|
||||
Notify();
|
||||
@ -232,11 +232,11 @@ int32
|
||||
Gradient::AddColor(const rgb_color& color, float offset)
|
||||
{
|
||||
// find the correct index (sorted by offset)
|
||||
BGradient::color_step* step = new BGradient::color_step(color, offset);
|
||||
BGradient::ColorStop* step = new BGradient::ColorStop(color, offset);
|
||||
int32 index = 0;
|
||||
int32 count = CountColors();
|
||||
for (; index < count; index++) {
|
||||
BGradient::color_step* s = ColorAtFast(index);
|
||||
BGradient::ColorStop* s = ColorAtFast(index);
|
||||
if (s->offset > step->offset)
|
||||
break;
|
||||
}
|
||||
@ -250,9 +250,9 @@ Gradient::AddColor(const rgb_color& color, float offset)
|
||||
|
||||
// AddColor
|
||||
bool
|
||||
Gradient::AddColor(const BGradient::color_step& color, int32 index)
|
||||
Gradient::AddColor(const BGradient::ColorStop& color, int32 index)
|
||||
{
|
||||
BGradient::color_step* step = new BGradient::color_step(color);
|
||||
BGradient::ColorStop* step = new BGradient::ColorStop(color);
|
||||
if (!fColors.AddItem((void*)step, index)) {
|
||||
delete step;
|
||||
return false;
|
||||
@ -265,8 +265,8 @@ Gradient::AddColor(const BGradient::color_step& color, int32 index)
|
||||
bool
|
||||
Gradient::RemoveColor(int32 index)
|
||||
{
|
||||
BGradient::color_step* step
|
||||
= (BGradient::color_step*)fColors.RemoveItem(index);
|
||||
BGradient::ColorStop* step
|
||||
= (BGradient::ColorStop*)fColors.RemoveItem(index);
|
||||
if (!step) {
|
||||
return false;
|
||||
}
|
||||
@ -279,9 +279,9 @@ Gradient::RemoveColor(int32 index)
|
||||
|
||||
// SetColor
|
||||
bool
|
||||
Gradient::SetColor(int32 index, const BGradient::color_step& color)
|
||||
Gradient::SetColor(int32 index, const BGradient::ColorStop& color)
|
||||
{
|
||||
if (BGradient::color_step* step = ColorAt(index)) {
|
||||
if (BGradient::ColorStop* step = ColorAt(index)) {
|
||||
if (*step != color) {
|
||||
step->color = color.color;
|
||||
step->offset = color.offset;
|
||||
@ -296,7 +296,7 @@ Gradient::SetColor(int32 index, const BGradient::color_step& color)
|
||||
bool
|
||||
Gradient::SetColor(int32 index, const rgb_color& color)
|
||||
{
|
||||
if (BGradient::color_step* step = ColorAt(index)) {
|
||||
if (BGradient::ColorStop* step = ColorAt(index)) {
|
||||
if ((uint32&)step->color != (uint32&)color) {
|
||||
step->color = color;
|
||||
Notify();
|
||||
@ -310,7 +310,7 @@ Gradient::SetColor(int32 index, const rgb_color& color)
|
||||
bool
|
||||
Gradient::SetOffset(int32 index, float offset)
|
||||
{
|
||||
BGradient::color_step* step = ColorAt(index);
|
||||
BGradient::ColorStop* step = ColorAt(index);
|
||||
if (step && step->offset != offset) {
|
||||
step->offset = offset;
|
||||
Notify();
|
||||
@ -329,17 +329,17 @@ Gradient::CountColors() const
|
||||
}
|
||||
|
||||
// ColorAt
|
||||
BGradient::color_step*
|
||||
BGradient::ColorStop*
|
||||
Gradient::ColorAt(int32 index) const
|
||||
{
|
||||
return (BGradient::color_step*)fColors.ItemAt(index);
|
||||
return (BGradient::ColorStop*)fColors.ItemAt(index);
|
||||
}
|
||||
|
||||
// ColorAtFast
|
||||
BGradient::color_step*
|
||||
BGradient::ColorStop*
|
||||
Gradient::ColorAtFast(int32 index) const
|
||||
{
|
||||
return (BGradient::color_step*)fColors.ItemAtFast(index);
|
||||
return (BGradient::ColorStop*)fColors.ItemAtFast(index);
|
||||
}
|
||||
|
||||
// #pragma mark -
|
||||
@ -395,13 +395,13 @@ gauss(double f)
|
||||
void
|
||||
Gradient::MakeGradient(uint32* colors, int32 count) const
|
||||
{
|
||||
BGradient::color_step* from = ColorAt(0);
|
||||
BGradient::ColorStop* from = ColorAt(0);
|
||||
|
||||
if (!from)
|
||||
return;
|
||||
|
||||
// find the step with the lowest offset
|
||||
for (int32 i = 0; BGradient::color_step* step = ColorAt(i); i++) {
|
||||
for (int32 i = 0; BGradient::ColorStop* step = ColorAt(i); i++) {
|
||||
if (step->offset < from->offset)
|
||||
from = step;
|
||||
}
|
||||
@ -426,7 +426,7 @@ Gradient::MakeGradient(uint32* colors, int32 count) const
|
||||
|
||||
// put all steps that we need to interpolate to into a list
|
||||
BList nextSteps(fColors.CountItems() - 1);
|
||||
for (int32 i = 0; BGradient::color_step* step = ColorAt(i); i++) {
|
||||
for (int32 i = 0; BGradient::ColorStop* step = ColorAt(i); i++) {
|
||||
if (step != from)
|
||||
nextSteps.AddItem((void*)step);
|
||||
}
|
||||
@ -435,10 +435,10 @@ Gradient::MakeGradient(uint32* colors, int32 count) const
|
||||
while (!nextSteps.IsEmpty()) {
|
||||
|
||||
// find the step with the next offset
|
||||
BGradient::color_step* to = NULL;
|
||||
BGradient::ColorStop* to = NULL;
|
||||
float nextOffsetDist = 2.0;
|
||||
for (int32 i = 0; BGradient::color_step* step
|
||||
= (BGradient::color_step*)nextSteps.ItemAt(i); i++) {
|
||||
for (int32 i = 0; BGradient::ColorStop* step
|
||||
= (BGradient::ColorStop*)nextSteps.ItemAt(i); i++) {
|
||||
float d = step->offset - from->offset;
|
||||
if (d < nextOffsetDist && d >= 0) {
|
||||
to = step;
|
||||
@ -588,7 +588,7 @@ Gradient::PrintToStream() const
|
||||
string_for_type(fType),
|
||||
string_for_interpolation(fInterpolation),
|
||||
fInheritTransformation);
|
||||
for (int32 i = 0; BGradient::color_step* step = ColorAt(i); i++) {
|
||||
for (int32 i = 0; BGradient::ColorStop* step = ColorAt(i); i++) {
|
||||
printf(" %ld: offset: %.1f -> color(%d, %d, %d, %d)\n",
|
||||
i, step->offset,
|
||||
step->color.red,
|
||||
|
@ -73,19 +73,19 @@ class Gradient : public Transformable {
|
||||
|
||||
|
||||
int32 AddColor(const rgb_color& color, float offset);
|
||||
bool AddColor(const BGradient::color_step& color,
|
||||
bool AddColor(const BGradient::ColorStop& color,
|
||||
int32 index);
|
||||
|
||||
bool RemoveColor(int32 index);
|
||||
|
||||
bool SetColor(int32 index,
|
||||
const BGradient::color_step& step);
|
||||
const BGradient::ColorStop& step);
|
||||
bool SetColor(int32 index, const rgb_color& color);
|
||||
bool SetOffset(int32 index, float offset);
|
||||
|
||||
int32 CountColors() const;
|
||||
BGradient::color_step* ColorAt(int32 index) const;
|
||||
BGradient::color_step* ColorAtFast(int32 index) const;
|
||||
BGradient::ColorStop* ColorAt(int32 index) const;
|
||||
BGradient::ColorStop* ColorAtFast(int32 index) const;
|
||||
|
||||
void SetType(gradients_type type);
|
||||
gradients_type Type() const
|
||||
|
@ -169,7 +169,7 @@ Style::HasTransparency() const
|
||||
if (fGradient) {
|
||||
int32 count = fGradient->CountColors();
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
BGradient::color_step* step = fGradient->ColorAtFast(i);
|
||||
BGradient::ColorStop* step = fGradient->ColorAtFast(i);
|
||||
if (step->color.alpha < 255)
|
||||
return true;
|
||||
}
|
||||
|
@ -814,7 +814,7 @@ View::ConvertToScreenForDrawing(BRegion* region) const
|
||||
void
|
||||
View::ConvertToScreenForDrawing(BGradient* gradient) const
|
||||
{
|
||||
switch(gradient->Type()) {
|
||||
switch(gradient->GetType()) {
|
||||
case BGradient::TYPE_LINEAR: {
|
||||
BGradientLinear* linear = (BGradientLinear*) gradient;
|
||||
BPoint start = linear->Start();
|
||||
@ -825,7 +825,7 @@ View::ConvertToScreenForDrawing(BGradient* gradient) const
|
||||
ConvertToScreen(&end);
|
||||
linear->SetStart(start);
|
||||
linear->SetEnd(end);
|
||||
linear->SortColorStepsByOffset();
|
||||
linear->SortColorStopsByOffset();
|
||||
break;
|
||||
}
|
||||
case BGradient::TYPE_RADIAL: {
|
||||
@ -834,7 +834,7 @@ View::ConvertToScreenForDrawing(BGradient* gradient) const
|
||||
fDrawState->Transform(¢er);
|
||||
ConvertToScreen(¢er);
|
||||
radial->SetCenter(center);
|
||||
radial->SortColorStepsByOffset();
|
||||
radial->SortColorStopsByOffset();
|
||||
break;
|
||||
}
|
||||
case BGradient::TYPE_RADIAL_FOCUS: {
|
||||
@ -847,7 +847,7 @@ View::ConvertToScreenForDrawing(BGradient* gradient) const
|
||||
ConvertToScreen(&focal);
|
||||
radialFocus->SetCenter(center);
|
||||
radialFocus->SetFocal(focal);
|
||||
radialFocus->SortColorStepsByOffset();
|
||||
radialFocus->SortColorStopsByOffset();
|
||||
break;
|
||||
}
|
||||
case BGradient::TYPE_DIAMOND: {
|
||||
@ -856,7 +856,7 @@ View::ConvertToScreenForDrawing(BGradient* gradient) const
|
||||
fDrawState->Transform(¢er);
|
||||
ConvertToScreen(¢er);
|
||||
diamond->SetCenter(center);
|
||||
diamond->SortColorStepsByOffset();
|
||||
diamond->SortColorStopsByOffset();
|
||||
break;
|
||||
}
|
||||
case BGradient::TYPE_CONIC: {
|
||||
@ -865,7 +865,7 @@ View::ConvertToScreenForDrawing(BGradient* gradient) const
|
||||
fDrawState->Transform(¢er);
|
||||
ConvertToScreen(¢er);
|
||||
conic->SetCenter(center);
|
||||
conic->SortColorStepsByOffset();
|
||||
conic->SortColorStopsByOffset();
|
||||
break;
|
||||
}
|
||||
case BGradient::TYPE_NONE: {
|
||||
|
@ -639,8 +639,7 @@ DrawingEngine::FillArc(BRect r, const float& angle, const float& span,
|
||||
BPoint center(r.left + xRadius,
|
||||
r.top + yRadius);
|
||||
|
||||
fPainter->FillArcGradient(center, xRadius, yRadius, angle, span,
|
||||
gradient);
|
||||
fPainter->FillArc(center, xRadius, yRadius, angle, span, gradient);
|
||||
|
||||
_CopyToFront(clipped);
|
||||
}
|
||||
@ -669,7 +668,7 @@ DrawingEngine::FillBezier(BPoint* pts, const BGradient& gradient)
|
||||
// TODO: figure out bounds and hide cursor depending on that
|
||||
AutoFloatingOverlaysHider _(fGraphicsCard);
|
||||
|
||||
BRect touched = fPainter->FillBezierGradient(pts, gradient);
|
||||
BRect touched = fPainter->FillBezier(pts, gradient);
|
||||
|
||||
_CopyToFront(touched);
|
||||
}
|
||||
@ -723,7 +722,7 @@ DrawingEngine::FillEllipse(BRect r, const BGradient& gradient)
|
||||
if (clipped.IsValid()) {
|
||||
AutoFloatingOverlaysHider _(fGraphicsCard, clipped);
|
||||
|
||||
fPainter->FillEllipseGradient(r, gradient);
|
||||
fPainter->FillEllipse(r, gradient);
|
||||
|
||||
_CopyToFront(clipped);
|
||||
}
|
||||
@ -761,7 +760,7 @@ DrawingEngine::FillPolygon(BPoint* ptlist, int32 numpts, BRect bounds,
|
||||
if (bounds.IsValid()) {
|
||||
AutoFloatingOverlaysHider _(fGraphicsCard, bounds);
|
||||
|
||||
fPainter->FillPolygonGradient(ptlist, numpts, gradient, closed);
|
||||
fPainter->FillPolygon(ptlist, numpts, gradient, closed);
|
||||
|
||||
_CopyToFront(bounds);
|
||||
}
|
||||
@ -979,7 +978,7 @@ DrawingEngine::FillRect(BRect r, const BGradient& gradient)
|
||||
|
||||
AutoFloatingOverlaysHider overlaysHider(fGraphicsCard, r);
|
||||
|
||||
fPainter->FillRectGradient(r, gradient);
|
||||
fPainter->FillRect(r, gradient);
|
||||
|
||||
_CopyToFront(r);
|
||||
}
|
||||
@ -1049,11 +1048,11 @@ DrawingEngine::FillRegion(BRegion& r, const BGradient& gradient)
|
||||
|
||||
AutoFloatingOverlaysHider overlaysHider(fGraphicsCard, clipped);
|
||||
|
||||
BRect touched = fPainter->FillRectGradient(r.RectAt(0), gradient);
|
||||
BRect touched = fPainter->FillRect(r.RectAt(0), gradient);
|
||||
|
||||
int32 count = r.CountRects();
|
||||
for (int32 i = 1; i < count; i++)
|
||||
touched = touched | fPainter->FillRectGradient(r.RectAt(i), gradient);
|
||||
touched = touched | fPainter->FillRect(r.RectAt(i), gradient);
|
||||
|
||||
_CopyToFront(r.Frame());
|
||||
}
|
||||
@ -1104,7 +1103,7 @@ DrawingEngine::FillRoundRect(BRect r, float xrad, float yrad,
|
||||
if (clipped.IsValid()) {
|
||||
AutoFloatingOverlaysHider _(fGraphicsCard, clipped);
|
||||
|
||||
BRect touched = fPainter->FillRoundRectGradient(r, xrad, yrad, gradient);
|
||||
BRect touched = fPainter->FillRoundRect(r, xrad, yrad, gradient);
|
||||
|
||||
_CopyToFront(touched);
|
||||
}
|
||||
@ -1140,7 +1139,7 @@ DrawingEngine::FillShape(const BRect& bounds, int32 opCount,
|
||||
// shape is drawn on screen, TODO: optimize
|
||||
AutoFloatingOverlaysHider _(fGraphicsCard);
|
||||
|
||||
BRect touched = fPainter->FillShapeGradient(opCount, opList, ptCount,
|
||||
BRect touched = fPainter->FillShape(opCount, opList, ptCount,
|
||||
ptList, gradient);
|
||||
|
||||
_CopyToFront(touched);
|
||||
@ -1179,7 +1178,7 @@ DrawingEngine::FillTriangle(BPoint* pts, const BRect& bounds,
|
||||
if (clipped.IsValid()) {
|
||||
AutoFloatingOverlaysHider _(fGraphicsCard, clipped);
|
||||
|
||||
fPainter->FillTriangleGradient(pts[0], pts[1], pts[2], gradient);
|
||||
fPainter->FillTriangle(pts[0], pts[1], pts[2], gradient);
|
||||
|
||||
_CopyToFront(clipped);
|
||||
}
|
||||
|
@ -506,10 +506,10 @@ Painter::FillTriangle(BPoint pt1, BPoint pt2, BPoint pt3) const
|
||||
return _DrawTriangle(pt1, pt2, pt3, true);
|
||||
}
|
||||
|
||||
// FillTriangleGradient
|
||||
// FillTriangle
|
||||
BRect
|
||||
Painter::FillTriangleGradient(BPoint pt1, BPoint pt2, BPoint pt3,
|
||||
const BGradient& gradient) const
|
||||
Painter::FillTriangle(BPoint pt1, BPoint pt2, BPoint pt3,
|
||||
const BGradient& gradient) const
|
||||
{
|
||||
CHECK_CLIPPING
|
||||
|
||||
@ -525,7 +525,7 @@ Painter::FillTriangleGradient(BPoint pt1, BPoint pt2, BPoint pt3,
|
||||
|
||||
fPath.close_polygon();
|
||||
|
||||
return _FillPathGradient(fPath, gradient);
|
||||
return _FillPath(fPath, gradient);
|
||||
}
|
||||
|
||||
// DrawPolygon
|
||||
@ -559,9 +559,9 @@ Painter::DrawPolygon(BPoint* p, int32 numPts,
|
||||
return BRect(0.0, 0.0, -1.0, -1.0);
|
||||
}
|
||||
|
||||
// FillPolygonGradient
|
||||
// FillPolygon
|
||||
BRect
|
||||
Painter::FillPolygonGradient(BPoint* p, int32 numPts,
|
||||
Painter::FillPolygon(BPoint* p, int32 numPts,
|
||||
const BGradient& gradient, bool closed) const
|
||||
{
|
||||
CHECK_CLIPPING
|
||||
@ -582,7 +582,7 @@ Painter::FillPolygonGradient(BPoint* p, int32 numPts,
|
||||
if (closed)
|
||||
fPath.close_polygon();
|
||||
|
||||
return _FillPathGradient(fPath, gradient);
|
||||
return _FillPath(fPath, gradient);
|
||||
}
|
||||
return BRect(0.0, 0.0, -1.0, -1.0);
|
||||
}
|
||||
@ -614,9 +614,9 @@ Painter::DrawBezier(BPoint* p, bool filled) const
|
||||
}
|
||||
}
|
||||
|
||||
// FillBezierGradient
|
||||
// FillBezier
|
||||
BRect
|
||||
Painter::FillBezierGradient(BPoint* p, const BGradient& gradient) const
|
||||
Painter::FillBezier(BPoint* p, const BGradient& gradient) const
|
||||
{
|
||||
CHECK_CLIPPING
|
||||
|
||||
@ -634,15 +634,14 @@ Painter::FillBezierGradient(BPoint* p, const BGradient& gradient) const
|
||||
|
||||
|
||||
fPath.close_polygon();
|
||||
return _FillPathGradient(fCurve, gradient);
|
||||
return _FillPath(fCurve, gradient);
|
||||
}
|
||||
|
||||
|
||||
// DrawShape
|
||||
BRect
|
||||
Painter::DrawShape(const int32& opCount, const uint32* opList,
|
||||
const int32& ptCount, const BPoint* points,
|
||||
bool filled) const
|
||||
const int32& ptCount, const BPoint* points, bool filled) const
|
||||
{
|
||||
CHECK_CLIPPING
|
||||
|
||||
@ -686,11 +685,11 @@ Painter::DrawShape(const int32& opCount, const uint32* opList,
|
||||
return _StrokePath(fCurve);
|
||||
}
|
||||
|
||||
// FillShapeGradient
|
||||
// FillShape
|
||||
BRect
|
||||
Painter::FillShapeGradient(const int32& opCount, const uint32* opList,
|
||||
const int32& ptCount, const BPoint* points,
|
||||
const BGradient& gradient) const
|
||||
Painter::FillShape(const int32& opCount, const uint32* opList,
|
||||
const int32& ptCount, const BPoint* points,
|
||||
const BGradient& gradient) const
|
||||
{
|
||||
CHECK_CLIPPING
|
||||
|
||||
@ -728,7 +727,7 @@ Painter::FillShapeGradient(const int32& opCount, const uint32* opList,
|
||||
fPath.close_polygon();
|
||||
}
|
||||
|
||||
return _FillPathGradient(fCurve, gradient);
|
||||
return _FillPath(fCurve, gradient);
|
||||
}
|
||||
|
||||
// StrokeRect
|
||||
@ -854,9 +853,9 @@ Painter::FillRect(const BRect& r) const
|
||||
return _FillPath(fPath);
|
||||
}
|
||||
|
||||
// FillRectGradient
|
||||
// FillRect
|
||||
BRect
|
||||
Painter::FillRectGradient(const BRect& r, const BGradient& gradient) const
|
||||
Painter::FillRect(const BRect& r, const BGradient& gradient) const
|
||||
{
|
||||
CHECK_CLIPPING
|
||||
|
||||
@ -879,7 +878,7 @@ Painter::FillRectGradient(const BRect& r, const BGradient& gradient) const
|
||||
fPath.line_to(a.x, b.y);
|
||||
fPath.close_polygon();
|
||||
|
||||
return _FillPathGradient(fPath, gradient);
|
||||
return _FillPath(fPath, gradient);
|
||||
}
|
||||
|
||||
// FillRect
|
||||
@ -921,6 +920,53 @@ gfxset32(offset + y1 * bpr, color.data32, (x2 - x1 + 1) * 4);
|
||||
} while (fBaseRenderer.next_clip_box());
|
||||
}
|
||||
|
||||
#if 0
|
||||
// FillRectVerticalGradient
|
||||
void
|
||||
Painter::FillRectVerticalGradient(const BRect& r,
|
||||
const BGradientLinear& gradient) const
|
||||
{
|
||||
if (!fValidClipping)
|
||||
return;
|
||||
|
||||
int32 gradientArraySize = r.IntegerHeight() + 1;
|
||||
rgb_color gradientArray[gradientArraySize];
|
||||
for (int32 i = 0; i < gradientArraySize; i++) {
|
||||
}
|
||||
|
||||
uint8* dst = fBuffer.row_ptr(0);
|
||||
uint32 bpr = fBuffer.stride();
|
||||
int32 left = (int32)r.left;
|
||||
int32 top = (int32)r.top;
|
||||
int32 right = (int32)r.right;
|
||||
int32 bottom = (int32)r.bottom;
|
||||
// get a 32 bit pixel ready with the color
|
||||
pixel32 color;
|
||||
color.data8[0] = c.blue;
|
||||
color.data8[1] = c.green;
|
||||
color.data8[2] = c.red;
|
||||
color.data8[3] = c.alpha;
|
||||
// fill rects, iterate over clipping boxes
|
||||
fBaseRenderer.first_clip_box();
|
||||
do {
|
||||
int32 x1 = max_c(fBaseRenderer.xmin(), left);
|
||||
int32 x2 = min_c(fBaseRenderer.xmax(), right);
|
||||
if (x1 <= x2) {
|
||||
int32 y1 = max_c(fBaseRenderer.ymin(), top);
|
||||
int32 y2 = min_c(fBaseRenderer.ymax(), bottom);
|
||||
uint8* offset = dst + x1 * 4;
|
||||
for (; y1 <= y2; y1++) {
|
||||
// uint32* handle = (uint32*)(offset + y1 * bpr);
|
||||
// for (int32 x = x1; x <= x2; x++) {
|
||||
// *handle++ = color.data32;
|
||||
// }
|
||||
gfxset32(offset + y1 * bpr, color.data32, (x2 - x1 + 1) * 4);
|
||||
}
|
||||
}
|
||||
} while (fBaseRenderer.next_clip_box());
|
||||
}
|
||||
#endif
|
||||
|
||||
// FillRectNoClipping
|
||||
void
|
||||
Painter::FillRectNoClipping(const clipping_rect& r, const rgb_color& c) const
|
||||
@ -970,10 +1016,11 @@ Painter::StrokeRoundRect(const BRect& r, float xRadius, float yRadius) const
|
||||
return _StrokePath(rect);
|
||||
} else {
|
||||
// NOTE: This implementation might seem a little strange, but it makes
|
||||
// stroked round rects look like on R5. A more correct way would be to use
|
||||
// _StrokePath() as above (independent from fPenSize).
|
||||
// stroked round rects look like on R5. A more correct way would be to
|
||||
// use _StrokePath() as above (independent from fPenSize).
|
||||
// The fact that the bounding box of the round rect is not enlarged
|
||||
// by fPenSize/2 is actually on purpose, though one could argue it is unexpected.
|
||||
// by fPenSize/2 is actually on purpose, though one could argue it is
|
||||
// unexpected.
|
||||
|
||||
// enclose the right and bottom edge
|
||||
rb.x++;
|
||||
@ -987,8 +1034,9 @@ Painter::StrokeRoundRect(const BRect& r, float xRadius, float yRadius) const
|
||||
fSubpixRasterizer.reset();
|
||||
fSubpixRasterizer.add_path(outer);
|
||||
|
||||
// don't add an inner hole if the "size is negative", this avoids some
|
||||
// defects that can be observed on R5 and could be regarded as a bug.
|
||||
// don't add an inner hole if the "size is negative", this avoids
|
||||
// some defects that can be observed on R5 and could be regarded
|
||||
// as a bug.
|
||||
if (2 * fPenSize < rb.x - lt.x && 2 * fPenSize < rb.y - lt.y) {
|
||||
agg::rounded_rect inner;
|
||||
inner.rect(lt.x + fPenSize, lt.y + fPenSize, rb.x - fPenSize,
|
||||
@ -1014,8 +1062,9 @@ Painter::StrokeRoundRect(const BRect& r, float xRadius, float yRadius) const
|
||||
fRasterizer.reset();
|
||||
fRasterizer.add_path(outer);
|
||||
|
||||
// don't add an inner hole if the "size is negative", this avoids some
|
||||
// defects that can be observed on R5 and could be regarded as a bug.
|
||||
// don't add an inner hole if the "size is negative", this avoids
|
||||
// some defects that can be observed on R5 and could be regarded as
|
||||
// a bug.
|
||||
if (2 * fPenSize < rb.x - lt.x && 2 * fPenSize < rb.y - lt.y) {
|
||||
agg::rounded_rect inner;
|
||||
inner.rect(lt.x + fPenSize, lt.y + fPenSize, rb.x - fPenSize,
|
||||
@ -1066,10 +1115,10 @@ Painter::FillRoundRect(const BRect& r, float xRadius, float yRadius) const
|
||||
return _FillPath(rect);
|
||||
}
|
||||
|
||||
// FillRoundRectGradient
|
||||
// FillRoundRect
|
||||
BRect
|
||||
Painter::FillRoundRectGradient(const BRect& r, float xRadius, float yRadius,
|
||||
const BGradient& gradient) const
|
||||
Painter::FillRoundRect(const BRect& r, float xRadius, float yRadius,
|
||||
const BGradient& gradient) const
|
||||
{
|
||||
CHECK_CLIPPING
|
||||
|
||||
@ -1088,7 +1137,7 @@ Painter::FillRoundRectGradient(const BRect& r, float xRadius, float yRadius,
|
||||
rect.rect(lt.x, lt.y, rb.x, rb.y);
|
||||
rect.radius(xRadius, yRadius);
|
||||
|
||||
return _FillPathGradient(rect, gradient);
|
||||
return _FillPath(rect, gradient);
|
||||
}
|
||||
|
||||
// AlignEllipseRect
|
||||
@ -1183,9 +1232,9 @@ Painter::DrawEllipse(BRect r, bool fill) const
|
||||
}
|
||||
}
|
||||
|
||||
// FillEllipseGradient
|
||||
// FillEllipse
|
||||
BRect
|
||||
Painter::FillEllipseGradient(BRect r, const BGradient& gradient) const
|
||||
Painter::FillEllipse(BRect r, const BGradient& gradient) const
|
||||
{
|
||||
CHECK_CLIPPING
|
||||
|
||||
@ -1203,7 +1252,7 @@ Painter::FillEllipseGradient(BRect r, const BGradient& gradient) const
|
||||
|
||||
agg::ellipse path(center.x, center.y, xRadius, yRadius, divisions);
|
||||
|
||||
return _FillPathGradient(path, gradient);
|
||||
return _FillPath(path, gradient);
|
||||
}
|
||||
|
||||
// StrokeArc
|
||||
@ -1262,10 +1311,10 @@ Painter::FillArc(BPoint center, float xRadius, float yRadius, float angle,
|
||||
return _FillPath(fPath);
|
||||
}
|
||||
|
||||
// FillArcGradient
|
||||
// FillArc
|
||||
BRect
|
||||
Painter::FillArcGradient(BPoint center, float xRadius, float yRadius, float angle,
|
||||
float span, const BGradient& gradient) const
|
||||
Painter::FillArc(BPoint center, float xRadius, float yRadius, float angle,
|
||||
float span, const BGradient& gradient) const
|
||||
{
|
||||
CHECK_CLIPPING
|
||||
|
||||
@ -1295,7 +1344,7 @@ Painter::FillArcGradient(BPoint center, float xRadius, float yRadius, float angl
|
||||
|
||||
fPath.close_polygon();
|
||||
|
||||
return _FillPathGradient(fPath, gradient);
|
||||
return _FillPath(fPath, gradient);
|
||||
}
|
||||
|
||||
// #pragma mark -
|
||||
@ -1404,17 +1453,17 @@ Painter::FillRegion(const BRegion* region) const
|
||||
return touched;
|
||||
}
|
||||
|
||||
// FillRegionGradient
|
||||
// FillRegion
|
||||
BRect
|
||||
Painter::FillRegionGradient(const BRegion* region, const BGradient& gradient) const
|
||||
Painter::FillRegion(const BRegion* region, const BGradient& gradient) const
|
||||
{
|
||||
CHECK_CLIPPING
|
||||
|
||||
BRegion copy(*region);
|
||||
int32 count = copy.CountRects();
|
||||
BRect touched = FillRectGradient(copy.RectAt(0), gradient);
|
||||
BRect touched = FillRect(copy.RectAt(0), gradient);
|
||||
for (int32 i = 1; i < count; i++) {
|
||||
touched = touched | FillRectGradient(copy.RectAt(i), gradient);
|
||||
touched = touched | FillRect(copy.RectAt(i), gradient);
|
||||
}
|
||||
return touched;
|
||||
}
|
||||
@ -2513,16 +2562,16 @@ Painter::_FillPath(VertexSource& path) const
|
||||
return _Clipped(_BoundingBox(path));
|
||||
}
|
||||
|
||||
// _FillPathGradient
|
||||
// _FillPath
|
||||
template<class VertexSource>
|
||||
BRect
|
||||
Painter::_FillPathGradient(VertexSource& path, const BGradient& gradient) const
|
||||
Painter::_FillPath(VertexSource& path, const BGradient& gradient) const
|
||||
{
|
||||
GTRACE("Painter::_FillPathGradient\n");
|
||||
GTRACE("Painter::_FillPath\n");
|
||||
|
||||
switch(gradient.Type()) {
|
||||
switch(gradient.GetType()) {
|
||||
case BGradient::TYPE_LINEAR: {
|
||||
GTRACE(("Painter::_FillPathGradient> type == TYPE_LINEAR\n"));
|
||||
GTRACE(("Painter::_FillPath> type == TYPE_LINEAR\n"));
|
||||
_FillPathGradientLinear(path, *((const BGradientLinear*) &gradient));
|
||||
break;
|
||||
}
|
||||
@ -2564,9 +2613,9 @@ template<class Array>
|
||||
void
|
||||
Painter::_MakeGradient(Array& array, const BGradient& gradient) const
|
||||
{
|
||||
for (int i = 0; i < gradient.CountColors() - 1; i++) {
|
||||
BGradient::color_step* from = gradient.ColorAtFast(i);
|
||||
BGradient::color_step* to = gradient.ColorAtFast(i + 1);
|
||||
for (int i = 0; i < gradient.CountColorStops() - 1; i++) {
|
||||
BGradient::ColorStop* from = gradient.ColorStopAtFast(i);
|
||||
BGradient::ColorStop* to = gradient.ColorStopAtFast(i + 1);
|
||||
agg::rgba8 fromColor(from->color.red, from->color.green,
|
||||
from->color.blue, from->color.alpha);
|
||||
agg::rgba8 toColor(to->color.red, to->color.green,
|
||||
|
@ -55,8 +55,8 @@ class Painter {
|
||||
{ return fClippingRegion; }
|
||||
|
||||
void SetDrawState(const DrawState* data,
|
||||
int32 xOffset = 0,
|
||||
int32 yOffset = 0);
|
||||
int32 xOffset = 0,
|
||||
int32 yOffset = 0);
|
||||
|
||||
// object settings
|
||||
void SetHighColor(const rgb_color& color);
|
||||
@ -73,7 +73,7 @@ class Painter {
|
||||
void SetStrokeMode(cap_mode lineCap,
|
||||
join_mode joinMode, float miterLimit);
|
||||
void SetPattern(const pattern& p,
|
||||
bool drawingText = false);
|
||||
bool drawingText = false);
|
||||
inline pattern Pattern() const
|
||||
{ return *fPatternHandler.GetR5Pattern(); }
|
||||
void SetDrawingMode(drawing_mode mode);
|
||||
@ -90,155 +90,133 @@ class Painter {
|
||||
// painting functions
|
||||
|
||||
// lines
|
||||
void StrokeLine( BPoint a,
|
||||
BPoint b);
|
||||
void StrokeLine(BPoint a, BPoint b);
|
||||
|
||||
// returns true if the line was either vertical or horizontal
|
||||
// draws a solid one pixel wide line of color c, no blending
|
||||
bool StraightLine( BPoint a,
|
||||
BPoint b,
|
||||
const rgb_color& c) const;
|
||||
bool StraightLine(BPoint a, BPoint b,
|
||||
const rgb_color& c) const;
|
||||
|
||||
// triangles
|
||||
BRect StrokeTriangle( BPoint pt1,
|
||||
BPoint pt2,
|
||||
BPoint pt3) const;
|
||||
BRect StrokeTriangle(BPoint pt1, BPoint pt2,
|
||||
BPoint pt3) const;
|
||||
|
||||
BRect FillTriangle( BPoint pt1,
|
||||
BPoint pt2,
|
||||
BPoint pt3) const;
|
||||
BRect FillTriangleGradient(BPoint pt1, BPoint pt2,
|
||||
BPoint pt3,
|
||||
const BGradient& gradient) const;
|
||||
BRect FillTriangle(BPoint pt1, BPoint pt2,
|
||||
BPoint pt3) const;
|
||||
BRect FillTriangle(BPoint pt1, BPoint pt2,
|
||||
BPoint pt3,
|
||||
const BGradient& gradient) const;
|
||||
|
||||
// polygons
|
||||
BRect DrawPolygon( BPoint* ptArray,
|
||||
int32 numPts,
|
||||
bool filled,
|
||||
bool closed) const;
|
||||
BRect FillPolygonGradient(BPoint* ptArray,
|
||||
int32 numPts,
|
||||
const BGradient& gradient,
|
||||
bool closed) const;
|
||||
BRect DrawPolygon(BPoint* ptArray, int32 numPts,
|
||||
bool filled, bool closed) const;
|
||||
BRect FillPolygon(BPoint* ptArray, int32 numPts,
|
||||
const BGradient& gradient,
|
||||
bool closed) const;
|
||||
|
||||
// bezier curves
|
||||
BRect DrawBezier( BPoint* controlPoints,
|
||||
bool filled) const;
|
||||
BRect FillBezierGradient(BPoint* controlPoints,
|
||||
const BGradient& gradient) const;
|
||||
BRect DrawBezier(BPoint* controlPoints,
|
||||
bool filled) const;
|
||||
BRect FillBezier(BPoint* controlPoints,
|
||||
const BGradient& gradient) const;
|
||||
|
||||
// shapes
|
||||
BRect DrawShape( const int32& opCount,
|
||||
const uint32* opList,
|
||||
const int32& ptCount,
|
||||
const BPoint* ptList,
|
||||
bool filled) const;
|
||||
BRect FillShapeGradient(const int32& opCount,
|
||||
BRect DrawShape(const int32& opCount,
|
||||
const uint32* opList, const int32& ptCount,
|
||||
const BPoint* ptList, bool filled) const;
|
||||
BRect FillShape(const int32& opCount,
|
||||
const uint32* opList,
|
||||
const int32& ptCount,
|
||||
const BPoint* ptList,
|
||||
const BGradient& gradient) const;
|
||||
|
||||
// rects
|
||||
BRect StrokeRect( const BRect& r) const;
|
||||
BRect StrokeRect(const BRect& r) const;
|
||||
|
||||
// strokes a one pixel wide solid rect, no blending
|
||||
void StrokeRect( const BRect& r,
|
||||
const rgb_color& c) const;
|
||||
void StrokeRect(const BRect& r,
|
||||
const rgb_color& c) const;
|
||||
|
||||
BRect FillRect( const BRect& r) const;
|
||||
BRect FillRectGradient(const BRect& r,
|
||||
const BGradient& gradient) const;
|
||||
BRect FillRect(const BRect& r) const;
|
||||
BRect FillRect(const BRect& r,
|
||||
const BGradient& gradient) const;
|
||||
|
||||
// fills a solid rect with color c, no blending
|
||||
void FillRect( const BRect& r,
|
||||
const rgb_color& c) const;
|
||||
void FillRect(const BRect& r,
|
||||
const rgb_color& c) const;
|
||||
// fills a solid rect with color c, no blending, no clipping
|
||||
void FillRectNoClipping(const clipping_rect& r,
|
||||
const rgb_color& c) const;
|
||||
const rgb_color& c) const;
|
||||
|
||||
// round rects
|
||||
BRect StrokeRoundRect(const BRect& r,
|
||||
float xRadius,
|
||||
float yRadius) const;
|
||||
BRect StrokeRoundRect(const BRect& r, float xRadius,
|
||||
float yRadius) const;
|
||||
|
||||
BRect FillRoundRect( const BRect& r,
|
||||
float xRadius,
|
||||
float yRadius) const;
|
||||
BRect FillRoundRectGradient(const BRect& r,
|
||||
float xRadius,
|
||||
float yRadius,
|
||||
const BGradient& gradient) const;
|
||||
BRect FillRoundRect(const BRect& r, float xRadius,
|
||||
float yRadius) const;
|
||||
BRect FillRoundRect(const BRect& r, float xRadius,
|
||||
float yRadius,
|
||||
const BGradient& gradient) const;
|
||||
|
||||
// ellipses
|
||||
void AlignEllipseRect(BRect* rect,
|
||||
bool filled) const;
|
||||
bool filled) const;
|
||||
|
||||
BRect DrawEllipse( BRect r,
|
||||
bool filled) const;
|
||||
BRect FillEllipseGradient(BRect r,
|
||||
const BGradient& gradient) const;
|
||||
BRect DrawEllipse(BRect r, bool filled) const;
|
||||
BRect FillEllipse(BRect r,
|
||||
const BGradient& gradient) const;
|
||||
|
||||
// arcs
|
||||
BRect StrokeArc( BPoint center,
|
||||
float xRadius,
|
||||
float yRadius,
|
||||
float angle,
|
||||
float span) const;
|
||||
BRect StrokeArc(BPoint center, float xRadius,
|
||||
float yRadius, float angle,
|
||||
float span) const;
|
||||
|
||||
BRect FillArc( BPoint center,
|
||||
float xRadius,
|
||||
float yRadius,
|
||||
float angle,
|
||||
float span) const;
|
||||
BRect FillArcGradient(BPoint center,
|
||||
float xRadius,
|
||||
float yRadius,
|
||||
float angle,
|
||||
float span,
|
||||
const BGradient& gradient) const;
|
||||
BRect FillArc(BPoint center, float xRadius,
|
||||
float yRadius, float angle,
|
||||
float span) const;
|
||||
BRect FillArc(BPoint center, float xRadius,
|
||||
float yRadius, float angle, float span,
|
||||
const BGradient& gradient) const;
|
||||
|
||||
// strings
|
||||
BRect DrawString( const char* utf8String,
|
||||
uint32 length,
|
||||
BPoint baseLine,
|
||||
const escapement_delta* delta,
|
||||
FontCacheReference* cacheReference = NULL);
|
||||
BRect DrawString(const char* utf8String,
|
||||
uint32 length, BPoint baseLine,
|
||||
const escapement_delta* delta,
|
||||
FontCacheReference* cacheReference = NULL);
|
||||
|
||||
BRect BoundingBox( const char* utf8String,
|
||||
uint32 length,
|
||||
BPoint baseLine,
|
||||
BPoint* penLocation,
|
||||
const escapement_delta* delta,
|
||||
FontCacheReference* cacheReference = NULL) const;
|
||||
BRect BoundingBox(const char* utf8String,
|
||||
uint32 length, BPoint baseLine,
|
||||
BPoint* penLocation,
|
||||
const escapement_delta* delta,
|
||||
FontCacheReference* cacheReference
|
||||
= NULL) const;
|
||||
|
||||
float StringWidth( const char* utf8String,
|
||||
uint32 length,
|
||||
const escapement_delta* delta = NULL);
|
||||
float StringWidth(const char* utf8String,
|
||||
uint32 length,
|
||||
const escapement_delta* delta = NULL);
|
||||
|
||||
|
||||
// bitmaps
|
||||
BRect DrawBitmap( const ServerBitmap* bitmap,
|
||||
BRect bitmapRect,
|
||||
BRect viewRect,
|
||||
uint32 options) const;
|
||||
BRect DrawBitmap(const ServerBitmap* bitmap,
|
||||
BRect bitmapRect, BRect viewRect,
|
||||
uint32 options) const;
|
||||
|
||||
// some convenience stuff
|
||||
BRect FillRegion( const BRegion* region) const;
|
||||
BRect FillRegionGradient(const BRegion* region,
|
||||
const BGradient& gradient) const;
|
||||
BRect FillRegion(const BRegion* region) const;
|
||||
BRect FillRegion(const BRegion* region,
|
||||
const BGradient& gradient) const;
|
||||
|
||||
BRect InvertRect( const BRect& r) const;
|
||||
BRect InvertRect(const BRect& r) const;
|
||||
|
||||
inline BRect ClipRect( BRect rect) const;
|
||||
inline BRect ClipRect(BRect rect) const;
|
||||
inline BRect AlignAndClipRect(BRect rect) const;
|
||||
|
||||
|
||||
private:
|
||||
void _Transform(BPoint* point,
|
||||
bool centerOffset = true) const;
|
||||
bool centerOffset = true) const;
|
||||
BPoint _Transform(const BPoint& point,
|
||||
bool centerOffset = true) const;
|
||||
bool centerOffset = true) const;
|
||||
BRect _Clipped(const BRect& rect) const;
|
||||
|
||||
void _UpdateFont() const;
|
||||
@ -247,10 +225,8 @@ class Painter {
|
||||
void _SetRendererColor(const rgb_color& color) const;
|
||||
|
||||
// drawing functions stroke/fill
|
||||
BRect _DrawTriangle( BPoint pt1,
|
||||
BPoint pt2,
|
||||
BPoint pt3,
|
||||
bool fill) const;
|
||||
BRect _DrawTriangle(BPoint pt1, BPoint pt2,
|
||||
BPoint pt3, bool fill) const;
|
||||
|
||||
template<typename sourcePixel>
|
||||
void _TransparentMagicToAlpha(sourcePixel *buffer,
|
||||
@ -259,39 +235,37 @@ class Painter {
|
||||
sourcePixel transparentMagic,
|
||||
BBitmap *output) const;
|
||||
|
||||
void _DrawBitmap( agg::rendering_buffer& srcBuffer,
|
||||
color_space format,
|
||||
BRect actualBitmapRect,
|
||||
BRect bitmapRect,
|
||||
BRect viewRect,
|
||||
uint32 bitmapFlags) const;
|
||||
void _DrawBitmap(agg::rendering_buffer& srcBuffer,
|
||||
color_space format,
|
||||
BRect actualBitmapRect,
|
||||
BRect bitmapRect, BRect viewRect,
|
||||
uint32 bitmapFlags) const;
|
||||
template <class F>
|
||||
void _DrawBitmapNoScale32(
|
||||
F copyRowFunction,
|
||||
uint32 bytesPerSourcePixel,
|
||||
agg::rendering_buffer& srcBuffer,
|
||||
int32 xOffset, int32 yOffset,
|
||||
BRect viewRect) const;
|
||||
void _DrawBitmapNoScale32( F copyRowFunction,
|
||||
uint32 bytesPerSourcePixel,
|
||||
agg::rendering_buffer& srcBuffer,
|
||||
int32 xOffset, int32 yOffset,
|
||||
BRect viewRect) const;
|
||||
void _DrawBitmapNearestNeighborCopy32(
|
||||
agg::rendering_buffer& srcBuffer,
|
||||
double xOffset, double yOffset,
|
||||
double xScale, double yScale,
|
||||
BRect viewRect) const;
|
||||
agg::rendering_buffer& srcBuffer,
|
||||
double xOffset, double yOffset,
|
||||
double xScale, double yScale,
|
||||
BRect viewRect) const;
|
||||
void _DrawBitmapBilinearCopy32(
|
||||
agg::rendering_buffer& srcBuffer,
|
||||
double xOffset, double yOffset,
|
||||
double xScale, double yScale,
|
||||
BRect viewRect) const;
|
||||
agg::rendering_buffer& srcBuffer,
|
||||
double xOffset, double yOffset,
|
||||
double xScale, double yScale,
|
||||
BRect viewRect) const;
|
||||
void _DrawBitmapGeneric32(
|
||||
agg::rendering_buffer& srcBuffer,
|
||||
double xOffset, double yOffset,
|
||||
double xScale, double yScale,
|
||||
BRect viewRect,
|
||||
uint32 bitmapFlags) const;
|
||||
agg::rendering_buffer& srcBuffer,
|
||||
double xOffset, double yOffset,
|
||||
double xScale, double yScale,
|
||||
BRect viewRect,
|
||||
uint32 bitmapFlags) const;
|
||||
|
||||
void _InvertRect32( BRect r) const;
|
||||
void _BlendRect32( const BRect& r,
|
||||
const rgb_color& c) const;
|
||||
void _InvertRect32(BRect r) const;
|
||||
void _BlendRect32(const BRect& r,
|
||||
const rgb_color& c) const;
|
||||
|
||||
|
||||
template<class VertexSource>
|
||||
@ -308,23 +282,23 @@ class Painter {
|
||||
void _MakeGradient(Array& array,
|
||||
const BGradient& gradient) const;
|
||||
template<class VertexSource>
|
||||
BRect _FillPathGradient(VertexSource& path,
|
||||
const BGradient& gradient) const;
|
||||
BRect _FillPath(VertexSource& path,
|
||||
const BGradient& gradient) const;
|
||||
template<class VertexSource>
|
||||
void _FillPathGradientLinear(VertexSource& path,
|
||||
const BGradientLinear& linear) const;
|
||||
const BGradientLinear& linear) const;
|
||||
template<class VertexSource>
|
||||
void _FillPathGradientRadial(VertexSource& path,
|
||||
const BGradientRadial& radial) const;
|
||||
const BGradientRadial& radial) const;
|
||||
template<class VertexSource>
|
||||
void _FillPathGradientRadialFocus(VertexSource& path,
|
||||
const BGradientRadialFocus& focus) const;
|
||||
const BGradientRadialFocus& focus) const;
|
||||
template<class VertexSource>
|
||||
void _FillPathGradientDiamond(VertexSource& path,
|
||||
const BGradientDiamond& diamond) const;
|
||||
const BGradientDiamond& diamond) const;
|
||||
template<class VertexSource>
|
||||
void _FillPathGradientConic(VertexSource& path,
|
||||
const BGradientConic& conic) const;
|
||||
const BGradientConic& conic) const;
|
||||
|
||||
mutable agg::rendering_buffer fBuffer;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user