From aca4f50d1eefef8bf137cc16f5b707d223494377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 4 Nov 2005 11:37:28 +0000 Subject: [PATCH] Merged DrawData and LayerData to one class DrawState. Removed that ambiguous second copy constructor and moved push state functionality into a separate PushState() method. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14679 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/servers/app/Decorator.h | 4 +- headers/private/servers/app/DisplayDriver.h | 77 ++- headers/private/servers/app/DrawState.h | 210 +++++++ headers/private/servers/app/LayerData.h | 226 ------- src/servers/app/Decorator.cpp | 8 +- src/servers/app/DefaultDecorator.cpp | 20 +- .../app/{LayerData.cpp => DrawState.cpp} | 592 ++++++++---------- src/servers/app/Jamfile | 2 +- src/servers/app/Layer.cpp | 44 +- src/servers/app/Layer.h | 4 +- src/servers/app/PicturePlayer.cpp | 2 +- src/servers/app/PicturePlayer.h | 6 +- src/servers/app/RootLayer.cpp | 60 +- src/servers/app/ServerApp.cpp | 4 +- src/servers/app/ServerWindow.cpp | 154 ++--- .../app/drawing/DisplayDriverPainter.cpp | 125 ++-- .../app/drawing/DisplayDriverPainter.h | 76 ++- src/servers/app/drawing/Painter/Painter.cpp | 14 +- src/servers/app/drawing/Painter/Painter.h | 14 +- src/tests/servers/app/Jamfile | 2 +- 20 files changed, 774 insertions(+), 870 deletions(-) create mode 100644 headers/private/servers/app/DrawState.h delete mode 100644 headers/private/servers/app/LayerData.h rename src/servers/app/{LayerData.cpp => DrawState.cpp} (73%) diff --git a/headers/private/servers/app/Decorator.h b/headers/private/servers/app/Decorator.h index c71d955dbd..aa9ed88567 100644 --- a/headers/private/servers/app/Decorator.h +++ b/headers/private/servers/app/Decorator.h @@ -16,7 +16,7 @@ #include #include "ColorSet.h" -#include "LayerData.h" +#include "DrawState.h" class DesktopSettings; class DisplayDriver; @@ -138,7 +138,7 @@ class Decorator { ColorSet* _colors; DisplayDriver* _driver; - DrawData _drawdata; + DrawState fDrawState; int32 _look; int32 _feel; diff --git a/headers/private/servers/app/DisplayDriver.h b/headers/private/servers/app/DisplayDriver.h index acf3e15457..17f2b9f355 100644 --- a/headers/private/servers/app/DisplayDriver.h +++ b/headers/private/servers/app/DisplayDriver.h @@ -1,19 +1,16 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2001-2005, Haiku, Inc. All rights reserved -// Distributed under the terms of the MIT license. -// -// File Name: DisplayDriver.h -// Authors: DarkWyrm -// Gabe Yoder -// Stephan Aßmus -// -// Description: Abstract class which handles all graphics output -// for the server -// -//------------------------------------------------------------------------------ +/* + * Copyright 2001-2005, Haiku, Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * DarkWyrm + * Gabe Yoder + * Stephan Aßmus + */ #ifndef _DISPLAY_DRIVER_H_ #define _DISPLAY_DRIVER_H_ + #include #include #include @@ -23,7 +20,7 @@ class BPoint; class BRect; class BRegion; -class DrawData; +class DrawState; class HWInterface; class RGBColor; class ServerBitmap; @@ -81,59 +78,59 @@ public: virtual void DrawBitmap( ServerBitmap *bitmap, const BRect &source, const BRect &dest, - const DrawData *d) = 0; + const DrawState *d) = 0; virtual void FillArc( BRect r, const float &angle, const float &span, - const DrawData *d) = 0; + const DrawState *d) = 0; virtual void FillBezier( BPoint *pts, - const DrawData *d) = 0; + const DrawState *d) = 0; virtual void FillEllipse( BRect r, - const DrawData *d) = 0; + const DrawState *d) = 0; virtual void FillPolygon( BPoint *ptlist, int32 numpts, BRect bounds, - const DrawData *d) = 0; + const DrawState *d) = 0; virtual void FillRect( BRect r, const RGBColor &color) = 0; virtual void FillRect( BRect r, - const DrawData *d) = 0; + const DrawState *d) = 0; virtual void FillRegion( BRegion &r, - const DrawData *d) = 0; + const DrawState *d) = 0; virtual void FillRoundRect( BRect r, const float &xrad, const float &yrad, - const DrawData *d) = 0; + const DrawState *d) = 0; virtual void FillShape( const BRect &bounds, const int32 &opcount, const int32 *oplist, const int32 &ptcount, const BPoint *ptlist, - const DrawData *d) = 0; + const DrawState *d) = 0; virtual void FillTriangle( BPoint *pts, BRect bounds, - const DrawData *d) = 0; + const DrawState *d) = 0; virtual void StrokeArc( BRect r, const float &angle, const float &span, - const DrawData *d) = 0; + const DrawState *d) = 0; virtual void StrokeBezier( BPoint *pts, - const DrawData *d) = 0; + const DrawState *d) = 0; virtual void StrokeEllipse( BRect r, - const DrawData *d) = 0; + const DrawState *d) = 0; // this version used by Decorator virtual void StrokeLine( const BPoint &start, @@ -142,23 +139,23 @@ public: virtual void StrokeLine( const BPoint &start, const BPoint &end, - DrawData *d) = 0; + DrawState *d) = 0; virtual void StrokeLineArray(const int32 &numlines, const LineArrayData *data, - const DrawData *d) = 0; + const DrawState *d) = 0; // this version used by Decorator virtual void StrokePoint( const BPoint &pt, const RGBColor &color) = 0; virtual void StrokePoint( const BPoint &pt, - DrawData *d) = 0; + DrawState *d) = 0; virtual void StrokePolygon( BPoint *ptlist, int32 numpts, BRect bounds, - const DrawData *d, + const DrawState *d, bool is_closed=true) = 0; // this version used by Decorator @@ -166,34 +163,34 @@ public: const RGBColor &color) = 0; virtual void StrokeRect( BRect r, - const DrawData *d) = 0; + const DrawState *d) = 0; virtual void StrokeRegion( BRegion &r, - const DrawData *d) = 0; + const DrawState *d) = 0; virtual void StrokeRoundRect(BRect r, const float &xrad, const float &yrad, - const DrawData *d) = 0; + const DrawState *d) = 0; virtual void StrokeShape( const BRect &bounds, const int32 &opcount, const int32 *oplist, const int32 &ptcount, const BPoint *ptlist, - const DrawData *d) = 0; + const DrawState *d) = 0; virtual void StrokeTriangle( BPoint *pts, const BRect &bounds, - const DrawData *d) = 0; + const DrawState *d) = 0; // Font-related calls - // DrawData is NOT const because this call updates the pen position in the passed DrawData + // DrawState is NOT const because this call updates the pen position in the passed DrawState virtual void DrawString( const char* string, int32 length, const BPoint& pt, - DrawData* d, + DrawState* d, escapement_delta *delta = NULL) = 0; /* virtual void DrawString( const char *string, @@ -204,7 +201,7 @@ public: virtual float StringWidth( const char* string, int32 length, - const DrawData* d, + const DrawState* d, escapement_delta *delta = NULL) = 0; virtual float StringWidth( const char* string, @@ -214,7 +211,7 @@ public: virtual float StringHeight( const char *string, int32 length, - const DrawData *d) = 0; + const DrawState *d) = 0; virtual bool Lock() = 0; virtual void Unlock() = 0; diff --git a/headers/private/servers/app/DrawState.h b/headers/private/servers/app/DrawState.h new file mode 100644 index 0000000000..3f93c12a89 --- /dev/null +++ b/headers/private/servers/app/DrawState.h @@ -0,0 +1,210 @@ +/* + * Copyright 2001-2005, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * DarkWyrm + * Adi Oanca + * Stephan Aßmus + * Axel Dörfler, axeld@pinc-software.de + */ +#ifndef _DRAW_STATE_H_ +#define _DRAW_STATE_H_ + + +#include +#include +#include +#include // for B_FONT_ALL + +#include "RGBColor.h" +#include "FontManager.h" +#include "ServerFont.h" +#include "PatternHandler.h" + +class BRegion; + +namespace BPrivate { + class LinkReceiver; + class LinkSender; +}; + + +class DrawState { + public: + DrawState(); + DrawState(const DrawState& from); + virtual ~DrawState(); + + DrawState& operator=(const DrawState& from); + + DrawState* PushState(); + DrawState* PopState(); + DrawState* PreviousState() const { return fPreviousState; } + + void ReadFontFromLink(BPrivate::LinkReceiver& link); + // NOTE: ReadFromLink() does not read Font state!! + // It was separate in ServerWindow, and I didn't + // want to change it without knowing implications. + void ReadFromLink(BPrivate::LinkReceiver& link); + void WriteToLink(BPrivate::LinkSender& link) const; + + // coordinate transformation + void SetOrigin(const BPoint& origin); + void OffsetOrigin(const BPoint& offset); + const BPoint& Origin() const + { return fOrigin; } + + void SetScale(float scale); + float Scale() const + { return fScale; } + + // additional clipping as requested by client + void SetClippingRegion(const BRegion& region); + const BRegion* ClippingRegion() const + { return fClippingRegion; } +/* inline int32 CountClippingRects() const + { return fClippingRegion ? fClippingRegion.CountRects() : 0; } + inline BRect ClippingRectAt(int32 index) const;*/ + + // color + void SetHighColor(const RGBColor& color); + const RGBColor& HighColor() const + { return fHighColor; } + + void SetLowColor(const RGBColor& color); + const RGBColor& LowColor() const + { return fLowColor; } + + void SetPattern(const Pattern& pattern); + const Pattern& GetPattern() const + { return fPattern; } + + // drawing/blending mode + void SetDrawingMode(drawing_mode mode); + drawing_mode GetDrawingMode() const + { return fDrawingMode; } + + void SetBlendingMode(source_alpha srcMode, + alpha_function fncMode); + source_alpha AlphaSrcMode() const + { return fAlphaSrcMode; } + alpha_function AlphaFncMode() const + { return fAlphaFncMode; } + + // pen + void SetPenLocation(const BPoint& location); + const BPoint& PenLocation() const; + + void SetPenSize(float size); + float PenSize() const; + + // font + void SetFont(const ServerFont& font, + uint32 flags = B_FONT_ALL); + const ServerFont& Font() const + { return fFont; } + + // overrides aliasing flag contained in SeverFont::Flags()) + void SetForceFontAliasing(bool aliasing); + bool ForceFontAliasing() const + { return fFontAliasing; } + + // postscript style settings + void SetLineCapMode(cap_mode mode); + cap_mode LineCapMode() const + { return fLineCapMode; } + + void SetLineJoinMode(join_mode mode); + join_mode LineJoinMode() const + { return fLineJoinMode; } + + void SetMiterLimit(float limit); + float MiterLimit() const + { return fMiterLimit; } + + // convenience functions + inline BPoint Transform(const BPoint& point) const; + inline BRect Transform(const BRect& rect) const; + void PrintToStream() const; + + void SetSubPixelPrecise(bool precise); + bool SubPixelPrecise() const + { return fSubPixelPrecise; } + + protected: + BPoint fOrigin; + float fScale; + + BRegion* fClippingRegion; + + RGBColor fHighColor; + RGBColor fLowColor; + Pattern fPattern; + + drawing_mode fDrawingMode; + source_alpha fAlphaSrcMode; + alpha_function fAlphaFncMode; + + BPoint fPenLocation; + float fPenSize; + + ServerFont fFont; + // overrides font aliasing flag + bool fFontAliasing; + + // This is not part of the normal state stack. + // Layer will update it in PushState/PopState. + // A BView can have a flag "B_SUBPIXEL_PRECISE", + // I never knew what it does on R5, but I can use + // it in Painter to actually draw stuff with + // sub-pixel coordinates. It means + // StrokeLine(BPoint(10, 5), BPoint(20, 9)); + // will look different from + // StrokeLine(BPoint(10.3, 5.8), BPoint(20.6, 9.5)); + bool fSubPixelPrecise; + + cap_mode fLineCapMode; + join_mode fLineJoinMode; + float fMiterLimit; + // "internal", used to calculate the size + // of the font (again) when the scale changes + float fUnscaledFontSize; + + DrawState* fPreviousState; +}; + + +// inline implementations + +// Transform +BPoint +DrawState::Transform(const BPoint& point) const +{ + BPoint p(point); + p += fOrigin; + p.x *= fScale; + p.y *= fScale; + return p; +} + +// Transform +BRect +DrawState::Transform(const BRect& rect) const +{ + return BRect(Transform(rect.LeftTop()), + Transform(rect.LeftBottom())); +} +/* +// ClippingRectAt +BRect +DrawState::ClippingRectAt(int32 index) const +{ + BRect r; + if (fClippingRegion) { + r = fClippingRegion.RectAt(index); + } + return r; +}*/ + +#endif /* _DRAW_STATE_H_ */ diff --git a/headers/private/servers/app/LayerData.h b/headers/private/servers/app/LayerData.h deleted file mode 100644 index c06f5c00d3..0000000000 --- a/headers/private/servers/app/LayerData.h +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright 2001-2005, Haiku. - * Distributed under the terms of the MIT License. - * - * Authors: - * DarkWyrm - * Adi Oanca - * Stephan Aßmus - */ -#ifndef LAYER_DATA_H_ -#define LAYER_DATA_H_ - - -#include -#include -#include -#include // for B_FONT_ALL - -#include "RGBColor.h" -#include "FontManager.h" -#include "ServerFont.h" -#include "PatternHandler.h" - -class BRegion; - -namespace BPrivate { - class LinkReceiver; - class LinkSender; -}; - - -class DrawData { - public: - DrawData(); - DrawData(const DrawData& from); - // used for the State stack, no - // true 1:1 copy! - DrawData(const DrawData* from); - virtual ~DrawData(); - - DrawData& operator=(const DrawData& from); - - // coordinate transformation - void SetOrigin(const BPoint& origin); - void OffsetOrigin(const BPoint& offset); - inline const BPoint& Origin() const - { return fOrigin; } - - void SetScale(float scale); - inline float Scale() const - { return fScale; } - - // additional clipping as requested by client - void SetClippingRegion(const BRegion& region); - inline const BRegion* ClippingRegion() const - { return fClippingRegion; } -/* inline int32 CountClippingRects() const - { return fClippingRegion ? fClippingRegion.CountRects() : 0; } - inline BRect ClippingRectAt(int32 index) const;*/ - - // color - void SetHighColor(const RGBColor& color); - inline const RGBColor& HighColor() const - { return fHighColor; } - - void SetLowColor(const RGBColor& color); - inline const RGBColor& LowColor() const - { return fLowColor; } - - void SetPattern(const Pattern& pattern); - inline const Pattern& GetPattern() const - { return fPattern; } - - // drawing/blending mode - void SetDrawingMode(drawing_mode mode); - inline drawing_mode GetDrawingMode() const - { return fDrawingMode; } - - void SetBlendingMode(source_alpha srcMode, - alpha_function fncMode); - inline source_alpha AlphaSrcMode() const - { return fAlphaSrcMode; } - inline alpha_function AlphaFncMode() const - { return fAlphaFncMode; } - - // pen - void SetPenLocation(const BPoint& location); - const BPoint& PenLocation() const; - - void SetPenSize(float size); - float PenSize() const; - - // font - void SetFont(const ServerFont& font, - uint32 flags = B_FONT_ALL); - inline const ServerFont& Font() const - { return fFont; } - -// overrides aliasing flag contained in SeverFont::Flags()) - void SetForceFontAliasing(bool aliasing); - inline bool ForceFontAliasing() const - { return fFontAliasing; } - - // postscript style settings - void SetLineCapMode(cap_mode mode); - inline cap_mode LineCapMode() const - { return fLineCapMode; } - - void SetLineJoinMode(join_mode mode); - inline join_mode LineJoinMode() const - { return fLineJoinMode; } - - void SetMiterLimit(float limit); - inline float MiterLimit() const - { return fMiterLimit; } - - // convenience functions - inline BPoint Transform(const BPoint& point) const; - inline BRect Transform(const BRect& rect) const; - - void SetSubPixelPrecise(bool precise); - inline bool SubPixelPrecise() const - { return fSubPixelPrecise; } - - protected: - BPoint fOrigin; - float fScale; - - BRegion* fClippingRegion; - - RGBColor fHighColor; - RGBColor fLowColor; - Pattern fPattern; - - drawing_mode fDrawingMode; - source_alpha fAlphaSrcMode; - alpha_function fAlphaFncMode; - - BPoint fPenLocation; - float fPenSize; - - ServerFont fFont; - // overrides font aliasing flag - bool fFontAliasing; - - // This is not part of the normal state stack. - // Layer will update it in PushState/PopState. - // A BView can have a flag "B_SUBPIXEL_PRECISE", - // I never knew what it does on R5, but I can use - // it in Painter to actually draw stuff with - // sub-pixel coordinates. It means - // StrokeLine(BPoint(10, 5), BPoint(20, 9)); - // will look different from - // StrokeLine(BPoint(10.3, 5.8), BPoint(20.6, 9.5)); - bool fSubPixelPrecise; - - cap_mode fLineCapMode; - join_mode fLineJoinMode; - float fMiterLimit; - // "internal", used to calculate the size - // of the font (again) when the scale changes - float fUnscaledFontSize; -}; - -class LayerData : public DrawData { - public: - LayerData(); - LayerData(const LayerData& data); - // this version used for the state - // stack, sets prevState to data too - LayerData(LayerData* data); - virtual ~LayerData(); - - LayerData& operator=(const LayerData &from); - - // convenience functions - virtual void PrintToStream() const; - - void ReadFontFromLink(BPrivate::LinkReceiver& link); - // NOTE: ReadFromLink() does not read Font state!! - // It was separate in ServerWindow, and I didn't - // want to change it without knowing implications. - void ReadFromLink(BPrivate::LinkReceiver& link); - void WriteToLink(BPrivate::LinkSender& link) const; - - LayerData* PreviousState() const { return fPreviousState; } - LayerData* PopState(); - - private: - // used for the state stack - LayerData* fPreviousState; -}; - -// inline implementations - -// Transform -BPoint -DrawData::Transform(const BPoint& point) const -{ - BPoint p(point); - p += fOrigin; - p.x *= fScale; - p.y *= fScale; - return p; -} - -// Transform -BRect -DrawData::Transform(const BRect& rect) const -{ - return BRect(Transform(rect.LeftTop()), - Transform(rect.LeftBottom())); -} -/* -// ClippingRectAt -BRect -DrawData::ClippingRectAt(int32 index) const -{ - BRect r; - if (fClippingRegion) { - r = fClippingRegion.RectAt(index); - } - return r; -}*/ - -#endif // LAYER_DATA_H_ diff --git a/src/servers/app/Decorator.cpp b/src/servers/app/Decorator.cpp index b3231a3a68..12f7adefea 100644 --- a/src/servers/app/Decorator.cpp +++ b/src/servers/app/Decorator.cpp @@ -32,7 +32,7 @@ Decorator::Decorator(DesktopSettings& settings, BRect rect, int32 look, int32 feel, int32 flags) : _colors(new ColorSet()), _driver(NULL), - _drawdata(), + fDrawState(), _look(look), _feel(feel), @@ -124,7 +124,7 @@ void Decorator::SetFont(ServerFont *font) { if (font) { - _drawdata.SetFont(*font); + fDrawState.SetFont(*font); } } @@ -514,14 +514,14 @@ Decorator::_ClipTitle(float width) // when it exists (if it doesn't already) if (_driver) { int32 strlength = fTitle.CountChars(); - float pixwidth=_driver->StringWidth(fTitle.String(),strlength,&_drawdata); + float pixwidth=_driver->StringWidth(fTitle.String(),strlength,&fDrawState); while (strlength >= 0) { if (pixwidth < width) return strlength; strlength--; - pixwidth=_driver->StringWidth(fTitle.String(), strlength, &_drawdata); + pixwidth=_driver->StringWidth(fTitle.String(), strlength, &fDrawState); } } return 0; diff --git a/src/servers/app/DefaultDecorator.cpp b/src/servers/app/DefaultDecorator.cpp index ad792fc8d9..2f4db0963e 100644 --- a/src/servers/app/DefaultDecorator.cpp +++ b/src/servers/app/DefaultDecorator.cpp @@ -15,8 +15,8 @@ #include "ColorUtils.h" #include "DesktopSettings.h" #include "DisplayDriver.h" +#include "DrawState.h" #include "FontManager.h" -#include "LayerData.h" #include "PatternHandler.h" #include "RGBColor.h" @@ -351,7 +351,7 @@ DefaultDecorator::_DoLayout() fTextOffset = (_look == B_FLOATING_WINDOW_LOOK) ? 10 : 18; font_height fontHeight; - _drawdata.Font().GetHeight(fontHeight); + fDrawState.Font().GetHeight(fontHeight); _tabrect.Set(_frame.left - fBorderWidth, _frame.top - fBorderWidth @@ -379,7 +379,7 @@ DefaultDecorator::_DoLayout() // fMaxTabWidth contains fMinWidth + the width required for the title fMaxTabWidth = _driver ? _driver->StringWidth(GetTitle(), strlen(GetTitle()), - &_drawdata) : 0.0; + &fDrawState) : 0.0; if (fMaxTabWidth > 0.0) fMaxTabWidth += fTextOffset; fMaxTabWidth += fMinTabWidth; @@ -436,8 +436,8 @@ STRACE(("_DrawFrame(%f,%f,%f,%f)\n", invalid.left, invalid.top, invalid.right, invalid.bottom)); #ifdef USE_VIEW_FILL_HACK - _drawdata.SetHighColor(RGBColor(192, 192, 192 )); - _driver->FillRect(_frame, _drawdata.HighColor()); + fDrawState.SetHighColor(RGBColor(192, 192, 192 )); + _driver->FillRect(_frame, fDrawState.HighColor()); #endif if (_look == B_NO_BORDER_WINDOW_LOOK) @@ -632,12 +632,12 @@ DefaultDecorator::_DrawTitle(BRect r) { STRACE(("_DrawTitle(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom)); - _drawdata.SetHighColor(fTextColor); - _drawdata.SetLowColor(fTabColor); + fDrawState.SetHighColor(fTextColor); + fDrawState.SetLowColor(fTabColor); // figure out position of text font_height fontHeight; - _drawdata.Font().GetHeight(fontHeight); + fDrawState.Font().GetHeight(fontHeight); BPoint titlePos; titlePos.x = _closerect.IsValid() ? _closerect.right + fTextOffset @@ -645,7 +645,7 @@ DefaultDecorator::_DrawTitle(BRect r) titlePos.y = floorf(((_tabrect.top + 2.0) + _tabrect.bottom + fontHeight.ascent + fontHeight.descent) / 2.0 - fontHeight.descent + 0.5); - _driver->DrawString(fTruncatedTitle.String(), fTruncatedTitleLength, titlePos, &_drawdata); + _driver->DrawString(fTruncatedTitle.String(), fTruncatedTitleLength, titlePos, &fDrawState); } // _DrawZoom @@ -786,6 +786,6 @@ DefaultDecorator::_LayoutTabItems(const BRect& tabRect) // also not appear perfectly in the middle float width = (_zoomrect.left - _closerect.right) - fTextOffset * 2 + 2; fTruncatedTitle = GetTitle(); - _drawdata.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END, width); + fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END, width); fTruncatedTitleLength = fTruncatedTitle.Length(); } diff --git a/src/servers/app/LayerData.cpp b/src/servers/app/DrawState.cpp similarity index 73% rename from src/servers/app/LayerData.cpp rename to src/servers/app/DrawState.cpp index 828f02f449..679323214f 100644 --- a/src/servers/app/LayerData.cpp +++ b/src/servers/app/DrawState.cpp @@ -6,6 +6,7 @@ * DarkWyrm * Adi Oanca * Stephan Aßmus + * Axel Dörfler, axeld@pinc-software.de */ /** Data classes for working with BView states and draw parameters */ @@ -18,11 +19,10 @@ #include "LinkReceiver.h" #include "LinkSender.h" -#include "DesktopSettings.h" -#include "LayerData.h" +#include "DrawState.h" -DrawData::DrawData() +DrawState::DrawState() : fOrigin(0.0, 0.0), fScale(1.0), fClippingRegion(NULL), @@ -38,63 +38,29 @@ DrawData::DrawData() fSubPixelPrecise(false), fLineCapMode(B_BUTT_CAP), fLineJoinMode(B_BEVEL_JOIN), - fMiterLimit(B_DEFAULT_MITER_LIMIT) + fMiterLimit(B_DEFAULT_MITER_LIMIT), + fPreviousState(NULL) { fUnscaledFontSize = fFont.Size(); } -DrawData::DrawData(const DrawData& from) +DrawState::DrawState(const DrawState& from) : fClippingRegion(NULL) { *this = from; } -DrawData::DrawData(const DrawData* from) - : fOrigin(0.0, 0.0), - fScale(1.0), - fClippingRegion(NULL) -{ - if (from->fClippingRegion) { - SetClippingRegion(*(from->fClippingRegion)); - } - - fHighColor = from->fHighColor; - fLowColor = from->fLowColor; - fPattern = from->fPattern; - - fDrawingMode = from->fDrawingMode; - fAlphaSrcMode = from->fAlphaSrcMode; - fAlphaFncMode = from->fAlphaFncMode; - - fPenLocation = from->fPenLocation; - fPenSize = from->fPenSize; - - fFont = from->fFont; - fFontAliasing = from->fFontAliasing; - - fSubPixelPrecise = from->fSubPixelPrecise; - - fLineCapMode = from->fLineCapMode; - fLineJoinMode = from->fLineJoinMode; - fMiterLimit = from->fMiterLimit; - - // Since fScale is reset to 1.0, the unscaled - // font size is the current size of the font - // (which is from->fUnscaledFontSize * from->fScale) - fUnscaledFontSize = fFont.Size(); -} - -// destructor -DrawData::~DrawData() +DrawState::~DrawState() { delete fClippingRegion; + delete fPreviousState; } -// operator= -DrawData& -DrawData::operator=(const DrawData& from) + +DrawState& +DrawState::operator=(const DrawState& from) { fOrigin = from.fOrigin; fScale = from.fScale; @@ -126,281 +92,41 @@ DrawData::operator=(const DrawData& from) fLineJoinMode = from.fLineJoinMode; fMiterLimit = from.fMiterLimit; + // Since fScale is reset to 1.0, the unscaled + // font size is the current size of the font + // (which is from->fUnscaledFontSize * from->fScale) fUnscaledFontSize = from.fUnscaledFontSize; + fPreviousState = from.fPreviousState; return *this; } -// SetOrigin + +DrawState* +DrawState::PushState() +{ + DrawState* next = new DrawState(*this); + // this may throw an exception that our caller should handle + + next->fPreviousState = this; + return next; +} + + +DrawState* +DrawState::PopState() +{ + DrawState* previous = PreviousState(); + + fPreviousState = NULL; + delete this; + + return previous; +} + + void -DrawData::SetOrigin(const BPoint& origin) -{ - fOrigin = origin; -} - -// OffsetOrigin -void -DrawData::OffsetOrigin(const BPoint& offset) -{ - fOrigin += offset; -} - -// SetScale -void -DrawData::SetScale(float scale) -{ - if (fScale != scale) { - fScale = scale; - // update font size - // (pen size is currently calulated on the fly) - fFont.SetSize(fUnscaledFontSize * fScale); - } -} - -// SetClippingRegion -void -DrawData::SetClippingRegion(const BRegion& region) -{ - if (region.Frame().IsValid()) { - if (fClippingRegion) - *fClippingRegion = region; - else - fClippingRegion = new BRegion(region); - } else { - delete fClippingRegion; - fClippingRegion = NULL; - } -} - -// SetHighColor -void -DrawData::SetHighColor(const RGBColor& color) -{ - fHighColor = color; -} - -// SetLowColor -void -DrawData::SetLowColor(const RGBColor& color) -{ - fLowColor = color; -} - -// SetPattern -void -DrawData::SetPattern(const Pattern& pattern) -{ - fPattern = pattern; -} - -// SetDrawingMode -void -DrawData::SetDrawingMode(drawing_mode mode) -{ - fDrawingMode = mode; -} - -// SetBlendingMode -void -DrawData::SetBlendingMode(source_alpha srcMode, alpha_function fncMode) -{ - fAlphaSrcMode = srcMode; - fAlphaFncMode = fncMode; -} - -// SetPenLocation -void -DrawData::SetPenLocation(const BPoint& location) -{ - // TODO: Needs to be in local coordinate system! - // There is going to be some work involved in - // other parts of app_server... - fPenLocation = location; -} - -// PenLocation -const BPoint& -DrawData::PenLocation() const -{ - // TODO: See above - return fPenLocation; -} - -// SetPenSize -void -DrawData::SetPenSize(float size) -{ - fPenSize = size; -} - -// PenSize -// * returns the scaled pen size -float -DrawData::PenSize() const -{ - float penSize = fPenSize * fScale; - // NOTE: As documented in the BeBook, - // pen size is never smaller than 1.0. - // This is supposed to be the smallest - // possible device size. - if (penSize < 1.0) - penSize = 1.0; - return penSize; -} - - -// SetFont -// * sets the font to be already scaled by fScale -void -DrawData::SetFont(const ServerFont& font, uint32 flags) -{ - if (flags == B_FONT_ALL) { - fFont = font; - fUnscaledFontSize = font.Size(); - fFont.SetSize(fUnscaledFontSize * fScale); - } else { - // family & style - if (flags & B_FONT_FAMILY_AND_STYLE) - fFont.SetFamilyAndStyle(font.GetFamilyAndStyle()); - // size - if (flags & B_FONT_SIZE) { - fUnscaledFontSize = font.Size(); - fFont.SetSize(fUnscaledFontSize * fScale); - } - // shear - if (flags & B_FONT_SHEAR) - fFont.SetShear(font.Shear()); - // rotation - if (flags & B_FONT_ROTATION) - fFont.SetRotation(font.Rotation()); - // spacing - if (flags & B_FONT_SPACING) - fFont.SetSpacing(font.Spacing()); - // encoding - if (flags & B_FONT_ENCODING) - fFont.SetEncoding(font.Encoding()); - // face - if (flags & B_FONT_FACE) - fFont.SetFace(font.Face()); - // flags - if (flags & B_FONT_FLAGS) - fFont.SetFlags(font.Flags()); - } -} - -// SetForceFontAliasing -void -DrawData::SetForceFontAliasing(bool aliasing) -{ - fFontAliasing = aliasing; -} - -// SetSubPixelPrecise -void -DrawData::SetSubPixelPrecise(bool precise) -{ - fSubPixelPrecise = precise; -} - -// SetLineCapMode -void -DrawData::SetLineCapMode(cap_mode mode) -{ - fLineCapMode = mode; -} - -// SetLineJoinMode -void -DrawData::SetLineJoinMode(join_mode mode) -{ - fLineJoinMode = mode; -} - -// SetMiterLimit -void -DrawData::SetMiterLimit(float limit) -{ - fMiterLimit = limit; -} - - -// #pragma mark - - - -LayerData::LayerData() - : DrawData(), - fPreviousState(NULL) -{ -} - - -LayerData::LayerData(const LayerData& data) - : DrawData(data), - fPreviousState(data.fPreviousState) -{ -} - - -LayerData::LayerData(LayerData* data) - : DrawData(data), - fPreviousState(data) -{ -} - - -LayerData::~LayerData() -{ - delete fPreviousState; -} - - -LayerData& -LayerData::operator=(const LayerData& from) -{ - DrawData::operator=(from); - fPreviousState = from.PreviousState(); - - return *this; -} - -// PrintToStream -void -LayerData::PrintToStream() const -{ - printf("\t Origin: (%.1f, %.1f)\n", fOrigin.x, fOrigin.y); - printf("\t Scale: %.2f\n", fScale); - - printf("\t Pen Location and Size: (%.1f, %.1f) - %.2f (%.2f)\n", - fPenLocation.x, fPenLocation.y, PenSize(), fPenSize); - - printf("\t HighColor: "); fHighColor.PrintToStream(); - printf("\t LowColor: "); fLowColor.PrintToStream(); - printf("\t Pattern: %llu\n", fPattern.GetInt64()); - - printf("\t DrawMode: %lu\n", (uint32)fDrawingMode); - printf("\t AlphaSrcMode: %ld\t AlphaFncMode: %ld\n", - (int32)fAlphaSrcMode, (int32)fAlphaFncMode); - - printf("\t LineCap: %d\t LineJoin: %d\t MiterLimit: %.2f\n", - (int16)fLineCapMode, (int16)fLineJoinMode, fMiterLimit); - - if (fClippingRegion) - fClippingRegion->PrintToStream(); - - printf("\t ===== Font Data =====\n"); - printf("\t Style: CURRENTLY NOT SET\n"); // ??? - printf("\t Size: %.1f (%.1f)\n", fFont.Size(), fUnscaledFontSize); - printf("\t Shear: %.2f\n", fFont.Shear()); - printf("\t Rotation: %.2f\n", fFont.Rotation()); - printf("\t Spacing: %ld\n", fFont.Spacing()); - printf("\t Encoding: %ld\n", fFont.Encoding()); - printf("\t Face: %d\n", fFont.Face()); - printf("\t Flags: %lu\n", fFont.Flags()); -} - -// ReadFontFromLink -void -LayerData::ReadFontFromLink(BPrivate::LinkReceiver& link) +DrawState::ReadFontFromLink(BPrivate::LinkReceiver& link) { uint16 mask; link.Read(&mask); @@ -454,9 +180,9 @@ LayerData::ReadFontFromLink(BPrivate::LinkReceiver& link) } } -// ReadFromLink + void -LayerData::ReadFromLink(BPrivate::LinkReceiver& link) +DrawState::ReadFromLink(BPrivate::LinkReceiver& link) { rgb_color highColor; rgb_color lowColor; @@ -496,9 +222,9 @@ LayerData::ReadFromLink(BPrivate::LinkReceiver& link) SetClippingRegion(region); } -// WriteToLink + void -LayerData::WriteToLink(BPrivate::LinkSender& link) const +DrawState::WriteToLink(BPrivate::LinkSender& link) const { rgb_color hc = fHighColor.GetColor32(); rgb_color lc = fLowColor.GetColor32(); @@ -539,14 +265,228 @@ LayerData::WriteToLink(BPrivate::LinkSender& link) const } -LayerData* -LayerData::PopState() +void +DrawState::SetOrigin(const BPoint& origin) { - LayerData* previous = PreviousState(); - - fPreviousState = NULL; - delete this; - - return previous; + fOrigin = origin; +} + + +void +DrawState::OffsetOrigin(const BPoint& offset) +{ + fOrigin += offset; +} + + +void +DrawState::SetScale(float scale) +{ + if (fScale != scale) { + fScale = scale; + // update font size + // (pen size is currently calulated on the fly) + fFont.SetSize(fUnscaledFontSize * fScale); + } +} + + +void +DrawState::SetClippingRegion(const BRegion& region) +{ + if (region.Frame().IsValid()) { + if (fClippingRegion) + *fClippingRegion = region; + else + fClippingRegion = new BRegion(region); + } else { + delete fClippingRegion; + fClippingRegion = NULL; + } +} + + +void +DrawState::SetHighColor(const RGBColor& color) +{ + fHighColor = color; +} + + +void +DrawState::SetLowColor(const RGBColor& color) +{ + fLowColor = color; +} + + +void +DrawState::SetPattern(const Pattern& pattern) +{ + fPattern = pattern; +} + + +void +DrawState::SetDrawingMode(drawing_mode mode) +{ + fDrawingMode = mode; +} + + +void +DrawState::SetBlendingMode(source_alpha srcMode, alpha_function fncMode) +{ + fAlphaSrcMode = srcMode; + fAlphaFncMode = fncMode; +} + + +void +DrawState::SetPenLocation(const BPoint& location) +{ + // TODO: Needs to be in local coordinate system! + // There is going to be some work involved in + // other parts of app_server... + fPenLocation = location; +} + + +const BPoint& +DrawState::PenLocation() const +{ + // TODO: See above + return fPenLocation; +} + + +void +DrawState::SetPenSize(float size) +{ + fPenSize = size; +} + + +//! returns the scaled pen size +float +DrawState::PenSize() const +{ + float penSize = fPenSize * fScale; + // NOTE: As documented in the BeBook, + // pen size is never smaller than 1.0. + // This is supposed to be the smallest + // possible device size. + if (penSize < 1.0) + penSize = 1.0; + return penSize; +} + + +//! sets the font to be already scaled by fScale +void +DrawState::SetFont(const ServerFont& font, uint32 flags) +{ + if (flags == B_FONT_ALL) { + fFont = font; + fUnscaledFontSize = font.Size(); + fFont.SetSize(fUnscaledFontSize * fScale); + } else { + // family & style + if (flags & B_FONT_FAMILY_AND_STYLE) + fFont.SetFamilyAndStyle(font.GetFamilyAndStyle()); + // size + if (flags & B_FONT_SIZE) { + fUnscaledFontSize = font.Size(); + fFont.SetSize(fUnscaledFontSize * fScale); + } + // shear + if (flags & B_FONT_SHEAR) + fFont.SetShear(font.Shear()); + // rotation + if (flags & B_FONT_ROTATION) + fFont.SetRotation(font.Rotation()); + // spacing + if (flags & B_FONT_SPACING) + fFont.SetSpacing(font.Spacing()); + // encoding + if (flags & B_FONT_ENCODING) + fFont.SetEncoding(font.Encoding()); + // face + if (flags & B_FONT_FACE) + fFont.SetFace(font.Face()); + // flags + if (flags & B_FONT_FLAGS) + fFont.SetFlags(font.Flags()); + } +} + + +void +DrawState::SetForceFontAliasing(bool aliasing) +{ + fFontAliasing = aliasing; +} + + +void +DrawState::SetSubPixelPrecise(bool precise) +{ + fSubPixelPrecise = precise; +} + + +void +DrawState::SetLineCapMode(cap_mode mode) +{ + fLineCapMode = mode; +} + + +void +DrawState::SetLineJoinMode(join_mode mode) +{ + fLineJoinMode = mode; +} + + +void +DrawState::SetMiterLimit(float limit) +{ + fMiterLimit = limit; +} + + +void +DrawState::PrintToStream() const +{ + printf("\t Origin: (%.1f, %.1f)\n", fOrigin.x, fOrigin.y); + printf("\t Scale: %.2f\n", fScale); + + printf("\t Pen Location and Size: (%.1f, %.1f) - %.2f (%.2f)\n", + fPenLocation.x, fPenLocation.y, PenSize(), fPenSize); + + printf("\t HighColor: "); fHighColor.PrintToStream(); + printf("\t LowColor: "); fLowColor.PrintToStream(); + printf("\t Pattern: %llu\n", fPattern.GetInt64()); + + printf("\t DrawMode: %lu\n", (uint32)fDrawingMode); + printf("\t AlphaSrcMode: %ld\t AlphaFncMode: %ld\n", + (int32)fAlphaSrcMode, (int32)fAlphaFncMode); + + printf("\t LineCap: %d\t LineJoin: %d\t MiterLimit: %.2f\n", + (int16)fLineCapMode, (int16)fLineJoinMode, fMiterLimit); + + if (fClippingRegion) + fClippingRegion->PrintToStream(); + + printf("\t ===== Font Data =====\n"); + printf("\t Style: CURRENTLY NOT SET\n"); // ??? + printf("\t Size: %.1f (%.1f)\n", fFont.Size(), fUnscaledFontSize); + printf("\t Shear: %.2f\n", fFont.Shear()); + printf("\t Rotation: %.2f\n", fFont.Rotation()); + printf("\t Spacing: %ld\n", fFont.Spacing()); + printf("\t Encoding: %ld\n", fFont.Encoding()); + printf("\t Face: %d\n", fFont.Face()); + printf("\t Flags: %lu\n", fFont.Flags()); } diff --git a/src/servers/app/Jamfile b/src/servers/app/Jamfile index cabb51854b..ce571d309a 100644 --- a/src/servers/app/Jamfile +++ b/src/servers/app/Jamfile @@ -28,9 +28,9 @@ SharedLibrary libappserver.so : CursorData.cpp CursorSet.cpp Decorator.cpp + DrawState.cpp FontFamily.cpp IPoint.cpp - LayerData.cpp RGBColor.cpp ServerBitmap.cpp ServerCursor.cpp diff --git a/src/servers/app/Layer.cpp b/src/servers/app/Layer.cpp index ee8597443b..ed291b719d 100644 --- a/src/servers/app/Layer.cpp +++ b/src/servers/app/Layer.cpp @@ -38,7 +38,7 @@ #include "DebugInfoManager.h" #include "DisplayDriver.h" -#include "LayerData.h" +#include "DrawState.h" #include "PortLink.h" #include "RootLayer.h" #include "ServerProtocol.h" @@ -106,7 +106,7 @@ Layer::Layer(BRect frame, const char* name, int32 token, fAdFlags(0), fDriver(driver), - fLayerData(new LayerData), + fDrawState(new DrawState), fRootLayer(NULL), @@ -125,18 +125,18 @@ CRITICAL(helper); if (!fDriver) CRITICAL("You MUST have a valid driver to init a Layer object\n"); - // NOTE: This flag is forwarded to a LayerData setting, even + // NOTE: This flag is forwarded to a DrawState setting, even // though it is actually not part of a "state". However, // it is an important detail of a graphics context, and we // have no other means to pass this setting on to the DisplayDriver - // other than through the LayerData. If we ever add a flag + // other than through the DrawState. If we ever add a flag // B_ANTI_ALIASING to the view flags, it would have to be passed // in the same way. Though when breaking binary compatibility, // we might want to make this an actual part of a "state" (with // a different API to set these). // Note that the flag is also tested (updated) in Push/PopState and // SetFlags(). - fLayerData->SetSubPixelPrecise(fFlags & B_SUBPIXEL_PRECISE); + fDrawState->SetSubPixelPrecise(fFlags & B_SUBPIXEL_PRECISE); STRACE(("Layer(%s) successfuly created\n", Name())); } @@ -144,7 +144,7 @@ CRITICAL(helper); Layer::~Layer() { - delete fLayerData; + delete fDrawState; // TODO: uncomment! //PruneTree(); @@ -486,7 +486,7 @@ void Layer::SetFlags(uint32 flags) { fFlags = flags; - fLayerData->SetSubPixelPrecise(fFlags & B_SUBPIXEL_PRECISE); + fDrawState->SetSubPixelPrecise(fFlags & B_SUBPIXEL_PRECISE); } #ifndef NEW_CLIPPING @@ -506,8 +506,8 @@ Layer::RebuildFullRegion(void) // TODO: Convert to screen coordinates - LayerData *ld; - ld = fLayerData; + DrawState *ld; + ld = fDrawState; do { // clip to user region if (const BRegion* userClipping = ld->ClippingRegion()) @@ -1010,23 +1010,21 @@ Layer::IsHidden(void) const void Layer::PushState() { - LayerData *data = new LayerData(fLayerData); - fLayerData = data; - - fLayerData->SetSubPixelPrecise(fFlags & B_SUBPIXEL_PRECISE); + fDrawState = fDrawState->PushState(); + fDrawState->SetSubPixelPrecise(fFlags & B_SUBPIXEL_PRECISE); } void Layer::PopState() { - if (fLayerData->PreviousState() == NULL) { + if (fDrawState->PreviousState() == NULL) { fprintf(stderr, "WARNING: User called BView(%s)::PopState(), but there is NO state on stack!\n", Name()); return; } - fLayerData = fLayerData->PopState(); - fLayerData->SetSubPixelPrecise(fFlags & B_SUBPIXEL_PRECISE); + fDrawState = fDrawState->PopState(); + fDrawState->SetSubPixelPrecise(fFlags & B_SUBPIXEL_PRECISE); } @@ -1204,7 +1202,7 @@ Layer::BoundsOrigin() const BPoint origin(0,0); float scale = Scale(); - LayerData* layerData = fLayerData; + DrawState* layerData = fDrawState; do { origin += layerData->Origin(); } while ((layerData = layerData->PreviousState()) != NULL); @@ -1221,7 +1219,7 @@ Layer::Scale() const { float scale = 1.0f; - LayerData* layerData = fLayerData; + DrawState* layerData = fDrawState; do { scale *= layerData->Scale(); } while ((layerData = layerData->PreviousState()) != NULL); @@ -1475,10 +1473,10 @@ Layer::PrintToStream() printf("ResizingMode: %lx ", fResizeMode); printf("Flags: %lx\n", fFlags); - if (fLayerData) - fLayerData->PrintToStream(); + if (fDrawState) + fDrawState->PrintToStream(); else - printf(" NO LayerData valid pointer\n"); + printf(" NO DrawState valid pointer\n"); } //! Prints pointer info kept by the current layer @@ -2479,7 +2477,7 @@ void Layer::do_MoveBy(float dx, float dy) void Layer::do_ScrollBy(float dx, float dy) { - fLayerData->OffsetOrigin(BPoint(dx, dy)); + fDrawState->OffsetOrigin(BPoint(dx, dy)); // fOrigin.Set(fOrigin.x + dx, fOrigin.y + dy); if (!IsHidden() && GetRootLayer()) { @@ -2532,7 +2530,7 @@ Layer::_GetWantedRegion(BRegion ®) // 3) impose user constrained regions - LayerData *stackData = fLayerData; + DrawState *stackData = fDrawState; while (stackData) { if (stackData->ClippingRegion()) { // transform in screen coords diff --git a/src/servers/app/Layer.h b/src/servers/app/Layer.h index 2829e1b424..cd0cbcd55e 100644 --- a/src/servers/app/Layer.h +++ b/src/servers/app/Layer.h @@ -64,7 +64,7 @@ enum { class ServerApp; class RootLayer; class DisplayDriver; -class LayerData; +class DrawState; class ServerBitmap; class PointerEvent { @@ -371,7 +371,7 @@ friend class OffscreenWinBorder; uint16 fAdFlags; DisplayDriver* fDriver; - LayerData* fLayerData; + DrawState* fDrawState; RootLayer* fRootLayer; diff --git a/src/servers/app/PicturePlayer.cpp b/src/servers/app/PicturePlayer.cpp index 46e1720b61..ef7eec787b 100644 --- a/src/servers/app/PicturePlayer.cpp +++ b/src/servers/app/PicturePlayer.cpp @@ -128,7 +128,7 @@ void PicturePlayer::GetData(void *data, int32 size) fData.Read(data, size); } -status_t PicturePlayer::Play(int32 tableEntries,void *userData, LayerData *d) +status_t PicturePlayer::Play(int32 tableEntries,void *userData, DrawState *d) { if(!userData || !d) return B_ERROR; diff --git a/src/servers/app/PicturePlayer.h b/src/servers/app/PicturePlayer.h index 985c563167..c16034d719 100644 --- a/src/servers/app/PicturePlayer.h +++ b/src/servers/app/PicturePlayer.h @@ -32,7 +32,7 @@ #include #include #include -#include "LayerData.h" +#include "DrawState.h" #include "PatternHandler.h" // for pattern_union class DisplayDriver; @@ -81,14 +81,14 @@ public: void SetClippingRegion(BRect *rects, int32 numrects); - status_t Play(int32 tableEntries,void *userData, LayerData *d); + status_t Play(int32 tableEntries,void *userData, DrawState *d); status_t Rewind(); private: BMemoryIO fData; int32 fSize; DisplayDriver *fdriver; - LayerData fldata; + DrawState fldata; BPoint forigin; Pattern stipplepat; BRegion *clipreg; diff --git a/src/servers/app/RootLayer.cpp b/src/servers/app/RootLayer.cpp index 13f7c1aee1..ffe7ddf4fe 100644 --- a/src/servers/app/RootLayer.cpp +++ b/src/servers/app/RootLayer.cpp @@ -1,34 +1,20 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2001-2005, Haiku, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// -// File Name: RootLayer.cpp -// Author: Gabe Yoder -// DarkWyrm -// Adi Oanca -// Stephan Aßmus -// Description: Class used for the top layer of each workspace's Layer tree -// -//------------------------------------------------------------------------------ +/* + * Copyright 2001-2005, Haiku, Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Gabe Yoder + * DarkWyrm + * Adrian Oanca + * Stephan Aßmus + * Axel Dörfler, axeld@pinc-software.de + */ + +/** Class used for the top layer of each workspace's Layer tree */ + #include + #include #include #include @@ -137,8 +123,8 @@ RootLayer::RootLayer(const char *name, int32 workspaceCount, // init the first, default workspace fWorkspace[fActiveWksIndex] = new Workspace(fActiveWksIndex, 0xFF00FF00, kDefaultWorkspaceColor); - fLayerData->SetHighColor(RGBColor(255, 255, 255)); - fLayerData->SetLowColor(fWorkspace[fActiveWksIndex]->BGColor()); + fDrawState->SetHighColor(RGBColor(255, 255, 255)); + fDrawState->SetLowColor(fWorkspace[fActiveWksIndex]->BGColor()); // Spawn our working thread fThreadID = spawn_thread(WorkingThread, name, B_DISPLAY_PRIORITY, this); @@ -559,10 +545,10 @@ bool RootLayer::SetActiveWorkspace(int32 index) // adjust our DrawData to workspace colors rgb_color bg = fWorkspace[index]->BGColor().GetColor32(); if ((bg.red + bg.green + bg.blue) / 3 > 128) - fLayerData->SetHighColor(RGBColor(0, 0, 0)); + fDrawState->SetHighColor(RGBColor(0, 0, 0)); else - fLayerData->SetHighColor(RGBColor(255, 255, 255)); - fLayerData->SetLowColor(fWorkspace[index]->BGColor()); + fDrawState->SetHighColor(RGBColor(255, 255, 255)); + fDrawState->SetLowColor(fWorkspace[index]->BGColor()); // save some datas int32 exIndex = ActiveWorkspaceIndex(); @@ -1587,7 +1573,7 @@ RootLayer::Draw(const BRect &r) char string[30]; sprintf(string, "Workspace %ld", fActiveWksIndex + 1); fDriver->DrawString(string, strlen(string), BPoint(5, 15), - fLayerData); + fDrawState); #endif // APPSERVER_ROOTLAYER_SHOW_WORKSPACE_NUMBER #if ON_SCREEN_DEBUGGING_INFO BPoint location(5, 40); @@ -1598,7 +1584,7 @@ RootLayer::Draw(const BRect &r) p++; if (*p == 0 || *p == '\n') { fDriver->DrawString(start, p - start, location, - fLayerData); + fDrawState); // NOTE: Eventually, this will be below the screen! location.y += textHeight; start = p + 1; @@ -1614,7 +1600,7 @@ RootLayer::Draw(const BRect &r) logoPos.y = floorf(fFrame.bottom - kLogoHeight * 1.5); BRect bitmapBounds = fLogoBitmap->Bounds(); fDriver->DrawBitmap(fLogoBitmap, bitmapBounds, - bitmapBounds.OffsetToCopy(logoPos), fLayerData); + bitmapBounds.OffsetToCopy(logoPos), fDrawState); } #endif // DISPLAY_HAIKU_LOGO } diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index 12e169ed06..07c99cd3ea 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -38,7 +38,7 @@ #include "DisplayDriver.h" #include "FontManager.h" #include "HWInterface.h" -#include "LayerData.h" +//#include "DrawState.h" #include "OffscreenServerWindow.h" #include "RAMLinkMsgReader.h" #include "RootLayer.h" @@ -494,8 +494,6 @@ ServerApp::_MessageLooper() void ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) { -// LayerData ld; - switch (code) { case AS_GET_WINDOW_LIST: team_id team; diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index 16e7ff6ead..0c98ec21a3 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -430,7 +430,7 @@ ServerWindow::SetLayerFontState(Layer *layer, BPrivate::LinkReceiver &link) fTitle, layer->Name())); // NOTE: no need to check for a lock. This is a private method. - layer->fLayerData->ReadFontFromLink(link); + layer->fDrawState->ReadFontFromLink(link); } @@ -441,7 +441,7 @@ ServerWindow::SetLayerState(Layer *layer, BPrivate::LinkReceiver &link) layer->Name())); // NOTE: no need to check for a lock. This is a private method. - layer->fLayerData->ReadFromLink(link); + layer->fDrawState->ReadFromLink(link); // TODO: Rebuild clipping here? } @@ -503,7 +503,7 @@ ServerWindow::CreateLayerTree(BPrivate::LinkReceiver &link, Layer **_parent) DesktopSettings settings(fDesktop); ServerFont font; settings.GetDefaultPlainFont(font); - newLayer->fLayerData->SetFont(font); + newLayer->fDrawState->SetFont(font); // TODO: rework the clipping stuff to remove RootLayer dependency and then // remove this hack: @@ -570,7 +570,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) // -> it will invalidate areas previously out of screen dst = dst | src; - fCurrentLayer->fLayerData->OffsetOrigin(BPoint(dh, dv)); + fCurrentLayer->fDrawState->OffsetOrigin(BPoint(dh, dv)); fCurrentLayer->CopyBits(src, dst, xOffset, yOffset); #else @@ -730,7 +730,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) fLink.StartMessage(SERVER_TRUE); // attach state data - fCurrentLayer->fLayerData->WriteToLink(fLink.Sender()); + fCurrentLayer->fDrawState->WriteToLink(fLink.Sender()); fLink.Flush(); break; } @@ -816,14 +816,14 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) link.Read(&x); link.Read(&y); - fCurrentLayer->fLayerData->SetOrigin(BPoint(x, y)); + fCurrentLayer->fDrawState->SetOrigin(BPoint(x, y)); break; } case AS_LAYER_GET_ORIGIN: { STRACE(("ServerWindow %s: Message AS_LAYER_GET_ORIGIN: Layer: %s\n", Title(), fCurrentLayer->Name())); fLink.StartMessage(SERVER_TRUE); - fLink.Attach(fCurrentLayer->fLayerData->Origin()); + fLink.Attach(fCurrentLayer->fDrawState->Origin()); fLink.Flush(); break; } @@ -878,9 +878,9 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) link.Read(&lineJoin); link.Read(&miterLimit); - fCurrentLayer->fLayerData->SetLineCapMode((cap_mode)lineCap); - fCurrentLayer->fLayerData->SetLineJoinMode((join_mode)lineJoin); - fCurrentLayer->fLayerData->SetMiterLimit(miterLimit); + fCurrentLayer->fDrawState->SetLineCapMode((cap_mode)lineCap); + fCurrentLayer->fDrawState->SetLineJoinMode((join_mode)lineJoin); + fCurrentLayer->fDrawState->SetMiterLimit(miterLimit); break; } @@ -888,9 +888,9 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) { DTRACE(("ServerWindow %s: Message AS_LAYER_GET_LINE_MODE: Layer: %s\n", Title(), fCurrentLayer->Name())); fLink.StartMessage(SERVER_TRUE); - fLink.Attach((int8)(fCurrentLayer->fLayerData->LineCapMode())); - fLink.Attach((int8)(fCurrentLayer->fLayerData->LineJoinMode())); - fLink.Attach(fCurrentLayer->fLayerData->MiterLimit()); + fLink.Attach((int8)(fCurrentLayer->fDrawState->LineCapMode())); + fLink.Attach((int8)(fCurrentLayer->fDrawState->LineJoinMode())); + fLink.Attach(fCurrentLayer->fDrawState->MiterLimit()); fLink.Flush(); break; @@ -922,13 +922,13 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) link.Read(&scale); // TODO: The BeBook says, if you call SetScale() it will be // multiplied with the scale from all previous states on the stack - fCurrentLayer->fLayerData->SetScale(scale); + fCurrentLayer->fDrawState->SetScale(scale); break; } case AS_LAYER_GET_SCALE: { DTRACE(("ServerWindow %s: Message AS_LAYER_GET_SCALE: Layer: %s\n", Title(), fCurrentLayer->Name())); - LayerData* layerData = fCurrentLayer->fLayerData; + DrawState* layerData = fCurrentLayer->fDrawState; // TODO: And here, we're taking that into account, but not above // -> refactor put scale into Layer, or better yet, when the @@ -952,14 +952,14 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) link.Read(&x); link.Read(&y); - fCurrentLayer->fLayerData->SetPenLocation(BPoint(x, y)); + fCurrentLayer->fDrawState->SetPenLocation(BPoint(x, y)); break; } case AS_LAYER_GET_PEN_LOC: { DTRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_LOC: Layer: %s\n", Title(), fCurrentLayer->Name())); fLink.StartMessage(SERVER_TRUE); - fLink.Attach(fCurrentLayer->fLayerData->PenLocation()); + fLink.Attach(fCurrentLayer->fDrawState->PenLocation()); fLink.Flush(); break; @@ -969,7 +969,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) DTRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_SIZE: Layer: %s\n", Title(), fCurrentLayer->Name())); float penSize; link.Read(&penSize); - fCurrentLayer->fLayerData->SetPenSize(penSize); + fCurrentLayer->fDrawState->SetPenSize(penSize); break; } @@ -977,7 +977,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) { DTRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_SIZE: Layer: %s\n", Title(), fCurrentLayer->Name())); fLink.StartMessage(SERVER_TRUE); - fLink.Attach(fCurrentLayer->fLayerData->PenSize()); + fLink.Attach(fCurrentLayer->fDrawState->PenSize()); fLink.Flush(); break; @@ -1006,7 +1006,7 @@ myRootLayer->Unlock(); Title(), fCurrentLayer->Name())); fLink.StartMessage(SERVER_TRUE); - fLink.Attach(fCurrentLayer->fLayerData->HighColor().GetColor32()); + fLink.Attach(fCurrentLayer->fDrawState->HighColor().GetColor32()); fLink.Flush(); break; @@ -1015,7 +1015,7 @@ myRootLayer->Unlock(); Title(), fCurrentLayer->Name())); fLink.StartMessage(SERVER_TRUE); - fLink.Attach(fCurrentLayer->fLayerData->LowColor().GetColor32()); + fLink.Attach(fCurrentLayer->fDrawState->LowColor().GetColor32()); fLink.Flush(); break; @@ -1036,7 +1036,7 @@ myRootLayer->Unlock(); link.Read(&srcAlpha); link.Read(&alphaFunc); - fCurrentLayer->fLayerData->SetBlendingMode((source_alpha)srcAlpha, + fCurrentLayer->fDrawState->SetBlendingMode((source_alpha)srcAlpha, (alpha_function)alphaFunc); break; @@ -1045,8 +1045,8 @@ myRootLayer->Unlock(); { DTRACE(("ServerWindow %s: Message AS_LAYER_GET_BLEND_MODE: Layer: %s\n", Title(), fCurrentLayer->Name())); fLink.StartMessage(SERVER_TRUE); - fLink.Attach((int8)(fCurrentLayer->fLayerData->AlphaSrcMode())); - fLink.Attach((int8)(fCurrentLayer->fLayerData->AlphaFncMode())); + fLink.Attach((int8)(fCurrentLayer->fDrawState->AlphaSrcMode())); + fLink.Attach((int8)(fCurrentLayer->fDrawState->AlphaFncMode())); fLink.Flush(); break; @@ -1058,7 +1058,7 @@ myRootLayer->Unlock(); link.Read(&drawingMode); - fCurrentLayer->fLayerData->SetDrawingMode((drawing_mode)drawingMode); + fCurrentLayer->fDrawState->SetDrawingMode((drawing_mode)drawingMode); break; } @@ -1066,7 +1066,7 @@ myRootLayer->Unlock(); { DTRACE(("ServerWindow %s: Message AS_LAYER_GET_DRAW_MODE: Layer: %s\n", Title(), fCurrentLayer->Name())); fLink.StartMessage(SERVER_TRUE); - fLink.Attach((int8)(fCurrentLayer->fLayerData->GetDrawingMode())); + fLink.Attach((int8)(fCurrentLayer->fDrawState->GetDrawingMode())); fLink.Flush(); break; @@ -1076,7 +1076,7 @@ myRootLayer->Unlock(); DTRACE(("ServerWindow %s: Message AS_LAYER_PRINT_ALIASING: Layer: %s\n", Title(), fCurrentLayer->Name())); bool fontAliasing; link.Read(&fontAliasing); - fCurrentLayer->fLayerData->SetForceFontAliasing(fontAliasing); + fCurrentLayer->fDrawState->SetForceFontAliasing(fontAliasing); break; } @@ -1106,7 +1106,7 @@ myRootLayer->Unlock(); if (PictureToRegion(picture, region, inverse, where) < B_OK) break; - fCurrentLayer->fLayerData->SetClippingRegion(region); + fCurrentLayer->fDrawState->SetClippingRegion(region); #ifndef NEW_CLIPPING fCurrentLayer->RebuildFullRegion(); @@ -1176,7 +1176,7 @@ myRootLayer->Unlock(); // We need to integrate user clipping more, in Layer::PopState, the clipping needs to be // restored too. "AS_LAYER_SET_CLIP_REGION" is irritating, as I think it should be // "AS_LAYER_CONSTRAIN_CLIP_REGION", since it means to "add" to the current clipping, not "set" it. -// fCurrentLayer->fLayerData->SetClippingRegion(region); +// fCurrentLayer->fDrawState->SetClippingRegion(region); #ifndef NEW_CLIPPING // TODO: set the clipping // fCurrentLayer->fVisible.IntersectWith(®ion); @@ -1515,7 +1515,7 @@ myRootLayer->Unlock(); link.Read(&c, sizeof(rgb_color)); - fCurrentLayer->fLayerData->SetHighColor(RGBColor(c)); + fCurrentLayer->fDrawState->SetHighColor(RGBColor(c)); break; } @@ -1526,7 +1526,7 @@ myRootLayer->Unlock(); link.Read(&c, sizeof(rgb_color)); - fCurrentLayer->fLayerData->SetLowColor(RGBColor(c)); + fCurrentLayer->fDrawState->SetLowColor(RGBColor(c)); break; } @@ -1537,7 +1537,7 @@ myRootLayer->Unlock(); link.Read(&pat, sizeof(pattern)); - fCurrentLayer->fLayerData->SetPattern(Pattern(pat)); + fCurrentLayer->fDrawState->SetPattern(Pattern(pat)); break; } @@ -1549,8 +1549,8 @@ myRootLayer->Unlock(); link.Read(&x); link.Read(&y); - if (fCurrentLayer && fCurrentLayer->fLayerData) - fCurrentLayer->fLayerData->SetPenLocation(BPoint(x, y)); + if (fCurrentLayer && fCurrentLayer->fDrawState) + fCurrentLayer->fDrawState->SetPenLocation(BPoint(x, y)); break; } @@ -1560,8 +1560,8 @@ myRootLayer->Unlock(); float size; link.Read(&size); - if (fCurrentLayer && fCurrentLayer->fLayerData) - fCurrentLayer->fLayerData->SetPenSize(size); + if (fCurrentLayer && fCurrentLayer->fDrawState) + fCurrentLayer->fDrawState->SetPenSize(size); break; } @@ -1702,7 +1702,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) DisplayDriver* driver = fWinBorder->GetDisplayDriver(); driver->ConstrainClippingRegion(&rreg); -// rgb_color rrr = fCurrentLayer->fLayerData->viewcolor.GetColor32(); +// rgb_color rrr = fCurrentLayer->fDrawState->viewcolor.GetColor32(); // RGBColor c(rand()%255,rand()%255,rand()%255); // driver->FillRect(BRect(0,0,639,479), c); @@ -1718,13 +1718,13 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) link.Read(&x2); link.Read(&y2); - if (fCurrentLayer && fCurrentLayer->fLayerData) { + if (fCurrentLayer && fCurrentLayer->fDrawState) { BPoint p1(x1,y1); BPoint p2(x2,y2); driver->StrokeLine(fCurrentLayer->ConvertToTop(p1), fCurrentLayer->ConvertToTop(p2), - fCurrentLayer->fLayerData); + fCurrentLayer->fDrawState); // We update the pen here because many DisplayDriver calls which do not update the // pen position actually call StrokeLine @@ -1732,7 +1732,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) // TODO: Decide where to put this, for example, it cannot be done // for DrawString(), also there needs to be a decision, if penlocation // is in View coordinates (I think it should be) or in screen coordinates. - fCurrentLayer->fLayerData->SetPenLocation(p2); + fCurrentLayer->fDrawState->SetPenLocation(p2); } break; } @@ -1743,7 +1743,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) BRect rect; link.Read(&rect); - if (fCurrentLayer && fCurrentLayer->fLayerData) + if (fCurrentLayer && fCurrentLayer->fDrawState) driver->InvertRect(fCurrentLayer->ConvertToTop(rect)); break; } @@ -1758,8 +1758,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) link.Read(&bottom); BRect rect(left,top,right,bottom); - if (fCurrentLayer && fCurrentLayer->fLayerData) - driver->StrokeRect(fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fLayerData); + if (fCurrentLayer && fCurrentLayer->fDrawState) + driver->StrokeRect(fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fDrawState); break; } case AS_FILL_RECT: @@ -1768,8 +1768,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) BRect rect; link.Read(&rect); - if (fCurrentLayer && fCurrentLayer->fLayerData) - driver->FillRect(fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fLayerData); + if (fCurrentLayer && fCurrentLayer->fDrawState) + driver->FillRect(fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fDrawState); break; } case AS_LAYER_DRAW_BITMAP_SYNC_AT_POINT: @@ -1787,7 +1787,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) BRect dst = src.OffsetToCopy(point); dst = fCurrentLayer->ConvertToTop(dst); - driver->DrawBitmap(sbmp, src, dst, fCurrentLayer->fLayerData); + driver->DrawBitmap(sbmp, src, dst, fCurrentLayer->fDrawState); } // TODO: Adi -- shouldn't AS_LAYER_DRAW_BITMAP_SYNC_AT_POINT sync with the client? @@ -1808,7 +1808,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) BRect dst = src.OffsetToCopy(point); dst = fCurrentLayer->ConvertToTop(dst); - driver->DrawBitmap(sbmp, src, dst, fCurrentLayer->fLayerData); + driver->DrawBitmap(sbmp, src, dst, fCurrentLayer->fDrawState); } break; } @@ -1826,7 +1826,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) if (sbmp) { dstRect = fCurrentLayer->ConvertToTop(dstRect); - driver->DrawBitmap(sbmp, srcRect, dstRect, fCurrentLayer->fLayerData); + driver->DrawBitmap(sbmp, srcRect, dstRect, fCurrentLayer->fDrawState); } // TODO: Adi -- shouldn't AS_LAYER_DRAW_BITMAP_SYNC_IN_RECT sync with the client? @@ -1846,7 +1846,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) if (sbmp) { dstRect = fCurrentLayer->ConvertToTop(dstRect); - driver->DrawBitmap(sbmp, srcRect, dstRect, fCurrentLayer->fLayerData); + driver->DrawBitmap(sbmp, srcRect, dstRect, fCurrentLayer->fDrawState); } break; } @@ -1860,8 +1860,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) link.Read(&r); link.Read(&angle); link.Read(&span); - if (fCurrentLayer && fCurrentLayer->fLayerData) - driver->StrokeArc(fCurrentLayer->ConvertToTop(r),angle,span, fCurrentLayer->fLayerData); + if (fCurrentLayer && fCurrentLayer->fDrawState) + driver->StrokeArc(fCurrentLayer->ConvertToTop(r),angle,span, fCurrentLayer->fDrawState); break; } case AS_FILL_ARC: @@ -1874,8 +1874,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) link.Read(&r); link.Read(&angle); link.Read(&span); - if (fCurrentLayer && fCurrentLayer->fLayerData) - driver->FillArc(fCurrentLayer->ConvertToTop(r),angle,span, fCurrentLayer->fLayerData); + if (fCurrentLayer && fCurrentLayer->fDrawState) + driver->FillArc(fCurrentLayer->ConvertToTop(r),angle,span, fCurrentLayer->fDrawState); break; } case AS_STROKE_BEZIER: @@ -1889,12 +1889,12 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) for (i=0; i<4; i++) link.Read(&(pts[i])); - if (fCurrentLayer && fCurrentLayer->fLayerData) + if (fCurrentLayer && fCurrentLayer->fDrawState) { for (i=0; i<4; i++) pts[i]=fCurrentLayer->ConvertToTop(pts[i]); - driver->StrokeBezier(pts, fCurrentLayer->fLayerData); + driver->StrokeBezier(pts, fCurrentLayer->fDrawState); } delete [] pts; break; @@ -1910,12 +1910,12 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) for (i=0; i<4; i++) link.Read(&(pts[i])); - if (fCurrentLayer && fCurrentLayer->fLayerData) + if (fCurrentLayer && fCurrentLayer->fDrawState) { for (i=0; i<4; i++) pts[i]=fCurrentLayer->ConvertToTop(pts[i]); - driver->FillBezier(pts, fCurrentLayer->fLayerData); + driver->FillBezier(pts, fCurrentLayer->fDrawState); } delete [] pts; break; @@ -1926,8 +1926,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) BRect rect; link.Read(&rect); - if (fCurrentLayer && fCurrentLayer->fLayerData) - driver->StrokeEllipse(fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fLayerData); + if (fCurrentLayer && fCurrentLayer->fDrawState) + driver->StrokeEllipse(fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fDrawState); break; } case AS_FILL_ELLIPSE: @@ -1936,8 +1936,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) BRect rect; link.Read(&rect); - if (fCurrentLayer && fCurrentLayer->fLayerData) - driver->FillEllipse(fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fLayerData); + if (fCurrentLayer && fCurrentLayer->fDrawState) + driver->FillEllipse(fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fDrawState); break; } case AS_STROKE_ROUNDRECT: @@ -1950,8 +1950,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) link.Read(&xrad); link.Read(&yrad); - if (fCurrentLayer && fCurrentLayer->fLayerData) - driver->StrokeRoundRect(fCurrentLayer->ConvertToTop(rect),xrad,yrad, fCurrentLayer->fLayerData); + if (fCurrentLayer && fCurrentLayer->fDrawState) + driver->StrokeRoundRect(fCurrentLayer->ConvertToTop(rect),xrad,yrad, fCurrentLayer->fDrawState); break; } case AS_FILL_ROUNDRECT: @@ -1964,8 +1964,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) link.Read(&xrad); link.Read(&yrad); - if (fCurrentLayer && fCurrentLayer->fLayerData) - driver->FillRoundRect(fCurrentLayer->ConvertToTop(rect),xrad,yrad, fCurrentLayer->fLayerData); + if (fCurrentLayer && fCurrentLayer->fDrawState) + driver->FillRoundRect(fCurrentLayer->ConvertToTop(rect),xrad,yrad, fCurrentLayer->fDrawState); break; } case AS_STROKE_TRIANGLE: @@ -1980,11 +1980,11 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) link.Read(&rect); - if (fCurrentLayer && fCurrentLayer->fLayerData) { + if (fCurrentLayer && fCurrentLayer->fDrawState) { for (int i = 0;i < 3; i++) pts[i] = fCurrentLayer->ConvertToTop(pts[i]); - driver->StrokeTriangle(pts, fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fLayerData); + driver->StrokeTriangle(pts, fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fDrawState); } break; } @@ -2000,11 +2000,11 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) link.Read(&rect); - if (fCurrentLayer && fCurrentLayer->fLayerData) { + if (fCurrentLayer && fCurrentLayer->fDrawState) { for (int i = 0; i < 3; i++) pts[i] = fCurrentLayer->ConvertToTop(pts[i]); - driver->FillTriangle(pts, fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fLayerData); + driver->FillTriangle(pts, fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fDrawState); } break; } @@ -2030,7 +2030,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) pointlist[i] = fCurrentLayer->ConvertToTop(pointlist[i]); driver->StrokePolygon(pointlist,pointcount,polyframe, - fCurrentLayer->fLayerData,isclosed); + fCurrentLayer->fDrawState,isclosed); delete [] pointlist; break; @@ -2053,7 +2053,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) for (int32 i = 0; i < pointcount; i++) pointlist[i] = fCurrentLayer->ConvertToTop(pointlist[i]); - driver->FillPolygon(pointlist,pointcount,polyframe, fCurrentLayer->fLayerData); + driver->FillPolygon(pointlist,pointcount,polyframe, fCurrentLayer->fDrawState); delete [] pointlist; break; @@ -2081,7 +2081,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) for (int32 i = 0; i < ptcount; i++) ptlist[i] = fCurrentLayer->ConvertToTop(ptlist[i]); - driver->StrokeShape(shaperect, opcount, oplist, ptcount, ptlist, fCurrentLayer->fLayerData); + driver->StrokeShape(shaperect, opcount, oplist, ptcount, ptlist, fCurrentLayer->fDrawState); delete[] oplist; delete[] ptlist; break; @@ -2109,7 +2109,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) for (int32 i = 0; i < ptcount; i++) ptlist[i] = fCurrentLayer->ConvertToTop(ptlist[i]); - driver->FillShape(shaperect, opcount, oplist, ptcount, ptlist, fCurrentLayer->fLayerData); + driver->FillShape(shaperect, opcount, oplist, ptcount, ptlist, fCurrentLayer->fDrawState); delete[] oplist; delete[] ptlist; @@ -2135,7 +2135,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) for (int32 i = 0; i < count; i++) { region.Include(fCurrentLayer->ConvertToTop(rects[i])); } - driver->FillRegion(region, fCurrentLayer->fLayerData); + driver->FillRegion(region, fCurrentLayer->fDrawState); delete[] rects; @@ -2169,7 +2169,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) index->pt1 = fCurrentLayer->ConvertToTop(index->pt1); index->pt2 = fCurrentLayer->ConvertToTop(index->pt2); } - driver->StrokeLineArray(linecount,linedata,fCurrentLayer->fLayerData); + driver->StrokeLineArray(linecount,linedata,fCurrentLayer->fDrawState); } break; } @@ -2186,10 +2186,10 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) link.Read(&delta); link.ReadString(&string); - if (fCurrentLayer && fCurrentLayer->fLayerData) + if (fCurrentLayer && fCurrentLayer->fDrawState) driver->DrawString(string, length, fCurrentLayer->ConvertToTop(location), - fCurrentLayer->fLayerData, &delta); + fCurrentLayer->fDrawState, &delta); free(string); break; diff --git a/src/servers/app/drawing/DisplayDriverPainter.cpp b/src/servers/app/drawing/DisplayDriverPainter.cpp index 811cb5af96..240d22354c 100644 --- a/src/servers/app/drawing/DisplayDriverPainter.cpp +++ b/src/servers/app/drawing/DisplayDriverPainter.cpp @@ -1,24 +1,27 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2001-2005, Haiku, Inc. All rights reserved. -// Distributed under the terms of the MIT license. -// -// File Name: DisplayDriverPainter.cpp -// Author: Stephan Aßmus -// Description: Implementation of DisplayDriver based on top of Painter -// -//------------------------------------------------------------------------------ +/* + * Copyright 2001-2005, Haiku, Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stephan Aßmus + */ + +/** Implementation of DisplayDriver based on top of Painter */ + + #include #include #include #include "HWInterface.h" -#include "LayerData.h" +#include "DrawState.h" #include "Painter.h" #include "PNGDump.h" #include "RenderingBuffer.h" #include "DisplayDriverPainter.h" + // make_rect_valid static inline void make_rect_valid(BRect& rect) @@ -37,7 +40,7 @@ make_rect_valid(BRect& rect) // extend_by_stroke_width static inline void -extend_by_stroke_width(BRect& rect, const DrawData* context) +extend_by_stroke_width(BRect& rect, const DrawState* context) { // "- 1.0" because if stroke width == 1, we don't need to extend float inset = -ceilf(context->PenSize() / 2.0 - 1.0); @@ -47,7 +50,7 @@ extend_by_stroke_width(BRect& rect, const DrawData* context) class FontLocker { public: - FontLocker(const DrawData* context) + FontLocker(const DrawState* context) : fFont(&context->Font()) { @@ -445,14 +448,14 @@ DisplayDriverPainter::InvertRect(BRect r) void DisplayDriverPainter::DrawBitmap(ServerBitmap *bitmap, const BRect &source, const BRect &dest, - const DrawData *d) + const DrawState *d) { if (Lock()) { BRect clipped = fPainter->ClipRect(dest); if (clipped.IsValid()) { fGraphicsCard->HideSoftwareCursor(clipped); - fPainter->SetDrawData(d); + fPainter->SetDrawState(d); fPainter->DrawBitmap(bitmap, source, dest); fGraphicsCard->Invalidate(clipped); @@ -466,7 +469,7 @@ DisplayDriverPainter::DrawBitmap(ServerBitmap *bitmap, // FillArc void DisplayDriverPainter::FillArc(BRect r, const float &angle, - const float &span, const DrawData *d) + const float &span, const DrawState *d) { if (Lock()) { make_rect_valid(r); @@ -474,7 +477,7 @@ DisplayDriverPainter::FillArc(BRect r, const float &angle, if (clipped.IsValid()) { fGraphicsCard->HideSoftwareCursor(clipped); - fPainter->SetDrawData(d); + fPainter->SetDrawState(d); float xRadius = r.Width() / 2.0; float yRadius = r.Width() / 2.0; @@ -493,12 +496,12 @@ DisplayDriverPainter::FillArc(BRect r, const float &angle, // FillBezier void -DisplayDriverPainter::FillBezier(BPoint *pts, const DrawData *d) +DisplayDriverPainter::FillBezier(BPoint *pts, const DrawState *d) { if (Lock()) { fGraphicsCard->HideSoftwareCursor(); - fPainter->SetDrawData(d); + fPainter->SetDrawState(d); BRect touched = fPainter->FillBezier(pts); @@ -511,7 +514,7 @@ DisplayDriverPainter::FillBezier(BPoint *pts, const DrawData *d) // FillEllipse void -DisplayDriverPainter::FillEllipse(BRect r, const DrawData *d) +DisplayDriverPainter::FillEllipse(BRect r, const DrawState *d) { if (Lock()) { make_rect_valid(r); @@ -519,7 +522,7 @@ DisplayDriverPainter::FillEllipse(BRect r, const DrawData *d) if (clipped.IsValid()) { fGraphicsCard->HideSoftwareCursor(clipped); - fPainter->SetDrawData(d); + fPainter->SetDrawState(d); float xRadius = r.Width() / 2.0; float yRadius = r.Height() / 2.0; @@ -539,7 +542,7 @@ DisplayDriverPainter::FillEllipse(BRect r, const DrawData *d) // FillPolygon void DisplayDriverPainter::FillPolygon(BPoint *ptlist, int32 numpts, - BRect bounds, const DrawData *d) + BRect bounds, const DrawState *d) { if (Lock()) { make_rect_valid(bounds); @@ -547,7 +550,7 @@ DisplayDriverPainter::FillPolygon(BPoint *ptlist, int32 numpts, if (clipped.IsValid()) { fGraphicsCard->HideSoftwareCursor(clipped); - fPainter->SetDrawData(d); + fPainter->SetDrawState(d); fPainter->FillPolygon(ptlist, numpts); fGraphicsCard->Invalidate(clipped); @@ -591,7 +594,7 @@ DisplayDriverPainter::FillRect(BRect r, const RGBColor& color) // FillRect void -DisplayDriverPainter::FillRect(BRect r, const DrawData *d) +DisplayDriverPainter::FillRect(BRect r, const DrawState *d) { // NOTE: Write locking because we might use HW acceleration. // This needs to be investigated, I'm doing this because of @@ -622,7 +625,7 @@ DisplayDriverPainter::FillRect(BRect r, const DrawData *d) } if (doInSoftware) { - fPainter->SetDrawData(d); + fPainter->SetDrawState(d); fPainter->FillRect(r); fGraphicsCard->Invalidate(r); @@ -637,7 +640,7 @@ DisplayDriverPainter::FillRect(BRect r, const DrawData *d) // FillRegion void -DisplayDriverPainter::FillRegion(BRegion& r, const DrawData *d) +DisplayDriverPainter::FillRegion(BRegion& r, const DrawState *d) { // NOTE: Write locking because we might use HW acceleration. // This needs to be investigated, I'm doing this because of @@ -663,7 +666,7 @@ DisplayDriverPainter::FillRegion(BRegion& r, const DrawData *d) } if (doInSoftware) { - fPainter->SetDrawData(d); + fPainter->SetDrawState(d); BRect touched = fPainter->FillRect(r.RectAt(0)); @@ -686,7 +689,7 @@ DisplayDriverPainter::FillRegion(BRegion& r, const DrawData *d) void DisplayDriverPainter::FillRoundRect(BRect r, const float &xrad, const float &yrad, - const DrawData *d) + const DrawState *d) { if (Lock()) { make_rect_valid(r); @@ -694,7 +697,7 @@ DisplayDriverPainter::FillRoundRect(BRect r, if (clipped.IsValid()) { fGraphicsCard->HideSoftwareCursor(clipped); - fPainter->SetDrawData(d); + fPainter->SetDrawState(d); BRect touched = fPainter->FillRoundRect(r, xrad, yrad); fGraphicsCard->Invalidate(touched); @@ -710,7 +713,7 @@ void DisplayDriverPainter::FillShape(const BRect &bounds, const int32 &opcount, const int32 *oplist, const int32 &ptcount, const BPoint *ptlist, - const DrawData *d) + const DrawState *d) { if (Lock()) { @@ -723,14 +726,14 @@ printf("DisplayDriverPainter::FillShape() - what is this stuff that gets passed // FillTriangle void DisplayDriverPainter::FillTriangle(BPoint *pts, BRect bounds, - const DrawData *d) + const DrawState *d) { if (Lock()) { bounds = fPainter->ClipRect(bounds); if (bounds.IsValid()) { fGraphicsCard->HideSoftwareCursor(bounds); - fPainter->SetDrawData(d); + fPainter->SetDrawState(d); fPainter->FillTriangle(pts[0], pts[1], pts[2]); fGraphicsCard->Invalidate(bounds); @@ -744,7 +747,7 @@ DisplayDriverPainter::FillTriangle(BPoint *pts, BRect bounds, // StrokeArc void DisplayDriverPainter::StrokeArc(BRect r, const float &angle, - const float &span, const DrawData *d) + const float &span, const DrawState *d) { if (Lock()) { make_rect_valid(r); @@ -752,7 +755,7 @@ DisplayDriverPainter::StrokeArc(BRect r, const float &angle, if (clipped.IsValid()) { fGraphicsCard->HideSoftwareCursor(r); - fPainter->SetDrawData(d); + fPainter->SetDrawState(d); float xRadius = r.Width() / 2.0; float yRadius = r.Width() / 2.0; @@ -771,12 +774,12 @@ DisplayDriverPainter::StrokeArc(BRect r, const float &angle, // StrokeBezier void -DisplayDriverPainter::StrokeBezier(BPoint *pts, const DrawData *d) +DisplayDriverPainter::StrokeBezier(BPoint *pts, const DrawState *d) { if (Lock()) { fGraphicsCard->HideSoftwareCursor(); - fPainter->SetDrawData(d); + fPainter->SetDrawState(d); BRect touched = fPainter->StrokeBezier(pts); fGraphicsCard->Invalidate(touched); @@ -788,7 +791,7 @@ DisplayDriverPainter::StrokeBezier(BPoint *pts, const DrawData *d) // StrokeEllipse void -DisplayDriverPainter::StrokeEllipse(BRect r, const DrawData *d) +DisplayDriverPainter::StrokeEllipse(BRect r, const DrawState *d) { if (Lock()) { make_rect_valid(r); @@ -798,7 +801,7 @@ DisplayDriverPainter::StrokeEllipse(BRect r, const DrawData *d) if (clipped.IsValid()) { fGraphicsCard->HideSoftwareCursor(r); - fPainter->SetDrawData(d); + fPainter->SetDrawState(d); float xRadius = r.Width() / 2.0; float yRadius = r.Height() / 2.0; @@ -829,7 +832,7 @@ DisplayDriverPainter::StrokeLine(const BPoint &start, const BPoint &end, const R fGraphicsCard->HideSoftwareCursor(touched); if (!fPainter->StraightLine(start, end, color.GetColor32())) { - static DrawData context; + static DrawState context; context.SetHighColor(color); context.SetDrawingMode(B_OP_OVER); StrokeLine(start, end, &context); @@ -843,7 +846,7 @@ DisplayDriverPainter::StrokeLine(const BPoint &start, const BPoint &end, const R // StrokeLine void -DisplayDriverPainter::StrokeLine(const BPoint &start, const BPoint &end, DrawData* context) +DisplayDriverPainter::StrokeLine(const BPoint &start, const BPoint &end, DrawState* context) { if (Lock()) { BRect touched(start, end); @@ -867,7 +870,7 @@ DisplayDriverPainter::StrokeLine(const BPoint &start, const BPoint &end, DrawDat void DisplayDriverPainter::StrokeLineArray(const int32 &numlines, const LineArrayData *linedata, - const DrawData *d) + const DrawState *d) { if(!d || !linedata || numlines <= 0) return; @@ -892,7 +895,7 @@ DisplayDriverPainter::StrokeLineArray(const int32 &numlines, if (touched.IsValid()) { fGraphicsCard->HideSoftwareCursor(touched); - DrawData context; + DrawState context; context.SetDrawingMode(B_OP_COPY); data = (const LineArrayData *)&(linedata[0]); @@ -924,7 +927,7 @@ DisplayDriverPainter::StrokePoint(const BPoint& pt, const RGBColor &color) // StrokePoint void -DisplayDriverPainter::StrokePoint(const BPoint& pt, DrawData *context) +DisplayDriverPainter::StrokePoint(const BPoint& pt, DrawState *context) { StrokeLine(pt, pt, context); } @@ -932,7 +935,7 @@ DisplayDriverPainter::StrokePoint(const BPoint& pt, DrawData *context) // StrokePolygon void DisplayDriverPainter::StrokePolygon(BPoint* ptlist, int32 numpts, - BRect bounds, const DrawData* d, + BRect bounds, const DrawState* d, bool closed) { if (Lock()) { @@ -941,7 +944,7 @@ DisplayDriverPainter::StrokePolygon(BPoint* ptlist, int32 numpts, if (bounds.IsValid()) { fGraphicsCard->HideSoftwareCursor(bounds); - fPainter->SetDrawData(d); + fPainter->SetDrawState(d); fPainter->StrokePolygon(ptlist, numpts, closed); fGraphicsCard->Invalidate(bounds); @@ -984,7 +987,7 @@ DisplayDriverPainter::StrokeRect(BRect r, const RGBColor &color) // StrokeRect void -DisplayDriverPainter::StrokeRect(BRect r, const DrawData *d) +DisplayDriverPainter::StrokeRect(BRect r, const DrawState *d) { if (Lock()) { // support invalid rects @@ -996,7 +999,7 @@ DisplayDriverPainter::StrokeRect(BRect r, const DrawData *d) fGraphicsCard->HideSoftwareCursor(clipped); - fPainter->SetDrawData(d); + fPainter->SetDrawState(d); fPainter->StrokeRect(r); fGraphicsCard->Invalidate(clipped); @@ -1009,7 +1012,7 @@ DisplayDriverPainter::StrokeRect(BRect r, const DrawData *d) // StrokeRegion void -DisplayDriverPainter::StrokeRegion(BRegion& r, const DrawData *d) +DisplayDriverPainter::StrokeRegion(BRegion& r, const DrawState *d) { if (Lock()) { BRect clipped(r.Frame()); @@ -1018,7 +1021,7 @@ DisplayDriverPainter::StrokeRegion(BRegion& r, const DrawData *d) if (clipped.IsValid()) { fGraphicsCard->HideSoftwareCursor(clipped); - fPainter->SetDrawData(d); + fPainter->SetDrawState(d); BRect touched = fPainter->StrokeRect(r.RectAt(0)); @@ -1038,7 +1041,7 @@ DisplayDriverPainter::StrokeRegion(BRegion& r, const DrawData *d) // StrokeRoundRect void DisplayDriverPainter::StrokeRoundRect(BRect r, const float &xrad, - const float &yrad, const DrawData *d) + const float &yrad, const DrawState *d) { if (Lock()) { // NOTE: the stroke does not extend past "r" in R5, @@ -1048,7 +1051,7 @@ DisplayDriverPainter::StrokeRoundRect(BRect r, const float &xrad, if (clipped.IsValid()) { fGraphicsCard->HideSoftwareCursor(clipped); - fPainter->SetDrawData(d); + fPainter->SetDrawState(d); BRect touched = fPainter->StrokeRoundRect(r, xrad, yrad); fGraphicsCard->Invalidate(touched); @@ -1063,7 +1066,7 @@ DisplayDriverPainter::StrokeRoundRect(BRect r, const float &xrad, void DisplayDriverPainter::StrokeShape(const BRect &bounds, const int32 &opcount, const int32 *oplist, const int32 &ptcount, - const BPoint *ptlist, const DrawData *d) + const BPoint *ptlist, const DrawState *d) { if (Lock()) { @@ -1076,7 +1079,7 @@ printf("DisplayDriverPainter::StrokeShape() - what is this stuff that gets passe // StrokeTriangle void DisplayDriverPainter::StrokeTriangle(BPoint *pts, const BRect &bounds, - const DrawData *d) + const DrawState *d) { if (Lock()) { BRect clipped(bounds); @@ -1085,7 +1088,7 @@ DisplayDriverPainter::StrokeTriangle(BPoint *pts, const BRect &bounds, if (clipped.IsValid()) { fGraphicsCard->HideSoftwareCursor(clipped); - fPainter->SetDrawData(d); + fPainter->SetDrawState(d); fPainter->StrokeTriangle(pts[0], pts[1], pts[2]); fGraphicsCard->Invalidate(clipped); @@ -1102,7 +1105,7 @@ DisplayDriverPainter::DrawString(const char *string, const int32 &length, const BPoint &pt, const RGBColor &color, escapement_delta *delta) { - static DrawData d; + static DrawState d; d.SetHighColor(color); DrawString(string, length, pt, &d, delta); @@ -1111,13 +1114,13 @@ DisplayDriverPainter::DrawString(const char *string, const int32 &length, // DrawString void DisplayDriverPainter::DrawString(const char* string, int32 length, - const BPoint& pt, DrawData* d, + const BPoint& pt, DrawState* d, escapement_delta* delta) { // TODO: use delta if (Lock()) { FontLocker locker(d); - fPainter->SetDrawData(d); + fPainter->SetDrawState(d); //bigtime_t now = system_time(); // TODO: BoundingBox is quite slow!! Optimizing it will be beneficial. // Cursiously, the DrawString after it is actually faster!?! @@ -1145,14 +1148,14 @@ DisplayDriverPainter::DrawString(const char* string, int32 length, // StringWidth float DisplayDriverPainter::StringWidth(const char* string, int32 length, - const DrawData* d, + const DrawState* d, escapement_delta* delta) { // TODO: use delta float width = 0.0; if (Lock()) { FontLocker locker(d); - fPainter->SetDrawData(d); + fPainter->SetDrawState(d); width = fPainter->StringWidth(string, length); Unlock(); } @@ -1167,7 +1170,7 @@ DisplayDriverPainter::StringWidth(const char* string, int32 length, { // TODO: use delta FontLocker locker(&font); - static DrawData d; + static DrawState d; d.SetFont(font); return StringWidth(string, length, &d); } @@ -1175,12 +1178,12 @@ DisplayDriverPainter::StringWidth(const char* string, int32 length, // StringHeight float DisplayDriverPainter::StringHeight(const char *string, int32 length, - const DrawData *d) + const DrawState *d) { float height = 0.0; if (Lock()) { FontLocker locker(d); - fPainter->SetDrawData(d); + fPainter->SetDrawState(d); static BPoint dummy(0.0, 0.0); height = fPainter->BoundingBox(string, length, dummy).Height(); Unlock(); diff --git a/src/servers/app/drawing/DisplayDriverPainter.h b/src/servers/app/drawing/DisplayDriverPainter.h index ffad9dea7b..c910d52248 100644 --- a/src/servers/app/drawing/DisplayDriverPainter.h +++ b/src/servers/app/drawing/DisplayDriverPainter.h @@ -1,23 +1,21 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2001-2005, Haiku, Inc. All rights reserved. -// Distributed under the terms of the MIT license. -// -// File Name: DisplayDriverPainter.h -// Authors: DarkWyrm -// Gabe Yoder -// Stephan Aßmus -// -// Description: Abstract class which handles all graphics output -// for the server -// -//------------------------------------------------------------------------------ +/* + * Copyright 2001-2005, Haiku, Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * DarkWyrm + * Gabe Yoder + * Stephan Aßmus + */ #ifndef _DISPLAY_DRIVER_PAINTER_H_ #define _DISPLAY_DRIVER_PAINTER_H_ + #include "DisplayDriver.h" class Painter; + class DisplayDriverPainter : public DisplayDriver { public: DisplayDriverPainter(HWInterface* interface = NULL); @@ -50,59 +48,59 @@ public: virtual void DrawBitmap( ServerBitmap *bitmap, const BRect &source, const BRect &dest, - const DrawData *d); + const DrawState *d); virtual void FillArc( BRect r, const float &angle, const float &span, - const DrawData *d); + const DrawState *d); virtual void FillBezier( BPoint *pts, - const DrawData *d); + const DrawState *d); virtual void FillEllipse( BRect r, - const DrawData *d); + const DrawState *d); virtual void FillPolygon( BPoint *ptlist, int32 numpts, BRect bounds, - const DrawData *d); + const DrawState *d); virtual void FillRect( BRect r, const RGBColor &color); virtual void FillRect( BRect r, - const DrawData *d); + const DrawState *d); virtual void FillRegion( BRegion &r, - const DrawData *d); + const DrawState *d); virtual void FillRoundRect( BRect r, const float &xrad, const float &yrad, - const DrawData *d); + const DrawState *d); virtual void FillShape( const BRect &bounds, const int32 &opcount, const int32 *oplist, const int32 &ptcount, const BPoint *ptlist, - const DrawData *d); + const DrawState *d); virtual void FillTriangle( BPoint *pts, BRect bounds, - const DrawData *d); + const DrawState *d); virtual void StrokeArc( BRect r, const float &angle, const float &span, - const DrawData *d); + const DrawState *d); virtual void StrokeBezier( BPoint *pts, - const DrawData *d); + const DrawState *d); virtual void StrokeEllipse( BRect r, - const DrawData *d); + const DrawState *d); // this version used by Decorator virtual void StrokeLine( const BPoint &start, @@ -111,23 +109,23 @@ public: virtual void StrokeLine( const BPoint &start, const BPoint &end, - DrawData *d); + DrawState *d); virtual void StrokeLineArray(const int32 &numlines, const LineArrayData *data, - const DrawData *d); + const DrawState *d); // this version used by Decorator virtual void StrokePoint( const BPoint &pt, const RGBColor &color); virtual void StrokePoint( const BPoint &pt, - DrawData *d); + DrawState *d); virtual void StrokePolygon( BPoint *ptlist, int32 numpts, BRect bounds, - const DrawData *d, + const DrawState *d, bool is_closed=true); // this version used by Decorator @@ -135,34 +133,34 @@ public: const RGBColor &color); virtual void StrokeRect( BRect r, - const DrawData *d); + const DrawState *d); virtual void StrokeRegion( BRegion &r, - const DrawData *d); + const DrawState *d); virtual void StrokeRoundRect(BRect r, const float &xrad, const float &yrad, - const DrawData *d); + const DrawState *d); virtual void StrokeShape( const BRect &bounds, const int32 &opcount, const int32 *oplist, const int32 &ptcount, const BPoint *ptlist, - const DrawData *d); + const DrawState *d); virtual void StrokeTriangle( BPoint *pts, const BRect &bounds, - const DrawData *d); + const DrawState *d); // Font-related calls - // DrawData is NOT const because this call updates the pen position in the passed DrawData + // DrawState is NOT const because this call updates the pen position in the passed DrawState virtual void DrawString( const char* string, int32 length, const BPoint& pt, - DrawData* d, + DrawState* d, escapement_delta* delta = NULL); /* virtual void DrawString( const char *string, @@ -173,7 +171,7 @@ public: virtual float StringWidth( const char* string, int32 length, - const DrawData* d, + const DrawState* d, escapement_delta* delta = NULL); virtual float StringWidth( const char* string, @@ -183,7 +181,7 @@ public: virtual float StringHeight( const char* string, int32 length, - const DrawData* d); + const DrawState* d); virtual bool Lock(); virtual void Unlock(); diff --git a/src/servers/app/drawing/Painter/Painter.cpp b/src/servers/app/drawing/Painter/Painter.cpp index 5e244fffef..f56f221f95 100644 --- a/src/servers/app/drawing/Painter/Painter.cpp +++ b/src/servers/app/drawing/Painter/Painter.cpp @@ -24,7 +24,7 @@ #include #include -#include "LayerData.h" +#include "DrawState.h" #include "AGGTextRenderer.h" #include "DrawingMode.h" @@ -168,9 +168,9 @@ Painter::DetachFromBuffer() _MakeEmpty(); } -// SetDrawData +// SetDrawState void -Painter::SetDrawData(const DrawData* data) +Painter::SetDrawState(const DrawState* data) { // NOTE: The custom clipping in "data" is ignored, because it has already been // taken into account elsewhere @@ -296,7 +296,7 @@ Painter::SetFont(const ServerFont& font) // StrokeLine BRect -Painter::StrokeLine(BPoint a, BPoint b, DrawData* context) +Painter::StrokeLine(BPoint a, BPoint b, DrawState* context) { // this happens independent of wether we actually draw something context->SetPenLocation(b); @@ -335,7 +335,7 @@ Painter::StrokeLine(BPoint a, BPoint b, DrawData* context) // SetDrawingMode(context->draw_mode); // SetBlendingMode(context->alphaSrcMode, context->alphaFncMode); // fPatternHandler->SetPattern(context->patt); - SetDrawData(context); + SetDrawState(context); // first, try an optimized version if (fPenSize == 1.0 && @@ -366,7 +366,7 @@ Painter::StrokeLine(BPoint a, BPoint b, DrawData* context) // StrokeLine BRect -Painter::StrokeLine(BPoint b, DrawData* context) +Painter::StrokeLine(BPoint b, DrawState* context) { // TODO: move this function elsewhere return StrokeLine(context->PenLocation(), b, context); @@ -1475,7 +1475,7 @@ Painter::_StrokePath(VertexSource& path) const // if (fPenSize > 1.0) { agg::conv_stroke stroke(path); // TODO: Investigate this for shapes. Maybe we are supposed to -// use the settings from DrawData! Would make some sense! +// use the settings from DrawState! Would make some sense! // stroke.line_join(agg::round_join); // stroke.line_cap(agg::butt_cap); stroke.width(fPenSize); diff --git a/src/servers/app/drawing/Painter/Painter.h b/src/servers/app/drawing/Painter/Painter.h index 28ec96d706..1430885044 100644 --- a/src/servers/app/drawing/Painter/Painter.h +++ b/src/servers/app/drawing/Painter/Painter.h @@ -23,7 +23,7 @@ class AGGTextRenderer; class BBitmap; class BRegion; -class DrawData; +class DrawState; class DrawingModeFactory; class PatternHandler; class RenderingBuffer; @@ -31,11 +31,11 @@ class ServerBitmap; class ServerFont; // TODO: API transition: -// * most all functions should take a DrawData* context parameter instead +// * most all functions should take a DrawState* context parameter instead // of the current pattern argument, that way, each function can -// decide for itself, which pieces of information in DrawData it +// decide for itself, which pieces of information in DrawState it // needs -> well I'm not so sure about this, there could also -// be a DrawData member in Painter fGraphicsState or something... +// be a DrawState member in Painter fGraphicsState or something... // * Painter itself should be made thread safe. Because no // ServerWindow is supposed to draw outside of its clipping region, // there is actually no reason to lock the DisplayDriver. Multiple @@ -62,7 +62,7 @@ class Painter { const BRegion* ClippingRegion() const { return fClippingRegion; } - void SetDrawData(const DrawData* data); + void SetDrawState(const DrawState* data); // object settings void SetHighColor(const rgb_color& color); @@ -88,10 +88,10 @@ class Painter { // lines BRect StrokeLine( BPoint a, BPoint b, - DrawData* context); + DrawState* context); BRect StrokeLine( BPoint b, - DrawData* context); + DrawState* context); // returns true if the line was either vertical or horizontal // draws a solid one pixel wide line of color c, no blending diff --git a/src/tests/servers/app/Jamfile b/src/tests/servers/app/Jamfile index 6d8847104b..5f77d6e401 100644 --- a/src/tests/servers/app/Jamfile +++ b/src/tests/servers/app/Jamfile @@ -58,9 +58,9 @@ SharedLibrary libhaikuappserver.so : CursorSet.cpp Decorator.cpp DesktopSettings.cpp + DrawState.cpp FontFamily.cpp IPoint.cpp - LayerData.cpp RGBColor.cpp ServerBitmap.cpp ServerCursor.cpp