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
This commit is contained in:
Axel Dörfler
2005-11-04 11:37:28 +00:00
parent eb5b2ccda8
commit aca4f50d1e
20 changed files with 774 additions and 870 deletions
+2 -2
View File
@@ -16,7 +16,7 @@
#include <Window.h> #include <Window.h>
#include "ColorSet.h" #include "ColorSet.h"
#include "LayerData.h" #include "DrawState.h"
class DesktopSettings; class DesktopSettings;
class DisplayDriver; class DisplayDriver;
@@ -138,7 +138,7 @@ class Decorator {
ColorSet* _colors; ColorSet* _colors;
DisplayDriver* _driver; DisplayDriver* _driver;
DrawData _drawdata; DrawState fDrawState;
int32 _look; int32 _look;
int32 _feel; int32 _feel;
+37 -40
View File
@@ -1,19 +1,16 @@
//------------------------------------------------------------------------------ /*
// Copyright (c) 2001-2005, Haiku, Inc. All rights reserved * Copyright 2001-2005, Haiku, Inc.
// Distributed under the terms of the MIT license. * Distributed under the terms of the MIT License.
// *
// File Name: DisplayDriver.h * Authors:
// Authors: DarkWyrm <[email protected]> * DarkWyrm <[email protected]>
// Gabe Yoder <[email protected]> * Gabe Yoder <[email protected]>
// Stephan Aßmus <[email protected]> * Stephan Aßmus <[email protected]>
// */
// Description: Abstract class which handles all graphics output
// for the server
//
//------------------------------------------------------------------------------
#ifndef _DISPLAY_DRIVER_H_ #ifndef _DISPLAY_DRIVER_H_
#define _DISPLAY_DRIVER_H_ #define _DISPLAY_DRIVER_H_
#include <Accelerant.h> #include <Accelerant.h>
#include <Font.h> #include <Font.h>
#include <Locker.h> #include <Locker.h>
@@ -23,7 +20,7 @@ class BPoint;
class BRect; class BRect;
class BRegion; class BRegion;
class DrawData; class DrawState;
class HWInterface; class HWInterface;
class RGBColor; class RGBColor;
class ServerBitmap; class ServerBitmap;
@@ -81,59 +78,59 @@ public:
virtual void DrawBitmap( ServerBitmap *bitmap, virtual void DrawBitmap( ServerBitmap *bitmap,
const BRect &source, const BRect &source,
const BRect &dest, const BRect &dest,
const DrawData *d) = 0; const DrawState *d) = 0;
virtual void FillArc( BRect r, virtual void FillArc( BRect r,
const float &angle, const float &angle,
const float &span, const float &span,
const DrawData *d) = 0; const DrawState *d) = 0;
virtual void FillBezier( BPoint *pts, virtual void FillBezier( BPoint *pts,
const DrawData *d) = 0; const DrawState *d) = 0;
virtual void FillEllipse( BRect r, virtual void FillEllipse( BRect r,
const DrawData *d) = 0; const DrawState *d) = 0;
virtual void FillPolygon( BPoint *ptlist, virtual void FillPolygon( BPoint *ptlist,
int32 numpts, int32 numpts,
BRect bounds, BRect bounds,
const DrawData *d) = 0; const DrawState *d) = 0;
virtual void FillRect( BRect r, virtual void FillRect( BRect r,
const RGBColor &color) = 0; const RGBColor &color) = 0;
virtual void FillRect( BRect r, virtual void FillRect( BRect r,
const DrawData *d) = 0; const DrawState *d) = 0;
virtual void FillRegion( BRegion &r, virtual void FillRegion( BRegion &r,
const DrawData *d) = 0; const DrawState *d) = 0;
virtual void FillRoundRect( BRect r, virtual void FillRoundRect( BRect r,
const float &xrad, const float &xrad,
const float &yrad, const float &yrad,
const DrawData *d) = 0; const DrawState *d) = 0;
virtual void FillShape( const BRect &bounds, virtual void FillShape( const BRect &bounds,
const int32 &opcount, const int32 &opcount,
const int32 *oplist, const int32 *oplist,
const int32 &ptcount, const int32 &ptcount,
const BPoint *ptlist, const BPoint *ptlist,
const DrawData *d) = 0; const DrawState *d) = 0;
virtual void FillTriangle( BPoint *pts, virtual void FillTriangle( BPoint *pts,
BRect bounds, BRect bounds,
const DrawData *d) = 0; const DrawState *d) = 0;
virtual void StrokeArc( BRect r, virtual void StrokeArc( BRect r,
const float &angle, const float &angle,
const float &span, const float &span,
const DrawData *d) = 0; const DrawState *d) = 0;
virtual void StrokeBezier( BPoint *pts, virtual void StrokeBezier( BPoint *pts,
const DrawData *d) = 0; const DrawState *d) = 0;
virtual void StrokeEllipse( BRect r, virtual void StrokeEllipse( BRect r,
const DrawData *d) = 0; const DrawState *d) = 0;
// this version used by Decorator // this version used by Decorator
virtual void StrokeLine( const BPoint &start, virtual void StrokeLine( const BPoint &start,
@@ -142,23 +139,23 @@ public:
virtual void StrokeLine( const BPoint &start, virtual void StrokeLine( const BPoint &start,
const BPoint &end, const BPoint &end,
DrawData *d) = 0; DrawState *d) = 0;
virtual void StrokeLineArray(const int32 &numlines, virtual void StrokeLineArray(const int32 &numlines,
const LineArrayData *data, const LineArrayData *data,
const DrawData *d) = 0; const DrawState *d) = 0;
// this version used by Decorator // this version used by Decorator
virtual void StrokePoint( const BPoint &pt, virtual void StrokePoint( const BPoint &pt,
const RGBColor &color) = 0; const RGBColor &color) = 0;
virtual void StrokePoint( const BPoint &pt, virtual void StrokePoint( const BPoint &pt,
DrawData *d) = 0; DrawState *d) = 0;
virtual void StrokePolygon( BPoint *ptlist, virtual void StrokePolygon( BPoint *ptlist,
int32 numpts, int32 numpts,
BRect bounds, BRect bounds,
const DrawData *d, const DrawState *d,
bool is_closed=true) = 0; bool is_closed=true) = 0;
// this version used by Decorator // this version used by Decorator
@@ -166,34 +163,34 @@ public:
const RGBColor &color) = 0; const RGBColor &color) = 0;
virtual void StrokeRect( BRect r, virtual void StrokeRect( BRect r,
const DrawData *d) = 0; const DrawState *d) = 0;
virtual void StrokeRegion( BRegion &r, virtual void StrokeRegion( BRegion &r,
const DrawData *d) = 0; const DrawState *d) = 0;
virtual void StrokeRoundRect(BRect r, virtual void StrokeRoundRect(BRect r,
const float &xrad, const float &xrad,
const float &yrad, const float &yrad,
const DrawData *d) = 0; const DrawState *d) = 0;
virtual void StrokeShape( const BRect &bounds, virtual void StrokeShape( const BRect &bounds,
const int32 &opcount, const int32 &opcount,
const int32 *oplist, const int32 *oplist,
const int32 &ptcount, const int32 &ptcount,
const BPoint *ptlist, const BPoint *ptlist,
const DrawData *d) = 0; const DrawState *d) = 0;
virtual void StrokeTriangle( BPoint *pts, virtual void StrokeTriangle( BPoint *pts,
const BRect &bounds, const BRect &bounds,
const DrawData *d) = 0; const DrawState *d) = 0;
// Font-related calls // 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, virtual void DrawString( const char* string,
int32 length, int32 length,
const BPoint& pt, const BPoint& pt,
DrawData* d, DrawState* d,
escapement_delta *delta = NULL) = 0; escapement_delta *delta = NULL) = 0;
/* virtual void DrawString( const char *string, /* virtual void DrawString( const char *string,
@@ -204,7 +201,7 @@ public:
virtual float StringWidth( const char* string, virtual float StringWidth( const char* string,
int32 length, int32 length,
const DrawData* d, const DrawState* d,
escapement_delta *delta = NULL) = 0; escapement_delta *delta = NULL) = 0;
virtual float StringWidth( const char* string, virtual float StringWidth( const char* string,
@@ -214,7 +211,7 @@ public:
virtual float StringHeight( const char *string, virtual float StringHeight( const char *string,
int32 length, int32 length,
const DrawData *d) = 0; const DrawState *d) = 0;
virtual bool Lock() = 0; virtual bool Lock() = 0;
virtual void Unlock() = 0; virtual void Unlock() = 0;
+210
View File
@@ -0,0 +1,210 @@
/*
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* DarkWyrm <[email protected]>
* Adi Oanca <[email protected]>
* Stephan Aßmus <[email protected]>
* Axel Dörfler, [email protected]
*/
#ifndef _DRAW_STATE_H_
#define _DRAW_STATE_H_
#include <GraphicsDefs.h>
#include <InterfaceDefs.h>
#include <Point.h>
#include <View.h> // 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_ */
-226
View File
@@ -1,226 +0,0 @@
/*
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* DarkWyrm <[email protected]>
* Adi Oanca <[email protected]>
* Stephan Aßmus <[email protected]>
*/
#ifndef LAYER_DATA_H_
#define LAYER_DATA_H_
#include <GraphicsDefs.h>
#include <InterfaceDefs.h>
#include <Point.h>
#include <View.h> // 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_
+4 -4
View File
@@ -32,7 +32,7 @@ Decorator::Decorator(DesktopSettings& settings, BRect rect, int32 look,
int32 feel, int32 flags) int32 feel, int32 flags)
: _colors(new ColorSet()), : _colors(new ColorSet()),
_driver(NULL), _driver(NULL),
_drawdata(), fDrawState(),
_look(look), _look(look),
_feel(feel), _feel(feel),
@@ -124,7 +124,7 @@ void
Decorator::SetFont(ServerFont *font) Decorator::SetFont(ServerFont *font)
{ {
if (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) // when it exists (if it doesn't already)
if (_driver) { if (_driver) {
int32 strlength = fTitle.CountChars(); int32 strlength = fTitle.CountChars();
float pixwidth=_driver->StringWidth(fTitle.String(),strlength,&_drawdata); float pixwidth=_driver->StringWidth(fTitle.String(),strlength,&fDrawState);
while (strlength >= 0) { while (strlength >= 0) {
if (pixwidth < width) if (pixwidth < width)
return strlength; return strlength;
strlength--; strlength--;
pixwidth=_driver->StringWidth(fTitle.String(), strlength, &_drawdata); pixwidth=_driver->StringWidth(fTitle.String(), strlength, &fDrawState);
} }
} }
return 0; return 0;
+10 -10
View File
@@ -15,8 +15,8 @@
#include "ColorUtils.h" #include "ColorUtils.h"
#include "DesktopSettings.h" #include "DesktopSettings.h"
#include "DisplayDriver.h" #include "DisplayDriver.h"
#include "DrawState.h"
#include "FontManager.h" #include "FontManager.h"
#include "LayerData.h"
#include "PatternHandler.h" #include "PatternHandler.h"
#include "RGBColor.h" #include "RGBColor.h"
@@ -351,7 +351,7 @@ DefaultDecorator::_DoLayout()
fTextOffset = (_look == B_FLOATING_WINDOW_LOOK) ? 10 : 18; fTextOffset = (_look == B_FLOATING_WINDOW_LOOK) ? 10 : 18;
font_height fontHeight; font_height fontHeight;
_drawdata.Font().GetHeight(fontHeight); fDrawState.Font().GetHeight(fontHeight);
_tabrect.Set(_frame.left - fBorderWidth, _tabrect.Set(_frame.left - fBorderWidth,
_frame.top - fBorderWidth _frame.top - fBorderWidth
@@ -379,7 +379,7 @@ DefaultDecorator::_DoLayout()
// fMaxTabWidth contains fMinWidth + the width required for the title // fMaxTabWidth contains fMinWidth + the width required for the title
fMaxTabWidth = _driver ? _driver->StringWidth(GetTitle(), strlen(GetTitle()), fMaxTabWidth = _driver ? _driver->StringWidth(GetTitle(), strlen(GetTitle()),
&_drawdata) : 0.0; &fDrawState) : 0.0;
if (fMaxTabWidth > 0.0) if (fMaxTabWidth > 0.0)
fMaxTabWidth += fTextOffset; fMaxTabWidth += fTextOffset;
fMaxTabWidth += fMinTabWidth; fMaxTabWidth += fMinTabWidth;
@@ -436,8 +436,8 @@ STRACE(("_DrawFrame(%f,%f,%f,%f)\n", invalid.left, invalid.top,
invalid.right, invalid.bottom)); invalid.right, invalid.bottom));
#ifdef USE_VIEW_FILL_HACK #ifdef USE_VIEW_FILL_HACK
_drawdata.SetHighColor(RGBColor(192, 192, 192 )); fDrawState.SetHighColor(RGBColor(192, 192, 192 ));
_driver->FillRect(_frame, _drawdata.HighColor()); _driver->FillRect(_frame, fDrawState.HighColor());
#endif #endif
if (_look == B_NO_BORDER_WINDOW_LOOK) 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)); STRACE(("_DrawTitle(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom));
_drawdata.SetHighColor(fTextColor); fDrawState.SetHighColor(fTextColor);
_drawdata.SetLowColor(fTabColor); fDrawState.SetLowColor(fTabColor);
// figure out position of text // figure out position of text
font_height fontHeight; font_height fontHeight;
_drawdata.Font().GetHeight(fontHeight); fDrawState.Font().GetHeight(fontHeight);
BPoint titlePos; BPoint titlePos;
titlePos.x = _closerect.IsValid() ? _closerect.right + fTextOffset 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 titlePos.y = floorf(((_tabrect.top + 2.0) + _tabrect.bottom + fontHeight.ascent
+ fontHeight.descent) / 2.0 - fontHeight.descent + 0.5); + fontHeight.descent) / 2.0 - fontHeight.descent + 0.5);
_driver->DrawString(fTruncatedTitle.String(), fTruncatedTitleLength, titlePos, &_drawdata); _driver->DrawString(fTruncatedTitle.String(), fTruncatedTitleLength, titlePos, &fDrawState);
} }
// _DrawZoom // _DrawZoom
@@ -786,6 +786,6 @@ DefaultDecorator::_LayoutTabItems(const BRect& tabRect)
// also not appear perfectly in the middle // also not appear perfectly in the middle
float width = (_zoomrect.left - _closerect.right) - fTextOffset * 2 + 2; float width = (_zoomrect.left - _closerect.right) - fTextOffset * 2 + 2;
fTruncatedTitle = GetTitle(); fTruncatedTitle = GetTitle();
_drawdata.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END, width); fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END, width);
fTruncatedTitleLength = fTruncatedTitle.Length(); fTruncatedTitleLength = fTruncatedTitle.Length();
} }
@@ -6,6 +6,7 @@
* DarkWyrm <bpmagic@columbus.rr.com> * DarkWyrm <bpmagic@columbus.rr.com>
* Adi Oanca <adioanca@mymail.ro> * Adi Oanca <adioanca@mymail.ro>
* Stephan Aßmus <superstippi@gmx.de> * Stephan Aßmus <superstippi@gmx.de>
* Axel Dörfler, axeld@pinc-software.de
*/ */
/** Data classes for working with BView states and draw parameters */ /** Data classes for working with BView states and draw parameters */
@@ -18,11 +19,10 @@
#include "LinkReceiver.h" #include "LinkReceiver.h"
#include "LinkSender.h" #include "LinkSender.h"
#include "DesktopSettings.h" #include "DrawState.h"
#include "LayerData.h"
DrawData::DrawData() DrawState::DrawState()
: fOrigin(0.0, 0.0), : fOrigin(0.0, 0.0),
fScale(1.0), fScale(1.0),
fClippingRegion(NULL), fClippingRegion(NULL),
@@ -38,63 +38,29 @@ DrawData::DrawData()
fSubPixelPrecise(false), fSubPixelPrecise(false),
fLineCapMode(B_BUTT_CAP), fLineCapMode(B_BUTT_CAP),
fLineJoinMode(B_BEVEL_JOIN), fLineJoinMode(B_BEVEL_JOIN),
fMiterLimit(B_DEFAULT_MITER_LIMIT) fMiterLimit(B_DEFAULT_MITER_LIMIT),
fPreviousState(NULL)
{ {
fUnscaledFontSize = fFont.Size(); fUnscaledFontSize = fFont.Size();
} }
DrawData::DrawData(const DrawData& from) DrawState::DrawState(const DrawState& from)
: fClippingRegion(NULL) : fClippingRegion(NULL)
{ {
*this = from; *this = from;
} }
DrawData::DrawData(const DrawData* from) DrawState::~DrawState()
: 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()
{ {
delete fClippingRegion; delete fClippingRegion;
delete fPreviousState;
} }
// operator=
DrawData& DrawState&
DrawData::operator=(const DrawData& from) DrawState::operator=(const DrawState& from)
{ {
fOrigin = from.fOrigin; fOrigin = from.fOrigin;
fScale = from.fScale; fScale = from.fScale;
@@ -126,281 +92,41 @@ DrawData::operator=(const DrawData& from)
fLineJoinMode = from.fLineJoinMode; fLineJoinMode = from.fLineJoinMode;
fMiterLimit = from.fMiterLimit; 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; fUnscaledFontSize = from.fUnscaledFontSize;
fPreviousState = from.fPreviousState;
return *this; 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 void
DrawData::SetOrigin(const BPoint& origin) DrawState::ReadFontFromLink(BPrivate::LinkReceiver& link)
{
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)
{ {
uint16 mask; uint16 mask;
link.Read<uint16>(&mask); link.Read<uint16>(&mask);
@@ -454,9 +180,9 @@ LayerData::ReadFontFromLink(BPrivate::LinkReceiver& link)
} }
} }
// ReadFromLink
void void
LayerData::ReadFromLink(BPrivate::LinkReceiver& link) DrawState::ReadFromLink(BPrivate::LinkReceiver& link)
{ {
rgb_color highColor; rgb_color highColor;
rgb_color lowColor; rgb_color lowColor;
@@ -496,9 +222,9 @@ LayerData::ReadFromLink(BPrivate::LinkReceiver& link)
SetClippingRegion(region); SetClippingRegion(region);
} }
// WriteToLink
void void
LayerData::WriteToLink(BPrivate::LinkSender& link) const DrawState::WriteToLink(BPrivate::LinkSender& link) const
{ {
rgb_color hc = fHighColor.GetColor32(); rgb_color hc = fHighColor.GetColor32();
rgb_color lc = fLowColor.GetColor32(); rgb_color lc = fLowColor.GetColor32();
@@ -539,14 +265,228 @@ LayerData::WriteToLink(BPrivate::LinkSender& link) const
} }
LayerData* void
LayerData::PopState() DrawState::SetOrigin(const BPoint& origin)
{ {
LayerData* previous = PreviousState(); fOrigin = origin;
}
fPreviousState = NULL;
delete this;
void
return previous; 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());
} }
+1 -1
View File
@@ -28,9 +28,9 @@ SharedLibrary libappserver.so :
CursorData.cpp CursorData.cpp
CursorSet.cpp CursorSet.cpp
Decorator.cpp Decorator.cpp
DrawState.cpp
FontFamily.cpp FontFamily.cpp
IPoint.cpp IPoint.cpp
LayerData.cpp
RGBColor.cpp RGBColor.cpp
ServerBitmap.cpp ServerBitmap.cpp
ServerCursor.cpp ServerCursor.cpp
+21 -23
View File
@@ -38,7 +38,7 @@
#include "DebugInfoManager.h" #include "DebugInfoManager.h"
#include "DisplayDriver.h" #include "DisplayDriver.h"
#include "LayerData.h" #include "DrawState.h"
#include "PortLink.h" #include "PortLink.h"
#include "RootLayer.h" #include "RootLayer.h"
#include "ServerProtocol.h" #include "ServerProtocol.h"
@@ -106,7 +106,7 @@ Layer::Layer(BRect frame, const char* name, int32 token,
fAdFlags(0), fAdFlags(0),
fDriver(driver), fDriver(driver),
fLayerData(new LayerData), fDrawState(new DrawState),
fRootLayer(NULL), fRootLayer(NULL),
@@ -125,18 +125,18 @@ CRITICAL(helper);
if (!fDriver) if (!fDriver)
CRITICAL("You MUST have a valid driver to init a Layer object\n"); 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, // though it is actually not part of a "state". However,
// it is an important detail of a graphics context, and we // it is an important detail of a graphics context, and we
// have no other means to pass this setting on to the DisplayDriver // 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 // B_ANTI_ALIASING to the view flags, it would have to be passed
// in the same way. Though when breaking binary compatibility, // in the same way. Though when breaking binary compatibility,
// we might want to make this an actual part of a "state" (with // we might want to make this an actual part of a "state" (with
// a different API to set these). // a different API to set these).
// Note that the flag is also tested (updated) in Push/PopState and // Note that the flag is also tested (updated) in Push/PopState and
// SetFlags(). // SetFlags().
fLayerData->SetSubPixelPrecise(fFlags & B_SUBPIXEL_PRECISE); fDrawState->SetSubPixelPrecise(fFlags & B_SUBPIXEL_PRECISE);
STRACE(("Layer(%s) successfuly created\n", Name())); STRACE(("Layer(%s) successfuly created\n", Name()));
} }
@@ -144,7 +144,7 @@ CRITICAL(helper);
Layer::~Layer() Layer::~Layer()
{ {
delete fLayerData; delete fDrawState;
// TODO: uncomment! // TODO: uncomment!
//PruneTree(); //PruneTree();
@@ -486,7 +486,7 @@ void
Layer::SetFlags(uint32 flags) Layer::SetFlags(uint32 flags)
{ {
fFlags = flags; fFlags = flags;
fLayerData->SetSubPixelPrecise(fFlags & B_SUBPIXEL_PRECISE); fDrawState->SetSubPixelPrecise(fFlags & B_SUBPIXEL_PRECISE);
} }
#ifndef NEW_CLIPPING #ifndef NEW_CLIPPING
@@ -506,8 +506,8 @@ Layer::RebuildFullRegion(void)
// TODO: Convert to screen coordinates // TODO: Convert to screen coordinates
LayerData *ld; DrawState *ld;
ld = fLayerData; ld = fDrawState;
do { do {
// clip to user region // clip to user region
if (const BRegion* userClipping = ld->ClippingRegion()) if (const BRegion* userClipping = ld->ClippingRegion())
@@ -1010,23 +1010,21 @@ Layer::IsHidden(void) const
void void
Layer::PushState() Layer::PushState()
{ {
LayerData *data = new LayerData(fLayerData); fDrawState = fDrawState->PushState();
fLayerData = data; fDrawState->SetSubPixelPrecise(fFlags & B_SUBPIXEL_PRECISE);
fLayerData->SetSubPixelPrecise(fFlags & B_SUBPIXEL_PRECISE);
} }
void void
Layer::PopState() 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()); fprintf(stderr, "WARNING: User called BView(%s)::PopState(), but there is NO state on stack!\n", Name());
return; return;
} }
fLayerData = fLayerData->PopState(); fDrawState = fDrawState->PopState();
fLayerData->SetSubPixelPrecise(fFlags & B_SUBPIXEL_PRECISE); fDrawState->SetSubPixelPrecise(fFlags & B_SUBPIXEL_PRECISE);
} }
@@ -1204,7 +1202,7 @@ Layer::BoundsOrigin() const
BPoint origin(0,0); BPoint origin(0,0);
float scale = Scale(); float scale = Scale();
LayerData* layerData = fLayerData; DrawState* layerData = fDrawState;
do { do {
origin += layerData->Origin(); origin += layerData->Origin();
} while ((layerData = layerData->PreviousState()) != NULL); } while ((layerData = layerData->PreviousState()) != NULL);
@@ -1221,7 +1219,7 @@ Layer::Scale() const
{ {
float scale = 1.0f; float scale = 1.0f;
LayerData* layerData = fLayerData; DrawState* layerData = fDrawState;
do { do {
scale *= layerData->Scale(); scale *= layerData->Scale();
} while ((layerData = layerData->PreviousState()) != NULL); } while ((layerData = layerData->PreviousState()) != NULL);
@@ -1475,10 +1473,10 @@ Layer::PrintToStream()
printf("ResizingMode: %lx ", fResizeMode); printf("ResizingMode: %lx ", fResizeMode);
printf("Flags: %lx\n", fFlags); printf("Flags: %lx\n", fFlags);
if (fLayerData) if (fDrawState)
fLayerData->PrintToStream(); fDrawState->PrintToStream();
else else
printf(" NO LayerData valid pointer\n"); printf(" NO DrawState valid pointer\n");
} }
//! Prints pointer info kept by the current layer //! Prints pointer info kept by the current layer
@@ -2479,7 +2477,7 @@ void Layer::do_MoveBy(float dx, float dy)
void void
Layer::do_ScrollBy(float dx, float dy) 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); // fOrigin.Set(fOrigin.x + dx, fOrigin.y + dy);
if (!IsHidden() && GetRootLayer()) { if (!IsHidden() && GetRootLayer()) {
@@ -2532,7 +2530,7 @@ Layer::_GetWantedRegion(BRegion &reg)
// 3) impose user constrained regions // 3) impose user constrained regions
LayerData *stackData = fLayerData; DrawState *stackData = fDrawState;
while (stackData) { while (stackData) {
if (stackData->ClippingRegion()) { if (stackData->ClippingRegion()) {
// transform in screen coords // transform in screen coords
+2 -2
View File
@@ -64,7 +64,7 @@ enum {
class ServerApp; class ServerApp;
class RootLayer; class RootLayer;
class DisplayDriver; class DisplayDriver;
class LayerData; class DrawState;
class ServerBitmap; class ServerBitmap;
class PointerEvent { class PointerEvent {
@@ -371,7 +371,7 @@ friend class OffscreenWinBorder;
uint16 fAdFlags; uint16 fAdFlags;
DisplayDriver* fDriver; DisplayDriver* fDriver;
LayerData* fLayerData; DrawState* fDrawState;
RootLayer* fRootLayer; RootLayer* fRootLayer;
+1 -1
View File
@@ -128,7 +128,7 @@ void PicturePlayer::GetData(void *data, int32 size)
fData.Read(data, 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) if(!userData || !d)
return B_ERROR; return B_ERROR;
+3 -3
View File
@@ -32,7 +32,7 @@
#include <Point.h> #include <Point.h>
#include <Rect.h> #include <Rect.h>
#include <DataIO.h> #include <DataIO.h>
#include "LayerData.h" #include "DrawState.h"
#include "PatternHandler.h" // for pattern_union #include "PatternHandler.h" // for pattern_union
class DisplayDriver; class DisplayDriver;
@@ -81,14 +81,14 @@ public:
void SetClippingRegion(BRect *rects, int32 numrects); 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(); status_t Rewind();
private: private:
BMemoryIO fData; BMemoryIO fData;
int32 fSize; int32 fSize;
DisplayDriver *fdriver; DisplayDriver *fdriver;
LayerData fldata; DrawState fldata;
BPoint forigin; BPoint forigin;
Pattern stipplepat; Pattern stipplepat;
BRegion *clipreg; BRegion *clipreg;
+23 -37
View File
@@ -1,34 +1,20 @@
//------------------------------------------------------------------------------ /*
// Copyright (c) 2001-2005, Haiku, Inc. * Copyright 2001-2005, Haiku, Inc.
// * Distributed under the terms of the MIT License.
// Permission is hereby granted, free of charge, to any person obtaining a *
// copy of this software and associated documentation files (the "Software"), * Authors:
// to deal in the Software without restriction, including without limitation * Gabe Yoder <gyoder@stny.rr.com>
// the rights to use, copy, modify, merge, publish, distribute, sublicense, * DarkWyrm <bpmagic@columbus.rr.com>
// and/or sell copies of the Software, and to permit persons to whom the * Adrian Oanca <adioanca@cotty.iren.ro>
// Software is furnished to do so, subject to the following conditions: * Stephan Aßmus <superstippi@gmx.de>
// * Axel Dörfler, axeld@pinc-software.de
// The above copyright notice and this permission notice shall be included in */
// all copies or substantial portions of the Software.
// /** Class used for the top layer of each workspace's Layer tree */
// 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 <[email protected]>
// DarkWyrm <[email protected]>
// Adi Oanca <[email protected]>
// Stephan Aßmus <[email protected]>
// Description: Class used for the top layer of each workspace's Layer tree
//
//------------------------------------------------------------------------------
#include <stdio.h> #include <stdio.h>
#include <Window.h> #include <Window.h>
#include <List.h> #include <List.h>
#include <Message.h> #include <Message.h>
@@ -137,8 +123,8 @@ RootLayer::RootLayer(const char *name, int32 workspaceCount,
// init the first, default workspace // init the first, default workspace
fWorkspace[fActiveWksIndex] = new Workspace(fActiveWksIndex, 0xFF00FF00, fWorkspace[fActiveWksIndex] = new Workspace(fActiveWksIndex, 0xFF00FF00,
kDefaultWorkspaceColor); kDefaultWorkspaceColor);
fLayerData->SetHighColor(RGBColor(255, 255, 255)); fDrawState->SetHighColor(RGBColor(255, 255, 255));
fLayerData->SetLowColor(fWorkspace[fActiveWksIndex]->BGColor()); fDrawState->SetLowColor(fWorkspace[fActiveWksIndex]->BGColor());
// Spawn our working thread // Spawn our working thread
fThreadID = spawn_thread(WorkingThread, name, B_DISPLAY_PRIORITY, this); fThreadID = spawn_thread(WorkingThread, name, B_DISPLAY_PRIORITY, this);
@@ -559,10 +545,10 @@ bool RootLayer::SetActiveWorkspace(int32 index)
// adjust our DrawData to workspace colors // adjust our DrawData to workspace colors
rgb_color bg = fWorkspace[index]->BGColor().GetColor32(); rgb_color bg = fWorkspace[index]->BGColor().GetColor32();
if ((bg.red + bg.green + bg.blue) / 3 > 128) if ((bg.red + bg.green + bg.blue) / 3 > 128)
fLayerData->SetHighColor(RGBColor(0, 0, 0)); fDrawState->SetHighColor(RGBColor(0, 0, 0));
else else
fLayerData->SetHighColor(RGBColor(255, 255, 255)); fDrawState->SetHighColor(RGBColor(255, 255, 255));
fLayerData->SetLowColor(fWorkspace[index]->BGColor()); fDrawState->SetLowColor(fWorkspace[index]->BGColor());
// save some datas // save some datas
int32 exIndex = ActiveWorkspaceIndex(); int32 exIndex = ActiveWorkspaceIndex();
@@ -1587,7 +1573,7 @@ RootLayer::Draw(const BRect &r)
char string[30]; char string[30];
sprintf(string, "Workspace %ld", fActiveWksIndex + 1); sprintf(string, "Workspace %ld", fActiveWksIndex + 1);
fDriver->DrawString(string, strlen(string), BPoint(5, 15), fDriver->DrawString(string, strlen(string), BPoint(5, 15),
fLayerData); fDrawState);
#endif // APPSERVER_ROOTLAYER_SHOW_WORKSPACE_NUMBER #endif // APPSERVER_ROOTLAYER_SHOW_WORKSPACE_NUMBER
#if ON_SCREEN_DEBUGGING_INFO #if ON_SCREEN_DEBUGGING_INFO
BPoint location(5, 40); BPoint location(5, 40);
@@ -1598,7 +1584,7 @@ RootLayer::Draw(const BRect &r)
p++; p++;
if (*p == 0 || *p == '\n') { if (*p == 0 || *p == '\n') {
fDriver->DrawString(start, p - start, location, fDriver->DrawString(start, p - start, location,
fLayerData); fDrawState);
// NOTE: Eventually, this will be below the screen! // NOTE: Eventually, this will be below the screen!
location.y += textHeight; location.y += textHeight;
start = p + 1; start = p + 1;
@@ -1614,7 +1600,7 @@ RootLayer::Draw(const BRect &r)
logoPos.y = floorf(fFrame.bottom - kLogoHeight * 1.5); logoPos.y = floorf(fFrame.bottom - kLogoHeight * 1.5);
BRect bitmapBounds = fLogoBitmap->Bounds(); BRect bitmapBounds = fLogoBitmap->Bounds();
fDriver->DrawBitmap(fLogoBitmap, bitmapBounds, fDriver->DrawBitmap(fLogoBitmap, bitmapBounds,
bitmapBounds.OffsetToCopy(logoPos), fLayerData); bitmapBounds.OffsetToCopy(logoPos), fDrawState);
} }
#endif // DISPLAY_HAIKU_LOGO #endif // DISPLAY_HAIKU_LOGO
} }
+1 -3
View File
@@ -38,7 +38,7 @@
#include "DisplayDriver.h" #include "DisplayDriver.h"
#include "FontManager.h" #include "FontManager.h"
#include "HWInterface.h" #include "HWInterface.h"
#include "LayerData.h" //#include "DrawState.h"
#include "OffscreenServerWindow.h" #include "OffscreenServerWindow.h"
#include "RAMLinkMsgReader.h" #include "RAMLinkMsgReader.h"
#include "RootLayer.h" #include "RootLayer.h"
@@ -494,8 +494,6 @@ ServerApp::_MessageLooper()
void void
ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
{ {
// LayerData ld;
switch (code) { switch (code) {
case AS_GET_WINDOW_LIST: case AS_GET_WINDOW_LIST:
team_id team; team_id team;
+77 -77
View File
@@ -430,7 +430,7 @@ ServerWindow::SetLayerFontState(Layer *layer, BPrivate::LinkReceiver &link)
fTitle, layer->Name())); fTitle, layer->Name()));
// NOTE: no need to check for a lock. This is a private method. // 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())); layer->Name()));
// NOTE: no need to check for a lock. This is a private method. // 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? // TODO: Rebuild clipping here?
} }
@@ -503,7 +503,7 @@ ServerWindow::CreateLayerTree(BPrivate::LinkReceiver &link, Layer **_parent)
DesktopSettings settings(fDesktop); DesktopSettings settings(fDesktop);
ServerFont font; ServerFont font;
settings.GetDefaultPlainFont(font); settings.GetDefaultPlainFont(font);
newLayer->fLayerData->SetFont(font); newLayer->fDrawState->SetFont(font);
// TODO: rework the clipping stuff to remove RootLayer dependency and then // TODO: rework the clipping stuff to remove RootLayer dependency and then
// remove this hack: // remove this hack:
@@ -570,7 +570,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
// -> it will invalidate areas previously out of screen // -> it will invalidate areas previously out of screen
dst = dst | src; dst = dst | src;
fCurrentLayer->fLayerData->OffsetOrigin(BPoint(dh, dv)); fCurrentLayer->fDrawState->OffsetOrigin(BPoint(dh, dv));
fCurrentLayer->CopyBits(src, dst, xOffset, yOffset); fCurrentLayer->CopyBits(src, dst, xOffset, yOffset);
#else #else
@@ -730,7 +730,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
fLink.StartMessage(SERVER_TRUE); fLink.StartMessage(SERVER_TRUE);
// attach state data // attach state data
fCurrentLayer->fLayerData->WriteToLink(fLink.Sender()); fCurrentLayer->fDrawState->WriteToLink(fLink.Sender());
fLink.Flush(); fLink.Flush();
break; break;
} }
@@ -816,14 +816,14 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<float>(&x); link.Read<float>(&x);
link.Read<float>(&y); link.Read<float>(&y);
fCurrentLayer->fLayerData->SetOrigin(BPoint(x, y)); fCurrentLayer->fDrawState->SetOrigin(BPoint(x, y));
break; break;
} }
case AS_LAYER_GET_ORIGIN: case AS_LAYER_GET_ORIGIN:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_GET_ORIGIN: Layer: %s\n", Title(), fCurrentLayer->Name())); STRACE(("ServerWindow %s: Message AS_LAYER_GET_ORIGIN: Layer: %s\n", Title(), fCurrentLayer->Name()));
fLink.StartMessage(SERVER_TRUE); fLink.StartMessage(SERVER_TRUE);
fLink.Attach<BPoint>(fCurrentLayer->fLayerData->Origin()); fLink.Attach<BPoint>(fCurrentLayer->fDrawState->Origin());
fLink.Flush(); fLink.Flush();
break; break;
} }
@@ -878,9 +878,9 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<int8>(&lineJoin); link.Read<int8>(&lineJoin);
link.Read<float>(&miterLimit); link.Read<float>(&miterLimit);
fCurrentLayer->fLayerData->SetLineCapMode((cap_mode)lineCap); fCurrentLayer->fDrawState->SetLineCapMode((cap_mode)lineCap);
fCurrentLayer->fLayerData->SetLineJoinMode((join_mode)lineJoin); fCurrentLayer->fDrawState->SetLineJoinMode((join_mode)lineJoin);
fCurrentLayer->fLayerData->SetMiterLimit(miterLimit); fCurrentLayer->fDrawState->SetMiterLimit(miterLimit);
break; 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())); DTRACE(("ServerWindow %s: Message AS_LAYER_GET_LINE_MODE: Layer: %s\n", Title(), fCurrentLayer->Name()));
fLink.StartMessage(SERVER_TRUE); fLink.StartMessage(SERVER_TRUE);
fLink.Attach<int8>((int8)(fCurrentLayer->fLayerData->LineCapMode())); fLink.Attach<int8>((int8)(fCurrentLayer->fDrawState->LineCapMode()));
fLink.Attach<int8>((int8)(fCurrentLayer->fLayerData->LineJoinMode())); fLink.Attach<int8>((int8)(fCurrentLayer->fDrawState->LineJoinMode()));
fLink.Attach<float>(fCurrentLayer->fLayerData->MiterLimit()); fLink.Attach<float>(fCurrentLayer->fDrawState->MiterLimit());
fLink.Flush(); fLink.Flush();
break; break;
@@ -922,13 +922,13 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<float>(&scale); link.Read<float>(&scale);
// TODO: The BeBook says, if you call SetScale() it will be // TODO: The BeBook says, if you call SetScale() it will be
// multiplied with the scale from all previous states on the stack // multiplied with the scale from all previous states on the stack
fCurrentLayer->fLayerData->SetScale(scale); fCurrentLayer->fDrawState->SetScale(scale);
break; break;
} }
case AS_LAYER_GET_SCALE: case AS_LAYER_GET_SCALE:
{ {
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_SCALE: Layer: %s\n", Title(), fCurrentLayer->Name())); 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 // TODO: And here, we're taking that into account, but not above
// -> refactor put scale into Layer, or better yet, when the // -> refactor put scale into Layer, or better yet, when the
@@ -952,14 +952,14 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<float>(&x); link.Read<float>(&x);
link.Read<float>(&y); link.Read<float>(&y);
fCurrentLayer->fLayerData->SetPenLocation(BPoint(x, y)); fCurrentLayer->fDrawState->SetPenLocation(BPoint(x, y));
break; break;
} }
case AS_LAYER_GET_PEN_LOC: case AS_LAYER_GET_PEN_LOC:
{ {
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_LOC: Layer: %s\n", Title(), fCurrentLayer->Name())); DTRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_LOC: Layer: %s\n", Title(), fCurrentLayer->Name()));
fLink.StartMessage(SERVER_TRUE); fLink.StartMessage(SERVER_TRUE);
fLink.Attach<BPoint>(fCurrentLayer->fLayerData->PenLocation()); fLink.Attach<BPoint>(fCurrentLayer->fDrawState->PenLocation());
fLink.Flush(); fLink.Flush();
break; 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())); DTRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_SIZE: Layer: %s\n", Title(), fCurrentLayer->Name()));
float penSize; float penSize;
link.Read<float>(&penSize); link.Read<float>(&penSize);
fCurrentLayer->fLayerData->SetPenSize(penSize); fCurrentLayer->fDrawState->SetPenSize(penSize);
break; 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())); DTRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_SIZE: Layer: %s\n", Title(), fCurrentLayer->Name()));
fLink.StartMessage(SERVER_TRUE); fLink.StartMessage(SERVER_TRUE);
fLink.Attach<float>(fCurrentLayer->fLayerData->PenSize()); fLink.Attach<float>(fCurrentLayer->fDrawState->PenSize());
fLink.Flush(); fLink.Flush();
break; break;
@@ -1006,7 +1006,7 @@ myRootLayer->Unlock();
Title(), fCurrentLayer->Name())); Title(), fCurrentLayer->Name()));
fLink.StartMessage(SERVER_TRUE); fLink.StartMessage(SERVER_TRUE);
fLink.Attach<rgb_color>(fCurrentLayer->fLayerData->HighColor().GetColor32()); fLink.Attach<rgb_color>(fCurrentLayer->fDrawState->HighColor().GetColor32());
fLink.Flush(); fLink.Flush();
break; break;
@@ -1015,7 +1015,7 @@ myRootLayer->Unlock();
Title(), fCurrentLayer->Name())); Title(), fCurrentLayer->Name()));
fLink.StartMessage(SERVER_TRUE); fLink.StartMessage(SERVER_TRUE);
fLink.Attach<rgb_color>(fCurrentLayer->fLayerData->LowColor().GetColor32()); fLink.Attach<rgb_color>(fCurrentLayer->fDrawState->LowColor().GetColor32());
fLink.Flush(); fLink.Flush();
break; break;
@@ -1036,7 +1036,7 @@ myRootLayer->Unlock();
link.Read<int8>(&srcAlpha); link.Read<int8>(&srcAlpha);
link.Read<int8>(&alphaFunc); link.Read<int8>(&alphaFunc);
fCurrentLayer->fLayerData->SetBlendingMode((source_alpha)srcAlpha, fCurrentLayer->fDrawState->SetBlendingMode((source_alpha)srcAlpha,
(alpha_function)alphaFunc); (alpha_function)alphaFunc);
break; break;
@@ -1045,8 +1045,8 @@ myRootLayer->Unlock();
{ {
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_BLEND_MODE: Layer: %s\n", Title(), fCurrentLayer->Name())); DTRACE(("ServerWindow %s: Message AS_LAYER_GET_BLEND_MODE: Layer: %s\n", Title(), fCurrentLayer->Name()));
fLink.StartMessage(SERVER_TRUE); fLink.StartMessage(SERVER_TRUE);
fLink.Attach<int8>((int8)(fCurrentLayer->fLayerData->AlphaSrcMode())); fLink.Attach<int8>((int8)(fCurrentLayer->fDrawState->AlphaSrcMode()));
fLink.Attach<int8>((int8)(fCurrentLayer->fLayerData->AlphaFncMode())); fLink.Attach<int8>((int8)(fCurrentLayer->fDrawState->AlphaFncMode()));
fLink.Flush(); fLink.Flush();
break; break;
@@ -1058,7 +1058,7 @@ myRootLayer->Unlock();
link.Read<int8>(&drawingMode); link.Read<int8>(&drawingMode);
fCurrentLayer->fLayerData->SetDrawingMode((drawing_mode)drawingMode); fCurrentLayer->fDrawState->SetDrawingMode((drawing_mode)drawingMode);
break; break;
} }
@@ -1066,7 +1066,7 @@ myRootLayer->Unlock();
{ {
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_DRAW_MODE: Layer: %s\n", Title(), fCurrentLayer->Name())); DTRACE(("ServerWindow %s: Message AS_LAYER_GET_DRAW_MODE: Layer: %s\n", Title(), fCurrentLayer->Name()));
fLink.StartMessage(SERVER_TRUE); fLink.StartMessage(SERVER_TRUE);
fLink.Attach<int8>((int8)(fCurrentLayer->fLayerData->GetDrawingMode())); fLink.Attach<int8>((int8)(fCurrentLayer->fDrawState->GetDrawingMode()));
fLink.Flush(); fLink.Flush();
break; break;
@@ -1076,7 +1076,7 @@ myRootLayer->Unlock();
DTRACE(("ServerWindow %s: Message AS_LAYER_PRINT_ALIASING: Layer: %s\n", Title(), fCurrentLayer->Name())); DTRACE(("ServerWindow %s: Message AS_LAYER_PRINT_ALIASING: Layer: %s\n", Title(), fCurrentLayer->Name()));
bool fontAliasing; bool fontAliasing;
link.Read<bool>(&fontAliasing); link.Read<bool>(&fontAliasing);
fCurrentLayer->fLayerData->SetForceFontAliasing(fontAliasing); fCurrentLayer->fDrawState->SetForceFontAliasing(fontAliasing);
break; break;
} }
@@ -1106,7 +1106,7 @@ myRootLayer->Unlock();
if (PictureToRegion(picture, region, inverse, where) < B_OK) if (PictureToRegion(picture, region, inverse, where) < B_OK)
break; break;
fCurrentLayer->fLayerData->SetClippingRegion(region); fCurrentLayer->fDrawState->SetClippingRegion(region);
#ifndef NEW_CLIPPING #ifndef NEW_CLIPPING
fCurrentLayer->RebuildFullRegion(); fCurrentLayer->RebuildFullRegion();
@@ -1176,7 +1176,7 @@ myRootLayer->Unlock();
// We need to integrate user clipping more, in Layer::PopState, the clipping needs to be // 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 // 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. // "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 #ifndef NEW_CLIPPING
// TODO: set the clipping // TODO: set the clipping
// fCurrentLayer->fVisible.IntersectWith(&region); // fCurrentLayer->fVisible.IntersectWith(&region);
@@ -1515,7 +1515,7 @@ myRootLayer->Unlock();
link.Read(&c, sizeof(rgb_color)); link.Read(&c, sizeof(rgb_color));
fCurrentLayer->fLayerData->SetHighColor(RGBColor(c)); fCurrentLayer->fDrawState->SetHighColor(RGBColor(c));
break; break;
} }
@@ -1526,7 +1526,7 @@ myRootLayer->Unlock();
link.Read(&c, sizeof(rgb_color)); link.Read(&c, sizeof(rgb_color));
fCurrentLayer->fLayerData->SetLowColor(RGBColor(c)); fCurrentLayer->fDrawState->SetLowColor(RGBColor(c));
break; break;
} }
@@ -1537,7 +1537,7 @@ myRootLayer->Unlock();
link.Read(&pat, sizeof(pattern)); link.Read(&pat, sizeof(pattern));
fCurrentLayer->fLayerData->SetPattern(Pattern(pat)); fCurrentLayer->fDrawState->SetPattern(Pattern(pat));
break; break;
} }
@@ -1549,8 +1549,8 @@ myRootLayer->Unlock();
link.Read<float>(&x); link.Read<float>(&x);
link.Read<float>(&y); link.Read<float>(&y);
if (fCurrentLayer && fCurrentLayer->fLayerData) if (fCurrentLayer && fCurrentLayer->fDrawState)
fCurrentLayer->fLayerData->SetPenLocation(BPoint(x, y)); fCurrentLayer->fDrawState->SetPenLocation(BPoint(x, y));
break; break;
} }
@@ -1560,8 +1560,8 @@ myRootLayer->Unlock();
float size; float size;
link.Read<float>(&size); link.Read<float>(&size);
if (fCurrentLayer && fCurrentLayer->fLayerData) if (fCurrentLayer && fCurrentLayer->fDrawState)
fCurrentLayer->fLayerData->SetPenSize(size); fCurrentLayer->fDrawState->SetPenSize(size);
break; break;
} }
@@ -1702,7 +1702,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
DisplayDriver* driver = fWinBorder->GetDisplayDriver(); DisplayDriver* driver = fWinBorder->GetDisplayDriver();
driver->ConstrainClippingRegion(&rreg); 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); // RGBColor c(rand()%255,rand()%255,rand()%255);
// driver->FillRect(BRect(0,0,639,479), c); // driver->FillRect(BRect(0,0,639,479), c);
@@ -1718,13 +1718,13 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<float>(&x2); link.Read<float>(&x2);
link.Read<float>(&y2); link.Read<float>(&y2);
if (fCurrentLayer && fCurrentLayer->fLayerData) { if (fCurrentLayer && fCurrentLayer->fDrawState) {
BPoint p1(x1,y1); BPoint p1(x1,y1);
BPoint p2(x2,y2); BPoint p2(x2,y2);
driver->StrokeLine(fCurrentLayer->ConvertToTop(p1), driver->StrokeLine(fCurrentLayer->ConvertToTop(p1),
fCurrentLayer->ConvertToTop(p2), fCurrentLayer->ConvertToTop(p2),
fCurrentLayer->fLayerData); fCurrentLayer->fDrawState);
// We update the pen here because many DisplayDriver calls which do not update the // We update the pen here because many DisplayDriver calls which do not update the
// pen position actually call StrokeLine // 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 // TODO: Decide where to put this, for example, it cannot be done
// for DrawString(), also there needs to be a decision, if penlocation // for DrawString(), also there needs to be a decision, if penlocation
// is in View coordinates (I think it should be) or in screen coordinates. // is in View coordinates (I think it should be) or in screen coordinates.
fCurrentLayer->fLayerData->SetPenLocation(p2); fCurrentLayer->fDrawState->SetPenLocation(p2);
} }
break; break;
} }
@@ -1743,7 +1743,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
BRect rect; BRect rect;
link.Read<BRect>(&rect); link.Read<BRect>(&rect);
if (fCurrentLayer && fCurrentLayer->fLayerData) if (fCurrentLayer && fCurrentLayer->fDrawState)
driver->InvertRect(fCurrentLayer->ConvertToTop(rect)); driver->InvertRect(fCurrentLayer->ConvertToTop(rect));
break; break;
} }
@@ -1758,8 +1758,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<float>(&bottom); link.Read<float>(&bottom);
BRect rect(left,top,right,bottom); BRect rect(left,top,right,bottom);
if (fCurrentLayer && fCurrentLayer->fLayerData) if (fCurrentLayer && fCurrentLayer->fDrawState)
driver->StrokeRect(fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fLayerData); driver->StrokeRect(fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fDrawState);
break; break;
} }
case AS_FILL_RECT: case AS_FILL_RECT:
@@ -1768,8 +1768,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
BRect rect; BRect rect;
link.Read<BRect>(&rect); link.Read<BRect>(&rect);
if (fCurrentLayer && fCurrentLayer->fLayerData) if (fCurrentLayer && fCurrentLayer->fDrawState)
driver->FillRect(fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fLayerData); driver->FillRect(fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fDrawState);
break; break;
} }
case AS_LAYER_DRAW_BITMAP_SYNC_AT_POINT: case AS_LAYER_DRAW_BITMAP_SYNC_AT_POINT:
@@ -1787,7 +1787,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
BRect dst = src.OffsetToCopy(point); BRect dst = src.OffsetToCopy(point);
dst = fCurrentLayer->ConvertToTop(dst); 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? // 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); BRect dst = src.OffsetToCopy(point);
dst = fCurrentLayer->ConvertToTop(dst); dst = fCurrentLayer->ConvertToTop(dst);
driver->DrawBitmap(sbmp, src, dst, fCurrentLayer->fLayerData); driver->DrawBitmap(sbmp, src, dst, fCurrentLayer->fDrawState);
} }
break; break;
} }
@@ -1826,7 +1826,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
if (sbmp) { if (sbmp) {
dstRect = fCurrentLayer->ConvertToTop(dstRect); 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? // 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) { if (sbmp) {
dstRect = fCurrentLayer->ConvertToTop(dstRect); dstRect = fCurrentLayer->ConvertToTop(dstRect);
driver->DrawBitmap(sbmp, srcRect, dstRect, fCurrentLayer->fLayerData); driver->DrawBitmap(sbmp, srcRect, dstRect, fCurrentLayer->fDrawState);
} }
break; break;
} }
@@ -1860,8 +1860,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<BRect>(&r); link.Read<BRect>(&r);
link.Read<float>(&angle); link.Read<float>(&angle);
link.Read<float>(&span); link.Read<float>(&span);
if (fCurrentLayer && fCurrentLayer->fLayerData) if (fCurrentLayer && fCurrentLayer->fDrawState)
driver->StrokeArc(fCurrentLayer->ConvertToTop(r),angle,span, fCurrentLayer->fLayerData); driver->StrokeArc(fCurrentLayer->ConvertToTop(r),angle,span, fCurrentLayer->fDrawState);
break; break;
} }
case AS_FILL_ARC: case AS_FILL_ARC:
@@ -1874,8 +1874,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<BRect>(&r); link.Read<BRect>(&r);
link.Read<float>(&angle); link.Read<float>(&angle);
link.Read<float>(&span); link.Read<float>(&span);
if (fCurrentLayer && fCurrentLayer->fLayerData) if (fCurrentLayer && fCurrentLayer->fDrawState)
driver->FillArc(fCurrentLayer->ConvertToTop(r),angle,span, fCurrentLayer->fLayerData); driver->FillArc(fCurrentLayer->ConvertToTop(r),angle,span, fCurrentLayer->fDrawState);
break; break;
} }
case AS_STROKE_BEZIER: case AS_STROKE_BEZIER:
@@ -1889,12 +1889,12 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
for (i=0; i<4; i++) for (i=0; i<4; i++)
link.Read<BPoint>(&(pts[i])); link.Read<BPoint>(&(pts[i]));
if (fCurrentLayer && fCurrentLayer->fLayerData) if (fCurrentLayer && fCurrentLayer->fDrawState)
{ {
for (i=0; i<4; i++) for (i=0; i<4; i++)
pts[i]=fCurrentLayer->ConvertToTop(pts[i]); pts[i]=fCurrentLayer->ConvertToTop(pts[i]);
driver->StrokeBezier(pts, fCurrentLayer->fLayerData); driver->StrokeBezier(pts, fCurrentLayer->fDrawState);
} }
delete [] pts; delete [] pts;
break; break;
@@ -1910,12 +1910,12 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
for (i=0; i<4; i++) for (i=0; i<4; i++)
link.Read<BPoint>(&(pts[i])); link.Read<BPoint>(&(pts[i]));
if (fCurrentLayer && fCurrentLayer->fLayerData) if (fCurrentLayer && fCurrentLayer->fDrawState)
{ {
for (i=0; i<4; i++) for (i=0; i<4; i++)
pts[i]=fCurrentLayer->ConvertToTop(pts[i]); pts[i]=fCurrentLayer->ConvertToTop(pts[i]);
driver->FillBezier(pts, fCurrentLayer->fLayerData); driver->FillBezier(pts, fCurrentLayer->fDrawState);
} }
delete [] pts; delete [] pts;
break; break;
@@ -1926,8 +1926,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
BRect rect; BRect rect;
link.Read<BRect>(&rect); link.Read<BRect>(&rect);
if (fCurrentLayer && fCurrentLayer->fLayerData) if (fCurrentLayer && fCurrentLayer->fDrawState)
driver->StrokeEllipse(fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fLayerData); driver->StrokeEllipse(fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fDrawState);
break; break;
} }
case AS_FILL_ELLIPSE: case AS_FILL_ELLIPSE:
@@ -1936,8 +1936,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
BRect rect; BRect rect;
link.Read<BRect>(&rect); link.Read<BRect>(&rect);
if (fCurrentLayer && fCurrentLayer->fLayerData) if (fCurrentLayer && fCurrentLayer->fDrawState)
driver->FillEllipse(fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fLayerData); driver->FillEllipse(fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fDrawState);
break; break;
} }
case AS_STROKE_ROUNDRECT: case AS_STROKE_ROUNDRECT:
@@ -1950,8 +1950,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<float>(&xrad); link.Read<float>(&xrad);
link.Read<float>(&yrad); link.Read<float>(&yrad);
if (fCurrentLayer && fCurrentLayer->fLayerData) if (fCurrentLayer && fCurrentLayer->fDrawState)
driver->StrokeRoundRect(fCurrentLayer->ConvertToTop(rect),xrad,yrad, fCurrentLayer->fLayerData); driver->StrokeRoundRect(fCurrentLayer->ConvertToTop(rect),xrad,yrad, fCurrentLayer->fDrawState);
break; break;
} }
case AS_FILL_ROUNDRECT: case AS_FILL_ROUNDRECT:
@@ -1964,8 +1964,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<float>(&xrad); link.Read<float>(&xrad);
link.Read<float>(&yrad); link.Read<float>(&yrad);
if (fCurrentLayer && fCurrentLayer->fLayerData) if (fCurrentLayer && fCurrentLayer->fDrawState)
driver->FillRoundRect(fCurrentLayer->ConvertToTop(rect),xrad,yrad, fCurrentLayer->fLayerData); driver->FillRoundRect(fCurrentLayer->ConvertToTop(rect),xrad,yrad, fCurrentLayer->fDrawState);
break; break;
} }
case AS_STROKE_TRIANGLE: case AS_STROKE_TRIANGLE:
@@ -1980,11 +1980,11 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<BRect>(&rect); link.Read<BRect>(&rect);
if (fCurrentLayer && fCurrentLayer->fLayerData) { if (fCurrentLayer && fCurrentLayer->fDrawState) {
for (int i = 0;i < 3; i++) for (int i = 0;i < 3; i++)
pts[i] = fCurrentLayer->ConvertToTop(pts[i]); pts[i] = fCurrentLayer->ConvertToTop(pts[i]);
driver->StrokeTriangle(pts, fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fLayerData); driver->StrokeTriangle(pts, fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fDrawState);
} }
break; break;
} }
@@ -2000,11 +2000,11 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<BRect>(&rect); link.Read<BRect>(&rect);
if (fCurrentLayer && fCurrentLayer->fLayerData) { if (fCurrentLayer && fCurrentLayer->fDrawState) {
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
pts[i] = fCurrentLayer->ConvertToTop(pts[i]); pts[i] = fCurrentLayer->ConvertToTop(pts[i]);
driver->FillTriangle(pts, fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fLayerData); driver->FillTriangle(pts, fCurrentLayer->ConvertToTop(rect), fCurrentLayer->fDrawState);
} }
break; break;
} }
@@ -2030,7 +2030,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
pointlist[i] = fCurrentLayer->ConvertToTop(pointlist[i]); pointlist[i] = fCurrentLayer->ConvertToTop(pointlist[i]);
driver->StrokePolygon(pointlist,pointcount,polyframe, driver->StrokePolygon(pointlist,pointcount,polyframe,
fCurrentLayer->fLayerData,isclosed); fCurrentLayer->fDrawState,isclosed);
delete [] pointlist; delete [] pointlist;
break; break;
@@ -2053,7 +2053,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
for (int32 i = 0; i < pointcount; i++) for (int32 i = 0; i < pointcount; i++)
pointlist[i] = fCurrentLayer->ConvertToTop(pointlist[i]); pointlist[i] = fCurrentLayer->ConvertToTop(pointlist[i]);
driver->FillPolygon(pointlist,pointcount,polyframe, fCurrentLayer->fLayerData); driver->FillPolygon(pointlist,pointcount,polyframe, fCurrentLayer->fDrawState);
delete [] pointlist; delete [] pointlist;
break; break;
@@ -2081,7 +2081,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
for (int32 i = 0; i < ptcount; i++) for (int32 i = 0; i < ptcount; i++)
ptlist[i] = fCurrentLayer->ConvertToTop(ptlist[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[] oplist;
delete[] ptlist; delete[] ptlist;
break; break;
@@ -2109,7 +2109,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
for (int32 i = 0; i < ptcount; i++) for (int32 i = 0; i < ptcount; i++)
ptlist[i] = fCurrentLayer->ConvertToTop(ptlist[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[] oplist;
delete[] ptlist; delete[] ptlist;
@@ -2135,7 +2135,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
for (int32 i = 0; i < count; i++) { for (int32 i = 0; i < count; i++) {
region.Include(fCurrentLayer->ConvertToTop(rects[i])); region.Include(fCurrentLayer->ConvertToTop(rects[i]));
} }
driver->FillRegion(region, fCurrentLayer->fLayerData); driver->FillRegion(region, fCurrentLayer->fDrawState);
delete[] rects; delete[] rects;
@@ -2169,7 +2169,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
index->pt1 = fCurrentLayer->ConvertToTop(index->pt1); index->pt1 = fCurrentLayer->ConvertToTop(index->pt1);
index->pt2 = fCurrentLayer->ConvertToTop(index->pt2); index->pt2 = fCurrentLayer->ConvertToTop(index->pt2);
} }
driver->StrokeLineArray(linecount,linedata,fCurrentLayer->fLayerData); driver->StrokeLineArray(linecount,linedata,fCurrentLayer->fDrawState);
} }
break; break;
} }
@@ -2186,10 +2186,10 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<escapement_delta>(&delta); link.Read<escapement_delta>(&delta);
link.ReadString(&string); link.ReadString(&string);
if (fCurrentLayer && fCurrentLayer->fLayerData) if (fCurrentLayer && fCurrentLayer->fDrawState)
driver->DrawString(string, length, driver->DrawString(string, length,
fCurrentLayer->ConvertToTop(location), fCurrentLayer->ConvertToTop(location),
fCurrentLayer->fLayerData, &delta); fCurrentLayer->fDrawState, &delta);
free(string); free(string);
break; break;
@@ -1,24 +1,27 @@
//------------------------------------------------------------------------------ /*
// Copyright (c) 2001-2005, Haiku, Inc. All rights reserved. * Copyright 2001-2005, Haiku, Inc.
// Distributed under the terms of the MIT license. * Distributed under the terms of the MIT License.
// *
// File Name: DisplayDriverPainter.cpp * Authors:
// Author: Stephan Aßmus <[email protected]> * Stephan Aßmus <superstippi@gmx.de>
// Description: Implementation of DisplayDriver based on top of Painter */
//
//------------------------------------------------------------------------------ /** Implementation of DisplayDriver based on top of Painter */
#include <stdio.h> #include <stdio.h>
#include <algo.h> #include <algo.h>
#include <stack.h> #include <stack.h>
#include "HWInterface.h" #include "HWInterface.h"
#include "LayerData.h" #include "DrawState.h"
#include "Painter.h" #include "Painter.h"
#include "PNGDump.h" #include "PNGDump.h"
#include "RenderingBuffer.h" #include "RenderingBuffer.h"
#include "DisplayDriverPainter.h" #include "DisplayDriverPainter.h"
// make_rect_valid // make_rect_valid
static inline void static inline void
make_rect_valid(BRect& rect) make_rect_valid(BRect& rect)
@@ -37,7 +40,7 @@ make_rect_valid(BRect& rect)
// extend_by_stroke_width // extend_by_stroke_width
static inline void 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 // "- 1.0" because if stroke width == 1, we don't need to extend
float inset = -ceilf(context->PenSize() / 2.0 - 1.0); float inset = -ceilf(context->PenSize() / 2.0 - 1.0);
@@ -47,7 +50,7 @@ extend_by_stroke_width(BRect& rect, const DrawData* context)
class FontLocker { class FontLocker {
public: public:
FontLocker(const DrawData* context) FontLocker(const DrawState* context)
: :
fFont(&context->Font()) fFont(&context->Font())
{ {
@@ -445,14 +448,14 @@ DisplayDriverPainter::InvertRect(BRect r)
void void
DisplayDriverPainter::DrawBitmap(ServerBitmap *bitmap, DisplayDriverPainter::DrawBitmap(ServerBitmap *bitmap,
const BRect &source, const BRect &dest, const BRect &source, const BRect &dest,
const DrawData *d) const DrawState *d)
{ {
if (Lock()) { if (Lock()) {
BRect clipped = fPainter->ClipRect(dest); BRect clipped = fPainter->ClipRect(dest);
if (clipped.IsValid()) { if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(clipped); fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->SetDrawData(d); fPainter->SetDrawState(d);
fPainter->DrawBitmap(bitmap, source, dest); fPainter->DrawBitmap(bitmap, source, dest);
fGraphicsCard->Invalidate(clipped); fGraphicsCard->Invalidate(clipped);
@@ -466,7 +469,7 @@ DisplayDriverPainter::DrawBitmap(ServerBitmap *bitmap,
// FillArc // FillArc
void void
DisplayDriverPainter::FillArc(BRect r, const float &angle, DisplayDriverPainter::FillArc(BRect r, const float &angle,
const float &span, const DrawData *d) const float &span, const DrawState *d)
{ {
if (Lock()) { if (Lock()) {
make_rect_valid(r); make_rect_valid(r);
@@ -474,7 +477,7 @@ DisplayDriverPainter::FillArc(BRect r, const float &angle,
if (clipped.IsValid()) { if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(clipped); fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->SetDrawData(d); fPainter->SetDrawState(d);
float xRadius = r.Width() / 2.0; float xRadius = r.Width() / 2.0;
float yRadius = r.Width() / 2.0; float yRadius = r.Width() / 2.0;
@@ -493,12 +496,12 @@ DisplayDriverPainter::FillArc(BRect r, const float &angle,
// FillBezier // FillBezier
void void
DisplayDriverPainter::FillBezier(BPoint *pts, const DrawData *d) DisplayDriverPainter::FillBezier(BPoint *pts, const DrawState *d)
{ {
if (Lock()) { if (Lock()) {
fGraphicsCard->HideSoftwareCursor(); fGraphicsCard->HideSoftwareCursor();
fPainter->SetDrawData(d); fPainter->SetDrawState(d);
BRect touched = fPainter->FillBezier(pts); BRect touched = fPainter->FillBezier(pts);
@@ -511,7 +514,7 @@ DisplayDriverPainter::FillBezier(BPoint *pts, const DrawData *d)
// FillEllipse // FillEllipse
void void
DisplayDriverPainter::FillEllipse(BRect r, const DrawData *d) DisplayDriverPainter::FillEllipse(BRect r, const DrawState *d)
{ {
if (Lock()) { if (Lock()) {
make_rect_valid(r); make_rect_valid(r);
@@ -519,7 +522,7 @@ DisplayDriverPainter::FillEllipse(BRect r, const DrawData *d)
if (clipped.IsValid()) { if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(clipped); fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->SetDrawData(d); fPainter->SetDrawState(d);
float xRadius = r.Width() / 2.0; float xRadius = r.Width() / 2.0;
float yRadius = r.Height() / 2.0; float yRadius = r.Height() / 2.0;
@@ -539,7 +542,7 @@ DisplayDriverPainter::FillEllipse(BRect r, const DrawData *d)
// FillPolygon // FillPolygon
void void
DisplayDriverPainter::FillPolygon(BPoint *ptlist, int32 numpts, DisplayDriverPainter::FillPolygon(BPoint *ptlist, int32 numpts,
BRect bounds, const DrawData *d) BRect bounds, const DrawState *d)
{ {
if (Lock()) { if (Lock()) {
make_rect_valid(bounds); make_rect_valid(bounds);
@@ -547,7 +550,7 @@ DisplayDriverPainter::FillPolygon(BPoint *ptlist, int32 numpts,
if (clipped.IsValid()) { if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(clipped); fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->SetDrawData(d); fPainter->SetDrawState(d);
fPainter->FillPolygon(ptlist, numpts); fPainter->FillPolygon(ptlist, numpts);
fGraphicsCard->Invalidate(clipped); fGraphicsCard->Invalidate(clipped);
@@ -591,7 +594,7 @@ DisplayDriverPainter::FillRect(BRect r, const RGBColor& color)
// FillRect // FillRect
void void
DisplayDriverPainter::FillRect(BRect r, const DrawData *d) DisplayDriverPainter::FillRect(BRect r, const DrawState *d)
{ {
// NOTE: Write locking because we might use HW acceleration. // NOTE: Write locking because we might use HW acceleration.
// This needs to be investigated, I'm doing this because of // This needs to be investigated, I'm doing this because of
@@ -622,7 +625,7 @@ DisplayDriverPainter::FillRect(BRect r, const DrawData *d)
} }
if (doInSoftware) { if (doInSoftware) {
fPainter->SetDrawData(d); fPainter->SetDrawState(d);
fPainter->FillRect(r); fPainter->FillRect(r);
fGraphicsCard->Invalidate(r); fGraphicsCard->Invalidate(r);
@@ -637,7 +640,7 @@ DisplayDriverPainter::FillRect(BRect r, const DrawData *d)
// FillRegion // FillRegion
void void
DisplayDriverPainter::FillRegion(BRegion& r, const DrawData *d) DisplayDriverPainter::FillRegion(BRegion& r, const DrawState *d)
{ {
// NOTE: Write locking because we might use HW acceleration. // NOTE: Write locking because we might use HW acceleration.
// This needs to be investigated, I'm doing this because of // This needs to be investigated, I'm doing this because of
@@ -663,7 +666,7 @@ DisplayDriverPainter::FillRegion(BRegion& r, const DrawData *d)
} }
if (doInSoftware) { if (doInSoftware) {
fPainter->SetDrawData(d); fPainter->SetDrawState(d);
BRect touched = fPainter->FillRect(r.RectAt(0)); BRect touched = fPainter->FillRect(r.RectAt(0));
@@ -686,7 +689,7 @@ DisplayDriverPainter::FillRegion(BRegion& r, const DrawData *d)
void void
DisplayDriverPainter::FillRoundRect(BRect r, DisplayDriverPainter::FillRoundRect(BRect r,
const float &xrad, const float &yrad, const float &xrad, const float &yrad,
const DrawData *d) const DrawState *d)
{ {
if (Lock()) { if (Lock()) {
make_rect_valid(r); make_rect_valid(r);
@@ -694,7 +697,7 @@ DisplayDriverPainter::FillRoundRect(BRect r,
if (clipped.IsValid()) { if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(clipped); fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->SetDrawData(d); fPainter->SetDrawState(d);
BRect touched = fPainter->FillRoundRect(r, xrad, yrad); BRect touched = fPainter->FillRoundRect(r, xrad, yrad);
fGraphicsCard->Invalidate(touched); fGraphicsCard->Invalidate(touched);
@@ -710,7 +713,7 @@ void
DisplayDriverPainter::FillShape(const BRect &bounds, DisplayDriverPainter::FillShape(const BRect &bounds,
const int32 &opcount, const int32 *oplist, const int32 &opcount, const int32 *oplist,
const int32 &ptcount, const BPoint *ptlist, const int32 &ptcount, const BPoint *ptlist,
const DrawData *d) const DrawState *d)
{ {
if (Lock()) { if (Lock()) {
@@ -723,14 +726,14 @@ printf("DisplayDriverPainter::FillShape() - what is this stuff that gets passed
// FillTriangle // FillTriangle
void void
DisplayDriverPainter::FillTriangle(BPoint *pts, BRect bounds, DisplayDriverPainter::FillTriangle(BPoint *pts, BRect bounds,
const DrawData *d) const DrawState *d)
{ {
if (Lock()) { if (Lock()) {
bounds = fPainter->ClipRect(bounds); bounds = fPainter->ClipRect(bounds);
if (bounds.IsValid()) { if (bounds.IsValid()) {
fGraphicsCard->HideSoftwareCursor(bounds); fGraphicsCard->HideSoftwareCursor(bounds);
fPainter->SetDrawData(d); fPainter->SetDrawState(d);
fPainter->FillTriangle(pts[0], pts[1], pts[2]); fPainter->FillTriangle(pts[0], pts[1], pts[2]);
fGraphicsCard->Invalidate(bounds); fGraphicsCard->Invalidate(bounds);
@@ -744,7 +747,7 @@ DisplayDriverPainter::FillTriangle(BPoint *pts, BRect bounds,
// StrokeArc // StrokeArc
void void
DisplayDriverPainter::StrokeArc(BRect r, const float &angle, DisplayDriverPainter::StrokeArc(BRect r, const float &angle,
const float &span, const DrawData *d) const float &span, const DrawState *d)
{ {
if (Lock()) { if (Lock()) {
make_rect_valid(r); make_rect_valid(r);
@@ -752,7 +755,7 @@ DisplayDriverPainter::StrokeArc(BRect r, const float &angle,
if (clipped.IsValid()) { if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(r); fGraphicsCard->HideSoftwareCursor(r);
fPainter->SetDrawData(d); fPainter->SetDrawState(d);
float xRadius = r.Width() / 2.0; float xRadius = r.Width() / 2.0;
float yRadius = r.Width() / 2.0; float yRadius = r.Width() / 2.0;
@@ -771,12 +774,12 @@ DisplayDriverPainter::StrokeArc(BRect r, const float &angle,
// StrokeBezier // StrokeBezier
void void
DisplayDriverPainter::StrokeBezier(BPoint *pts, const DrawData *d) DisplayDriverPainter::StrokeBezier(BPoint *pts, const DrawState *d)
{ {
if (Lock()) { if (Lock()) {
fGraphicsCard->HideSoftwareCursor(); fGraphicsCard->HideSoftwareCursor();
fPainter->SetDrawData(d); fPainter->SetDrawState(d);
BRect touched = fPainter->StrokeBezier(pts); BRect touched = fPainter->StrokeBezier(pts);
fGraphicsCard->Invalidate(touched); fGraphicsCard->Invalidate(touched);
@@ -788,7 +791,7 @@ DisplayDriverPainter::StrokeBezier(BPoint *pts, const DrawData *d)
// StrokeEllipse // StrokeEllipse
void void
DisplayDriverPainter::StrokeEllipse(BRect r, const DrawData *d) DisplayDriverPainter::StrokeEllipse(BRect r, const DrawState *d)
{ {
if (Lock()) { if (Lock()) {
make_rect_valid(r); make_rect_valid(r);
@@ -798,7 +801,7 @@ DisplayDriverPainter::StrokeEllipse(BRect r, const DrawData *d)
if (clipped.IsValid()) { if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(r); fGraphicsCard->HideSoftwareCursor(r);
fPainter->SetDrawData(d); fPainter->SetDrawState(d);
float xRadius = r.Width() / 2.0; float xRadius = r.Width() / 2.0;
float yRadius = r.Height() / 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); fGraphicsCard->HideSoftwareCursor(touched);
if (!fPainter->StraightLine(start, end, color.GetColor32())) { if (!fPainter->StraightLine(start, end, color.GetColor32())) {
static DrawData context; static DrawState context;
context.SetHighColor(color); context.SetHighColor(color);
context.SetDrawingMode(B_OP_OVER); context.SetDrawingMode(B_OP_OVER);
StrokeLine(start, end, &context); StrokeLine(start, end, &context);
@@ -843,7 +846,7 @@ DisplayDriverPainter::StrokeLine(const BPoint &start, const BPoint &end, const R
// StrokeLine // StrokeLine
void void
DisplayDriverPainter::StrokeLine(const BPoint &start, const BPoint &end, DrawData* context) DisplayDriverPainter::StrokeLine(const BPoint &start, const BPoint &end, DrawState* context)
{ {
if (Lock()) { if (Lock()) {
BRect touched(start, end); BRect touched(start, end);
@@ -867,7 +870,7 @@ DisplayDriverPainter::StrokeLine(const BPoint &start, const BPoint &end, DrawDat
void void
DisplayDriverPainter::StrokeLineArray(const int32 &numlines, DisplayDriverPainter::StrokeLineArray(const int32 &numlines,
const LineArrayData *linedata, const LineArrayData *linedata,
const DrawData *d) const DrawState *d)
{ {
if(!d || !linedata || numlines <= 0) if(!d || !linedata || numlines <= 0)
return; return;
@@ -892,7 +895,7 @@ DisplayDriverPainter::StrokeLineArray(const int32 &numlines,
if (touched.IsValid()) { if (touched.IsValid()) {
fGraphicsCard->HideSoftwareCursor(touched); fGraphicsCard->HideSoftwareCursor(touched);
DrawData context; DrawState context;
context.SetDrawingMode(B_OP_COPY); context.SetDrawingMode(B_OP_COPY);
data = (const LineArrayData *)&(linedata[0]); data = (const LineArrayData *)&(linedata[0]);
@@ -924,7 +927,7 @@ DisplayDriverPainter::StrokePoint(const BPoint& pt, const RGBColor &color)
// StrokePoint // StrokePoint
void void
DisplayDriverPainter::StrokePoint(const BPoint& pt, DrawData *context) DisplayDriverPainter::StrokePoint(const BPoint& pt, DrawState *context)
{ {
StrokeLine(pt, pt, context); StrokeLine(pt, pt, context);
} }
@@ -932,7 +935,7 @@ DisplayDriverPainter::StrokePoint(const BPoint& pt, DrawData *context)
// StrokePolygon // StrokePolygon
void void
DisplayDriverPainter::StrokePolygon(BPoint* ptlist, int32 numpts, DisplayDriverPainter::StrokePolygon(BPoint* ptlist, int32 numpts,
BRect bounds, const DrawData* d, BRect bounds, const DrawState* d,
bool closed) bool closed)
{ {
if (Lock()) { if (Lock()) {
@@ -941,7 +944,7 @@ DisplayDriverPainter::StrokePolygon(BPoint* ptlist, int32 numpts,
if (bounds.IsValid()) { if (bounds.IsValid()) {
fGraphicsCard->HideSoftwareCursor(bounds); fGraphicsCard->HideSoftwareCursor(bounds);
fPainter->SetDrawData(d); fPainter->SetDrawState(d);
fPainter->StrokePolygon(ptlist, numpts, closed); fPainter->StrokePolygon(ptlist, numpts, closed);
fGraphicsCard->Invalidate(bounds); fGraphicsCard->Invalidate(bounds);
@@ -984,7 +987,7 @@ DisplayDriverPainter::StrokeRect(BRect r, const RGBColor &color)
// StrokeRect // StrokeRect
void void
DisplayDriverPainter::StrokeRect(BRect r, const DrawData *d) DisplayDriverPainter::StrokeRect(BRect r, const DrawState *d)
{ {
if (Lock()) { if (Lock()) {
// support invalid rects // support invalid rects
@@ -996,7 +999,7 @@ DisplayDriverPainter::StrokeRect(BRect r, const DrawData *d)
fGraphicsCard->HideSoftwareCursor(clipped); fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->SetDrawData(d); fPainter->SetDrawState(d);
fPainter->StrokeRect(r); fPainter->StrokeRect(r);
fGraphicsCard->Invalidate(clipped); fGraphicsCard->Invalidate(clipped);
@@ -1009,7 +1012,7 @@ DisplayDriverPainter::StrokeRect(BRect r, const DrawData *d)
// StrokeRegion // StrokeRegion
void void
DisplayDriverPainter::StrokeRegion(BRegion& r, const DrawData *d) DisplayDriverPainter::StrokeRegion(BRegion& r, const DrawState *d)
{ {
if (Lock()) { if (Lock()) {
BRect clipped(r.Frame()); BRect clipped(r.Frame());
@@ -1018,7 +1021,7 @@ DisplayDriverPainter::StrokeRegion(BRegion& r, const DrawData *d)
if (clipped.IsValid()) { if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(clipped); fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->SetDrawData(d); fPainter->SetDrawState(d);
BRect touched = fPainter->StrokeRect(r.RectAt(0)); BRect touched = fPainter->StrokeRect(r.RectAt(0));
@@ -1038,7 +1041,7 @@ DisplayDriverPainter::StrokeRegion(BRegion& r, const DrawData *d)
// StrokeRoundRect // StrokeRoundRect
void void
DisplayDriverPainter::StrokeRoundRect(BRect r, const float &xrad, DisplayDriverPainter::StrokeRoundRect(BRect r, const float &xrad,
const float &yrad, const DrawData *d) const float &yrad, const DrawState *d)
{ {
if (Lock()) { if (Lock()) {
// NOTE: the stroke does not extend past "r" in R5, // NOTE: the stroke does not extend past "r" in R5,
@@ -1048,7 +1051,7 @@ DisplayDriverPainter::StrokeRoundRect(BRect r, const float &xrad,
if (clipped.IsValid()) { if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(clipped); fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->SetDrawData(d); fPainter->SetDrawState(d);
BRect touched = fPainter->StrokeRoundRect(r, xrad, yrad); BRect touched = fPainter->StrokeRoundRect(r, xrad, yrad);
fGraphicsCard->Invalidate(touched); fGraphicsCard->Invalidate(touched);
@@ -1063,7 +1066,7 @@ DisplayDriverPainter::StrokeRoundRect(BRect r, const float &xrad,
void void
DisplayDriverPainter::StrokeShape(const BRect &bounds, const int32 &opcount, DisplayDriverPainter::StrokeShape(const BRect &bounds, const int32 &opcount,
const int32 *oplist, const int32 &ptcount, const int32 *oplist, const int32 &ptcount,
const BPoint *ptlist, const DrawData *d) const BPoint *ptlist, const DrawState *d)
{ {
if (Lock()) { if (Lock()) {
@@ -1076,7 +1079,7 @@ printf("DisplayDriverPainter::StrokeShape() - what is this stuff that gets passe
// StrokeTriangle // StrokeTriangle
void void
DisplayDriverPainter::StrokeTriangle(BPoint *pts, const BRect &bounds, DisplayDriverPainter::StrokeTriangle(BPoint *pts, const BRect &bounds,
const DrawData *d) const DrawState *d)
{ {
if (Lock()) { if (Lock()) {
BRect clipped(bounds); BRect clipped(bounds);
@@ -1085,7 +1088,7 @@ DisplayDriverPainter::StrokeTriangle(BPoint *pts, const BRect &bounds,
if (clipped.IsValid()) { if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(clipped); fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->SetDrawData(d); fPainter->SetDrawState(d);
fPainter->StrokeTriangle(pts[0], pts[1], pts[2]); fPainter->StrokeTriangle(pts[0], pts[1], pts[2]);
fGraphicsCard->Invalidate(clipped); fGraphicsCard->Invalidate(clipped);
@@ -1102,7 +1105,7 @@ DisplayDriverPainter::DrawString(const char *string, const int32 &length,
const BPoint &pt, const RGBColor &color, const BPoint &pt, const RGBColor &color,
escapement_delta *delta) escapement_delta *delta)
{ {
static DrawData d; static DrawState d;
d.SetHighColor(color); d.SetHighColor(color);
DrawString(string, length, pt, &d, delta); DrawString(string, length, pt, &d, delta);
@@ -1111,13 +1114,13 @@ DisplayDriverPainter::DrawString(const char *string, const int32 &length,
// DrawString // DrawString
void void
DisplayDriverPainter::DrawString(const char* string, int32 length, DisplayDriverPainter::DrawString(const char* string, int32 length,
const BPoint& pt, DrawData* d, const BPoint& pt, DrawState* d,
escapement_delta* delta) escapement_delta* delta)
{ {
// TODO: use delta // TODO: use delta
if (Lock()) { if (Lock()) {
FontLocker locker(d); FontLocker locker(d);
fPainter->SetDrawData(d); fPainter->SetDrawState(d);
//bigtime_t now = system_time(); //bigtime_t now = system_time();
// TODO: BoundingBox is quite slow!! Optimizing it will be beneficial. // TODO: BoundingBox is quite slow!! Optimizing it will be beneficial.
// Cursiously, the DrawString after it is actually faster!?! // Cursiously, the DrawString after it is actually faster!?!
@@ -1145,14 +1148,14 @@ DisplayDriverPainter::DrawString(const char* string, int32 length,
// StringWidth // StringWidth
float float
DisplayDriverPainter::StringWidth(const char* string, int32 length, DisplayDriverPainter::StringWidth(const char* string, int32 length,
const DrawData* d, const DrawState* d,
escapement_delta* delta) escapement_delta* delta)
{ {
// TODO: use delta // TODO: use delta
float width = 0.0; float width = 0.0;
if (Lock()) { if (Lock()) {
FontLocker locker(d); FontLocker locker(d);
fPainter->SetDrawData(d); fPainter->SetDrawState(d);
width = fPainter->StringWidth(string, length); width = fPainter->StringWidth(string, length);
Unlock(); Unlock();
} }
@@ -1167,7 +1170,7 @@ DisplayDriverPainter::StringWidth(const char* string, int32 length,
{ {
// TODO: use delta // TODO: use delta
FontLocker locker(&font); FontLocker locker(&font);
static DrawData d; static DrawState d;
d.SetFont(font); d.SetFont(font);
return StringWidth(string, length, &d); return StringWidth(string, length, &d);
} }
@@ -1175,12 +1178,12 @@ DisplayDriverPainter::StringWidth(const char* string, int32 length,
// StringHeight // StringHeight
float float
DisplayDriverPainter::StringHeight(const char *string, int32 length, DisplayDriverPainter::StringHeight(const char *string, int32 length,
const DrawData *d) const DrawState *d)
{ {
float height = 0.0; float height = 0.0;
if (Lock()) { if (Lock()) {
FontLocker locker(d); FontLocker locker(d);
fPainter->SetDrawData(d); fPainter->SetDrawState(d);
static BPoint dummy(0.0, 0.0); static BPoint dummy(0.0, 0.0);
height = fPainter->BoundingBox(string, length, dummy).Height(); height = fPainter->BoundingBox(string, length, dummy).Height();
Unlock(); Unlock();
+37 -39
View File
@@ -1,23 +1,21 @@
//------------------------------------------------------------------------------ /*
// Copyright (c) 2001-2005, Haiku, Inc. All rights reserved. * Copyright 2001-2005, Haiku, Inc.
// Distributed under the terms of the MIT license. * Distributed under the terms of the MIT License.
// *
// File Name: DisplayDriverPainter.h * Authors:
// Authors: DarkWyrm <[email protected]> * DarkWyrm <bpmagic@columbus.rr.com>
// Gabe Yoder <[email protected]> * Gabe Yoder <gyoder@stny.rr.com>
// Stephan Aßmus <[email protected]> * Stephan Aßmus <superstippi@gmx.de>
// */
// Description: Abstract class which handles all graphics output
// for the server
//
//------------------------------------------------------------------------------
#ifndef _DISPLAY_DRIVER_PAINTER_H_ #ifndef _DISPLAY_DRIVER_PAINTER_H_
#define _DISPLAY_DRIVER_PAINTER_H_ #define _DISPLAY_DRIVER_PAINTER_H_
#include "DisplayDriver.h" #include "DisplayDriver.h"
class Painter; class Painter;
class DisplayDriverPainter : public DisplayDriver { class DisplayDriverPainter : public DisplayDriver {
public: public:
DisplayDriverPainter(HWInterface* interface = NULL); DisplayDriverPainter(HWInterface* interface = NULL);
@@ -50,59 +48,59 @@ public:
virtual void DrawBitmap( ServerBitmap *bitmap, virtual void DrawBitmap( ServerBitmap *bitmap,
const BRect &source, const BRect &source,
const BRect &dest, const BRect &dest,
const DrawData *d); const DrawState *d);
virtual void FillArc( BRect r, virtual void FillArc( BRect r,
const float &angle, const float &angle,
const float &span, const float &span,
const DrawData *d); const DrawState *d);
virtual void FillBezier( BPoint *pts, virtual void FillBezier( BPoint *pts,
const DrawData *d); const DrawState *d);
virtual void FillEllipse( BRect r, virtual void FillEllipse( BRect r,
const DrawData *d); const DrawState *d);
virtual void FillPolygon( BPoint *ptlist, virtual void FillPolygon( BPoint *ptlist,
int32 numpts, int32 numpts,
BRect bounds, BRect bounds,
const DrawData *d); const DrawState *d);
virtual void FillRect( BRect r, virtual void FillRect( BRect r,
const RGBColor &color); const RGBColor &color);
virtual void FillRect( BRect r, virtual void FillRect( BRect r,
const DrawData *d); const DrawState *d);
virtual void FillRegion( BRegion &r, virtual void FillRegion( BRegion &r,
const DrawData *d); const DrawState *d);
virtual void FillRoundRect( BRect r, virtual void FillRoundRect( BRect r,
const float &xrad, const float &xrad,
const float &yrad, const float &yrad,
const DrawData *d); const DrawState *d);
virtual void FillShape( const BRect &bounds, virtual void FillShape( const BRect &bounds,
const int32 &opcount, const int32 &opcount,
const int32 *oplist, const int32 *oplist,
const int32 &ptcount, const int32 &ptcount,
const BPoint *ptlist, const BPoint *ptlist,
const DrawData *d); const DrawState *d);
virtual void FillTriangle( BPoint *pts, virtual void FillTriangle( BPoint *pts,
BRect bounds, BRect bounds,
const DrawData *d); const DrawState *d);
virtual void StrokeArc( BRect r, virtual void StrokeArc( BRect r,
const float &angle, const float &angle,
const float &span, const float &span,
const DrawData *d); const DrawState *d);
virtual void StrokeBezier( BPoint *pts, virtual void StrokeBezier( BPoint *pts,
const DrawData *d); const DrawState *d);
virtual void StrokeEllipse( BRect r, virtual void StrokeEllipse( BRect r,
const DrawData *d); const DrawState *d);
// this version used by Decorator // this version used by Decorator
virtual void StrokeLine( const BPoint &start, virtual void StrokeLine( const BPoint &start,
@@ -111,23 +109,23 @@ public:
virtual void StrokeLine( const BPoint &start, virtual void StrokeLine( const BPoint &start,
const BPoint &end, const BPoint &end,
DrawData *d); DrawState *d);
virtual void StrokeLineArray(const int32 &numlines, virtual void StrokeLineArray(const int32 &numlines,
const LineArrayData *data, const LineArrayData *data,
const DrawData *d); const DrawState *d);
// this version used by Decorator // this version used by Decorator
virtual void StrokePoint( const BPoint &pt, virtual void StrokePoint( const BPoint &pt,
const RGBColor &color); const RGBColor &color);
virtual void StrokePoint( const BPoint &pt, virtual void StrokePoint( const BPoint &pt,
DrawData *d); DrawState *d);
virtual void StrokePolygon( BPoint *ptlist, virtual void StrokePolygon( BPoint *ptlist,
int32 numpts, int32 numpts,
BRect bounds, BRect bounds,
const DrawData *d, const DrawState *d,
bool is_closed=true); bool is_closed=true);
// this version used by Decorator // this version used by Decorator
@@ -135,34 +133,34 @@ public:
const RGBColor &color); const RGBColor &color);
virtual void StrokeRect( BRect r, virtual void StrokeRect( BRect r,
const DrawData *d); const DrawState *d);
virtual void StrokeRegion( BRegion &r, virtual void StrokeRegion( BRegion &r,
const DrawData *d); const DrawState *d);
virtual void StrokeRoundRect(BRect r, virtual void StrokeRoundRect(BRect r,
const float &xrad, const float &xrad,
const float &yrad, const float &yrad,
const DrawData *d); const DrawState *d);
virtual void StrokeShape( const BRect &bounds, virtual void StrokeShape( const BRect &bounds,
const int32 &opcount, const int32 &opcount,
const int32 *oplist, const int32 *oplist,
const int32 &ptcount, const int32 &ptcount,
const BPoint *ptlist, const BPoint *ptlist,
const DrawData *d); const DrawState *d);
virtual void StrokeTriangle( BPoint *pts, virtual void StrokeTriangle( BPoint *pts,
const BRect &bounds, const BRect &bounds,
const DrawData *d); const DrawState *d);
// Font-related calls // 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, virtual void DrawString( const char* string,
int32 length, int32 length,
const BPoint& pt, const BPoint& pt,
DrawData* d, DrawState* d,
escapement_delta* delta = NULL); escapement_delta* delta = NULL);
/* virtual void DrawString( const char *string, /* virtual void DrawString( const char *string,
@@ -173,7 +171,7 @@ public:
virtual float StringWidth( const char* string, virtual float StringWidth( const char* string,
int32 length, int32 length,
const DrawData* d, const DrawState* d,
escapement_delta* delta = NULL); escapement_delta* delta = NULL);
virtual float StringWidth( const char* string, virtual float StringWidth( const char* string,
@@ -183,7 +181,7 @@ public:
virtual float StringHeight( const char* string, virtual float StringHeight( const char* string,
int32 length, int32 length,
const DrawData* d); const DrawState* d);
virtual bool Lock(); virtual bool Lock();
virtual void Unlock(); virtual void Unlock();
+7 -7
View File
@@ -24,7 +24,7 @@
#include <agg_span_image_filter_rgba32.h> #include <agg_span_image_filter_rgba32.h>
#include <agg_span_interpolator_linear.h> #include <agg_span_interpolator_linear.h>
#include "LayerData.h" #include "DrawState.h"
#include "AGGTextRenderer.h" #include "AGGTextRenderer.h"
#include "DrawingMode.h" #include "DrawingMode.h"
@@ -168,9 +168,9 @@ Painter::DetachFromBuffer()
_MakeEmpty(); _MakeEmpty();
} }
// SetDrawData // SetDrawState
void void
Painter::SetDrawData(const DrawData* data) Painter::SetDrawState(const DrawState* data)
{ {
// NOTE: The custom clipping in "data" is ignored, because it has already been // NOTE: The custom clipping in "data" is ignored, because it has already been
// taken into account elsewhere // taken into account elsewhere
@@ -296,7 +296,7 @@ Painter::SetFont(const ServerFont& font)
// StrokeLine // StrokeLine
BRect 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 // this happens independent of wether we actually draw something
context->SetPenLocation(b); context->SetPenLocation(b);
@@ -335,7 +335,7 @@ Painter::StrokeLine(BPoint a, BPoint b, DrawData* context)
// SetDrawingMode(context->draw_mode); // SetDrawingMode(context->draw_mode);
// SetBlendingMode(context->alphaSrcMode, context->alphaFncMode); // SetBlendingMode(context->alphaSrcMode, context->alphaFncMode);
// fPatternHandler->SetPattern(context->patt); // fPatternHandler->SetPattern(context->patt);
SetDrawData(context); SetDrawState(context);
// first, try an optimized version // first, try an optimized version
if (fPenSize == 1.0 && if (fPenSize == 1.0 &&
@@ -366,7 +366,7 @@ Painter::StrokeLine(BPoint a, BPoint b, DrawData* context)
// StrokeLine // StrokeLine
BRect BRect
Painter::StrokeLine(BPoint b, DrawData* context) Painter::StrokeLine(BPoint b, DrawState* context)
{ {
// TODO: move this function elsewhere // TODO: move this function elsewhere
return StrokeLine(context->PenLocation(), b, context); return StrokeLine(context->PenLocation(), b, context);
@@ -1475,7 +1475,7 @@ Painter::_StrokePath(VertexSource& path) const
// if (fPenSize > 1.0) { // if (fPenSize > 1.0) {
agg::conv_stroke<VertexSource> stroke(path); agg::conv_stroke<VertexSource> stroke(path);
// TODO: Investigate this for shapes. Maybe we are supposed to // 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_join(agg::round_join);
// stroke.line_cap(agg::butt_cap); // stroke.line_cap(agg::butt_cap);
stroke.width(fPenSize); stroke.width(fPenSize);
+7 -7
View File
@@ -23,7 +23,7 @@
class AGGTextRenderer; class AGGTextRenderer;
class BBitmap; class BBitmap;
class BRegion; class BRegion;
class DrawData; class DrawState;
class DrawingModeFactory; class DrawingModeFactory;
class PatternHandler; class PatternHandler;
class RenderingBuffer; class RenderingBuffer;
@@ -31,11 +31,11 @@ class ServerBitmap;
class ServerFont; class ServerFont;
// TODO: API transition: // 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 // 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 // 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 // * Painter itself should be made thread safe. Because no
// ServerWindow is supposed to draw outside of its clipping region, // ServerWindow is supposed to draw outside of its clipping region,
// there is actually no reason to lock the DisplayDriver. Multiple // there is actually no reason to lock the DisplayDriver. Multiple
@@ -62,7 +62,7 @@ class Painter {
const BRegion* ClippingRegion() const const BRegion* ClippingRegion() const
{ return fClippingRegion; } { return fClippingRegion; }
void SetDrawData(const DrawData* data); void SetDrawState(const DrawState* data);
// object settings // object settings
void SetHighColor(const rgb_color& color); void SetHighColor(const rgb_color& color);
@@ -88,10 +88,10 @@ class Painter {
// lines // lines
BRect StrokeLine( BPoint a, BRect StrokeLine( BPoint a,
BPoint b, BPoint b,
DrawData* context); DrawState* context);
BRect StrokeLine( BPoint b, BRect StrokeLine( BPoint b,
DrawData* context); DrawState* context);
// returns true if the line was either vertical or horizontal // returns true if the line was either vertical or horizontal
// draws a solid one pixel wide line of color c, no blending // draws a solid one pixel wide line of color c, no blending
+1 -1
View File
@@ -58,9 +58,9 @@ SharedLibrary libhaikuappserver.so :
CursorSet.cpp CursorSet.cpp
Decorator.cpp Decorator.cpp
DesktopSettings.cpp DesktopSettings.cpp
DrawState.cpp
FontFamily.cpp FontFamily.cpp
IPoint.cpp IPoint.cpp
LayerData.cpp
RGBColor.cpp RGBColor.cpp
ServerBitmap.cpp ServerBitmap.cpp
ServerCursor.cpp ServerCursor.cpp