From 10aef7cbc0b763cec9f6e7341f73931c245c2461 Mon Sep 17 00:00:00 2001 From: DarkWyrm Date: Mon, 28 Jul 2003 19:13:24 +0000 Subject: [PATCH] Retooled pattern passing - much neater now. :) git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4119 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/servers/app/DisplayDriver.h | 39 ++++----- headers/private/servers/app/PatternHandler.h | 46 ++++++++-- src/servers/app/server/AccelerantDriver.cpp | 47 ++++++----- src/servers/app/server/AccelerantDriver.h | 37 ++++---- src/servers/app/server/BitmapDriver.cpp | 32 +++---- src/servers/app/server/BitmapDriver.h | 36 ++++---- src/servers/app/server/DefaultDecorator.cpp | 43 +++++----- src/servers/app/server/DisplayDriver.cpp | 76 ++++++++--------- src/servers/app/server/PatternHandler.cpp | 59 +++++++++++-- src/servers/app/server/PicturePlayer.cpp | 30 +++---- src/servers/app/server/PicturePlayer.h | 2 +- src/servers/app/server/RootLayer.cpp | 4 +- src/servers/app/server/ScreenDriver.cpp | 88 ++++++++++---------- src/servers/app/server/ScreenDriver.h | 37 ++++---- src/servers/app/server/ViewDriver.cpp | 88 ++++++++++---------- src/servers/app/server/ViewDriver.h | 36 ++++---- 16 files changed, 386 insertions(+), 314 deletions(-) diff --git a/headers/private/servers/app/DisplayDriver.h b/headers/private/servers/app/DisplayDriver.h index 9a9228efde..c00f22f2aa 100644 --- a/headers/private/servers/app/DisplayDriver.h +++ b/headers/private/servers/app/DisplayDriver.h @@ -37,6 +37,7 @@ #include #include "RGBColor.h" #include +#include "PatternHandler.h" class ServerCursor; class ServerBitmap; @@ -102,15 +103,15 @@ public: virtual void DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest, LayerData *d); virtual void DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *delta=NULL); - virtual void FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat); - virtual void FillBezier(BPoint *pts, LayerData *d, int8 *pat); - virtual void FillEllipse(BRect r, LayerData *d, int8 *pat); - virtual void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat); - virtual void FillRect(BRect r, LayerData *d, int8 *pat); - virtual void FillRegion(BRegion *r, LayerData *d, int8 *pat); - virtual void FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat); -// virtual void FillShape(SShape *sh, LayerData *d, int8 *pat); - virtual void FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat); + virtual void FillArc(BRect r, float angle, float span, LayerData *d, const Pattern &pat); + virtual void FillBezier(BPoint *pts, LayerData *d, const Pattern &pat); + virtual void FillEllipse(BRect r, LayerData *d, const Pattern &pat); + virtual void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, const Pattern &pat); + virtual void FillRect(BRect r, LayerData *d, const Pattern &pat); + virtual void FillRegion(BRegion *r, LayerData *d, const Pattern &pat); + virtual void FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, const Pattern &pat); +// virtual void FillShape(SShape *sh, LayerData *d, const Pattern &pat); + virtual void FillTriangle(BPoint *pts, BRect r, LayerData *d, const Pattern &pat); virtual void HideCursor(void); virtual bool IsCursorHidden(void); @@ -120,16 +121,16 @@ public: virtual void ObscureCursor(void); virtual void SetCursor(ServerCursor *cursor); - virtual void StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat); - virtual void StrokeBezier(BPoint *pts, LayerData *d, int8 *pat); - virtual void StrokeEllipse(BRect r, LayerData *d, int8 *pat); - virtual void StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat); - virtual void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed=true); - virtual void StrokeRect(BRect r, LayerData *d, int8 *pat); - virtual void StrokeRegion(BRegion *r, LayerData *d, int8 *pat); - virtual void StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat); -// virtual void StrokeShape(SShape *sh, LayerData *d, int8 *pat); - virtual void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat); + virtual void StrokeArc(BRect r, float angle, float span, LayerData *d, const Pattern &pat); + virtual void StrokeBezier(BPoint *pts, LayerData *d, const Pattern &pat); + virtual void StrokeEllipse(BRect r, LayerData *d, const Pattern &pat); + virtual void StrokeLine(BPoint start, BPoint end, LayerData *d, const Pattern &pat); + virtual void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, const Pattern &pat, bool is_closed=true); + virtual void StrokeRect(BRect r, LayerData *d, const Pattern &pat); + virtual void StrokeRegion(BRegion *r, LayerData *d, const Pattern &pat); + virtual void StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, const Pattern &pat); +// virtual void StrokeShape(SShape *sh, LayerData *d, const Pattern &pat); + virtual void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, const Pattern &pat); virtual void StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d); virtual void SetMode(int32 mode); virtual bool DumpToFile(const char *path); diff --git a/headers/private/servers/app/PatternHandler.h b/headers/private/servers/app/PatternHandler.h index 3d22f19a17..ccfa1e5dc9 100644 --- a/headers/private/servers/app/PatternHandler.h +++ b/headers/private/servers/app/PatternHandler.h @@ -25,15 +25,43 @@ // //------------------------------------------------------------------------------ #ifndef PATTERNHADLER_H +#define PATTERNHADLER_H #include #include "RGBColor.h" -typedef union +class Pattern { - uint64 type64; - int8 type8[8]; -} pattern_union; +public: + + Pattern(void) {} + + Pattern(const uint64 &pat) { _pat.type64=pat; } + + Pattern(int8 *pat) { _pat.type64=*((uint64*)pat); } + + Pattern(const Pattern &src) { _pat.type64=src._pat.type64; } + + const int8 *GetInt8(void) const { return _pat.type8; } + + uint64 GetInt64(void) const { return _pat.type64; } + + void Set(int8 *pat) { _pat.type64=*((uint64*)pat); } + + void Set(const uint64 &pat) { _pat.type64=pat; } + + Pattern & operator=(const Pattern &from) { _pat.type64=from._pat.type64; return *this; } + Pattern & operator=(const int64 &from) { _pat.type64=from; return *this; } +private: + + typedef union + { + uint64 type64; + int8 type8[8]; + } pattern_union; + + pattern_union _pat; +}; /*! \brief Class for easy calculation and use of patterns @@ -48,16 +76,24 @@ class PatternHandler public: PatternHandler(void); PatternHandler(int8 *pat); + PatternHandler(const uint64 &pat); + PatternHandler(const Pattern &pat); ~PatternHandler(void); void SetTarget(int8 *pat); + void SetTarget(const uint64 &pat); + void SetTarget(const Pattern &pat); void SetColors(const RGBColor &high, const RGBColor &low); RGBColor GetColor(const BPoint &pt); RGBColor GetColor(const float &x, const float &y); bool GetValue(const float &x, const float &y); bool GetValue(const BPoint &pt); private: - pattern_union _pat; + Pattern _pat; RGBColor *_high,*_low; }; +extern const Pattern pat_solidhigh; +extern const Pattern pat_solidlow; +extern const Pattern pat_mixedcolors; + #endif diff --git a/src/servers/app/server/AccelerantDriver.cpp b/src/servers/app/server/AccelerantDriver.cpp index aced0755d5..12c1a85721 100644 --- a/src/servers/app/server/AccelerantDriver.cpp +++ b/src/servers/app/server/AccelerantDriver.cpp @@ -507,7 +507,7 @@ void AccelerantDriver::DrawString(const char *string, int32 length, BPoint pt, L Bounds checking must be done in this call because only part of the arc may end up being clipped. */ -void AccelerantDriver::FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat) +void AccelerantDriver::FillArc(BRect r, float angle, float span, LayerData *d, const Pattern &pat) { float xc = (r.left+r.right)/2; float yc = (r.top+r.bottom)/2; @@ -1050,7 +1050,7 @@ void AccelerantDriver::FillArc(BRect r, float angle, float span, LayerData *d, i I am not sure if this correctly handles cases where the curve backtracks along the diagonal line. I should probably investigate how the be code handles that, but it is a low priority. */ -void AccelerantDriver::FillBezier(BPoint *pts, LayerData *d, int8 *pat) +void AccelerantDriver::FillBezier(BPoint *pts, LayerData *d, const Pattern &pat) { double Ax, Bx, Cx, Dx; double Ay, By, Cy, Dy; @@ -1129,7 +1129,7 @@ void AccelerantDriver::FillBezier(BPoint *pts, LayerData *d, int8 *pat) Bounds checking must be done in this call because only part of the ellipse may end up being clipped. */ -void AccelerantDriver::FillEllipse(BRect r, LayerData *d, int8 *pat) +void AccelerantDriver::FillEllipse(BRect r, LayerData *d, const Pattern &pat) { float xc = (r.left+r.right)/2; float yc = (r.top+r.bottom)/2; @@ -1216,7 +1216,7 @@ void AccelerantDriver::FillEllipse(BRect r, LayerData *d, int8 *pat) The points in the array are not guaranteed to be within the framebuffer's coordinate range. */ -void AccelerantDriver::FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat) +void AccelerantDriver::FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, const Pattern &pat) { /* Here's the plan. Record all line segments in polygon. If a line segments crosses the y-value of a point not in the segment, split the segment into 2 segments. @@ -1349,9 +1349,10 @@ void AccelerantDriver::FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, Lay \param pat 8-byte array containing the pattern to use. Always non-NULL. */ -void AccelerantDriver::FillRect(BRect r, LayerData *d, int8 *pat) +void AccelerantDriver::FillRect(BRect r, LayerData *d, const Pattern &pattern) { Lock(); + const int8 *pat=pattern.GetInt8(); #ifndef DISABLE_HARDWARE_ACCELERATION if ( accFillRect && AcquireEngine && (((uint8)*pat == 0xFF) || (*pat == 0)) ) { @@ -1431,8 +1432,8 @@ void AccelerantDriver::FillRect(BRect r, LayerData *d, int8 *pat) } #endif - PatternHandler pattern(pat); - pattern.SetColors(d->highcolor, d->lowcolor); + PatternHandler pathandler(pattern); + pathandler.SetColors(d->highcolor, d->lowcolor); switch (mDisplayMode.space) { @@ -1445,7 +1446,7 @@ void AccelerantDriver::FillRect(BRect r, LayerData *d, int8 *pat) { for (x=(int)r.left; x<=r.right; x++) { - fb[x] = pattern.GetColor(x,y).GetColor8(); + fb[x] = pathandler.GetColor(x,y).GetColor8(); } fb += mFrameBufferConfig.bytes_per_row; } @@ -1463,7 +1464,7 @@ void AccelerantDriver::FillRect(BRect r, LayerData *d, int8 *pat) { for (x=(int)r.left; x<=r.right; x++) { - fb[x] = pattern.GetColor(x,y).GetColor16(); + fb[x] = pathandler.GetColor(x,y).GetColor16(); } fb = (uint16 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row); } @@ -1480,7 +1481,7 @@ void AccelerantDriver::FillRect(BRect r, LayerData *d, int8 *pat) { for (x=(int)r.left; x<=r.right; x++) { - color = pattern.GetColor(x,y).GetColor32(); + color = pathandler.GetColor(x,y).GetColor32(); fb[x] = (color.alpha << 24) | (color.red << 16) | (color.green << 8) | (color.blue); } fb = (uint32 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row); @@ -1504,7 +1505,7 @@ void AccelerantDriver::FillRect(BRect r, LayerData *d, int8 *pat) Bounds checking must be done in this call because only part of the roundrect may end up being clipped. */ -void AccelerantDriver::FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat) +void AccelerantDriver::FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, const Pattern &pat) { float arc_x; float yrad2 = yrad*yrad; @@ -1530,7 +1531,7 @@ void AccelerantDriver::FillRoundRect(BRect r, float xrad, float yrad, LayerData Unlock(); } -//void AccelerantDriver::FillShape(SShape *sh, LayerData *d, int8 *pat) +//void AccelerantDriver::FillShape(SShape *sh, LayerData *d, const Pattern &pat) //{ //} @@ -1545,9 +1546,9 @@ void AccelerantDriver::FillRoundRect(BRect r, float xrad, float yrad, LayerData Bounds checking must be done in this call because only part of the triangle may end up being clipped. */ -void AccelerantDriver::FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat) +void AccelerantDriver::FillTriangle(BPoint *pts, BRect r, LayerData *d, const Pattern &pat) { - if(!pts || !d || !pat) + if(!pts || !d) return; Lock(); @@ -1927,7 +1928,7 @@ void AccelerantDriver::SetCursor(ServerCursor *csr) Bounds checking must be done in this call because only part of the arc may end up being clipped. -*/void AccelerantDriver::StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat) +*/void AccelerantDriver::StrokeArc(BRect r, float angle, float span, LayerData *d, const Pattern &pat) { float xc = (r.left+r.right)/2; float yc = (r.top+r.bottom)/2; @@ -2094,7 +2095,7 @@ void AccelerantDriver::SetCursor(ServerCursor *csr) Bounds checking must be done in this call. */ -void AccelerantDriver::StrokeBezier(BPoint *pts, LayerData *d, int8 *pat) +void AccelerantDriver::StrokeBezier(BPoint *pts, LayerData *d, const Pattern &pat) { double Ax, Bx, Cx, Dx; double Ay, By, Cy, Dy; @@ -2162,7 +2163,7 @@ void AccelerantDriver::StrokeBezier(BPoint *pts, LayerData *d, int8 *pat) Bounds checking must be done in this call because only part of the ellipse may end up being clipped. */ -void AccelerantDriver::StrokeEllipse(BRect r, LayerData *d, int8 *pat) +void AccelerantDriver::StrokeEllipse(BRect r, LayerData *d, const Pattern &pat) { float xc = (r.left+r.right)/2; float yc = (r.top+r.bottom)/2; @@ -2244,7 +2245,7 @@ void AccelerantDriver::StrokeEllipse(BRect r, LayerData *d, int8 *pat) a thickness greater than 1 will need to be done. This is capable of handling lines with invalid points. */ -void AccelerantDriver::StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat) +void AccelerantDriver::StrokeLine(BPoint start, BPoint end, LayerData *d, const Pattern &pat) { int x1 = ROUND(start.x); int y1 = ROUND(start.y); @@ -2292,7 +2293,7 @@ void AccelerantDriver::StrokeLine(BPoint start, BPoint end, LayerData *d, int8 * The points in the array are not guaranteed to be within the framebuffer's coordinate range. */ -void AccelerantDriver::StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed) +void AccelerantDriver::StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, const Pattern &pat, bool is_closed) { /* Bounds checking is handled by StrokeLine and the functions it uses */ Lock(); @@ -2310,7 +2311,7 @@ void AccelerantDriver::StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, L \param pat 8-byte array containing the pattern to use. Always non-NULL. */ -void AccelerantDriver::StrokeRect(BRect r, LayerData *d, int8 *pat) +void AccelerantDriver::StrokeRect(BRect r, LayerData *d, const Pattern &pat) { Lock(); int thick = (int)d->pensize; @@ -2335,7 +2336,7 @@ void AccelerantDriver::StrokeRect(BRect r, LayerData *d, int8 *pat) Bounds checking must be done in this call because only part of the roundrect may end up being clipped. */ -void AccelerantDriver::StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat) +void AccelerantDriver::StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, const Pattern &pat) { float hLeft, hRight; float vTop, vBottom; @@ -2367,7 +2368,7 @@ void AccelerantDriver::StrokeRoundRect(BRect r, float xrad, float yrad, LayerDat Unlock(); } -//void AccelerantDriver::StrokeShape(SShape *sh, LayerData *d, int8 *pat) +//void AccelerantDriver::StrokeShape(SShape *sh, LayerData *d, const Pattern &pat) //{ //} @@ -2382,7 +2383,7 @@ void AccelerantDriver::StrokeRoundRect(BRect r, float xrad, float yrad, LayerDat Bounds checking must be done in this call because only part of the triangle may end up being clipped. */ -void AccelerantDriver::StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat) +void AccelerantDriver::StrokeTriangle(BPoint *pts, BRect r, LayerData *d, const Pattern &pat) { /* Bounds checking is handled by StrokeLine and the functions it calls */ Lock(); diff --git a/src/servers/app/server/AccelerantDriver.h b/src/servers/app/server/AccelerantDriver.h index bbee280e81..3712d18e2b 100644 --- a/src/servers/app/server/AccelerantDriver.h +++ b/src/servers/app/server/AccelerantDriver.h @@ -42,9 +42,6 @@ #include #include "DisplayDriver.h" #include "PatternHandler.h" -//#include -//#include FT_FREETYPE_H -//#include FT_GLYPH_H #include "FontServer.h" #if 0 class VDWindow; @@ -68,14 +65,14 @@ public: virtual void DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest, LayerData *d); virtual void DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *edelta=NULL); - virtual void FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat); - virtual void FillBezier(BPoint *pts, LayerData *d, int8 *pat); - virtual void FillEllipse(BRect r, LayerData *d, int8 *pat); - virtual void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat); - virtual void FillRect(BRect r, LayerData *d, int8 *pat); - virtual void FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat); -// virtual void FillShape(SShape *sh, LayerData *d, int8 *pat); - virtual void FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat); + virtual void FillArc(BRect r, float angle, float span, LayerData *d, const Pattern &pat); + virtual void FillBezier(BPoint *pts, LayerData *d, const Pattern &pat); + virtual void FillEllipse(BRect r, LayerData *d, const Pattern &pat); + virtual void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, const Pattern &pat); + virtual void FillRect(BRect r, LayerData *d, const Pattern &pat); + virtual void FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, const Pattern &pat); +// virtual void FillShape(SShape *sh, LayerData *d, const Pattern &pat); + virtual void FillTriangle(BPoint *pts, BRect r, LayerData *d, const Pattern &pat); virtual void HideCursor(void); virtual void MoveCursorTo(float x, float y); @@ -84,15 +81,15 @@ public: virtual void ObscureCursor(void); virtual void SetCursor(ServerCursor *csr); - virtual void StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat); - virtual void StrokeBezier(BPoint *pts, LayerData *d, int8 *pat); - virtual void StrokeEllipse(BRect r, LayerData *d, int8 *pat); - virtual void StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat); - virtual void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed=true); - virtual void StrokeRect(BRect r, LayerData *d, int8 *pat); - virtual void StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat); -// virtual void StrokeShape(SShape *sh, LayerData *d, int8 *pat); - virtual void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat); + virtual void StrokeArc(BRect r, float angle, float span, LayerData *d, const Pattern &pat); + virtual void StrokeBezier(BPoint *pts, LayerData *d, const Pattern &pat); + virtual void StrokeEllipse(BRect r, LayerData *d, const Pattern &pat); + virtual void StrokeLine(BPoint start, BPoint end, LayerData *d, const Pattern &pat); + virtual void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, const Pattern &pat, bool is_closed=true); + virtual void StrokeRect(BRect r, LayerData *d, const Pattern &pat); + virtual void StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, const Pattern &pat); +// virtual void StrokeShape(SShape *sh, LayerData *d, const Pattern &pat); + virtual void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, const Pattern &pat); virtual void StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d); virtual void SetMode(int32 mode); virtual bool DumpToFile(const char *path); diff --git a/src/servers/app/server/BitmapDriver.cpp b/src/servers/app/server/BitmapDriver.cpp index fe74a6e058..441e1c6e72 100644 --- a/src/servers/app/server/BitmapDriver.cpp +++ b/src/servers/app/server/BitmapDriver.cpp @@ -205,7 +205,7 @@ void BitmapDriver::DrawBitmap(ServerBitmap *bitmap, BRect source, BRect dest, La Bounds checking must be done in this call because only part of the arc may end up being clipped. */ -void BitmapDriver::FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat) +void BitmapDriver::FillArc(BRect r, float angle, float span, LayerData *d, const Pattern &pat) { } @@ -218,7 +218,7 @@ void BitmapDriver::FillArc(BRect r, float angle, float span, LayerData *d, int8 Bounds checking must be done in this call. */ -void BitmapDriver::FillBezier(BPoint *pts, LayerData *d, int8 *pat) +void BitmapDriver::FillBezier(BPoint *pts, LayerData *d, const Pattern &pat) { } @@ -231,7 +231,7 @@ void BitmapDriver::FillBezier(BPoint *pts, LayerData *d, int8 *pat) Bounds checking must be done in this call because only part of the ellipse may end up being clipped. */ -void BitmapDriver::FillEllipse(BRect r, LayerData *ldata, int8 *pat) +void BitmapDriver::FillEllipse(BRect r, LayerData *ldata, const Pattern &pat) { // Ellipse code shamelessly stolen from the graphics library gd v2.0.1 and bolted on // to support our API @@ -326,7 +326,7 @@ void BitmapDriver::FillEllipse(BRect r, LayerData *ldata, int8 *pat) \param pat 8-byte array containing the pattern to use. Always non-NULL. */ -void BitmapDriver::FillRect(BRect r, LayerData *d, int8 *pat) +void BitmapDriver::FillRect(BRect r, LayerData *d, const Pattern &pat) { Lock(); if(_target) @@ -350,7 +350,7 @@ void BitmapDriver::FillRect(BRect r, LayerData *d, int8 *pat) Bounds checking must be done in this call because only part of the roundrect may end up being clipped. */ -void BitmapDriver::FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat) +void BitmapDriver::FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, const Pattern &pat) { printf("BitmapDriver::FillRoundRect unimplemented\n"); StrokeRoundRect(r,xrad,yrad,d,pat); @@ -367,9 +367,9 @@ void BitmapDriver::FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, Bounds checking must be done in this call because only part of the triangle may end up being clipped. */ -void BitmapDriver::FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat) +void BitmapDriver::FillTriangle(BPoint *pts, BRect r, LayerData *d, const Pattern &pat) { - if(!pts || !d || !pat) + if(!pts || !d) return; Lock(); @@ -622,7 +622,7 @@ void BitmapDriver::SetMode(int32 space) Bounds checking must be done in this call because only part of the arc may end up being clipped. */ -void BitmapDriver::StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat) +void BitmapDriver::StrokeArc(BRect r, float angle, float span, LayerData *d, const Pattern &pat) { // TODO: Add pattern support float xc = (r.left+r.right)/2; @@ -783,7 +783,7 @@ void BitmapDriver::StrokeArc(BRect r, float angle, float span, LayerData *d, int Bounds checking must be done in this call. */ -void BitmapDriver::StrokeBezier(BPoint *pts, LayerData *d, int8 *pat) +void BitmapDriver::StrokeBezier(BPoint *pts, LayerData *d, const Pattern &pat) { // TODO: Add pattern support double Ax, Bx, Cx, Dx; @@ -846,7 +846,7 @@ void BitmapDriver::StrokeBezier(BPoint *pts, LayerData *d, int8 *pat) Bounds checking must be done in this call because only part of the ellipse may end up being clipped. */ -void BitmapDriver::StrokeEllipse(BRect r, LayerData *ldata, int8 *pat) +void BitmapDriver::StrokeEllipse(BRect r, LayerData *ldata, const Pattern &pat) { // Ellipse code shamelessly stolen from the graphics library gd v2.0.1 and bolted on // to support our API @@ -951,7 +951,7 @@ void BitmapDriver::StrokeEllipse(BRect r, LayerData *ldata, int8 *pat) The endpoints themselves are guaranteed to be in bounds, but clipping for lines with a thickness greater than 1 will need to be done. */ -void BitmapDriver::StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat) +void BitmapDriver::StrokeLine(BPoint start, BPoint end, LayerData *d, const Pattern &pat) { Lock(); if(_target) @@ -1008,7 +1008,7 @@ void BitmapDriver::StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat) The points in the array are not guaranteed to be within the framebuffer's coordinate range. */ -void BitmapDriver::StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed) +void BitmapDriver::StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, const Pattern &pat, bool is_closed) { Lock(); if(_target) @@ -1029,7 +1029,7 @@ void BitmapDriver::StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, Layer \param pat 8-byte array containing the pattern to use. Always non-NULL. */ -void BitmapDriver::StrokeRect(BRect r, LayerData *d, int8 *pat) +void BitmapDriver::StrokeRect(BRect r, LayerData *d, const Pattern &pat) { Lock(); if(_target) @@ -1053,7 +1053,7 @@ void BitmapDriver::StrokeRect(BRect r, LayerData *d, int8 *pat) Bounds checking must be done in this call because only part of the roundrect may end up being clipped. */ -void BitmapDriver::StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat) +void BitmapDriver::StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, const Pattern &pat) { float hLeft, hRight; float vTop, vBottom; @@ -1095,7 +1095,7 @@ void BitmapDriver::StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d Bounds checking must be done in this call because only part of the triangle may end up being clipped. */ -void BitmapDriver::StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat) +void BitmapDriver::StrokeTriangle(BPoint *pts, BRect r, LayerData *d, const Pattern &pat) { Lock(); if(_target) @@ -1151,7 +1151,7 @@ void BitmapDriver::SetPixelPattern(int x, int y, uint8 *pattern, uint8 patternin } } -void BitmapDriver::Line(BPoint start, BPoint end, LayerData *d, int8 *pat) +void BitmapDriver::Line(BPoint start, BPoint end, LayerData *d, const Pattern &pat) { // Internal function which is called from within other functions diff --git a/src/servers/app/server/BitmapDriver.h b/src/servers/app/server/BitmapDriver.h index 54a91fc3f0..9113604377 100644 --- a/src/servers/app/server/BitmapDriver.h +++ b/src/servers/app/server/BitmapDriver.h @@ -79,14 +79,14 @@ public: // virtual void DrawPicture(SPicture *pic, BPoint pt); virtual void DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *delta=NULL); - virtual void FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat); - virtual void FillBezier(BPoint *pts, LayerData *d, int8 *pat); - virtual void FillEllipse(BRect r, LayerData *d, int8 *pat); -// virtual void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat); - virtual void FillRect(BRect r, LayerData *d, int8 *pat); - virtual void FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat); -// virtual void FillShape(SShape *sh, LayerData *d, int8 *pat); - virtual void FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat); + virtual void FillArc(BRect r, float angle, float span, LayerData *d, const Pattern &pat); + virtual void FillBezier(BPoint *pts, LayerData *d, const Pattern &pat); + virtual void FillEllipse(BRect r, LayerData *d, const Pattern &pat); +// virtual void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, const Pattern &pat); + virtual void FillRect(BRect r, LayerData *d, const Pattern &pat); + virtual void FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, const Pattern &pat); +// virtual void FillShape(SShape *sh, LayerData *d, const Pattern &pat); + virtual void FillTriangle(BPoint *pts, BRect r, LayerData *d, const Pattern &pat); virtual void HideCursor(void); virtual void MoveCursorTo(float x, float y); @@ -95,15 +95,15 @@ public: virtual void ObscureCursor(void); virtual void SetCursor(ServerCursor *cursor); - virtual void StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat); - virtual void StrokeBezier(BPoint *pts, LayerData *d, int8 *pat); - virtual void StrokeEllipse(BRect r, LayerData *d, int8 *pat); - virtual void StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat); - virtual void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed=true); - virtual void StrokeRect(BRect r, LayerData *d, int8 *pat); - virtual void StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat); -// virtual void StrokeShape(SShape *sh, LayerData *d, int8 *pat); - virtual void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat); + virtual void StrokeArc(BRect r, float angle, float span, LayerData *d, const Pattern &pat); + virtual void StrokeBezier(BPoint *pts, LayerData *d, const Pattern &pat); + virtual void StrokeEllipse(BRect r, LayerData *d, const Pattern &pat); + virtual void StrokeLine(BPoint start, BPoint end, LayerData *d, const Pattern &pat); + virtual void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, const Pattern &pat, bool is_closed=true); + virtual void StrokeRect(BRect r, LayerData *d, const Pattern &pat); + virtual void StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, const Pattern &pat); +// virtual void StrokeShape(SShape *sh, LayerData *d, const Pattern &pat); + virtual void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, const Pattern &pat); // virtual void StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d); virtual void SetMode(int32 mode); float StringWidth(const char *string, int32 length, LayerData *d); @@ -115,7 +115,7 @@ protected: void BlitBitmap(ServerBitmap *sourcebmp, BRect sourcerect, BRect destrect, drawing_mode mode=B_OP_COPY); void ExtractToBitmap(ServerBitmap *destbmp, BRect destrect, BRect sourcerect); void SetPixelPattern(int x, int y, uint8 *pattern, uint8 patternindex); - void Line(BPoint start, BPoint end, LayerData *d, int8 *pat); + void Line(BPoint start, BPoint end, LayerData *d, const Pattern &pat); void HLine(int32 x1, int32 x2, int32 y, RGBColor color); void HLineThick(int32 x1, int32 x2, int32 y, int32 thick, PatternHandler *pat); rgb_color GetBlitColor(rgb_color src, rgb_color dest, LayerData *d, bool use_high=true); diff --git a/src/servers/app/server/DefaultDecorator.cpp b/src/servers/app/server/DefaultDecorator.cpp index c1c881598e..5db23eb899 100644 --- a/src/servers/app/server/DefaultDecorator.cpp +++ b/src/servers/app/server/DefaultDecorator.cpp @@ -61,8 +61,6 @@ DefaultDecorator::DefaultDecorator(BRect rect, int32 wlook, int32 wfeel, int32 w // This flag is used to determine whether or not we're moving the tab slidetab=false; - solidhigh=0xFFFFFFFFFFFFFFFFLL; - solidlow=0; // tab_highcol=_colors->window_tab; // tab_lowcol=_colors->window_tab; @@ -339,7 +337,7 @@ printf("DefaultDecorator: Draw(%.1f,%.1f,%.1f,%.1f)\n",update.left,update.top,up _layerdata.highcolor=_colors->document_background; if(_borderrect.Intersects(update)) - _driver->FillRect(_borderrect & update,&_layerdata,(int8*)&solidhigh); + _driver->FillRect(_borderrect & update,&_layerdata,pat_solidhigh); _DrawFrame(update); @@ -353,7 +351,7 @@ void DefaultDecorator::Draw(void) // Draw the top view's client area - just a hack :) // _layerdata.highcolor=_colors->document_background; -// _driver->FillRect(_borderrect,&_layerdata,(int8*)&solidhigh); +// _driver->FillRect(_borderrect,&_layerdata,pat_solidhigh); DrawFrame(); @@ -386,9 +384,9 @@ void DefaultDecorator::_DrawTab(BRect r) return; _layerdata.highcolor=(GetFocus())?_colors->window_tab:_colors->inactive_window_tab; - _driver->FillRect(_tabrect,&_layerdata,(int8*)&solidhigh); + _driver->FillRect(_tabrect,&_layerdata,pat_solidhigh); _layerdata.highcolor=framecolors[3]; - _driver->StrokeLine(_tabrect.LeftBottom(),_tabrect.RightBottom(),&_layerdata,(int8*)&solidhigh); + _driver->StrokeLine(_tabrect.LeftBottom(),_tabrect.RightBottom(),&_layerdata,pat_solidhigh); _DrawTitle(_tabrect); @@ -442,7 +440,7 @@ void DefaultDecorator::DrawBlendedRect(BRect r, bool down) uint8(startcol.blue-(i*bstep))); _layerdata.highcolor=tmpcol; _driver->StrokeLine(BPoint(r.left,r.top+i), - BPoint(r.left+i,r.top),&_layerdata,(int8*)&solidhigh); + BPoint(r.left+i,r.top),&_layerdata,pat_solidhigh); SetRGBColor(&tmpcol, uint8(halfcol.red-(i*rstep)), uint8(halfcol.green-(i*gstep)), @@ -450,14 +448,14 @@ void DefaultDecorator::DrawBlendedRect(BRect r, bool down) _layerdata.highcolor=tmpcol; _driver->StrokeLine(BPoint(r.left+steps,r.top+i), - BPoint(r.left+i,r.top+steps),&_layerdata,(int8*)&solidhigh); + BPoint(r.left+i,r.top+steps),&_layerdata,pat_solidhigh); } // _layerdata.highcolor=startcol; -// _driver->FillRect(r,&_layerdata,(int8*)&solidhigh); +// _driver->FillRect(r,&_layerdata,pat_solidhigh); _layerdata.highcolor=framecolors[3]; - _driver->StrokeRect(r,&_layerdata,(int8*)&solidhigh); + _driver->StrokeRect(r,&_layerdata,pat_solidhigh); } void DefaultDecorator::_DrawFrame(BRect invalid) @@ -467,7 +465,7 @@ void DefaultDecorator::_DrawFrame(BRect invalid) // we must clip the lines drawn by this function to the invalid rectangle we are given #ifdef USE_VIEW_FILL_HACK - _driver->FillRect(_borderrect,&_layerdata,(int8*)&solidhigh); + _driver->FillRect(_borderrect,&_layerdata,pat_solidhigh); #endif if(!borderwidth) @@ -744,8 +742,6 @@ void DefaultDecorator::_DrawFrame(BRect invalid) // Draw the resize thumb if we're supposed to if(!(_flags & B_NOT_RESIZABLE)) { - pattern_union highcolor; - highcolor.type64=0xffffffffffffffffLL; r=_resizerect; // int32 w=r.IntegerWidth(), h=r.IntegerHeight(); @@ -756,17 +752,18 @@ void DefaultDecorator::_DrawFrame(BRect invalid) r.right-=4; r.bottom-=4; _layerdata.highcolor=framecolors[2]; - _driver->StrokeLine(r.LeftTop(),r.RightTop(),&_layerdata,highcolor.type8); - _driver->StrokeLine(r.LeftTop(),r.LeftBottom(),&_layerdata,highcolor.type8); + + _driver->StrokeLine(r.LeftTop(),r.RightTop(),&_layerdata,pat_solidhigh); + _driver->StrokeLine(r.LeftTop(),r.LeftBottom(),&_layerdata,pat_solidhigh); r.OffsetBy(1,1); _layerdata.highcolor=framecolors[0]; - _driver->StrokeLine(r.LeftTop(),r.RightTop(),&_layerdata,highcolor.type8); - _driver->StrokeLine(r.LeftTop(),r.LeftBottom(),&_layerdata,highcolor.type8); + _driver->StrokeLine(r.LeftTop(),r.RightTop(),&_layerdata,pat_solidhigh); + _driver->StrokeLine(r.LeftTop(),r.LeftBottom(),&_layerdata,pat_solidhigh); r.OffsetBy(1,1); _layerdata.highcolor=framecolors[1]; - _driver->FillRect(r,&_layerdata,highcolor.type8); + _driver->FillRect(r,&_layerdata,pat_solidhigh); /* r.left+=2; r.top+=2; @@ -802,25 +799,25 @@ void DefaultDecorator::_DrawFrame(BRect invalid) uint8(startcol.blue-(i*bstep))); _driver->StrokeLine(BPoint(r.left,r.top+i), - BPoint(r.left+i,r.top),&_layerdata,(int8*)&solidhigh); + BPoint(r.left+i,r.top),&_layerdata,pat_solidhigh); _layerdata.highcolor.SetColor(uint8(halfcol.red-(i*rstep)), uint8(halfcol.green-(i*gstep)), uint8(halfcol.blue-(i*bstep))); _driver->StrokeLine(BPoint(r.left+steps,r.top+i), - BPoint(r.left+i,r.top+steps),&_layerdata,(int8*)&solidhigh); + BPoint(r.left+i,r.top+steps),&_layerdata,pat_solidhigh); } _driver->Unlock(); // _layerdata.highcolor=framecolors[4]; -// _driver->StrokeRect(r,&_layerdata,(int8*)&solidhigh); +// _driver->StrokeRect(r,&_layerdata,pat_solidhigh); } else { _layerdata.highcolor=framecolors[4]; _driver->StrokeLine(BPoint(r.right,r.top),BPoint(r.right-3,r.top), - &_layerdata,(int8*)&solidhigh); + &_layerdata,pat_solidhigh); _driver->StrokeLine(BPoint(r.left,r.bottom),BPoint(r.left,r.bottom-3), - &_layerdata,(int8*)&solidhigh); + &_layerdata,pat_solidhigh); } } diff --git a/src/servers/app/server/DisplayDriver.cpp b/src/servers/app/server/DisplayDriver.cpp index d7fa9c67c5..6845c1b983 100644 --- a/src/servers/app/server/DisplayDriver.cpp +++ b/src/servers/app/server/DisplayDriver.cpp @@ -143,12 +143,12 @@ void DisplayDriver::DrawString(const char *string, int32 length, BPoint pt, Laye \param angle Starting angle for the arc in degrees \param span Span of the arc in degrees. Ending angle = angle+span. \param d Data structure containing any other data necessary for the call. Always non-NULL. - \param pat 8-byte array containing the pattern to use. Always non-NULL. + \param pat 8-byte array containing the const Pattern &to use. Always non-NULL. Bounds checking must be done in this call because only part of the arc may end up being clipped. */ -void DisplayDriver::FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat) +void DisplayDriver::FillArc(BRect r, float angle, float span, LayerData *d, const Pattern &pat) { } @@ -157,11 +157,11 @@ void DisplayDriver::FillArc(BRect r, float angle, float span, LayerData *d, int8 \param pts 4-element array of BPoints in the order of start, end, and then the two control points. \param d Data structure containing any other data necessary for the call. Always non-NULL. - \param pat 8-byte array containing the pattern to use. Always non-NULL. + \param pat 8-byte array containing the const Pattern &to use. Always non-NULL. Bounds checking must be done in this call. */ -void DisplayDriver::FillBezier(BPoint *pts, LayerData *d, int8 *pat) +void DisplayDriver::FillBezier(BPoint *pts, LayerData *d, const Pattern &pat) { } @@ -169,12 +169,12 @@ void DisplayDriver::FillBezier(BPoint *pts, LayerData *d, int8 *pat) \brief Called for all BView::FillEllipse calls \param r BRect enclosing the ellipse to be drawn. \param d Data structure containing any other data necessary for the call. Always non-NULL. - \param pat 8-byte array containing the pattern to use. Always non-NULL. + \param pat 8-byte array containing the const Pattern &to use. Always non-NULL. Bounds checking must be done in this call because only part of the ellipse may end up being clipped. */ -void DisplayDriver::FillEllipse(BRect r, LayerData *d, int8 *pat) +void DisplayDriver::FillEllipse(BRect r, LayerData *d, const Pattern &pat) { } @@ -184,12 +184,12 @@ void DisplayDriver::FillEllipse(BRect r, LayerData *d, int8 *pat) \param numpts Number of points in the BPoint array. \param rect Rectangle which contains the polygon \param d Data structure containing any other data necessary for the call. Always non-NULL. - \param pat 8-byte array containing the pattern to use. Always non-NULL. + \param pat 8-byte array containing the const Pattern &to use. Always non-NULL. The points in the array are not guaranteed to be within the framebuffer's coordinate range. */ -void DisplayDriver::FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat) +void DisplayDriver::FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, const Pattern &pat) { } @@ -197,10 +197,10 @@ void DisplayDriver::FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerD \brief Called for all BView::FillRect calls \param r BRect to be filled. Guaranteed to be in the frame buffer's coordinate space \param d Data structure containing any other data necessary for the call. Always non-NULL. - \param pat 8-byte array containing the pattern to use. Always non-NULL. + \param pat 8-byte array containing the const Pattern &to use. Always non-NULL. */ -void DisplayDriver::FillRect(BRect r, LayerData *d, int8 *pat) +void DisplayDriver::FillRect(BRect r, LayerData *d, const Pattern &pat) { } @@ -208,12 +208,12 @@ void DisplayDriver::FillRect(BRect r, LayerData *d, int8 *pat) \brief Convenience function for server use \param r BRegion to be filled \param d Data structure containing any other data necessary for the call. Always non-NULL. - \param pat 8-byte array containing the pattern to use. Always non-NULL. + \param pat 8-byte array containing the const Pattern &to use. Always non-NULL. */ -void DisplayDriver::FillRegion(BRegion *r, LayerData *d, int8 *pat) +void DisplayDriver::FillRegion(BRegion *r, LayerData *d, const Pattern &pat) { - if(!r || !d || !pat) + if(!r || !d) return; Lock(); @@ -230,16 +230,16 @@ void DisplayDriver::FillRegion(BRegion *r, LayerData *d, int8 *pat) \param xrad X radius of the corner arcs \param yrad Y radius of the corner arcs \param d Data structure containing any other data necessary for the call. Always non-NULL. - \param pat 8-byte array containing the pattern to use. Always non-NULL. + \param pat 8-byte array containing the const Pattern &to use. Always non-NULL. Bounds checking must be done in this call because only part of the roundrect may end up being clipped. */ -void DisplayDriver::FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat) +void DisplayDriver::FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, const Pattern &pat) { } -//void DisplayDriver::FillShape(SShape *sh, LayerData *d, int8 *pat) +//void DisplayDriver::FillShape(SShape *sh, LayerData *d, const Pattern &pat) //{ //} @@ -249,12 +249,12 @@ void DisplayDriver::FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, \param r BRect enclosing the triangle. While it will definitely enclose the triangle, it may not be within the frame buffer's bounds. \param d Data structure containing any other data necessary for the call. Always non-NULL. - \param pat 8-byte array containing the pattern to use. Always non-NULL. + \param pat 8-byte array containing the const Pattern &to use. Always non-NULL. Bounds checking must be done in this call because only part of the triangle may end up being clipped. */ -void DisplayDriver::FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat) +void DisplayDriver::FillTriangle(BPoint *pts, BRect r, LayerData *d, const Pattern &pat) { } @@ -364,12 +364,12 @@ void DisplayDriver::SetCursor(ServerCursor *cursor) \param angle Starting angle for the arc in degrees \param span Span of the arc in degrees. Ending angle = angle+span. \param d Data structure containing any other data necessary for the call. Always non-NULL. - \param pat 8-byte array containing the pattern to use. Always non-NULL. + \param pat 8-byte array containing the const Pattern &to use. Always non-NULL. Bounds checking must be done in this call because only part of the arc may end up being clipped. */ -void DisplayDriver::StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat) +void DisplayDriver::StrokeArc(BRect r, float angle, float span, LayerData *d, const Pattern &pat) { } @@ -378,11 +378,11 @@ void DisplayDriver::StrokeArc(BRect r, float angle, float span, LayerData *d, in \param pts 4-element array of BPoints in the order of start, end, and then the two control points. \param d Data structure containing any other data necessary for the call. Always non-NULL. - \param pat 8-byte array containing the pattern to use. Always non-NULL. + \param pat 8-byte array containing the const Pattern &to use. Always non-NULL. Bounds checking must be done in this call. */ -void DisplayDriver::StrokeBezier(BPoint *pts, LayerData *d, int8 *pat) +void DisplayDriver::StrokeBezier(BPoint *pts, LayerData *d, const Pattern &pat) { } @@ -390,12 +390,12 @@ void DisplayDriver::StrokeBezier(BPoint *pts, LayerData *d, int8 *pat) \brief Called for all BView::StrokeEllipse calls \param r BRect enclosing the ellipse to be drawn. \param d Data structure containing any other data necessary for the call. Always non-NULL. - \param pat 8-byte array containing the pattern to use. Always non-NULL. + \param pat 8-byte array containing the const Pattern &to use. Always non-NULL. Bounds checking must be done in this call because only part of the ellipse may end up being clipped. */ -void DisplayDriver::StrokeEllipse(BRect r, LayerData *d, int8 *pat) +void DisplayDriver::StrokeEllipse(BRect r, LayerData *d, const Pattern &pat) { } @@ -404,12 +404,12 @@ void DisplayDriver::StrokeEllipse(BRect r, LayerData *d, int8 *pat) \param start Starting point \param end Ending point \param d Data structure containing any other data necessary for the call. Always non-NULL. - \param pat 8-byte array containing the pattern to use. Always non-NULL. + \param pat 8-byte array containing the const Pattern &to use. Always non-NULL. The endpoints themselves are guaranteed to be in bounds, but clipping for lines with a thickness greater than 1 will need to be done. */ -void DisplayDriver::StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat) +void DisplayDriver::StrokeLine(BPoint start, BPoint end, LayerData *d, const Pattern &pat) { } @@ -419,12 +419,12 @@ void DisplayDriver::StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat \param numpts Number of points in the BPoint array. \param rect Rectangle which contains the polygon \param d Data structure containing any other data necessary for the call. Always non-NULL. - \param pat 8-byte array containing the pattern to use. Always non-NULL. + \param pat 8-byte array containing the const Pattern &to use. Always non-NULL. The points in the array are not guaranteed to be within the framebuffer's coordinate range. */ -void DisplayDriver::StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed) +void DisplayDriver::StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, const Pattern &pat, bool is_closed) { } @@ -432,10 +432,10 @@ void DisplayDriver::StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, Laye \brief Called for all BView::StrokeRect calls \param r BRect to be filled. Guaranteed to be in the frame buffer's coordinate space \param d Data structure containing any other data necessary for the call. Always non-NULL. - \param pat 8-byte array containing the pattern to use. Always non-NULL. + \param pat 8-byte array containing the const Pattern &to use. Always non-NULL. */ -void DisplayDriver::StrokeRect(BRect r, LayerData *d, int8 *pat) +void DisplayDriver::StrokeRect(BRect r, LayerData *d, const Pattern &pat) { } @@ -443,12 +443,12 @@ void DisplayDriver::StrokeRect(BRect r, LayerData *d, int8 *pat) \brief Convenience function for server use \param r BRegion to be stroked \param d Data structure containing any other data necessary for the call. Always non-NULL. - \param pat 8-byte array containing the pattern to use. Always non-NULL. + \param pat 8-byte array containing the const Pattern &to use. Always non-NULL. */ -void DisplayDriver::StrokeRegion(BRegion *r, LayerData *d, int8 *pat) +void DisplayDriver::StrokeRegion(BRegion *r, LayerData *d, const Pattern &pat) { - if(!r || !d || !pat) + if(!r || !d) return; Lock(); @@ -465,16 +465,16 @@ void DisplayDriver::StrokeRegion(BRegion *r, LayerData *d, int8 *pat) \param xrad X radius of the corner arcs \param yrad Y radius of the corner arcs \param d Data structure containing any other data necessary for the call. Always non-NULL. - \param pat 8-byte array containing the pattern to use. Always non-NULL. + \param pat 8-byte array containing the const Pattern &to use. Always non-NULL. Bounds checking must be done in this call because only part of the roundrect may end up being clipped. */ -void DisplayDriver::StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat) +void DisplayDriver::StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, const Pattern &pat) { } -//void DisplayDriver::StrokeShape(SShape *sh, LayerData *d, int8 *pat) +//void DisplayDriver::StrokeShape(SShape *sh, LayerData *d, const Pattern &pat) //{ //} @@ -484,12 +484,12 @@ void DisplayDriver::StrokeRoundRect(BRect r, float xrad, float yrad, LayerData * \param r BRect enclosing the triangle. While it will definitely enclose the triangle, it may not be within the frame buffer's bounds. \param d Data structure containing any other data necessary for the call. Always non-NULL. - \param pat 8-byte array containing the pattern to use. Always non-NULL. + \param pat 8-byte array containing the const Pattern &to use. Always non-NULL. Bounds checking must be done in this call because only part of the triangle may end up being clipped. */ -void DisplayDriver::StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat) +void DisplayDriver::StrokeTriangle(BPoint *pts, BRect r, LayerData *d, const Pattern &pat) { } diff --git a/src/servers/app/server/PatternHandler.cpp b/src/servers/app/server/PatternHandler.cpp index 33746cde40..5f0b7620fd 100644 --- a/src/servers/app/server/PatternHandler.cpp +++ b/src/servers/app/server/PatternHandler.cpp @@ -27,6 +27,10 @@ #include #include "PatternHandler.h" +const Pattern pat_solidhigh(0xFFFFFFFFFFFFFFFFLL); +const Pattern pat_solidlow((uint64)0); +const Pattern pat_mixedcolors(0xAAAAAAAAAAAAAAAALL); + /*! \brief Void constructor @@ -35,7 +39,7 @@ */ PatternHandler::PatternHandler(void) { - _pat.type64=0xFFFFFFFFLL; + _pat=0xFFFFFFFFFFFFFFFFLL; _high=new RGBColor(0,0,0,255); _low=new RGBColor(255,255,255,255); } @@ -50,14 +54,35 @@ PatternHandler::PatternHandler(void) PatternHandler::PatternHandler(int8 *pat) { if(pat) - _pat.type64=*((uint64*)pat); + _pat.Set(pat); else - _pat.type64=0xFFFFFFFFLL; + _pat=0xFFFFFFFFFFFFFFFFLL; _high=new RGBColor(0,0,0,255); _low=new RGBColor(255,255,255,255); } +/*! + \brief Constructor initializes to given pattern + \param pat Pattern to use. + + This initializes to the given pattern or B_SOLID_HIGH if the pattern + is NULL. High color is set to black, and low color is set to white. +*/ +PatternHandler::PatternHandler(const uint64 &pat) +{ + _pat=pat; + _high=new RGBColor(0,0,0,255); + _low=new RGBColor(255,255,255,255); +} + +PatternHandler::PatternHandler(const Pattern &pat) +{ + _pat=pat; + _high=new RGBColor(0,0,0,255); + _low=new RGBColor(255,255,255,255); +} + //! Destructor frees internal color variables PatternHandler::~PatternHandler(void) { @@ -75,9 +100,27 @@ PatternHandler::~PatternHandler(void) void PatternHandler::SetTarget(int8 *pat) { if(pat) - _pat.type64=*((uint64*)pat); + _pat.Set(pat); else - _pat.type64=0xFFFFFFFFLL; + _pat=0xFFFFFFFFFFFFFFFFLL; +} + +/*! + \brief Sets the pattern for the handler to the one given + \param pat Pattern to use. +*/ +void PatternHandler::SetTarget(const uint64 &pat) +{ + _pat=pat; +} + +/*! + \brief Sets the pattern for the handler to the one given + \param pat Pattern to use. +*/ +void PatternHandler::SetTarget(const Pattern &pat) +{ + _pat=pat; } /*! @@ -109,7 +152,8 @@ RGBColor PatternHandler::GetColor(const BPoint &pt) */ RGBColor PatternHandler::GetColor(const float &x, const float &y) { - int32 value=_pat.type8[(uint32)y%8] & (1 << (7-((uint32)x%8)) ); + const int8 *ptr=_pat.GetInt8(); + int32 value=ptr[(uint32)y%8] & (1 << (7-((uint32)x%8)) ); return (value==0)?*_low:*_high; } @@ -122,7 +166,8 @@ RGBColor PatternHandler::GetColor(const float &x, const float &y) */ bool PatternHandler::GetValue(const float &x, const float &y) { - int32 value=_pat.type8[(uint32)y%8] & (1 << (7-((uint32)x%8)) ); + const int8 *ptr=_pat.GetInt8(); + int32 value=ptr[(uint32)y%8] & (1 << (7-((uint32)x%8)) ); return (value==0)?false:true; } diff --git a/src/servers/app/server/PicturePlayer.cpp b/src/servers/app/server/PicturePlayer.cpp index 63dc8e9677..f32d7760e8 100644 --- a/src/servers/app/server/PicturePlayer.cpp +++ b/src/servers/app/server/PicturePlayer.cpp @@ -35,7 +35,7 @@ PicturePlayer::PicturePlayer(DisplayDriver *d,void *data, int32 size) : fData(data, size) { fdriver=d; - pat.type64=0xFFFFFFFFFFFFFFFFLL; + pat=0xFFFFFFFFFFFFFFFFLL; } PicturePlayer::~PicturePlayer() @@ -148,47 +148,47 @@ status_t PicturePlayer::Play(int32 tableEntries,void *userData, LayerData *d) { BPoint start = GetCoord(); BPoint end = GetCoord(); - fdriver->StrokeLine(start,end,&fldata,pat.type8); + fdriver->StrokeLine(start,end,&fldata,pat); break; } case B_PIC_STROKE_RECT: { BRect rect = GetRect(); - fdriver->StrokeRect(rect,&fldata,pat.type8); + fdriver->StrokeRect(rect,&fldata,pat); break; } case B_PIC_FILL_RECT: { BRect rect = GetRect(); - fdriver->FillRect(rect,&fldata,pat.type8); + fdriver->FillRect(rect,&fldata,pat); break; } case B_PIC_STROKE_ROUND_RECT: { BRect rect = GetRect(); BPoint radii = GetCoord(); - fdriver->StrokeRoundRect(rect,radii.x,radii.y,&fldata,pat.type8); + fdriver->StrokeRoundRect(rect,radii.x,radii.y,&fldata,pat); break; } case B_PIC_FILL_ROUND_RECT: { BRect rect = GetRect(); BPoint radii = GetCoord(); - fdriver->FillRoundRect(rect,radii.x,radii.y,&fldata,pat.type8); + fdriver->FillRoundRect(rect,radii.x,radii.y,&fldata,pat); break; } case B_PIC_STROKE_BEZIER: { BPoint control[4]; GetData(control, sizeof(control)); - fdriver->StrokeBezier(control,&fldata,pat.type8); + fdriver->StrokeBezier(control,&fldata,pat); break; } case B_PIC_FILL_BEZIER: { BPoint control[4]; GetData(control, sizeof(control)); - fdriver->FillBezier(control,&fldata,pat.type8); + fdriver->FillBezier(control,&fldata,pat); break; } case B_PIC_STROKE_POLYGON: @@ -197,7 +197,7 @@ status_t PicturePlayer::Play(int32 tableEntries,void *userData, LayerData *d) BPoint *points = new BPoint[numPoints]; GetData(points, numPoints * sizeof(BPoint)); bool isClosed = GetBool(); - fdriver->StrokePolygon(points,numPoints,BRect(0,0,0,0),&fldata,pat.type8,isClosed); + fdriver->StrokePolygon(points,numPoints,BRect(0,0,0,0),&fldata,pat,isClosed); delete points; break; } @@ -206,7 +206,7 @@ status_t PicturePlayer::Play(int32 tableEntries,void *userData, LayerData *d) int32 numPoints = GetInt32(); BPoint *points = new BPoint[numPoints]; GetData(points, numPoints * sizeof(BPoint)); - fdriver->FillPolygon(points,numPoints,BRect(0,0,0,0),&fldata,pat.type8); + fdriver->FillPolygon(points,numPoints,BRect(0,0,0,0),&fldata,pat); delete points; break; } @@ -260,7 +260,7 @@ status_t PicturePlayer::Play(int32 tableEntries,void *userData, LayerData *d) float startTheta = GetFloat(); float arcTheta = GetFloat(); fdriver->StrokeArc(BRect(center.x-radii.x,center.y-radii.y,center.x+radii.x, - center.y+radii.y),startTheta, arcTheta, &fldata,pat.type8); + center.y+radii.y),startTheta, arcTheta, &fldata,pat); break; } case B_PIC_FILL_ARC: @@ -270,7 +270,7 @@ status_t PicturePlayer::Play(int32 tableEntries,void *userData, LayerData *d) float startTheta = GetFloat(); float arcTheta = GetFloat(); fdriver->FillArc(BRect(center.x-radii.x,center.y-radii.y,center.x+radii.x, - center.y+radii.y),startTheta, arcTheta, &fldata,pat.type8); + center.y+radii.y),startTheta, arcTheta, &fldata,pat); break; } case B_PIC_STROKE_ELLIPSE: @@ -279,7 +279,7 @@ status_t PicturePlayer::Play(int32 tableEntries,void *userData, LayerData *d) BPoint center; BPoint radii((rect.Width() + 1) / 2.0f, (rect.Height() + 1) / 2.0f); center = rect.LeftTop() + radii; - fdriver->StrokeEllipse(rect,&fldata,pat.type8); + fdriver->StrokeEllipse(rect,&fldata,pat); break; } case B_PIC_FILL_ELLIPSE: @@ -288,7 +288,7 @@ status_t PicturePlayer::Play(int32 tableEntries,void *userData, LayerData *d) BPoint center; BPoint radii((rect.Width() + 1) / 2.0f, (rect.Height() + 1) / 2.0f); center = rect.LeftTop() + radii; - fdriver->FillEllipse(rect,&fldata,pat.type8); + fdriver->FillEllipse(rect,&fldata,pat); break; } case B_PIC_ENTER_STATE_CHANGE: @@ -375,7 +375,7 @@ status_t PicturePlayer::Play(int32 tableEntries,void *userData, LayerData *d) { pattern p; GetData(&p, sizeof(p)); - pat.type64=*((uint64*)p.data); + pat=*((uint64*)p.data); break; } case B_PIC_ENTER_FONT_STATE: diff --git a/src/servers/app/server/PicturePlayer.h b/src/servers/app/server/PicturePlayer.h index d382a50e13..78d9f788cf 100644 --- a/src/servers/app/server/PicturePlayer.h +++ b/src/servers/app/server/PicturePlayer.h @@ -88,7 +88,7 @@ private: DisplayDriver *fdriver; LayerData fldata; BPoint forigin; - pattern_union pat; + Pattern pat; }; #endif diff --git a/src/servers/app/server/RootLayer.cpp b/src/servers/app/server/RootLayer.cpp index 29ae578d76..9682be740a 100644 --- a/src/servers/app/server/RootLayer.cpp +++ b/src/servers/app/server/RootLayer.cpp @@ -70,8 +70,6 @@ void RootLayer::RequestDraw(void) { if(!_is_dirty) return; - pattern_union low; - low.type64=0LL; // Redraw the base if(_invalid) @@ -79,7 +77,7 @@ void RootLayer::RequestDraw(void) for(int32 i=0; _invalid->CountRects();i++) { if(_invalid->RectAt(i).IsValid()) - _driver->FillRect(_invalid->RectAt(i),_layerdata, (int8*)low.type8); + _driver->FillRect(_invalid->RectAt(i),_layerdata, pat_solidlow); else break; } diff --git a/src/servers/app/server/ScreenDriver.cpp b/src/servers/app/server/ScreenDriver.cpp index 630480860f..2d44232718 100644 --- a/src/servers/app/server/ScreenDriver.cpp +++ b/src/servers/app/server/ScreenDriver.cpp @@ -516,28 +516,28 @@ bool ScreenDriver::DumpToFile(const char *path) return true; } -void ScreenDriver::FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat) +void ScreenDriver::FillArc(BRect r, float angle, float span, LayerData *d, const Pattern &pat) { - if(!pat || !d) + if(!d) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->FillArc(r,angle,span,*((pattern*)pat)); + drawview->FillArc(r,angle,span,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(r); framebuffer->Unlock(); screenwin->Unlock(); } -void ScreenDriver::FillBezier(BPoint *pts, LayerData *d, int8 *pat) +void ScreenDriver::FillBezier(BPoint *pts, LayerData *d, const Pattern &pat) { - if(!pat || !pts) + if(!pts) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->FillBezier(pts,*((pattern*)pat)); + drawview->FillBezier(pts,*((pattern*)pat.GetInt8())); drawview->Sync(); // Invalidate the whole view until I get around to adding in the invalid rect calc code @@ -546,56 +546,56 @@ void ScreenDriver::FillBezier(BPoint *pts, LayerData *d, int8 *pat) screenwin->Unlock(); } -void ScreenDriver::FillEllipse(BRect r, LayerData *d, int8 *pat) +void ScreenDriver::FillEllipse(BRect r, LayerData *d, const Pattern &pat) { - if(!pat || !d) + if(!d) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->FillEllipse(r,*((pattern*)pat)); + drawview->FillEllipse(r,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(r); framebuffer->Unlock(); screenwin->Unlock(); } -void ScreenDriver::FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat) +void ScreenDriver::FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, const Pattern &pat) { - if(!pat || !d) + if(!d) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->FillPolygon(ptlist,numpts,rect,*((pattern*)pat)); + drawview->FillPolygon(ptlist,numpts,rect,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(rect); framebuffer->Unlock(); screenwin->Unlock(); } -void ScreenDriver::FillRect(BRect r, LayerData *d, int8 *pat) +void ScreenDriver::FillRect(BRect r, LayerData *d, const Pattern &pat) { - if(!pat || !d) + if(!d) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->FillRect(r,*((pattern*)pat)); + drawview->FillRect(r,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(r); framebuffer->Unlock(); screenwin->Unlock(); } -void ScreenDriver::FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat) +void ScreenDriver::FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, const Pattern &pat) { - if(!pat || !d) + if(!d) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->FillRoundRect(r,xrad,yrad,*((pattern*)pat)); + drawview->FillRoundRect(r,xrad,yrad,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(r); framebuffer->Unlock(); @@ -603,15 +603,15 @@ void ScreenDriver::FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, } -void ScreenDriver::FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat) +void ScreenDriver::FillTriangle(BPoint *pts, BRect r, LayerData *d, const Pattern &pat) { - if(!pat || !pts) + if(!pts) return; screenwin->Lock(); framebuffer->Lock(); BPoint first=pts[0],second=pts[1],third=pts[2]; SetLayerData(d); - drawview->FillTriangle(first,second,third,r,*((pattern*)pat)); + drawview->FillTriangle(first,second,third,r,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(r); framebuffer->Unlock(); @@ -707,14 +707,14 @@ void ScreenDriver::ShowCursor(void) } -void ScreenDriver::StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat) +void ScreenDriver::StrokeArc(BRect r, float angle, float span, LayerData *d, const Pattern &pat) { - if(!pat || !d) + if(!d) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->StrokeArc(r,angle,span,*((pattern*)pat)); + drawview->StrokeArc(r,angle,span,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(r); framebuffer->Unlock(); @@ -722,14 +722,14 @@ void ScreenDriver::StrokeArc(BRect r, float angle, float span, LayerData *d, int } -void ScreenDriver::StrokeBezier(BPoint *pts, LayerData *d, int8 *pat) +void ScreenDriver::StrokeBezier(BPoint *pts, LayerData *d, const Pattern &pat) { - if(!pat || !pts) + if(!pts) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->StrokeBezier(pts,*((pattern*)pat)); + drawview->StrokeBezier(pts,*((pattern*)pat.GetInt8())); drawview->Sync(); // Invalidate the whole view until I get around to adding in the invalid rect calc code @@ -739,14 +739,14 @@ void ScreenDriver::StrokeBezier(BPoint *pts, LayerData *d, int8 *pat) } -void ScreenDriver::StrokeEllipse(BRect r, LayerData *d, int8 *pat) +void ScreenDriver::StrokeEllipse(BRect r, LayerData *d, const Pattern &pat) { - if(!pat || !d) + if(!d) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->StrokeEllipse(r,*((pattern*)pat)); + drawview->StrokeEllipse(r,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(r); framebuffer->Unlock(); @@ -754,14 +754,14 @@ void ScreenDriver::StrokeEllipse(BRect r, LayerData *d, int8 *pat) } -void ScreenDriver::StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat) +void ScreenDriver::StrokeLine(BPoint start, BPoint end, LayerData *d, const Pattern &pat) { - if(!pat || !d) + if(!d) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->StrokeLine(start,end,*((pattern*)pat)); + drawview->StrokeLine(start,end,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(BRect(start,end)); framebuffer->Unlock(); @@ -775,9 +775,9 @@ printf("ScreenDriver:: StrokeLineArray unimplemented\n"); #endif } -void ScreenDriver::StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed) +void ScreenDriver::StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, const Pattern &pat, bool is_closed) { - if(!pat || !ptlist) + if(!ptlist) return; screenwin->Lock(); framebuffer->Lock(); @@ -806,28 +806,28 @@ void ScreenDriver::StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, Layer } -void ScreenDriver::StrokeRect(BRect r, LayerData *d, int8 *pat) +void ScreenDriver::StrokeRect(BRect r, LayerData *d, const Pattern &pat) { - if(!pat || !d) + if(!d) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->StrokeRect(r,*((pattern*)pat)); + drawview->StrokeRect(r,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(r); framebuffer->Unlock(); screenwin->Unlock(); } -void ScreenDriver::StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat) +void ScreenDriver::StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, const Pattern &pat) { - if(!pat || !d) + if(!d) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->StrokeRoundRect(r,xrad,yrad,*((pattern*)pat)); + drawview->StrokeRoundRect(r,xrad,yrad,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(r); framebuffer->Unlock(); @@ -835,15 +835,15 @@ void ScreenDriver::StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d } -void ScreenDriver::StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat) +void ScreenDriver::StrokeTriangle(BPoint *pts, BRect r, LayerData *d, const Pattern &pat) { - if(!pat || !pts || !d) + if(!pts || !d) return; screenwin->Lock(); framebuffer->Lock(); BPoint first=pts[0],second=pts[1],third=pts[2]; SetLayerData(d); - drawview->StrokeTriangle(first,second,third,r,*((pattern*)pat)); + drawview->StrokeTriangle(first,second,third,r,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(r); framebuffer->Unlock(); diff --git a/src/servers/app/server/ScreenDriver.h b/src/servers/app/server/ScreenDriver.h index ea8b54e00d..b404226486 100644 --- a/src/servers/app/server/ScreenDriver.h +++ b/src/servers/app/server/ScreenDriver.h @@ -38,10 +38,9 @@ #include #include #include "DisplayDriver.h" -//#include #include -//#include FT_FREETYPE_H #include "FontServer.h" +#include "PatternHandler.h" class BBitmap; class PortLink; @@ -145,14 +144,14 @@ public: // virtual void DrawPicture(SPicture *pic, BPoint pt); void DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *delta=NULL); - void FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat); - void FillBezier(BPoint *pts, LayerData *d, int8 *pat); - void FillEllipse(BRect r, LayerData *d, int8 *pat); - void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat); - void FillRect(BRect r, LayerData *d, int8 *pat); - void FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat); -// void FillShape(SShape *sh, LayerData *d, int8 *pat); - void FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat); + void FillArc(BRect r, float angle, float span, LayerData *d, const Pattern &pat); + void FillBezier(BPoint *pts, LayerData *d, const Pattern &pat); + void FillEllipse(BRect r, LayerData *d, const Pattern &pat); + void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, const Pattern &pat); + void FillRect(BRect r, LayerData *d, const Pattern &pat); + void FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, const Pattern &pat); +// void FillShape(SShape *sh, LayerData *d, const Pattern &pat); + void FillTriangle(BPoint *pts, BRect r, LayerData *d, const Pattern &pat); void HideCursor(void); void InvertRect(BRect r); @@ -167,16 +166,16 @@ public: // void SetDrawingMode(drawing_mode mode); void ShowCursor(void); - void StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat); - void StrokeBezier(BPoint *pts, LayerData *d, int8 *pat); - void StrokeEllipse(BRect r, LayerData *d, int8 *pat); - void StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat); + void StrokeArc(BRect r, float angle, float span, LayerData *d, const Pattern &pat); + void StrokeBezier(BPoint *pts, LayerData *d, const Pattern &pat); + void StrokeEllipse(BRect r, LayerData *d, const Pattern &pat); + void StrokeLine(BPoint start, BPoint end, LayerData *d, const Pattern &pat); void StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d); - void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed=true); - void StrokeRect(BRect r, LayerData *d, int8 *pat); - void StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat); -// void StrokeShape(SShape *sh, LayerData *d, int8 *pat); - void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat); + void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, const Pattern &pat, bool is_closed=true); + void StrokeRect(BRect r, LayerData *d, const Pattern &pat); + void StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, const Pattern &pat); +// void StrokeShape(SShape *sh, LayerData *d, const Pattern &pat); + void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, const Pattern &pat); void SetMode(int32 mode); float StringWidth(const char *string, int32 length, LayerData *d); float StringHeight(const char *string, int32 length, LayerData *d); diff --git a/src/servers/app/server/ViewDriver.cpp b/src/servers/app/server/ViewDriver.cpp index b29afa5b54..69dbfd8596 100644 --- a/src/servers/app/server/ViewDriver.cpp +++ b/src/servers/app/server/ViewDriver.cpp @@ -789,28 +789,28 @@ bool ViewDriver::DumpToFile(const char *path) return true; } -void ViewDriver::FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat) +void ViewDriver::FillArc(BRect r, float angle, float span, LayerData *d, const Pattern &pat) { - if(!pat || !d) + if(!d) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->FillArc(r,angle,span,*((pattern*)pat)); + drawview->FillArc(r,angle,span,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(r); framebuffer->Unlock(); screenwin->Unlock(); } -void ViewDriver::FillBezier(BPoint *pts, LayerData *d, int8 *pat) +void ViewDriver::FillBezier(BPoint *pts, LayerData *d, const Pattern &pat) { - if(!pat || !pts) + if(!pts) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->FillBezier(pts,*((pattern*)pat)); + drawview->FillBezier(pts,*((pattern*)pat.GetInt8())); drawview->Sync(); // Invalidate the whole view until I get around to adding in the invalid rect calc code @@ -819,56 +819,56 @@ void ViewDriver::FillBezier(BPoint *pts, LayerData *d, int8 *pat) screenwin->Unlock(); } -void ViewDriver::FillEllipse(BRect r, LayerData *d, int8 *pat) +void ViewDriver::FillEllipse(BRect r, LayerData *d, const Pattern &pat) { - if(!pat || !d) + if(!d) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->FillEllipse(r,*((pattern*)pat)); + drawview->FillEllipse(r,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(r); framebuffer->Unlock(); screenwin->Unlock(); } -void ViewDriver::FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat) +void ViewDriver::FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, const Pattern &pat) { - if(!pat || !d) + if(!d) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->FillPolygon(ptlist,numpts,rect,*((pattern*)pat)); + drawview->FillPolygon(ptlist,numpts,rect,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(rect); framebuffer->Unlock(); screenwin->Unlock(); } -void ViewDriver::FillRect(BRect r, LayerData *d, int8 *pat) +void ViewDriver::FillRect(BRect r, LayerData *d, const Pattern &pat) { - if(!pat || !d) + if(!d) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->FillRect(r,*((pattern*)pat)); + drawview->FillRect(r,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(r); framebuffer->Unlock(); screenwin->Unlock(); } -void ViewDriver::FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat) +void ViewDriver::FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, const Pattern &pat) { - if(!pat || !d) + if(!d) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->FillRoundRect(r,xrad,yrad,*((pattern*)pat)); + drawview->FillRoundRect(r,xrad,yrad,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(r); framebuffer->Unlock(); @@ -876,15 +876,15 @@ void ViewDriver::FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, in } -void ViewDriver::FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat) +void ViewDriver::FillTriangle(BPoint *pts, BRect r, LayerData *d, const Pattern &pat) { - if(!pat || !pts) + if(!pts) return; screenwin->Lock(); framebuffer->Lock(); BPoint first=pts[0],second=pts[1],third=pts[2]; SetLayerData(d); - drawview->FillTriangle(first,second,third,r,*((pattern*)pat)); + drawview->FillTriangle(first,second,third,r,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(r); framebuffer->Unlock(); @@ -977,14 +977,14 @@ void ViewDriver::ShowCursor(void) } -void ViewDriver::StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat) +void ViewDriver::StrokeArc(BRect r, float angle, float span, LayerData *d, const Pattern &pat) { - if(!pat || !d) + if(!d) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->StrokeArc(r,angle,span,*((pattern*)pat)); + drawview->StrokeArc(r,angle,span,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(r); framebuffer->Unlock(); @@ -992,14 +992,14 @@ void ViewDriver::StrokeArc(BRect r, float angle, float span, LayerData *d, int8 } -void ViewDriver::StrokeBezier(BPoint *pts, LayerData *d, int8 *pat) +void ViewDriver::StrokeBezier(BPoint *pts, LayerData *d, const Pattern &pat) { - if(!pat || !pts) + if(!pts) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->StrokeBezier(pts,*((pattern*)pat)); + drawview->StrokeBezier(pts,*((pattern*)pat.GetInt8())); drawview->Sync(); // Invalidate the whole view until I get around to adding in the invalid rect calc code @@ -1009,14 +1009,14 @@ void ViewDriver::StrokeBezier(BPoint *pts, LayerData *d, int8 *pat) } -void ViewDriver::StrokeEllipse(BRect r, LayerData *d, int8 *pat) +void ViewDriver::StrokeEllipse(BRect r, LayerData *d, const Pattern &pat) { - if(!pat || !d) + if(!d) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->StrokeEllipse(r,*((pattern*)pat)); + drawview->StrokeEllipse(r,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(r); framebuffer->Unlock(); @@ -1024,14 +1024,14 @@ void ViewDriver::StrokeEllipse(BRect r, LayerData *d, int8 *pat) } -void ViewDriver::StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat) +void ViewDriver::StrokeLine(BPoint start, BPoint end, LayerData *d, const Pattern &pat) { - if(!pat || !d) + if(!d) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->StrokeLine(start,end,*((pattern*)pat)); + drawview->StrokeLine(start,end,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(BRect(start,end)); framebuffer->Unlock(); @@ -1076,9 +1076,9 @@ void ViewDriver::StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, } -void ViewDriver::StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed) +void ViewDriver::StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, const Pattern &pat, bool is_closed) { - if(!pat || !ptlist) + if(!ptlist) return; screenwin->Lock(); framebuffer->Lock(); @@ -1107,28 +1107,28 @@ void ViewDriver::StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerDa } -void ViewDriver::StrokeRect(BRect r, LayerData *d, int8 *pat) +void ViewDriver::StrokeRect(BRect r, LayerData *d, const Pattern &pat) { - if(!pat || !d) + if(!d) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->StrokeRect(r,*((pattern*)pat)); + drawview->StrokeRect(r,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(r); framebuffer->Unlock(); screenwin->Unlock(); } -void ViewDriver::StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat) +void ViewDriver::StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, const Pattern &pat) { - if(!pat || !d) + if(!d) return; screenwin->Lock(); framebuffer->Lock(); SetLayerData(d); - drawview->StrokeRoundRect(r,xrad,yrad,*((pattern*)pat)); + drawview->StrokeRoundRect(r,xrad,yrad,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(r); framebuffer->Unlock(); @@ -1136,15 +1136,15 @@ void ViewDriver::StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, } -void ViewDriver::StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat) +void ViewDriver::StrokeTriangle(BPoint *pts, BRect r, LayerData *d, const Pattern &pat) { - if(!pat || !pts || !d) + if(!pts || !d) return; screenwin->Lock(); framebuffer->Lock(); BPoint first=pts[0],second=pts[1],third=pts[2]; SetLayerData(d); - drawview->StrokeTriangle(first,second,third,r,*((pattern*)pat)); + drawview->StrokeTriangle(first,second,third,r,*((pattern*)pat.GetInt8())); drawview->Sync(); screenwin->view->Invalidate(r); framebuffer->Unlock(); diff --git a/src/servers/app/server/ViewDriver.h b/src/servers/app/server/ViewDriver.h index 14531c9751..2dcdefb1fc 100644 --- a/src/servers/app/server/ViewDriver.h +++ b/src/servers/app/server/ViewDriver.h @@ -37,8 +37,6 @@ #include #include #include "DisplayDriver.h" -//#include -//#include FT_FREETYPE_H #include "FontServer.h" class BBitmap; @@ -115,14 +113,14 @@ public: // virtual void DrawPicture(SPicture *pic, BPoint pt); void DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *delta=NULL); - void FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat); - void FillBezier(BPoint *pts, LayerData *d, int8 *pat); - void FillEllipse(BRect r, LayerData *d, int8 *pat); - void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat); - void FillRect(BRect r, LayerData *d, int8 *pat); - void FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat); -// void FillShape(SShape *sh, LayerData *d, int8 *pat); - void FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat); + void FillArc(BRect r, float angle, float span, LayerData *d, const Pattern &pat); + void FillBezier(BPoint *pts, LayerData *d, const Pattern &pat); + void FillEllipse(BRect r, LayerData *d, const Pattern &pat); + void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, const Pattern &pat); + void FillRect(BRect r, LayerData *d, const Pattern &pat); + void FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, const Pattern &pat); +// void FillShape(SShape *sh, LayerData *d, const Pattern &pat); + void FillTriangle(BPoint *pts, BRect r, LayerData *d, const Pattern &pat); void HideCursor(void); void InvertRect(BRect r); @@ -137,16 +135,16 @@ public: // void SetDrawingMode(drawing_mode mode); void ShowCursor(void); - void StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat); - void StrokeBezier(BPoint *pts, LayerData *d, int8 *pat); - void StrokeEllipse(BRect r, LayerData *d, int8 *pat); - void StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat); + void StrokeArc(BRect r, float angle, float span, LayerData *d, const Pattern &pat); + void StrokeBezier(BPoint *pts, LayerData *d, const Pattern &pat); + void StrokeEllipse(BRect r, LayerData *d, const Pattern &pat); + void StrokeLine(BPoint start, BPoint end, LayerData *d, const Pattern &pat); void StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d); - void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed=true); - void StrokeRect(BRect r, LayerData *d, int8 *pat); - void StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat); -// void StrokeShape(SShape *sh, LayerData *d, int8 *pat); - void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat); + void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, const Pattern &pat, bool is_closed=true); + void StrokeRect(BRect r, LayerData *d, const Pattern &pat); + void StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, const Pattern &pat); +// void StrokeShape(SShape *sh, LayerData *d, const Pattern &pat); + void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, const Pattern &pat); void SetMode(int32 mode); float StringWidth(const char *string, int32 length, LayerData *d); float StringHeight(const char *string, int32 length, LayerData *d);