* renamed HWInterface locking to LockParallelAccess() and
LockExclusiveAccess() (meaning more or less access to the frame buffer) * extracted the AGGTextRenderer to be a global instance used by each Painter instance (currently, it is thread safe because of the global font lock, so there is some work left in this regard) * gave every ServerWindow it's own DrawingEngine instance, this is work in progress. So far, there doesn't seem to be a regression, but less fighting over the exclusive access to the frame buffer, now each ServerWindow thread can draw in parallel. There is room for improvement, plus I think I'm leaking the DrawingEngine... * changed the locking for the software cursor. ShowSoftwareCursor() can only be called if HideSoftwareCursor(BRect) returned true, or if you called the generic HideSoftwareCursor(), since it needs to keep the cursor lock and unlocks in Show...! * some clean up and renaming in Decorator and friends * moved PatternHandler.h to live along with the .cpp git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19427 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -31,10 +31,10 @@
|
|||||||
#define ANGLE_PI 3.14159265358979323846
|
#define ANGLE_PI 3.14159265358979323846
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool sTablesInitialized = false;
|
static bool sTablesInitialized = false;
|
||||||
float sSinTable[360];
|
static float sSinTable[360];
|
||||||
float sCosTable[360];
|
static float sCosTable[360];
|
||||||
float sTanTable[360];
|
static float sTanTable[360];
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Constructor
|
\brief Constructor
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ DecorInfo::Instantiate(Desktop* desktop, BRect rect, const char *title,
|
|||||||
|
|
||||||
desktop->UnlockSingleWindow();
|
desktop->UnlockSingleWindow();
|
||||||
|
|
||||||
decorator->SetDriver(desktop->GetDrawingEngine());
|
decorator->SetDrawingEngine(desktop->GetDrawingEngine());
|
||||||
decorator->SetTitle(title);
|
decorator->SetTitle(title);
|
||||||
|
|
||||||
return decorator;
|
return decorator;
|
||||||
|
|||||||
@@ -30,19 +30,19 @@
|
|||||||
Decorator::Decorator(DesktopSettings& settings, BRect rect,
|
Decorator::Decorator(DesktopSettings& settings, BRect rect,
|
||||||
window_look look, uint32 flags)
|
window_look look, uint32 flags)
|
||||||
:
|
:
|
||||||
_driver(NULL),
|
fDrawingEngine(NULL),
|
||||||
fDrawState(),
|
fDrawState(),
|
||||||
|
|
||||||
fLook(look),
|
fLook(look),
|
||||||
fFlags(flags),
|
fFlags(flags),
|
||||||
|
|
||||||
_zoomrect(),
|
fZoomRect(),
|
||||||
_closerect(),
|
fCloseRect(),
|
||||||
_minimizerect(),
|
fMinimizeRect(),
|
||||||
_tabrect(),
|
fTabRect(),
|
||||||
_frame(rect),
|
fFrame(rect),
|
||||||
_resizerect(),
|
fResizeRect(),
|
||||||
_borderrect(),
|
fBorderRect(),
|
||||||
|
|
||||||
fClosePressed(false),
|
fClosePressed(false),
|
||||||
fZoomPressed(false),
|
fZoomPressed(false),
|
||||||
@@ -68,12 +68,12 @@ Decorator::~Decorator()
|
|||||||
\param driver A valid DrawingEngine object
|
\param driver A valid DrawingEngine object
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Decorator::SetDriver(DrawingEngine *driver)
|
Decorator::SetDrawingEngine(DrawingEngine* engine)
|
||||||
{
|
{
|
||||||
_driver = driver;
|
fDrawingEngine = engine;
|
||||||
// lots of subclasses will depend on the driver for text support, so call
|
// lots of subclasses will depend on the driver for text support, so call
|
||||||
// _DoLayout() after we have it
|
// _DoLayout() after we have it
|
||||||
if (_driver) {
|
if (fDrawingEngine) {
|
||||||
_DoLayout();
|
_DoLayout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -227,7 +227,7 @@ Decorator::Title() const
|
|||||||
BRect
|
BRect
|
||||||
Decorator::BorderRect() const
|
Decorator::BorderRect() const
|
||||||
{
|
{
|
||||||
return _borderrect;
|
return fBorderRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -238,7 +238,7 @@ Decorator::BorderRect() const
|
|||||||
BRect
|
BRect
|
||||||
Decorator::TabRect() const
|
Decorator::TabRect() const
|
||||||
{
|
{
|
||||||
return _tabrect;
|
return fTabRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -373,14 +373,14 @@ Decorator::MoveBy(float x, float y)
|
|||||||
void
|
void
|
||||||
Decorator::MoveBy(BPoint pt)
|
Decorator::MoveBy(BPoint pt)
|
||||||
{
|
{
|
||||||
_zoomrect.OffsetBy(pt);
|
fZoomRect.OffsetBy(pt);
|
||||||
_closerect.OffsetBy(pt);
|
fCloseRect.OffsetBy(pt);
|
||||||
_minimizerect.OffsetBy(pt);
|
fMinimizeRect.OffsetBy(pt);
|
||||||
_minimizerect.OffsetBy(pt);
|
fMinimizeRect.OffsetBy(pt);
|
||||||
_tabrect.OffsetBy(pt);
|
fTabRect.OffsetBy(pt);
|
||||||
_frame.OffsetBy(pt);
|
fFrame.OffsetBy(pt);
|
||||||
_resizerect.OffsetBy(pt);
|
fResizeRect.OffsetBy(pt);
|
||||||
_borderrect.OffsetBy(pt);
|
fBorderRect.OffsetBy(pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -389,7 +389,7 @@ Decorator::MoveBy(BPoint pt)
|
|||||||
\param dy y offset
|
\param dy y offset
|
||||||
|
|
||||||
This is a required function for subclasses to implement - the default does nothing.
|
This is a required function for subclasses to implement - the default does nothing.
|
||||||
Note that window resize flags should be followed and _frame should be resized
|
Note that window resize flags should be followed and fFrame should be resized
|
||||||
accordingly. It would also be a wise idea to ensure that the window's rectangles
|
accordingly. It would also be a wise idea to ensure that the window's rectangles
|
||||||
are not inverted.
|
are not inverted.
|
||||||
*/
|
*/
|
||||||
@@ -423,62 +423,62 @@ Decorator::GetSettings(BMessage* settings) const
|
|||||||
void
|
void
|
||||||
Decorator::Draw(BRect r)
|
Decorator::Draw(BRect r)
|
||||||
{
|
{
|
||||||
_DrawFrame(r & _frame);
|
_DrawFrame(r & fFrame);
|
||||||
_DrawTab(r & _tabrect);
|
_DrawTab(r & fTabRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Forces a complete decorator update
|
//! Forces a complete decorator update
|
||||||
void
|
void
|
||||||
Decorator::Draw()
|
Decorator::Draw()
|
||||||
{
|
{
|
||||||
_DrawFrame(_frame);
|
_DrawFrame(fFrame);
|
||||||
_DrawTab(_tabrect);
|
_DrawTab(fTabRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Draws the close button
|
//! Draws the close button
|
||||||
void
|
void
|
||||||
Decorator::DrawClose()
|
Decorator::DrawClose()
|
||||||
{
|
{
|
||||||
_DrawClose(_closerect);
|
_DrawClose(fCloseRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! draws the frame
|
//! draws the frame
|
||||||
void
|
void
|
||||||
Decorator::DrawFrame()
|
Decorator::DrawFrame()
|
||||||
{
|
{
|
||||||
_DrawFrame(_frame);
|
_DrawFrame(fFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! draws the minimize button
|
//! draws the minimize button
|
||||||
void
|
void
|
||||||
Decorator::DrawMinimize(void)
|
Decorator::DrawMinimize(void)
|
||||||
{
|
{
|
||||||
_DrawTab(_minimizerect);
|
_DrawTab(fMinimizeRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! draws the tab, title, and buttons
|
//! draws the tab, title, and buttons
|
||||||
void
|
void
|
||||||
Decorator::DrawTab()
|
Decorator::DrawTab()
|
||||||
{
|
{
|
||||||
_DrawTab(_tabrect);
|
_DrawTab(fTabRect);
|
||||||
_DrawZoom(_zoomrect);
|
_DrawZoom(fZoomRect);
|
||||||
_DrawMinimize(_minimizerect);
|
_DrawMinimize(fMinimizeRect);
|
||||||
_DrawTitle(_tabrect);
|
_DrawTitle(fTabRect);
|
||||||
_DrawClose(_closerect);
|
_DrawClose(fCloseRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
// draws the title
|
// draws the title
|
||||||
void
|
void
|
||||||
Decorator::DrawTitle()
|
Decorator::DrawTitle()
|
||||||
{
|
{
|
||||||
_DrawTitle(_tabrect);
|
_DrawTitle(fTabRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! draws the zoom button
|
//! draws the zoom button
|
||||||
void
|
void
|
||||||
Decorator::DrawZoom(void)
|
Decorator::DrawZoom(void)
|
||||||
{
|
{
|
||||||
_DrawZoom(_zoomrect);
|
_DrawZoom(fZoomRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -501,16 +501,16 @@ Decorator::_ClipTitle(float width)
|
|||||||
{
|
{
|
||||||
// TODO: eventually, use ServerFont::TruncateString()
|
// TODO: eventually, use ServerFont::TruncateString()
|
||||||
// when it exists (if it doesn't already)
|
// when it exists (if it doesn't already)
|
||||||
if (_driver) {
|
if (fDrawingEngine) {
|
||||||
int32 strlength = fTitle.CountChars();
|
int32 strlength = fTitle.CountChars();
|
||||||
float pixwidth=_driver->StringWidth(fTitle.String(),strlength,&fDrawState);
|
float pixwidth=fDrawingEngine->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, &fDrawState);
|
pixwidth=fDrawingEngine->StringWidth(fTitle.String(), strlength, &fDrawState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
+12
-10
@@ -50,7 +50,9 @@ class Decorator {
|
|||||||
window_look look, uint32 flags);
|
window_look look, uint32 flags);
|
||||||
virtual ~Decorator();
|
virtual ~Decorator();
|
||||||
|
|
||||||
void SetDriver(DrawingEngine *driver);
|
void SetDrawingEngine(DrawingEngine *driver);
|
||||||
|
inline DrawingEngine* GetDrawingEngine() const
|
||||||
|
{ return fDrawingEngine; }
|
||||||
void SetFont(ServerFont *font);
|
void SetFont(ServerFont *font);
|
||||||
|
|
||||||
virtual void SetLook(DesktopSettings& settings,
|
virtual void SetLook(DesktopSettings& settings,
|
||||||
@@ -68,7 +70,7 @@ class Decorator {
|
|||||||
|
|
||||||
const char* Title() const;
|
const char* Title() const;
|
||||||
|
|
||||||
// we need to know its border(frame). WinBorder's _frame rect
|
// we need to know its border(frame). WinBorder's fFrame rect
|
||||||
// must expand to include Decorator borders. Otherwise we can't
|
// must expand to include Decorator borders. Otherwise we can't
|
||||||
// draw the border. We also add TabRect because I feel we'll need it
|
// draw the border. We also add TabRect because I feel we'll need it
|
||||||
BRect BorderRect() const;
|
BRect BorderRect() const;
|
||||||
@@ -138,19 +140,19 @@ class Decorator {
|
|||||||
|
|
||||||
virtual void _SetFocus();
|
virtual void _SetFocus();
|
||||||
|
|
||||||
DrawingEngine* _driver;
|
DrawingEngine* fDrawingEngine;
|
||||||
DrawState fDrawState;
|
DrawState fDrawState;
|
||||||
|
|
||||||
window_look fLook;
|
window_look fLook;
|
||||||
uint32 fFlags;
|
uint32 fFlags;
|
||||||
|
|
||||||
BRect _zoomrect;
|
BRect fZoomRect;
|
||||||
BRect _closerect;
|
BRect fCloseRect;
|
||||||
BRect _minimizerect;
|
BRect fMinimizeRect;
|
||||||
BRect _tabrect;
|
BRect fTabRect;
|
||||||
BRect _frame;
|
BRect fFrame;
|
||||||
BRect _resizerect;
|
BRect fResizeRect;
|
||||||
BRect _borderrect;
|
BRect fBorderRect;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool fClosePressed;
|
bool fClosePressed;
|
||||||
|
|||||||
@@ -207,12 +207,12 @@ DefaultDecorator::MoveBy(BPoint pt)
|
|||||||
{
|
{
|
||||||
STRACE(("DefaultDecorator: Move By (%.1f, %.1f)\n",pt.x,pt.y));
|
STRACE(("DefaultDecorator: Move By (%.1f, %.1f)\n",pt.x,pt.y));
|
||||||
// Move all internal rectangles the appropriate amount
|
// Move all internal rectangles the appropriate amount
|
||||||
_frame.OffsetBy(pt);
|
fFrame.OffsetBy(pt);
|
||||||
_closerect.OffsetBy(pt);
|
fCloseRect.OffsetBy(pt);
|
||||||
_tabrect.OffsetBy(pt);
|
fTabRect.OffsetBy(pt);
|
||||||
_resizerect.OffsetBy(pt);
|
fResizeRect.OffsetBy(pt);
|
||||||
_zoomrect.OffsetBy(pt);
|
fZoomRect.OffsetBy(pt);
|
||||||
_borderrect.OffsetBy(pt);
|
fBorderRect.OffsetBy(pt);
|
||||||
|
|
||||||
fLeftBorder.OffsetBy(pt);
|
fLeftBorder.OffsetBy(pt);
|
||||||
fRightBorder.OffsetBy(pt);
|
fRightBorder.OffsetBy(pt);
|
||||||
@@ -226,15 +226,15 @@ DefaultDecorator::ResizeBy(BPoint pt, BRegion* dirty)
|
|||||||
{
|
{
|
||||||
STRACE(("DefaultDecorator: Resize By (%.1f, %.1f)\n", pt.x, pt.y));
|
STRACE(("DefaultDecorator: Resize By (%.1f, %.1f)\n", pt.x, pt.y));
|
||||||
// Move all internal rectangles the appropriate amount
|
// Move all internal rectangles the appropriate amount
|
||||||
_frame.right += pt.x;
|
fFrame.right += pt.x;
|
||||||
_frame.bottom += pt.y;
|
fFrame.bottom += pt.y;
|
||||||
|
|
||||||
// handle invalidation of resize rect
|
// handle invalidation of resize rect
|
||||||
if (dirty && !(fFlags & B_NOT_RESIZABLE)) {
|
if (dirty && !(fFlags & B_NOT_RESIZABLE)) {
|
||||||
BRect realResizeRect;
|
BRect realResizeRect;
|
||||||
switch (fLook) {
|
switch (fLook) {
|
||||||
case B_DOCUMENT_WINDOW_LOOK:
|
case B_DOCUMENT_WINDOW_LOOK:
|
||||||
realResizeRect = _resizerect;
|
realResizeRect = fResizeRect;
|
||||||
// resize rect at old location
|
// resize rect at old location
|
||||||
dirty->Include(realResizeRect);
|
dirty->Include(realResizeRect);
|
||||||
realResizeRect.OffsetBy(pt);
|
realResizeRect.OffsetBy(pt);
|
||||||
@@ -266,10 +266,10 @@ DefaultDecorator::ResizeBy(BPoint pt, BRegion* dirty)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_resizerect.OffsetBy(pt);
|
fResizeRect.OffsetBy(pt);
|
||||||
|
|
||||||
_borderrect.right += pt.x;
|
fBorderRect.right += pt.x;
|
||||||
_borderrect.bottom += pt.y;
|
fBorderRect.bottom += pt.y;
|
||||||
|
|
||||||
fLeftBorder.bottom += pt.y;
|
fLeftBorder.bottom += pt.y;
|
||||||
fTopBorder.right += pt.x;
|
fTopBorder.right += pt.x;
|
||||||
@@ -307,8 +307,8 @@ DefaultDecorator::ResizeBy(BPoint pt, BRegion* dirty)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// resize tab and layout tab items
|
// resize tab and layout tab items
|
||||||
if (_tabrect.IsValid()) {
|
if (fTabRect.IsValid()) {
|
||||||
BRect oldTabRect(_tabrect);
|
BRect oldTabRect(fTabRect);
|
||||||
|
|
||||||
float tabSize;
|
float tabSize;
|
||||||
float maxLocation;
|
float maxLocation;
|
||||||
@@ -325,30 +325,30 @@ DefaultDecorator::ResizeBy(BPoint pt, BRegion* dirty)
|
|||||||
float delta = tabOffset - fTabOffset;
|
float delta = tabOffset - fTabOffset;
|
||||||
fTabOffset = (uint32)tabOffset;
|
fTabOffset = (uint32)tabOffset;
|
||||||
if (fLook != kLeftTitledWindowLook)
|
if (fLook != kLeftTitledWindowLook)
|
||||||
_tabrect.OffsetBy(delta, 0.0);
|
fTabRect.OffsetBy(delta, 0.0);
|
||||||
else
|
else
|
||||||
_tabrect.OffsetBy(0.0, delta);
|
fTabRect.OffsetBy(0.0, delta);
|
||||||
|
|
||||||
if (tabSize < fMinTabSize)
|
if (tabSize < fMinTabSize)
|
||||||
tabSize = fMinTabSize;
|
tabSize = fMinTabSize;
|
||||||
if (tabSize > fMaxTabSize)
|
if (tabSize > fMaxTabSize)
|
||||||
tabSize = fMaxTabSize;
|
tabSize = fMaxTabSize;
|
||||||
|
|
||||||
if (fLook != kLeftTitledWindowLook && tabSize != _tabrect.Width()) {
|
if (fLook != kLeftTitledWindowLook && tabSize != fTabRect.Width()) {
|
||||||
_tabrect.right = _tabrect.left + tabSize;
|
fTabRect.right = fTabRect.left + tabSize;
|
||||||
} else if (fLook == kLeftTitledWindowLook && tabSize != _tabrect.Height()) {
|
} else if (fLook == kLeftTitledWindowLook && tabSize != fTabRect.Height()) {
|
||||||
_tabrect.bottom = _tabrect.top + tabSize;
|
fTabRect.bottom = fTabRect.top + tabSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldTabRect != _tabrect) {
|
if (oldTabRect != fTabRect) {
|
||||||
_LayoutTabItems(_tabrect);
|
_LayoutTabItems(fTabRect);
|
||||||
|
|
||||||
if (dirty) {
|
if (dirty) {
|
||||||
// NOTE: the tab rect becoming smaller only would
|
// NOTE: the tab rect becoming smaller only would
|
||||||
// handled be the Desktop anyways, so it is sufficient
|
// handled be the Desktop anyways, so it is sufficient
|
||||||
// to include it into the dirty region in it's
|
// to include it into the dirty region in it's
|
||||||
// final state
|
// final state
|
||||||
BRect redraw(_tabrect);
|
BRect redraw(fTabRect);
|
||||||
if (delta != 0.0) {
|
if (delta != 0.0) {
|
||||||
redraw = redraw | oldTabRect;
|
redraw = redraw | oldTabRect;
|
||||||
if (fLook != kLeftTitledWindowLook)
|
if (fLook != kLeftTitledWindowLook)
|
||||||
@@ -367,13 +367,13 @@ bool
|
|||||||
DefaultDecorator::SetTabLocation(float location, BRegion* updateRegion)
|
DefaultDecorator::SetTabLocation(float location, BRegion* updateRegion)
|
||||||
{
|
{
|
||||||
STRACE(("DefaultDecorator: Set Tab Location(%.1f)\n", location));
|
STRACE(("DefaultDecorator: Set Tab Location(%.1f)\n", location));
|
||||||
if (!_tabrect.IsValid())
|
if (!fTabRect.IsValid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (location < 0)
|
if (location < 0)
|
||||||
location = 0;
|
location = 0;
|
||||||
|
|
||||||
float maxLocation = fRightBorder.right - fLeftBorder.left - _tabrect.Width();
|
float maxLocation = fRightBorder.right - fLeftBorder.left - fTabRect.Width();
|
||||||
if (location > maxLocation)
|
if (location > maxLocation)
|
||||||
location = maxLocation;
|
location = maxLocation;
|
||||||
|
|
||||||
@@ -382,18 +382,18 @@ DefaultDecorator::SetTabLocation(float location, BRegion* updateRegion)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// redraw old rect (1 pix on the border also must be updated)
|
// redraw old rect (1 pix on the border also must be updated)
|
||||||
BRect trect(_tabrect);
|
BRect trect(fTabRect);
|
||||||
trect.bottom++;
|
trect.bottom++;
|
||||||
updateRegion->Include(trect);
|
updateRegion->Include(trect);
|
||||||
|
|
||||||
_tabrect.OffsetBy(delta, 0);
|
fTabRect.OffsetBy(delta, 0);
|
||||||
fTabOffset = (int32)location;
|
fTabOffset = (int32)location;
|
||||||
_LayoutTabItems(_tabrect);
|
_LayoutTabItems(fTabRect);
|
||||||
|
|
||||||
fTabLocation = maxLocation > 0.0 ? fTabOffset / maxLocation : 0.0;
|
fTabLocation = maxLocation > 0.0 ? fTabOffset / maxLocation : 0.0;
|
||||||
|
|
||||||
// redraw new rect as well
|
// redraw new rect as well
|
||||||
trect = _tabrect;
|
trect = fTabRect;
|
||||||
trect.bottom++;
|
trect.bottom++;
|
||||||
updateRegion->Include(trect);
|
updateRegion->Include(trect);
|
||||||
return true;
|
return true;
|
||||||
@@ -414,7 +414,7 @@ DefaultDecorator::SetSettings(const BMessage& settings, BRegion* updateRegion)
|
|||||||
bool
|
bool
|
||||||
DefaultDecorator::GetSettings(BMessage* settings) const
|
DefaultDecorator::GetSettings(BMessage* settings) const
|
||||||
{
|
{
|
||||||
if (!_tabrect.IsValid())
|
if (!fTabRect.IsValid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return settings->AddFloat("tab location", (float)fTabOffset) == B_OK;
|
return settings->AddFloat("tab location", (float)fTabOffset) == B_OK;
|
||||||
@@ -445,7 +445,7 @@ DefaultDecorator::Draw()
|
|||||||
// things
|
// things
|
||||||
|
|
||||||
_DrawFrame(BRect(fTopBorder.LeftTop(), fBottomBorder.RightBottom()));
|
_DrawFrame(BRect(fTopBorder.LeftTop(), fBottomBorder.RightBottom()));
|
||||||
_DrawTab(_tabrect);
|
_DrawTab(fTabRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSizeLimits
|
// GetSizeLimits
|
||||||
@@ -453,10 +453,10 @@ void
|
|||||||
DefaultDecorator::GetSizeLimits(int32* minWidth, int32* minHeight,
|
DefaultDecorator::GetSizeLimits(int32* minWidth, int32* minHeight,
|
||||||
int32* maxWidth, int32* maxHeight) const
|
int32* maxWidth, int32* maxHeight) const
|
||||||
{
|
{
|
||||||
if (_tabrect.IsValid())
|
if (fTabRect.IsValid())
|
||||||
*minWidth = (int32)roundf(max_c(*minWidth, fMinTabSize - 2 * fBorderWidth));
|
*minWidth = (int32)roundf(max_c(*minWidth, fMinTabSize - 2 * fBorderWidth));
|
||||||
if (_resizerect.IsValid())
|
if (fResizeRect.IsValid())
|
||||||
*minHeight = (int32)roundf(max_c(*minHeight, _resizerect.Height() - fBorderWidth));
|
*minHeight = (int32)roundf(max_c(*minHeight, fResizeRect.Height() - fBorderWidth));
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFootprint
|
// GetFootprint
|
||||||
@@ -483,12 +483,12 @@ DefaultDecorator::GetFootprint(BRegion *region)
|
|||||||
if (fLook == B_BORDERED_WINDOW_LOOK)
|
if (fLook == B_BORDERED_WINDOW_LOOK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
region->Include(_tabrect);
|
region->Include(fTabRect);
|
||||||
|
|
||||||
if (fLook == B_DOCUMENT_WINDOW_LOOK) {
|
if (fLook == B_DOCUMENT_WINDOW_LOOK) {
|
||||||
// include the rectangular resize knob on the bottom right
|
// include the rectangular resize knob on the bottom right
|
||||||
region->Include(BRect(_frame.right - 13.0f, _frame.bottom - 13.0f,
|
region->Include(BRect(fFrame.right - 13.0f, fFrame.bottom - 13.0f,
|
||||||
_frame.right, _frame.bottom));
|
fFrame.right, fFrame.bottom));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -511,19 +511,19 @@ DefaultDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
|
|||||||
|
|
||||||
// In checking for hit test stuff, we start with the smallest rectangles the user might
|
// In checking for hit test stuff, we start with the smallest rectangles the user might
|
||||||
// be clicking on and gradually work our way out into larger rectangles.
|
// be clicking on and gradually work our way out into larger rectangles.
|
||||||
if (!(fFlags & B_NOT_CLOSABLE) && _closerect.Contains(pt))
|
if (!(fFlags & B_NOT_CLOSABLE) && fCloseRect.Contains(pt))
|
||||||
return DEC_CLOSE;
|
return DEC_CLOSE;
|
||||||
|
|
||||||
if (!(fFlags & B_NOT_ZOOMABLE) && _zoomrect.Contains(pt))
|
if (!(fFlags & B_NOT_ZOOMABLE) && fZoomRect.Contains(pt))
|
||||||
return DEC_ZOOM;
|
return DEC_ZOOM;
|
||||||
|
|
||||||
if (fLook == B_DOCUMENT_WINDOW_LOOK && _resizerect.Contains(pt))
|
if (fLook == B_DOCUMENT_WINDOW_LOOK && fResizeRect.Contains(pt))
|
||||||
return DEC_RESIZE;
|
return DEC_RESIZE;
|
||||||
|
|
||||||
bool clicked = false;
|
bool clicked = false;
|
||||||
|
|
||||||
// Clicking in the tab?
|
// Clicking in the tab?
|
||||||
if (_tabrect.Contains(pt)) {
|
if (fTabRect.Contains(pt)) {
|
||||||
// tab sliding in any case if either shift key is held down
|
// tab sliding in any case if either shift key is held down
|
||||||
// except sliding up-down by moving mouse left-right would look strange
|
// except sliding up-down by moving mouse left-right would look strange
|
||||||
if ((modifiers & B_SHIFT_KEY) && (fLook != kLeftTitledWindowLook))
|
if ((modifiers & B_SHIFT_KEY) && (fLook != kLeftTitledWindowLook))
|
||||||
@@ -610,26 +610,26 @@ DefaultDecorator::_DoLayout()
|
|||||||
fDrawState.Font().GetHeight(fontHeight);
|
fDrawState.Font().GetHeight(fontHeight);
|
||||||
|
|
||||||
if (fLook != kLeftTitledWindowLook) {
|
if (fLook != kLeftTitledWindowLook) {
|
||||||
_tabrect.Set(_frame.left - fBorderWidth,
|
fTabRect.Set(fFrame.left - fBorderWidth,
|
||||||
_frame.top - fBorderWidth - ceilf(fontHeight.ascent + fontHeight.descent + 7.0),
|
fFrame.top - fBorderWidth - ceilf(fontHeight.ascent + fontHeight.descent + 7.0),
|
||||||
((_frame.right - _frame.left) < 35.0 ?
|
((fFrame.right - fFrame.left) < 35.0 ?
|
||||||
_frame.left + 35.0 : _frame.right) + fBorderWidth,
|
fFrame.left + 35.0 : fFrame.right) + fBorderWidth,
|
||||||
_frame.top - fBorderWidth);
|
fFrame.top - fBorderWidth);
|
||||||
} else {
|
} else {
|
||||||
_tabrect.Set(_frame.left - fBorderWidth - ceilf(fontHeight.ascent + fontHeight.descent + 5.0),
|
fTabRect.Set(fFrame.left - fBorderWidth - ceilf(fontHeight.ascent + fontHeight.descent + 5.0),
|
||||||
_frame.top - fBorderWidth, _frame.left - fBorderWidth,
|
fFrame.top - fBorderWidth, fFrame.left - fBorderWidth,
|
||||||
_frame.bottom + fBorderWidth);
|
fFrame.bottom + fBorderWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
// format tab rect for a floating window - make the rect smaller
|
// format tab rect for a floating window - make the rect smaller
|
||||||
if (fLook == B_FLOATING_WINDOW_LOOK) {
|
if (fLook == B_FLOATING_WINDOW_LOOK) {
|
||||||
_tabrect.InsetBy(0, 2);
|
fTabRect.InsetBy(0, 2);
|
||||||
_tabrect.OffsetBy(0, 2);
|
fTabRect.OffsetBy(0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
float offset;
|
float offset;
|
||||||
float size;
|
float size;
|
||||||
_GetButtonSizeAndOffset(_tabrect, &offset, &size);
|
_GetButtonSizeAndOffset(fTabRect, &offset, &size);
|
||||||
|
|
||||||
// fMinTabSize contains just the room for the buttons
|
// fMinTabSize contains just the room for the buttons
|
||||||
fMinTabSize = 4.0 + fTextOffset;
|
fMinTabSize = 4.0 + fTextOffset;
|
||||||
@@ -639,13 +639,13 @@ DefaultDecorator::_DoLayout()
|
|||||||
fMinTabSize += offset + size;
|
fMinTabSize += offset + size;
|
||||||
|
|
||||||
// fMaxTabSize contains fMinWidth + the width required for the title
|
// fMaxTabSize contains fMinWidth + the width required for the title
|
||||||
fMaxTabSize = _driver ? ceilf(_driver->StringWidth(Title(), strlen(Title()),
|
fMaxTabSize = fDrawingEngine ? ceilf(fDrawingEngine->StringWidth(Title(), strlen(Title()),
|
||||||
&fDrawState)) : 0.0;
|
&fDrawState)) : 0.0;
|
||||||
if (fMaxTabSize > 0.0)
|
if (fMaxTabSize > 0.0)
|
||||||
fMaxTabSize += fTextOffset;
|
fMaxTabSize += fTextOffset;
|
||||||
fMaxTabSize += fMinTabSize;
|
fMaxTabSize += fMinTabSize;
|
||||||
|
|
||||||
float tabSize = fLook != kLeftTitledWindowLook ? _frame.Width() : _frame.Height();
|
float tabSize = fLook != kLeftTitledWindowLook ? fFrame.Width() : fFrame.Height();
|
||||||
if (tabSize < fMinTabSize)
|
if (tabSize < fMinTabSize)
|
||||||
tabSize = fMinTabSize;
|
tabSize = fMinTabSize;
|
||||||
if (tabSize > fMaxTabSize)
|
if (tabSize > fMaxTabSize)
|
||||||
@@ -653,33 +653,33 @@ DefaultDecorator::_DoLayout()
|
|||||||
|
|
||||||
// layout buttons and truncate text
|
// layout buttons and truncate text
|
||||||
if (fLook != kLeftTitledWindowLook)
|
if (fLook != kLeftTitledWindowLook)
|
||||||
_tabrect.right = _tabrect.left + tabSize;
|
fTabRect.right = fTabRect.left + tabSize;
|
||||||
else
|
else
|
||||||
_tabrect.bottom = _tabrect.top + tabSize;
|
fTabRect.bottom = fTabRect.top + tabSize;
|
||||||
} else {
|
} else {
|
||||||
// no tab
|
// no tab
|
||||||
fMinTabSize = 0.0;
|
fMinTabSize = 0.0;
|
||||||
fMaxTabSize = 0.0;
|
fMaxTabSize = 0.0;
|
||||||
_tabrect.Set(0.0, 0.0, -1.0, -1.0);
|
fTabRect.Set(0.0, 0.0, -1.0, -1.0);
|
||||||
_closerect.Set(0.0, 0.0, -1.0, -1.0);
|
fCloseRect.Set(0.0, 0.0, -1.0, -1.0);
|
||||||
_zoomrect.Set(0.0, 0.0, -1.0, -1.0);
|
fZoomRect.Set(0.0, 0.0, -1.0, -1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate left/top/right/bottom borders
|
// calculate left/top/right/bottom borders
|
||||||
if (fBorderWidth > 0) {
|
if (fBorderWidth > 0) {
|
||||||
// NOTE: no overlapping, the left and right border rects
|
// NOTE: no overlapping, the left and right border rects
|
||||||
// don't include the corners!
|
// don't include the corners!
|
||||||
fLeftBorder.Set(_frame.left - fBorderWidth, _frame.top,
|
fLeftBorder.Set(fFrame.left - fBorderWidth, fFrame.top,
|
||||||
_frame.left - 1, _frame.bottom);
|
fFrame.left - 1, fFrame.bottom);
|
||||||
|
|
||||||
fRightBorder.Set(_frame.right + 1, _frame.top ,
|
fRightBorder.Set(fFrame.right + 1, fFrame.top ,
|
||||||
_frame.right + fBorderWidth, _frame.bottom);
|
fFrame.right + fBorderWidth, fFrame.bottom);
|
||||||
|
|
||||||
fTopBorder.Set(_frame.left - fBorderWidth, _frame.top - fBorderWidth,
|
fTopBorder.Set(fFrame.left - fBorderWidth, fFrame.top - fBorderWidth,
|
||||||
_frame.right + fBorderWidth, _frame.top - 1);
|
fFrame.right + fBorderWidth, fFrame.top - 1);
|
||||||
|
|
||||||
fBottomBorder.Set(_frame.left - fBorderWidth, _frame.bottom + 1,
|
fBottomBorder.Set(fFrame.left - fBorderWidth, fFrame.bottom + 1,
|
||||||
_frame.right + fBorderWidth, _frame.bottom + fBorderWidth);
|
fFrame.right + fBorderWidth, fFrame.bottom + fBorderWidth);
|
||||||
} else {
|
} else {
|
||||||
// no border
|
// no border
|
||||||
fLeftBorder.Set(0.0, 0.0, -1.0, -1.0);
|
fLeftBorder.Set(0.0, 0.0, -1.0, -1.0);
|
||||||
@@ -689,21 +689,21 @@ DefaultDecorator::_DoLayout()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// calculate resize rect
|
// calculate resize rect
|
||||||
_resizerect.Set(fBottomBorder.right - 18.0, fBottomBorder.bottom - 18.0,
|
fResizeRect.Set(fBottomBorder.right - 18.0, fBottomBorder.bottom - 18.0,
|
||||||
fBottomBorder.right, fBottomBorder.bottom);
|
fBottomBorder.right, fBottomBorder.bottom);
|
||||||
|
|
||||||
if (hasTab) {
|
if (hasTab) {
|
||||||
// make sure fTabOffset is within limits and apply it to
|
// make sure fTabOffset is within limits and apply it to
|
||||||
// the _tabrect
|
// the fTabRect
|
||||||
if (fTabOffset < 0)
|
if (fTabOffset < 0)
|
||||||
fTabOffset = 0;
|
fTabOffset = 0;
|
||||||
if (fTabLocation != 0.0
|
if (fTabLocation != 0.0
|
||||||
&& fTabOffset > (fRightBorder.right - fLeftBorder.left - _tabrect.Width()))
|
&& fTabOffset > (fRightBorder.right - fLeftBorder.left - fTabRect.Width()))
|
||||||
fTabOffset = uint32(fRightBorder.right - fLeftBorder.left - _tabrect.Width());
|
fTabOffset = uint32(fRightBorder.right - fLeftBorder.left - fTabRect.Width());
|
||||||
_tabrect.OffsetBy(fTabOffset, 0);
|
fTabRect.OffsetBy(fTabOffset, 0);
|
||||||
|
|
||||||
// finally, layout the buttons and text within the tab rect
|
// finally, layout the buttons and text within the tab rect
|
||||||
_LayoutTabItems(_tabrect);
|
_LayoutTabItems(fTabRect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -733,21 +733,21 @@ DefaultDecorator::_DrawFrame(BRect invalid)
|
|||||||
// top
|
// top
|
||||||
if (invalid.Intersects(fTopBorder)) {
|
if (invalid.Intersects(fTopBorder)) {
|
||||||
for (int8 i = 0; i < 5; i++) {
|
for (int8 i = 0; i < 5; i++) {
|
||||||
_driver->StrokeLine(BPoint(r.left + i, r.top + i),
|
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
|
||||||
BPoint(r.right - i, r.top + i),
|
BPoint(r.right - i, r.top + i),
|
||||||
fFrameColors[i]);
|
fFrameColors[i]);
|
||||||
}
|
}
|
||||||
if (_tabrect.IsValid()) {
|
if (fTabRect.IsValid()) {
|
||||||
// grey along the bottom of the tab (overwrites "white" from frame)
|
// grey along the bottom of the tab (overwrites "white" from frame)
|
||||||
_driver->StrokeLine(BPoint(_tabrect.left + 2, _tabrect.bottom + 1),
|
fDrawingEngine->StrokeLine(BPoint(fTabRect.left + 2, fTabRect.bottom + 1),
|
||||||
BPoint(_tabrect.right - 2, _tabrect.bottom + 1),
|
BPoint(fTabRect.right - 2, fTabRect.bottom + 1),
|
||||||
fFrameColors[2]);
|
fFrameColors[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// left
|
// left
|
||||||
if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
|
if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
|
||||||
for (int8 i = 0; i < 5; i++) {
|
for (int8 i = 0; i < 5; i++) {
|
||||||
_driver->StrokeLine(BPoint(r.left + i, r.top + i),
|
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
|
||||||
BPoint(r.left + i, r.bottom - i),
|
BPoint(r.left + i, r.bottom - i),
|
||||||
fFrameColors[i]);
|
fFrameColors[i]);
|
||||||
}
|
}
|
||||||
@@ -755,7 +755,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
|
|||||||
// bottom
|
// bottom
|
||||||
if (invalid.Intersects(fBottomBorder)) {
|
if (invalid.Intersects(fBottomBorder)) {
|
||||||
for (int8 i = 0; i < 5; i++) {
|
for (int8 i = 0; i < 5; i++) {
|
||||||
_driver->StrokeLine(BPoint(r.left + i, r.bottom - i),
|
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.bottom - i),
|
||||||
BPoint(r.right - i, r.bottom - i),
|
BPoint(r.right - i, r.bottom - i),
|
||||||
fFrameColors[(4 - i) == 4 ? 5 : (4 - i)]);
|
fFrameColors[(4 - i) == 4 ? 5 : (4 - i)]);
|
||||||
}
|
}
|
||||||
@@ -763,7 +763,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
|
|||||||
// right
|
// right
|
||||||
if (invalid.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) {
|
if (invalid.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) {
|
||||||
for (int8 i = 0; i < 5; i++) {
|
for (int8 i = 0; i < 5; i++) {
|
||||||
_driver->StrokeLine(BPoint(r.right - i, r.top + i),
|
fDrawingEngine->StrokeLine(BPoint(r.right - i, r.top + i),
|
||||||
BPoint(r.right - i, r.bottom - i),
|
BPoint(r.right - i, r.bottom - i),
|
||||||
fFrameColors[(4 - i) == 4 ? 5 : (4 - i)]);
|
fFrameColors[(4 - i) == 4 ? 5 : (4 - i)]);
|
||||||
}
|
}
|
||||||
@@ -777,35 +777,35 @@ DefaultDecorator::_DrawFrame(BRect invalid)
|
|||||||
// top
|
// top
|
||||||
if (invalid.Intersects(fTopBorder)) {
|
if (invalid.Intersects(fTopBorder)) {
|
||||||
for (int8 i = 0; i < 3; i++) {
|
for (int8 i = 0; i < 3; i++) {
|
||||||
_driver->StrokeLine(BPoint(r.left + i, r.top + i),
|
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
|
||||||
BPoint(r.right - i, r.top + i),
|
BPoint(r.right - i, r.top + i),
|
||||||
fFrameColors[i * 2]);
|
fFrameColors[i * 2]);
|
||||||
}
|
}
|
||||||
if (_tabrect.IsValid() && fLook != kLeftTitledWindowLook) {
|
if (fTabRect.IsValid() && fLook != kLeftTitledWindowLook) {
|
||||||
// grey along the bottom of the tab (overwrites "white" from frame)
|
// grey along the bottom of the tab (overwrites "white" from frame)
|
||||||
_driver->StrokeLine(BPoint(_tabrect.left + 2, _tabrect.bottom + 1),
|
fDrawingEngine->StrokeLine(BPoint(fTabRect.left + 2, fTabRect.bottom + 1),
|
||||||
BPoint(_tabrect.right - 2, _tabrect.bottom + 1),
|
BPoint(fTabRect.right - 2, fTabRect.bottom + 1),
|
||||||
fFrameColors[2]);
|
fFrameColors[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// left
|
// left
|
||||||
if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
|
if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
|
||||||
for (int8 i = 0; i < 3; i++) {
|
for (int8 i = 0; i < 3; i++) {
|
||||||
_driver->StrokeLine(BPoint(r.left + i, r.top + i),
|
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
|
||||||
BPoint(r.left + i, r.bottom - i),
|
BPoint(r.left + i, r.bottom - i),
|
||||||
fFrameColors[i * 2]);
|
fFrameColors[i * 2]);
|
||||||
}
|
}
|
||||||
if (fLook == kLeftTitledWindowLook && _tabrect.IsValid()) {
|
if (fLook == kLeftTitledWindowLook && fTabRect.IsValid()) {
|
||||||
// grey along the right side of the tab (overwrites "white" from frame)
|
// grey along the right side of the tab (overwrites "white" from frame)
|
||||||
_driver->StrokeLine(BPoint(_tabrect.right + 1, _tabrect.top + 2),
|
fDrawingEngine->StrokeLine(BPoint(fTabRect.right + 1, fTabRect.top + 2),
|
||||||
BPoint(_tabrect.right + 1, _tabrect.bottom - 2),
|
BPoint(fTabRect.right + 1, fTabRect.bottom - 2),
|
||||||
fFrameColors[2]);
|
fFrameColors[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// bottom
|
// bottom
|
||||||
if (invalid.Intersects(fBottomBorder)) {
|
if (invalid.Intersects(fBottomBorder)) {
|
||||||
for (int8 i = 0; i < 3; i++) {
|
for (int8 i = 0; i < 3; i++) {
|
||||||
_driver->StrokeLine(BPoint(r.left + i, r.bottom - i),
|
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.bottom - i),
|
||||||
BPoint(r.right - i, r.bottom - i),
|
BPoint(r.right - i, r.bottom - i),
|
||||||
fFrameColors[(2 - i) == 2 ? 5 : (2 - i) * 2]);
|
fFrameColors[(2 - i) == 2 ? 5 : (2 - i) * 2]);
|
||||||
}
|
}
|
||||||
@@ -813,7 +813,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
|
|||||||
// right
|
// right
|
||||||
if (invalid.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) {
|
if (invalid.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) {
|
||||||
for (int8 i = 0; i < 3; i++) {
|
for (int8 i = 0; i < 3; i++) {
|
||||||
_driver->StrokeLine(BPoint(r.right - i, r.top + i),
|
fDrawingEngine->StrokeLine(BPoint(r.right - i, r.top + i),
|
||||||
BPoint(r.right - i, r.bottom - i),
|
BPoint(r.right - i, r.bottom - i),
|
||||||
fFrameColors[(2 - i) == 2 ? 5 : (2 - i) * 2]);
|
fFrameColors[(2 - i) == 2 ? 5 : (2 - i) * 2]);
|
||||||
}
|
}
|
||||||
@@ -822,7 +822,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case B_BORDERED_WINDOW_LOOK:
|
case B_BORDERED_WINDOW_LOOK:
|
||||||
_driver->StrokeRect(r, fFrameColors[5]);
|
fDrawingEngine->StrokeRect(r, fFrameColors[5]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -832,7 +832,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
|
|||||||
|
|
||||||
// Draw the resize thumb if we're supposed to
|
// Draw the resize thumb if we're supposed to
|
||||||
if (!(fFlags & B_NOT_RESIZABLE)) {
|
if (!(fFlags & B_NOT_RESIZABLE)) {
|
||||||
r = _resizerect;
|
r = fResizeRect;
|
||||||
|
|
||||||
switch (fLook) {
|
switch (fLook) {
|
||||||
case B_DOCUMENT_WINDOW_LOOK:
|
case B_DOCUMENT_WINDOW_LOOK:
|
||||||
@@ -843,14 +843,14 @@ DefaultDecorator::_DrawFrame(BRect invalid)
|
|||||||
float x = r.right - 3;
|
float x = r.right - 3;
|
||||||
float y = r.bottom - 3;
|
float y = r.bottom - 3;
|
||||||
|
|
||||||
_driver->FillRect(BRect(x - 13, y - 13, x, y), fFrameColors[2]);
|
fDrawingEngine->FillRect(BRect(x - 13, y - 13, x, y), fFrameColors[2]);
|
||||||
_driver->StrokeLine(BPoint(x - 15, y - 15), BPoint(x - 15, y - 2),
|
fDrawingEngine->StrokeLine(BPoint(x - 15, y - 15), BPoint(x - 15, y - 2),
|
||||||
fFrameColors[0]);
|
fFrameColors[0]);
|
||||||
_driver->StrokeLine(BPoint(x - 14, y - 14), BPoint(x - 14, y - 1),
|
fDrawingEngine->StrokeLine(BPoint(x - 14, y - 14), BPoint(x - 14, y - 1),
|
||||||
fFrameColors[1]);
|
fFrameColors[1]);
|
||||||
_driver->StrokeLine(BPoint(x - 15, y - 15), BPoint(x - 2, y - 15),
|
fDrawingEngine->StrokeLine(BPoint(x - 15, y - 15), BPoint(x - 2, y - 15),
|
||||||
fFrameColors[0]);
|
fFrameColors[0]);
|
||||||
_driver->StrokeLine(BPoint(x - 14, y - 14), BPoint(x - 1, y - 14),
|
fDrawingEngine->StrokeLine(BPoint(x - 14, y - 14), BPoint(x - 1, y - 14),
|
||||||
fFrameColors[1]);
|
fFrameColors[1]);
|
||||||
|
|
||||||
if (!IsFocus())
|
if (!IsFocus())
|
||||||
@@ -860,8 +860,8 @@ DefaultDecorator::_DrawFrame(BRect invalid)
|
|||||||
for (int8 j = 1; j <= i; j++) {
|
for (int8 j = 1; j <= i; j++) {
|
||||||
BPoint pt1(x - (3 * j) + 1, y - (3 * (5 - i)) + 1);
|
BPoint pt1(x - (3 * j) + 1, y - (3 * (5 - i)) + 1);
|
||||||
BPoint pt2(x - (3 * j) + 2, y - (3 * (5 - i)) + 2);
|
BPoint pt2(x - (3 * j) + 2, y - (3 * (5 - i)) + 2);
|
||||||
_driver->StrokePoint(pt1, fFrameColors[0]);
|
fDrawingEngine->StrokePoint(pt1, fFrameColors[0]);
|
||||||
_driver->StrokePoint(pt2, fFrameColors[1]);
|
fDrawingEngine->StrokePoint(pt2, fFrameColors[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -877,10 +877,10 @@ DefaultDecorator::_DrawFrame(BRect invalid)
|
|||||||
fBottomBorder.bottom - 1)))
|
fBottomBorder.bottom - 1)))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
_driver->StrokeLine(BPoint(fRightBorder.left, fBottomBorder.bottom - 22),
|
fDrawingEngine->StrokeLine(BPoint(fRightBorder.left, fBottomBorder.bottom - 22),
|
||||||
BPoint(fRightBorder.right - 1, fBottomBorder.bottom - 22),
|
BPoint(fRightBorder.right - 1, fBottomBorder.bottom - 22),
|
||||||
fFrameColors[0]);
|
fFrameColors[0]);
|
||||||
_driver->StrokeLine(BPoint(fRightBorder.right - 22, fBottomBorder.top),
|
fDrawingEngine->StrokeLine(BPoint(fRightBorder.right - 22, fBottomBorder.top),
|
||||||
BPoint(fRightBorder.right - 22, fBottomBorder.bottom - 1),
|
BPoint(fRightBorder.right - 22, fBottomBorder.bottom - 1),
|
||||||
fFrameColors[0]);
|
fFrameColors[0]);
|
||||||
break;
|
break;
|
||||||
@@ -901,7 +901,7 @@ DefaultDecorator::_DrawTab(BRect invalid)
|
|||||||
invalid.left, invalid.top, invalid.right, invalid.bottom));
|
invalid.left, invalid.top, invalid.right, invalid.bottom));
|
||||||
// If a window has a tab, this will draw it and any buttons which are
|
// If a window has a tab, this will draw it and any buttons which are
|
||||||
// in it.
|
// in it.
|
||||||
if (!_tabrect.IsValid() || !invalid.Intersects(_tabrect))
|
if (!fTabRect.IsValid() || !invalid.Intersects(fTabRect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO: cache these
|
// TODO: cache these
|
||||||
@@ -911,45 +911,45 @@ DefaultDecorator::_DrawTab(BRect invalid)
|
|||||||
B_DARKEN_2_TINT));
|
B_DARKEN_2_TINT));
|
||||||
|
|
||||||
// outer frame
|
// outer frame
|
||||||
_driver->StrokeLine(_tabrect.LeftTop(), _tabrect.LeftBottom(), fFrameColors[0]);
|
fDrawingEngine->StrokeLine(fTabRect.LeftTop(), fTabRect.LeftBottom(), fFrameColors[0]);
|
||||||
_driver->StrokeLine(_tabrect.LeftTop(), _tabrect.RightTop(), fFrameColors[0]);
|
fDrawingEngine->StrokeLine(fTabRect.LeftTop(), fTabRect.RightTop(), fFrameColors[0]);
|
||||||
if (fLook != kLeftTitledWindowLook)
|
if (fLook != kLeftTitledWindowLook)
|
||||||
_driver->StrokeLine(_tabrect.RightTop(),_tabrect.RightBottom(), fFrameColors[5]);
|
fDrawingEngine->StrokeLine(fTabRect.RightTop(),fTabRect.RightBottom(), fFrameColors[5]);
|
||||||
else
|
else
|
||||||
_driver->StrokeLine(_tabrect.LeftBottom(),_tabrect.RightBottom(), fFrameColors[5]);
|
fDrawingEngine->StrokeLine(fTabRect.LeftBottom(),fTabRect.RightBottom(), fFrameColors[5]);
|
||||||
|
|
||||||
// bevel
|
// bevel
|
||||||
_driver->StrokeLine(BPoint(_tabrect.left + 1, _tabrect.top + 1),
|
fDrawingEngine->StrokeLine(BPoint(fTabRect.left + 1, fTabRect.top + 1),
|
||||||
BPoint(_tabrect.left + 1, _tabrect.bottom - (fLook == kLeftTitledWindowLook ? 1 : 0)),
|
BPoint(fTabRect.left + 1, fTabRect.bottom - (fLook == kLeftTitledWindowLook ? 1 : 0)),
|
||||||
tabColorLight);
|
tabColorLight);
|
||||||
_driver->StrokeLine(BPoint(_tabrect.left + 1, _tabrect.top + 1),
|
fDrawingEngine->StrokeLine(BPoint(fTabRect.left + 1, fTabRect.top + 1),
|
||||||
BPoint(_tabrect.right - (fLook == kLeftTitledWindowLook ? 0 : 1), _tabrect.top + 1),
|
BPoint(fTabRect.right - (fLook == kLeftTitledWindowLook ? 0 : 1), fTabRect.top + 1),
|
||||||
tabColorLight);
|
tabColorLight);
|
||||||
|
|
||||||
if (fLook != kLeftTitledWindowLook) {
|
if (fLook != kLeftTitledWindowLook) {
|
||||||
_driver->StrokeLine(BPoint(_tabrect.right - 1, _tabrect.top + 2),
|
fDrawingEngine->StrokeLine(BPoint(fTabRect.right - 1, fTabRect.top + 2),
|
||||||
BPoint(_tabrect.right - 1, _tabrect.bottom), tabColorShadow);
|
BPoint(fTabRect.right - 1, fTabRect.bottom), tabColorShadow);
|
||||||
} else {
|
} else {
|
||||||
_driver->StrokeLine(BPoint(_tabrect.left + 2, _tabrect.bottom - 1),
|
fDrawingEngine->StrokeLine(BPoint(fTabRect.left + 2, fTabRect.bottom - 1),
|
||||||
BPoint(_tabrect.right, _tabrect.bottom - 1), tabColorShadow);
|
BPoint(fTabRect.right, fTabRect.bottom - 1), tabColorShadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill
|
// fill
|
||||||
if (fLook != kLeftTitledWindowLook) {
|
if (fLook != kLeftTitledWindowLook) {
|
||||||
_driver->FillRect(BRect(_tabrect.left + 2, _tabrect.top + 2,
|
fDrawingEngine->FillRect(BRect(fTabRect.left + 2, fTabRect.top + 2,
|
||||||
_tabrect.right - 2, _tabrect.bottom), fTabColor);
|
fTabRect.right - 2, fTabRect.bottom), fTabColor);
|
||||||
} else {
|
} else {
|
||||||
_driver->FillRect(BRect(_tabrect.left + 2, _tabrect.top + 2,
|
fDrawingEngine->FillRect(BRect(fTabRect.left + 2, fTabRect.top + 2,
|
||||||
_tabrect.right, _tabrect.bottom - 2), fTabColor);
|
fTabRect.right, fTabRect.bottom - 2), fTabColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
_DrawTitle(_tabrect);
|
_DrawTitle(fTabRect);
|
||||||
|
|
||||||
// Draw the buttons if we're supposed to
|
// Draw the buttons if we're supposed to
|
||||||
if (!(fFlags & B_NOT_CLOSABLE) && invalid.Intersects(_closerect))
|
if (!(fFlags & B_NOT_CLOSABLE) && invalid.Intersects(fCloseRect))
|
||||||
_DrawClose(_closerect);
|
_DrawClose(fCloseRect);
|
||||||
if (!(fFlags & B_NOT_ZOOMABLE) && invalid.Intersects(_zoomrect))
|
if (!(fFlags & B_NOT_ZOOMABLE) && invalid.Intersects(fZoomRect))
|
||||||
_DrawZoom(_zoomrect);
|
_DrawZoom(fZoomRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
// _DrawClose
|
// _DrawClose
|
||||||
@@ -976,18 +976,18 @@ DefaultDecorator::_DrawTitle(BRect r)
|
|||||||
|
|
||||||
BPoint titlePos;
|
BPoint titlePos;
|
||||||
if (fLook != kLeftTitledWindowLook) {
|
if (fLook != kLeftTitledWindowLook) {
|
||||||
titlePos.x = _closerect.IsValid() ? _closerect.right + fTextOffset
|
titlePos.x = fCloseRect.IsValid() ? fCloseRect.right + fTextOffset
|
||||||
: _tabrect.left + fTextOffset;
|
: fTabRect.left + fTextOffset;
|
||||||
titlePos.y = floorf(((_tabrect.top + 2.0) + _tabrect.bottom + fontHeight.ascent
|
titlePos.y = floorf(((fTabRect.top + 2.0) + fTabRect.bottom + fontHeight.ascent
|
||||||
+ fontHeight.descent) / 2.0 - fontHeight.descent + 0.5);
|
+ fontHeight.descent) / 2.0 - fontHeight.descent + 0.5);
|
||||||
} else {
|
} else {
|
||||||
titlePos.x = floorf(((_tabrect.left + 2.0) + _tabrect.right + fontHeight.ascent
|
titlePos.x = floorf(((fTabRect.left + 2.0) + fTabRect.right + fontHeight.ascent
|
||||||
+ fontHeight.descent) / 2.0 - fontHeight.descent + 0.5);
|
+ fontHeight.descent) / 2.0 - fontHeight.descent + 0.5);
|
||||||
titlePos.y = _zoomrect.IsValid() ? _zoomrect.top - fTextOffset
|
titlePos.y = fZoomRect.IsValid() ? fZoomRect.top - fTextOffset
|
||||||
: _tabrect.bottom - fTextOffset;
|
: fTabRect.bottom - fTextOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
_driver->DrawString(fTruncatedTitle.String(), fTruncatedTitleLength, titlePos, &fDrawState);
|
fDrawingEngine->DrawString(fTruncatedTitle.String(), fTruncatedTitleLength, titlePos, &fDrawState);
|
||||||
}
|
}
|
||||||
|
|
||||||
// _DrawZoom
|
// _DrawZoom
|
||||||
@@ -1088,17 +1088,17 @@ DefaultDecorator::_DrawBlendedRect(BRect r, bool down)
|
|||||||
uint8(startColor.green - (i * gstep)),
|
uint8(startColor.green - (i * gstep)),
|
||||||
uint8(startColor.blue - (i * bstep)));
|
uint8(startColor.blue - (i * bstep)));
|
||||||
|
|
||||||
_driver->StrokeLine(BPoint(r.left, r.top + i),
|
fDrawingEngine->StrokeLine(BPoint(r.left, r.top + i),
|
||||||
BPoint(r.left + i, r.top), temprgbcol);
|
BPoint(r.left + i, r.top), temprgbcol);
|
||||||
|
|
||||||
temprgbcol.SetColor(uint8(halfColor.red - (i * rstep)),
|
temprgbcol.SetColor(uint8(halfColor.red - (i * rstep)),
|
||||||
uint8(halfColor.green - (i * gstep)),
|
uint8(halfColor.green - (i * gstep)),
|
||||||
uint8(halfColor.blue - (i * bstep)));
|
uint8(halfColor.blue - (i * bstep)));
|
||||||
|
|
||||||
_driver->StrokeLine(BPoint(r.left + steps, r.top + i),
|
fDrawingEngine->StrokeLine(BPoint(r.left + steps, r.top + i),
|
||||||
BPoint(r.left + i, r.top + steps), temprgbcol);
|
BPoint(r.left + i, r.top + steps), temprgbcol);
|
||||||
}
|
}
|
||||||
_driver->StrokeRect(r, fFrameColors[3]);
|
fDrawingEngine->StrokeRect(r, fFrameColors[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// _GetButtonSizeAndOffset
|
// _GetButtonSizeAndOffset
|
||||||
@@ -1126,29 +1126,29 @@ DefaultDecorator::_LayoutTabItems(const BRect& tabRect)
|
|||||||
|
|
||||||
// calulate close rect based on the tab rectangle
|
// calulate close rect based on the tab rectangle
|
||||||
if (fLook != kLeftTitledWindowLook) {
|
if (fLook != kLeftTitledWindowLook) {
|
||||||
_closerect.Set(tabRect.left + offset, tabRect.top + offset,
|
fCloseRect.Set(tabRect.left + offset, tabRect.top + offset,
|
||||||
tabRect.left + offset + size, tabRect.top + offset + size);
|
tabRect.left + offset + size, tabRect.top + offset + size);
|
||||||
|
|
||||||
_zoomrect.Set(tabRect.right - offset - size, tabRect.top + offset,
|
fZoomRect.Set(tabRect.right - offset - size, tabRect.top + offset,
|
||||||
tabRect.right - offset, tabRect.top + offset + size);
|
tabRect.right - offset, tabRect.top + offset + size);
|
||||||
|
|
||||||
// hidden buttons have no width
|
// hidden buttons have no width
|
||||||
if ((Flags() & B_NOT_CLOSABLE) != 0)
|
if ((Flags() & B_NOT_CLOSABLE) != 0)
|
||||||
_closerect.right = _closerect.left - offset;
|
fCloseRect.right = fCloseRect.left - offset;
|
||||||
if ((Flags() & B_NOT_ZOOMABLE) != 0)
|
if ((Flags() & B_NOT_ZOOMABLE) != 0)
|
||||||
_zoomrect.left = _zoomrect.right + offset;
|
fZoomRect.left = fZoomRect.right + offset;
|
||||||
} else {
|
} else {
|
||||||
_closerect.Set(tabRect.left + offset, tabRect.top + offset,
|
fCloseRect.Set(tabRect.left + offset, tabRect.top + offset,
|
||||||
tabRect.left + offset + size, tabRect.top + offset + size);
|
tabRect.left + offset + size, tabRect.top + offset + size);
|
||||||
|
|
||||||
_zoomrect.Set(tabRect.left + offset, tabRect.bottom - offset - size,
|
fZoomRect.Set(tabRect.left + offset, tabRect.bottom - offset - size,
|
||||||
tabRect.left + size + offset, tabRect.bottom - offset);
|
tabRect.left + size + offset, tabRect.bottom - offset);
|
||||||
|
|
||||||
// hidden buttons have no height
|
// hidden buttons have no height
|
||||||
if ((Flags() & B_NOT_CLOSABLE) != 0)
|
if ((Flags() & B_NOT_CLOSABLE) != 0)
|
||||||
_closerect.bottom = _closerect.top - offset;
|
fCloseRect.bottom = fCloseRect.top - offset;
|
||||||
if ((Flags() & B_NOT_ZOOMABLE) != 0)
|
if ((Flags() & B_NOT_ZOOMABLE) != 0)
|
||||||
_zoomrect.top = _zoomrect.bottom + offset;
|
fZoomRect.top = fZoomRect.bottom + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate room for title
|
// calculate room for title
|
||||||
@@ -1156,9 +1156,9 @@ DefaultDecorator::_LayoutTabItems(const BRect& tabRect)
|
|||||||
// truncated for no apparent reason - OTOH the title does
|
// truncated for no apparent reason - OTOH the title does
|
||||||
// also not appear perfectly in the middle
|
// also not appear perfectly in the middle
|
||||||
if (fLook != kLeftTitledWindowLook)
|
if (fLook != kLeftTitledWindowLook)
|
||||||
size = (_zoomrect.left - _closerect.right) - fTextOffset * 2 + 2;
|
size = (fZoomRect.left - fCloseRect.right) - fTextOffset * 2 + 2;
|
||||||
else
|
else
|
||||||
size = (_zoomrect.top - _closerect.bottom) - fTextOffset * 2 + 2;
|
size = (fZoomRect.top - fCloseRect.bottom) - fTextOffset * 2 + 2;
|
||||||
|
|
||||||
fTruncatedTitle = Title();
|
fTruncatedTitle = Title();
|
||||||
fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END, size);
|
fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END, size);
|
||||||
|
|||||||
@@ -2315,11 +2315,11 @@ Desktop::_SetBackground(BRegion& background)
|
|||||||
dirtyBackground.IntersectWith(&background);
|
dirtyBackground.IntersectWith(&background);
|
||||||
fBackgroundRegion = background;
|
fBackgroundRegion = background;
|
||||||
if (dirtyBackground.Frame().IsValid()) {
|
if (dirtyBackground.Frame().IsValid()) {
|
||||||
if (GetDrawingEngine()->Lock()) {
|
if (GetDrawingEngine()->LockParallelAccess()) {
|
||||||
GetDrawingEngine()->FillRegion(dirtyBackground,
|
GetDrawingEngine()->FillRegion(dirtyBackground,
|
||||||
fWorkspaces[fCurrentWorkspace].Color());
|
fWorkspaces[fCurrentWorkspace].Color());
|
||||||
|
|
||||||
GetDrawingEngine()->Unlock();
|
GetDrawingEngine()->UnlockParallelAccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ UseFreeTypeHeaders ;
|
|||||||
Server app_server :
|
Server app_server :
|
||||||
Angle.cpp
|
Angle.cpp
|
||||||
AppServer.cpp
|
AppServer.cpp
|
||||||
|
BitfieldRegion.cpp
|
||||||
BitmapManager.cpp
|
BitmapManager.cpp
|
||||||
ClientMemoryAllocator.cpp
|
ClientMemoryAllocator.cpp
|
||||||
CursorData.cpp
|
CursorData.cpp
|
||||||
|
|||||||
@@ -115,19 +115,27 @@ class AutoReadLocker {
|
|||||||
AutoReadLocker(MultiLocker* lock)
|
AutoReadLocker(MultiLocker* lock)
|
||||||
: fLock(*lock)
|
: fLock(*lock)
|
||||||
{
|
{
|
||||||
fLock.ReadLock();
|
fLocked = fLock.ReadLock();
|
||||||
}
|
}
|
||||||
AutoReadLocker(MultiLocker& lock)
|
AutoReadLocker(MultiLocker& lock)
|
||||||
: fLock(lock)
|
: fLock(lock)
|
||||||
{
|
{
|
||||||
fLock.ReadLock();
|
fLocked = fLock.ReadLock();
|
||||||
}
|
}
|
||||||
~AutoReadLocker()
|
~AutoReadLocker()
|
||||||
{
|
{
|
||||||
fLock.ReadUnlock();
|
Unlock();
|
||||||
|
}
|
||||||
|
void Unlock()
|
||||||
|
{
|
||||||
|
if (fLocked) {
|
||||||
|
fLock.ReadUnlock();
|
||||||
|
fLocked = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
MultiLocker& fLock;
|
MultiLocker& fLock;
|
||||||
|
bool fLocked;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -39,11 +39,11 @@ OffscreenWindowLayer::OffscreenWindowLayer(ServerBitmap* bitmap,
|
|||||||
|
|
||||||
OffscreenWindowLayer::~OffscreenWindowLayer()
|
OffscreenWindowLayer::~OffscreenWindowLayer()
|
||||||
{
|
{
|
||||||
fHWInterface->WriteLock();
|
fHWInterface->LockExclusiveAccess();
|
||||||
// Unlike normal Layers, we own the DrawingEngine instance
|
// Unlike normal Layers, we own the DrawingEngine instance
|
||||||
delete GetDrawingEngine();
|
delete GetDrawingEngine();
|
||||||
fHWInterface->Shutdown();
|
fHWInterface->Shutdown();
|
||||||
fHWInterface->WriteUnlock();
|
fHWInterface->UnlockExclusiveAccess();
|
||||||
delete fHWInterface;
|
delete fHWInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1966,10 +1966,8 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// prevent other ServerWindows from messing with the drawing engine
|
drawingEngine->LockParallelAccess();
|
||||||
// as long as each uses the same instance... TODO: remove the locking
|
// TODO: avoid setting the region each time
|
||||||
// when each has its own
|
|
||||||
drawingEngine->Lock();
|
|
||||||
drawingEngine->ConstrainClippingRegion(&fCurrentDrawingRegion);
|
drawingEngine->ConstrainClippingRegion(&fCurrentDrawingRegion);
|
||||||
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
@@ -2288,7 +2286,7 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
drawingEngine->Unlock();
|
drawingEngine->UnlockParallelAccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2698,7 +2696,8 @@ ServerWindow::MakeWindowLayer(BRect frame, const char* name,
|
|||||||
{
|
{
|
||||||
// The non-offscreen ServerWindow uses the DrawingEngine instance from the desktop.
|
// The non-offscreen ServerWindow uses the DrawingEngine instance from the desktop.
|
||||||
return new (nothrow) WindowLayer(frame, name, look, feel, flags,
|
return new (nothrow) WindowLayer(frame, name, look, feel, flags,
|
||||||
workspace, this, fDesktop->GetDrawingEngine());
|
// workspace, this, fDesktop->GetDrawingEngine());
|
||||||
|
workspace, this, new DrawingEngine(fDesktop->HWInterface()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2830,7 +2829,7 @@ ServerWindow::_SetCurrentLayer(ViewLayer* layer)
|
|||||||
#if DELAYED_BACKGROUND_CLEARING
|
#if DELAYED_BACKGROUND_CLEARING
|
||||||
if (fCurrentLayer && fCurrentLayer->IsBackgroundDirty() && fWindowLayer->InUpdate()) {
|
if (fCurrentLayer && fCurrentLayer->IsBackgroundDirty() && fWindowLayer->InUpdate()) {
|
||||||
DrawingEngine* drawingEngine = fWindowLayer->GetDrawingEngine();
|
DrawingEngine* drawingEngine = fWindowLayer->GetDrawingEngine();
|
||||||
if (drawingEngine->Lock()) {
|
if (drawingEngine->LockParallelAccess()) {
|
||||||
|
|
||||||
fWindowLayer->GetEffectiveDrawingRegion(fCurrentLayer, fCurrentDrawingRegion);
|
fWindowLayer->GetEffectiveDrawingRegion(fCurrentLayer, fCurrentDrawingRegion);
|
||||||
fCurrentDrawingRegionValid = true;
|
fCurrentDrawingRegionValid = true;
|
||||||
@@ -2841,7 +2840,7 @@ ServerWindow::_SetCurrentLayer(ViewLayer* layer)
|
|||||||
|
|
||||||
fCurrentLayer->Draw(drawingEngine, &dirty, &content, false);
|
fCurrentLayer->Draw(drawingEngine, &dirty, &content, false);
|
||||||
|
|
||||||
drawingEngine->Unlock();
|
drawingEngine->UnlockParallelAccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1354,8 +1354,13 @@ ViewLayer::AddTokensForLayersInRegion(BPrivate::PortLink& link,
|
|||||||
if (!fVisible)
|
if (!fVisible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (region.Intersects(ScreenClipping(windowContentClipping).Frame()))
|
// if (region.Intersects(ScreenClipping(windowContentClipping).Frame()))
|
||||||
link.Attach<int32>(fToken);
|
IntRect screenBounds(Bounds());
|
||||||
|
ConvertToScreen(&screenBounds);
|
||||||
|
if (!region.Intersects((clipping_rect)screenBounds))
|
||||||
|
return;
|
||||||
|
|
||||||
|
link.Attach<int32>(fToken);
|
||||||
|
|
||||||
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling())
|
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling())
|
||||||
child->AddTokensForLayersInRegion(link, region,
|
child->AddTokensForLayersInRegion(link, region,
|
||||||
|
|||||||
@@ -796,8 +796,9 @@ WindowLayer::MouseDown(BMessage* message, BPoint where, int32* _viewToken)
|
|||||||
GetBorderRegion(visibleBorder);
|
GetBorderRegion(visibleBorder);
|
||||||
visibleBorder->IntersectWith(&VisibleRegion());
|
visibleBorder->IntersectWith(&VisibleRegion());
|
||||||
|
|
||||||
fDrawingEngine->Lock();
|
DrawingEngine* engine = fDecorator->GetDrawingEngine();
|
||||||
fDrawingEngine->ConstrainClippingRegion(visibleBorder);
|
engine->LockExclusiveAccess();
|
||||||
|
engine->ConstrainClippingRegion(visibleBorder);
|
||||||
|
|
||||||
if (fIsZooming) {
|
if (fIsZooming) {
|
||||||
fDecorator->SetZoom(true);
|
fDecorator->SetZoom(true);
|
||||||
@@ -807,7 +808,7 @@ WindowLayer::MouseDown(BMessage* message, BPoint where, int32* _viewToken)
|
|||||||
fDecorator->SetMinimize(true);
|
fDecorator->SetMinimize(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
fDrawingEngine->Unlock();
|
engine->UnlockExclusiveAccess();
|
||||||
|
|
||||||
fRegionPool.Recycle(visibleBorder);
|
fRegionPool.Recycle(visibleBorder);
|
||||||
|
|
||||||
@@ -872,8 +873,9 @@ WindowLayer::MouseUp(BMessage* message, BPoint where, int32* _viewToken)
|
|||||||
GetBorderRegion(visibleBorder);
|
GetBorderRegion(visibleBorder);
|
||||||
visibleBorder->IntersectWith(&VisibleRegion());
|
visibleBorder->IntersectWith(&VisibleRegion());
|
||||||
|
|
||||||
fDrawingEngine->Lock();
|
DrawingEngine* engine = fDecorator->GetDrawingEngine();
|
||||||
fDrawingEngine->ConstrainClippingRegion(visibleBorder);
|
engine->LockExclusiveAccess();
|
||||||
|
engine->ConstrainClippingRegion(visibleBorder);
|
||||||
|
|
||||||
if (fIsZooming) {
|
if (fIsZooming) {
|
||||||
fIsZooming = false;
|
fIsZooming = false;
|
||||||
@@ -900,7 +902,7 @@ WindowLayer::MouseUp(BMessage* message, BPoint where, int32* _viewToken)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fDrawingEngine->Unlock();
|
engine->UnlockExclusiveAccess();
|
||||||
|
|
||||||
fRegionPool.Recycle(visibleBorder);
|
fRegionPool.Recycle(visibleBorder);
|
||||||
}
|
}
|
||||||
@@ -959,8 +961,9 @@ WindowLayer::MouseMoved(BMessage *message, BPoint where, int32* _viewToken,
|
|||||||
GetBorderRegion(visibleBorder);
|
GetBorderRegion(visibleBorder);
|
||||||
visibleBorder->IntersectWith(&VisibleRegion());
|
visibleBorder->IntersectWith(&VisibleRegion());
|
||||||
|
|
||||||
fDrawingEngine->Lock();
|
DrawingEngine* engine = fDecorator->GetDrawingEngine();
|
||||||
fDrawingEngine->ConstrainClippingRegion(visibleBorder);
|
engine->LockExclusiveAccess();
|
||||||
|
engine->ConstrainClippingRegion(visibleBorder);
|
||||||
|
|
||||||
if (fIsZooming) {
|
if (fIsZooming) {
|
||||||
fDecorator->SetZoom(_ActionFor(message) == DEC_ZOOM);
|
fDecorator->SetZoom(_ActionFor(message) == DEC_ZOOM);
|
||||||
@@ -970,7 +973,7 @@ WindowLayer::MouseMoved(BMessage *message, BPoint where, int32* _viewToken,
|
|||||||
fDecorator->SetMinimize(_ActionFor(message) == DEC_MINIMIZE);
|
fDecorator->SetMinimize(_ActionFor(message) == DEC_MINIMIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
fDrawingEngine->Unlock();
|
engine->UnlockExclusiveAccess();
|
||||||
fRegionPool.Recycle(visibleBorder);
|
fRegionPool.Recycle(visibleBorder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1737,14 +1740,14 @@ WindowLayer::_TriggerContentRedraw(BRegion& dirtyContentRegion)
|
|||||||
backgroundClearingRegion = &fPendingUpdateSession.DirtyRegion();
|
backgroundClearingRegion = &fPendingUpdateSession.DirtyRegion();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fDrawingEngine->Lock()) {
|
if (fDrawingEngine->LockParallelAccess()) {
|
||||||
fDrawingEngine->SuspendAutoSync();
|
fDrawingEngine->SuspendAutoSync();
|
||||||
|
|
||||||
fTopLayer->Draw(fDrawingEngine, backgroundClearingRegion,
|
fTopLayer->Draw(fDrawingEngine, backgroundClearingRegion,
|
||||||
&fContentRegion, true);
|
&fContentRegion, true);
|
||||||
|
|
||||||
fDrawingEngine->Sync();
|
fDrawingEngine->Sync();
|
||||||
fDrawingEngine->Unlock();
|
fDrawingEngine->UnlockParallelAccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1771,16 +1774,20 @@ WindowLayer::_DrawBorder()
|
|||||||
// intersect with the dirty region
|
// intersect with the dirty region
|
||||||
dirtyBorderRegion->IntersectWith(&fDirtyRegion);
|
dirtyBorderRegion->IntersectWith(&fDirtyRegion);
|
||||||
|
|
||||||
if (dirtyBorderRegion->CountRects() > 0 && fDrawingEngine->Lock()) {
|
DrawingEngine* engine = fDecorator->GetDrawingEngine();
|
||||||
fDrawingEngine->ConstrainClippingRegion(dirtyBorderRegion);
|
if (dirtyBorderRegion->CountRects() > 0 && engine->LockExclusiveAccess()) {
|
||||||
|
engine->ConstrainClippingRegion(dirtyBorderRegion);
|
||||||
fDecorator->Draw(dirtyBorderRegion->Frame());
|
fDecorator->Draw(dirtyBorderRegion->Frame());
|
||||||
|
|
||||||
fDrawingEngine->Unlock();
|
engine->UnlockExclusiveAccess();
|
||||||
}
|
}
|
||||||
fRegionPool.Recycle(dirtyBorderRegion);
|
fRegionPool.Recycle(dirtyBorderRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//static rgb_color sPendingColor;
|
||||||
|
//static rgb_color sCurrentColor;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
pre: the clipping is readlocked (this function is
|
pre: the clipping is readlocked (this function is
|
||||||
only called from _TriggerContentRedraw()), which
|
only called from _TriggerContentRedraw()), which
|
||||||
@@ -1793,7 +1800,7 @@ WindowLayer::_TransferToUpdateSession(BRegion* contentDirtyRegion)
|
|||||||
if (contentDirtyRegion->CountRects() <= 0)
|
if (contentDirtyRegion->CountRects() <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//fDrawingEngine->FillRegion(*contentDirtyRegion, RGBColor(255, 255, 0, 255));
|
//fDrawingEngine->FillRegion(*contentDirtyRegion, RGBColor(sPendingColor));
|
||||||
//snooze(10000);
|
//snooze(10000);
|
||||||
|
|
||||||
// add to pending
|
// add to pending
|
||||||
@@ -1873,6 +1880,15 @@ WindowLayer::BeginUpdate(BPrivate::PortLink& link)
|
|||||||
|
|
||||||
dirty->IntersectWith(&VisibleContentRegion());
|
dirty->IntersectWith(&VisibleContentRegion());
|
||||||
|
|
||||||
|
//sCurrentColor.red = rand() % 255;
|
||||||
|
//sCurrentColor.green = rand() % 255;
|
||||||
|
//sCurrentColor.blue = rand() % 255;
|
||||||
|
//sPendingColor.red = rand() % 255;
|
||||||
|
//sPendingColor.green = rand() % 255;
|
||||||
|
//sPendingColor.blue = rand() % 255;
|
||||||
|
//fDrawingEngine->FillRegion(*dirty, RGBColor(sCurrentColor));
|
||||||
|
//snooze(10000);
|
||||||
|
|
||||||
link.StartMessage(B_OK);
|
link.StartMessage(B_OK);
|
||||||
// append the current window geometry to the
|
// append the current window geometry to the
|
||||||
// message, the client will need it
|
// message, the client will need it
|
||||||
@@ -1888,7 +1904,7 @@ WindowLayer::BeginUpdate(BPrivate::PortLink& link)
|
|||||||
link.Attach<int32>(B_NULL_TOKEN);
|
link.Attach<int32>(B_NULL_TOKEN);
|
||||||
link.Flush();
|
link.Flush();
|
||||||
|
|
||||||
if (!fCurrentUpdateSession.IsExpose() && fDrawingEngine->Lock()) {
|
if (!fCurrentUpdateSession.IsExpose() && fDrawingEngine->LockParallelAccess()) {
|
||||||
//fDrawingEngine->FillRegion(dirty, RGBColor(255, 0, 0, 255));
|
//fDrawingEngine->FillRegion(dirty, RGBColor(255, 0, 0, 255));
|
||||||
fDrawingEngine->SuspendAutoSync();
|
fDrawingEngine->SuspendAutoSync();
|
||||||
|
|
||||||
@@ -1896,7 +1912,7 @@ WindowLayer::BeginUpdate(BPrivate::PortLink& link)
|
|||||||
&fContentRegion, true);
|
&fContentRegion, true);
|
||||||
|
|
||||||
fDrawingEngine->Sync();
|
fDrawingEngine->Sync();
|
||||||
fDrawingEngine->Unlock();
|
fDrawingEngine->UnlockParallelAccess();
|
||||||
} // else the background was cleared already
|
} // else the background was cleared already
|
||||||
|
|
||||||
fRegionPool.Recycle(dirty);
|
fRegionPool.Recycle(dirty);
|
||||||
|
|||||||
@@ -545,9 +545,9 @@ AccelerantHWInterface::SetMode(const display_mode& mode)
|
|||||||
void
|
void
|
||||||
AccelerantHWInterface::GetMode(display_mode *mode)
|
AccelerantHWInterface::GetMode(display_mode *mode)
|
||||||
{
|
{
|
||||||
if (mode && ReadLock()) {
|
if (mode && LockParallelAccess()) {
|
||||||
*mode = fDisplayMode;
|
*mode = fDisplayMode;
|
||||||
ReadUnlock();
|
UnlockParallelAccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -997,13 +997,13 @@ void
|
|||||||
AccelerantHWInterface::SetCursor(ServerCursor* cursor)
|
AccelerantHWInterface::SetCursor(ServerCursor* cursor)
|
||||||
{
|
{
|
||||||
HWInterface::SetCursor(cursor);
|
HWInterface::SetCursor(cursor);
|
||||||
// if (WriteLock()) {
|
// if (LockExclusiveAccess()) {
|
||||||
// TODO: implement setting the hard ware cursor
|
// TODO: implement setting the hard ware cursor
|
||||||
// NOTE: cursor should be always B_RGBA32
|
// NOTE: cursor should be always B_RGBA32
|
||||||
// NOTE: The HWInterface implementation should
|
// NOTE: The HWInterface implementation should
|
||||||
// still be called, since it takes ownership of
|
// still be called, since it takes ownership of
|
||||||
// the cursor.
|
// the cursor.
|
||||||
// WriteUnlock();
|
// UnlockExclusiveAccess();
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1012,9 +1012,9 @@ void
|
|||||||
AccelerantHWInterface::SetCursorVisible(bool visible)
|
AccelerantHWInterface::SetCursorVisible(bool visible)
|
||||||
{
|
{
|
||||||
HWInterface::SetCursorVisible(visible);
|
HWInterface::SetCursorVisible(visible);
|
||||||
// if (WriteLock()) {
|
// if (LockExclusiveAccess()) {
|
||||||
// TODO: update graphics hardware
|
// TODO: update graphics hardware
|
||||||
// WriteUnlock();
|
// UnlockExclusiveAccess();
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1023,9 +1023,9 @@ void
|
|||||||
AccelerantHWInterface::MoveCursorTo(const float& x, const float& y)
|
AccelerantHWInterface::MoveCursorTo(const float& x, const float& y)
|
||||||
{
|
{
|
||||||
HWInterface::MoveCursorTo(x, y);
|
HWInterface::MoveCursorTo(x, y);
|
||||||
// if (WriteLock()) {
|
// if (LockExclusiveAccess()) {
|
||||||
// TODO: update graphics hardware
|
// TODO: update graphics hardware
|
||||||
// WriteUnlock();
|
// UnlockExclusiveAccess();
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -44,17 +44,18 @@ public:
|
|||||||
// HWInterfaceListener interface
|
// HWInterfaceListener interface
|
||||||
virtual void FrameBufferChanged();
|
virtual void FrameBufferChanged();
|
||||||
|
|
||||||
// locking
|
|
||||||
bool Lock();
|
|
||||||
void Unlock();
|
|
||||||
bool IsLocked();
|
|
||||||
|
|
||||||
bool WriteLock();
|
|
||||||
void WriteUnlock();
|
|
||||||
|
|
||||||
// for "changing" hardware
|
// for "changing" hardware
|
||||||
void SetHWInterface(HWInterface* interface);
|
void SetHWInterface(HWInterface* interface);
|
||||||
|
|
||||||
|
// locking
|
||||||
|
bool LockParallelAccess();
|
||||||
|
bool IsParallelAccessLocked();
|
||||||
|
void UnlockParallelAccess();
|
||||||
|
|
||||||
|
bool LockExclusiveAccess();
|
||||||
|
bool IsExclusiveAccessLocked();
|
||||||
|
void UnlockExclusiveAccess();
|
||||||
|
|
||||||
// for screen shots
|
// for screen shots
|
||||||
bool DumpToFile(const char *path);
|
bool DumpToFile(const char *path);
|
||||||
ServerBitmap* DumpToBitmap();
|
ServerBitmap* DumpToBitmap();
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ HWInterfaceListener::~HWInterfaceListener() {}
|
|||||||
HWInterface::HWInterface(bool doubleBuffered)
|
HWInterface::HWInterface(bool doubleBuffered)
|
||||||
: MultiLocker("hw interface lock"),
|
: MultiLocker("hw interface lock"),
|
||||||
fCursorAreaBackup(NULL),
|
fCursorAreaBackup(NULL),
|
||||||
|
fSoftwareCursorLock("software cursor lock"),
|
||||||
fCursor(NULL),
|
fCursor(NULL),
|
||||||
fDragBitmap(NULL),
|
fDragBitmap(NULL),
|
||||||
fDragBitmapOffset(0, 0),
|
fDragBitmapOffset(0, 0),
|
||||||
@@ -78,74 +79,78 @@ HWInterface::GetDriverPath(BString &path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// SetCursor
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
HWInterface::SetCursor(ServerCursor* cursor)
|
HWInterface::SetCursor(ServerCursor* cursor)
|
||||||
{
|
{
|
||||||
if (WriteLock()) {
|
if (!fSoftwareCursorLock.Lock())
|
||||||
// TODO: if a bitmap is being dragged, it could
|
return;
|
||||||
// be considered iritating to the user to change
|
|
||||||
// cursor shapes while something is dragged.
|
|
||||||
// The disabled code below would do this (except
|
|
||||||
// for the minor annoyance that the cursor is not
|
|
||||||
// updated when the drag is over)
|
|
||||||
// if (fDragBitmap) {
|
|
||||||
// // TODO: like a "+" or "-" sign when dragging some files to indicate
|
|
||||||
// // the current drag mode?
|
|
||||||
// WriteUnlock();
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
if (fCursor != cursor) {
|
|
||||||
BRect oldFrame = _CursorFrame();
|
|
||||||
|
|
||||||
if (fCursorAndDragBitmap == fCursor) {
|
// TODO: if a bitmap is being dragged, it could
|
||||||
// make sure _AdoptDragBitmap doesn't delete a real cursor
|
// be considered iritating to the user to change
|
||||||
fCursorAndDragBitmap = NULL;
|
// cursor shapes while something is dragged.
|
||||||
}
|
// The disabled code below would prevent this (except
|
||||||
|
// for the minor annoyance that the cursor is not
|
||||||
|
// updated when the drag is over)
|
||||||
|
// if (fDragBitmap) {
|
||||||
|
// // TODO: like a "+" or "-" sign when dragging some files to indicate
|
||||||
|
// // the current drag mode?
|
||||||
|
// UnlockExclusiveAccess();
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
if (fCursor != cursor) {
|
||||||
|
BRect oldFrame = _CursorFrame();
|
||||||
|
|
||||||
if (fCursor)
|
if (fCursorAndDragBitmap == fCursor) {
|
||||||
fCursor->Release();
|
// make sure _AdoptDragBitmap doesn't delete a real cursor
|
||||||
|
fCursorAndDragBitmap = NULL;
|
||||||
fCursor = cursor;
|
|
||||||
|
|
||||||
if (fCursor)
|
|
||||||
fCursor->Acquire();
|
|
||||||
|
|
||||||
Invalidate(oldFrame);
|
|
||||||
|
|
||||||
_AdoptDragBitmap(fDragBitmap, fDragBitmapOffset);
|
|
||||||
Invalidate(_CursorFrame());
|
|
||||||
}
|
}
|
||||||
WriteUnlock();
|
|
||||||
|
if (fCursor)
|
||||||
|
fCursor->Release();
|
||||||
|
|
||||||
|
fCursor = cursor;
|
||||||
|
|
||||||
|
if (fCursor)
|
||||||
|
fCursor->Acquire();
|
||||||
|
|
||||||
|
Invalidate(oldFrame);
|
||||||
|
|
||||||
|
_AdoptDragBitmap(fDragBitmap, fDragBitmapOffset);
|
||||||
|
Invalidate(_CursorFrame());
|
||||||
}
|
}
|
||||||
|
fSoftwareCursorLock.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetCursorVisible
|
// SetCursorVisible
|
||||||
void
|
void
|
||||||
HWInterface::SetCursorVisible(bool visible)
|
HWInterface::SetCursorVisible(bool visible)
|
||||||
{
|
{
|
||||||
if (WriteLock()) {
|
if (!fSoftwareCursorLock.Lock())
|
||||||
if (fCursorVisible != visible) {
|
return;
|
||||||
// NOTE: _CursorFrame() will
|
|
||||||
// return an invalid rect if
|
|
||||||
// fCursorVisible == false!
|
|
||||||
if (visible) {
|
|
||||||
fCursorVisible = visible;
|
|
||||||
fCursorObscured = false;
|
|
||||||
BRect r = _CursorFrame();
|
|
||||||
|
|
||||||
_DrawCursor(r);
|
if (fCursorVisible != visible) {
|
||||||
Invalidate(r);
|
// NOTE: _CursorFrame() will
|
||||||
} else {
|
// return an invalid rect if
|
||||||
BRect r = _CursorFrame();
|
// fCursorVisible == false!
|
||||||
fCursorVisible = visible;
|
if (visible) {
|
||||||
|
fCursorVisible = visible;
|
||||||
|
fCursorObscured = false;
|
||||||
|
BRect r = _CursorFrame();
|
||||||
|
|
||||||
_RestoreCursorArea();
|
_DrawCursor(r);
|
||||||
Invalidate(r);
|
Invalidate(r);
|
||||||
}
|
} else {
|
||||||
|
BRect r = _CursorFrame();
|
||||||
|
fCursorVisible = visible;
|
||||||
|
|
||||||
|
_RestoreCursorArea();
|
||||||
|
Invalidate(r);
|
||||||
}
|
}
|
||||||
WriteUnlock();
|
|
||||||
}
|
}
|
||||||
|
fSoftwareCursorLock.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsCursorVisible
|
// IsCursorVisible
|
||||||
@@ -153,9 +158,9 @@ bool
|
|||||||
HWInterface::IsCursorVisible()
|
HWInterface::IsCursorVisible()
|
||||||
{
|
{
|
||||||
bool visible = true;
|
bool visible = true;
|
||||||
if (ReadLock()) {
|
if (fSoftwareCursorLock.Lock()) {
|
||||||
visible = fCursorVisible;
|
visible = fCursorVisible;
|
||||||
ReadUnlock();
|
fSoftwareCursorLock.Unlock();
|
||||||
}
|
}
|
||||||
return visible;
|
return visible;
|
||||||
}
|
}
|
||||||
@@ -164,46 +169,46 @@ HWInterface::IsCursorVisible()
|
|||||||
void
|
void
|
||||||
HWInterface::ObscureCursor()
|
HWInterface::ObscureCursor()
|
||||||
{
|
{
|
||||||
if (WriteLock()) {
|
if (!fSoftwareCursorLock.Lock())
|
||||||
if (!fCursorObscured) {
|
return;
|
||||||
SetCursorVisible(false);
|
|
||||||
fCursorObscured = true;
|
if (!fCursorObscured) {
|
||||||
}
|
SetCursorVisible(false);
|
||||||
WriteUnlock();
|
fCursorObscured = true;
|
||||||
}
|
}
|
||||||
|
fSoftwareCursorLock.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
// MoveCursorTo
|
// MoveCursorTo
|
||||||
void
|
void
|
||||||
HWInterface::MoveCursorTo(const float& x, const float& y)
|
HWInterface::MoveCursorTo(const float& x, const float& y)
|
||||||
{
|
{
|
||||||
if (WriteLock()) {
|
if (!fSoftwareCursorLock.Lock())
|
||||||
BPoint p(x, y);
|
return;
|
||||||
if (p != fCursorLocation) {
|
|
||||||
// unhide cursor if it is obscured only
|
BPoint p(x, y);
|
||||||
if (fCursorObscured) {
|
if (p != fCursorLocation) {
|
||||||
// TODO: causes nested lock, which
|
// unhide cursor if it is obscured only
|
||||||
// the MultiLocker doesn't actually support?
|
if (fCursorObscured) {
|
||||||
SetCursorVisible(true);
|
SetCursorVisible(true);
|
||||||
}
|
}
|
||||||
BRect oldFrame = _CursorFrame();
|
BRect oldFrame = _CursorFrame();
|
||||||
fCursorLocation = p;
|
fCursorLocation = p;
|
||||||
if (fCursorVisible) {
|
if (fCursorVisible) {
|
||||||
// Invalidate and _DrawCursor would not draw
|
// Invalidate and _DrawCursor would not draw
|
||||||
// anything if the cursor is hidden
|
// anything if the cursor is hidden
|
||||||
// (invalid cursor frame), but explicitly
|
// (invalid cursor frame), but explicitly
|
||||||
// testing for it here saves us some cycles
|
// testing for it here saves us some cycles
|
||||||
if (fCursorAreaBackup) {
|
if (fCursorAreaBackup) {
|
||||||
// means we have a software cursor which we need to draw
|
// means we have a software cursor which we need to draw
|
||||||
_RestoreCursorArea();
|
_RestoreCursorArea();
|
||||||
_DrawCursor(_CursorFrame());
|
_DrawCursor(_CursorFrame());
|
||||||
}
|
}
|
||||||
Invalidate(oldFrame);
|
Invalidate(oldFrame);
|
||||||
Invalidate(_CursorFrame());
|
Invalidate(_CursorFrame());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
WriteUnlock();
|
|
||||||
}
|
}
|
||||||
|
fSoftwareCursorLock.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -211,25 +216,28 @@ BPoint
|
|||||||
HWInterface::CursorPosition()
|
HWInterface::CursorPosition()
|
||||||
{
|
{
|
||||||
BPoint location;
|
BPoint location;
|
||||||
if (ReadLock()) {
|
if (fSoftwareCursorLock.Lock()) {
|
||||||
location = fCursorLocation;
|
location = fCursorLocation;
|
||||||
ReadUnlock();
|
fSoftwareCursorLock.Unlock();
|
||||||
}
|
}
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDragBitmap
|
|
||||||
void
|
void
|
||||||
HWInterface::SetDragBitmap(const ServerBitmap* bitmap,
|
HWInterface::SetDragBitmap(const ServerBitmap* bitmap,
|
||||||
const BPoint& offsetFromCursor)
|
const BPoint& offsetFromCursor)
|
||||||
{
|
{
|
||||||
if (WriteLock()) {
|
if (fSoftwareCursorLock.Lock()) {
|
||||||
_AdoptDragBitmap(bitmap, offsetFromCursor);
|
_AdoptDragBitmap(bitmap, offsetFromCursor);
|
||||||
WriteUnlock();
|
fSoftwareCursorLock.Unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DrawingBuffer
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
RenderingBuffer*
|
RenderingBuffer*
|
||||||
HWInterface::DrawingBuffer() const
|
HWInterface::DrawingBuffer() const
|
||||||
{
|
{
|
||||||
@@ -238,14 +246,14 @@ HWInterface::DrawingBuffer() const
|
|||||||
return FrontBuffer();
|
return FrontBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsDoubleBuffered
|
|
||||||
bool
|
bool
|
||||||
HWInterface::IsDoubleBuffered() const
|
HWInterface::IsDoubleBuffered() const
|
||||||
{
|
{
|
||||||
return fDoubleBuffered;
|
return fDoubleBuffered;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invalidate
|
|
||||||
// * the object needs to be already locked!
|
// * the object needs to be already locked!
|
||||||
status_t
|
status_t
|
||||||
HWInterface::Invalidate(const BRect& frame)
|
HWInterface::Invalidate(const BRect& frame)
|
||||||
@@ -269,7 +277,7 @@ HWInterface::Invalidate(const BRect& frame)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// CopyBackToFront
|
|
||||||
// * the object must already be locked!
|
// * the object must already be locked!
|
||||||
status_t
|
status_t
|
||||||
HWInterface::CopyBackToFront(const BRect& frame)
|
HWInterface::CopyBackToFront(const BRect& frame)
|
||||||
@@ -370,7 +378,9 @@ HWInterface::HideSoftwareCursor(const BRect& area)
|
|||||||
fCursorAreaBackup->right,
|
fCursorAreaBackup->right,
|
||||||
fCursorAreaBackup->bottom);
|
fCursorAreaBackup->bottom);
|
||||||
if (area.Intersects(backupArea)) {
|
if (area.Intersects(backupArea)) {
|
||||||
|
fSoftwareCursorLock.Lock();
|
||||||
_RestoreCursorArea();
|
_RestoreCursorArea();
|
||||||
|
// do not unlock the cursor lock
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -381,6 +391,7 @@ HWInterface::HideSoftwareCursor(const BRect& area)
|
|||||||
void
|
void
|
||||||
HWInterface::HideSoftwareCursor()
|
HWInterface::HideSoftwareCursor()
|
||||||
{
|
{
|
||||||
|
fSoftwareCursorLock.Lock();
|
||||||
_RestoreCursorArea();
|
_RestoreCursorArea();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,6 +402,7 @@ HWInterface::ShowSoftwareCursor()
|
|||||||
if (fCursorAreaBackup && fCursorAreaBackup->cursor_hidden) {
|
if (fCursorAreaBackup && fCursorAreaBackup->cursor_hidden) {
|
||||||
_DrawCursor(_CursorFrame());
|
_DrawCursor(_CursorFrame());
|
||||||
}
|
}
|
||||||
|
fSoftwareCursorLock.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -415,7 +427,7 @@ HWInterface::RemoveListener(HWInterfaceListener* listener)
|
|||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
// _DrawCursor
|
|
||||||
// * default implementation, can be used as fallback or for
|
// * default implementation, can be used as fallback or for
|
||||||
// software cursor
|
// software cursor
|
||||||
// * area is where we potentially draw the cursor, the cursor
|
// * area is where we potentially draw the cursor, the cursor
|
||||||
@@ -433,6 +445,7 @@ HWInterface::_DrawCursor(BRect area) const
|
|||||||
area = backBuffer->Bounds() & area;
|
area = backBuffer->Bounds() & area;
|
||||||
|
|
||||||
if (cf.IsValid() && area.Intersects(cf)) {
|
if (cf.IsValid() && area.Intersects(cf)) {
|
||||||
|
|
||||||
// clip to common area
|
// clip to common area
|
||||||
area = area & cf;
|
area = area & cf;
|
||||||
|
|
||||||
@@ -465,7 +478,8 @@ HWInterface::_DrawCursor(BRect area) const
|
|||||||
|
|
||||||
uint8* dst = buffer;
|
uint8* dst = buffer;
|
||||||
|
|
||||||
if (fCursorAreaBackup && fCursorAreaBackup->buffer) {
|
if (fCursorAreaBackup && fCursorAreaBackup->buffer
|
||||||
|
&& fSoftwareCursorLock.Lock()) {
|
||||||
fCursorAreaBackup->cursor_hidden = false;
|
fCursorAreaBackup->cursor_hidden = false;
|
||||||
// remember which area the backup contains
|
// remember which area the backup contains
|
||||||
fCursorAreaBackup->left = left;
|
fCursorAreaBackup->left = left;
|
||||||
@@ -501,6 +515,7 @@ HWInterface::_DrawCursor(BRect area) const
|
|||||||
dst += width * 4;
|
dst += width * 4;
|
||||||
bup += bupBPR;
|
bup += bupBPR;
|
||||||
}
|
}
|
||||||
|
fSoftwareCursorLock.Unlock();
|
||||||
} else {
|
} else {
|
||||||
// blending
|
// blending
|
||||||
for (int32 y = top; y <= bottom; y++) {
|
for (int32 y = top; y <= bottom; y++) {
|
||||||
@@ -531,8 +546,7 @@ HWInterface::_DrawCursor(BRect area) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// _CopyToFront
|
|
||||||
//
|
|
||||||
// * source is assumed to be already at the right offset
|
// * source is assumed to be already at the right offset
|
||||||
// * source is assumed to be in B_RGBA32 format
|
// * source is assumed to be in B_RGBA32 format
|
||||||
// * location in front buffer is calculated
|
// * location in front buffer is calculated
|
||||||
@@ -563,8 +577,7 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR,
|
|||||||
dst += dstBPR;
|
dst += dstBPR;
|
||||||
src += srcBPR;
|
src += srcBPR;
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
printf("nothing to copy\n");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// NOTE: on R5, B_RGB24 bitmaps are not supported by DrawBitmap()
|
// NOTE: on R5, B_RGB24 bitmaps are not supported by DrawBitmap()
|
||||||
@@ -679,8 +692,6 @@ printf("nothing to copy\n");
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// _CursorFrame
|
|
||||||
//
|
|
||||||
// PRE: the object must be locked
|
// PRE: the object must be locked
|
||||||
BRect
|
BRect
|
||||||
HWInterface::_CursorFrame() const
|
HWInterface::_CursorFrame() const
|
||||||
@@ -693,7 +704,7 @@ HWInterface::_CursorFrame() const
|
|||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
// _RestoreCursorArea
|
|
||||||
void
|
void
|
||||||
HWInterface::_RestoreCursorArea() const
|
HWInterface::_RestoreCursorArea() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include <Accelerant.h>
|
#include <Accelerant.h>
|
||||||
#include <GraphicsCard.h>
|
#include <GraphicsCard.h>
|
||||||
#include <List.h>
|
#include <List.h>
|
||||||
|
#include <Locker.h>
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include <Region.h>
|
#include <Region.h>
|
||||||
|
|
||||||
@@ -42,11 +43,20 @@ class HWInterfaceListener {
|
|||||||
virtual void FrameBufferChanged() = 0;
|
virtual void FrameBufferChanged() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class HWInterface : public MultiLocker {
|
class HWInterface : protected MultiLocker {
|
||||||
public:
|
public:
|
||||||
HWInterface(bool doubleBuffered = false);
|
HWInterface(bool doubleBuffered = false);
|
||||||
virtual ~HWInterface();
|
virtual ~HWInterface();
|
||||||
|
|
||||||
|
// locking
|
||||||
|
bool LockParallelAccess() { return ReadLock(); }
|
||||||
|
bool IsParallelAccessLocked() { return IsReadLocked(); }
|
||||||
|
void UnlockParallelAccess() { ReadUnlock(); }
|
||||||
|
|
||||||
|
bool LockExclusiveAccess() { return WriteLock(); }
|
||||||
|
bool IsExclusiveAccessLocked() { return IsWriteLocked(); }
|
||||||
|
void UnlockExclusiveAccess() { WriteUnlock(); }
|
||||||
|
|
||||||
// You need to WriteLock
|
// You need to WriteLock
|
||||||
virtual status_t Initialize();
|
virtual status_t Initialize();
|
||||||
virtual status_t Shutdown() = 0;
|
virtual status_t Shutdown() = 0;
|
||||||
@@ -200,6 +210,7 @@ class HWInterface : public MultiLocker {
|
|||||||
};
|
};
|
||||||
|
|
||||||
buffer_clip* fCursorAreaBackup;
|
buffer_clip* fCursorAreaBackup;
|
||||||
|
mutable BLocker fSoftwareCursorLock;
|
||||||
|
|
||||||
ServerCursor* fCursor;
|
ServerCursor* fCursor;
|
||||||
const ServerBitmap* fDragBitmap;
|
const ServerBitmap* fDragBitmap;
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ Painter::Painter()
|
|||||||
fSubpixelPrecise(false),
|
fSubpixelPrecise(false),
|
||||||
|
|
||||||
fPenSize(1.0),
|
fPenSize(1.0),
|
||||||
fClippingRegion(new BRegion()),
|
fClippingRegion(NULL),
|
||||||
fValidClipping(false),
|
fValidClipping(false),
|
||||||
fDrawingMode(B_OP_COPY),
|
fDrawingMode(B_OP_COPY),
|
||||||
fDrawingText(false),
|
fDrawingText(false),
|
||||||
@@ -96,7 +96,7 @@ Painter::Painter()
|
|||||||
fMiterLimit(B_DEFAULT_MITER_LIMIT),
|
fMiterLimit(B_DEFAULT_MITER_LIMIT),
|
||||||
|
|
||||||
fPatternHandler(new PatternHandler()),
|
fPatternHandler(new PatternHandler()),
|
||||||
fTextRenderer(new AGGTextRenderer())
|
fTextRenderer(AGGTextRenderer::Default())
|
||||||
{
|
{
|
||||||
// Usually, the drawing engine will lock the font for us when
|
// Usually, the drawing engine will lock the font for us when
|
||||||
// needed - unfortunately, it can't know we need it here
|
// needed - unfortunately, it can't know we need it here
|
||||||
@@ -114,9 +114,7 @@ Painter::~Painter()
|
|||||||
{
|
{
|
||||||
_MakeEmpty();
|
_MakeEmpty();
|
||||||
|
|
||||||
delete fClippingRegion;
|
|
||||||
delete fPatternHandler;
|
delete fPatternHandler;
|
||||||
delete fTextRenderer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
@@ -141,8 +139,6 @@ Painter::AttachToBuffer(RenderingBuffer* buffer)
|
|||||||
fPixelFormat->SetDrawingMode(fDrawingMode, fAlphaSrcMode, fAlphaFncMode, false);
|
fPixelFormat->SetDrawingMode(fDrawingMode, fAlphaSrcMode, fAlphaFncMode, false);
|
||||||
|
|
||||||
fBaseRenderer = new renderer_base(*fPixelFormat);
|
fBaseRenderer = new renderer_base(*fPixelFormat);
|
||||||
// attach our clipping region to the renderer, it keeps a pointer
|
|
||||||
fBaseRenderer->set_clipping_region(fClippingRegion);
|
|
||||||
|
|
||||||
// These are the AGG renderes and rasterizes which
|
// These are the AGG renderes and rasterizes which
|
||||||
// will be used for stroking paths
|
// will be used for stroking paths
|
||||||
@@ -234,17 +230,14 @@ Painter::SetDrawState(const DrawState* data, bool updateFont)
|
|||||||
void
|
void
|
||||||
Painter::ConstrainClipping(const BRegion* region)
|
Painter::ConstrainClipping(const BRegion* region)
|
||||||
{
|
{
|
||||||
*fClippingRegion = *region;
|
fClippingRegion = region;
|
||||||
fValidClipping = fClippingRegion->Frame().IsValid();
|
fBaseRenderer->set_clipping_region(const_cast<BRegion*>(region));
|
||||||
|
fValidClipping = region->Frame().IsValid();
|
||||||
|
|
||||||
if (fValidClipping) {
|
if (fValidClipping) {
|
||||||
clipping_rect cb = fClippingRegion->FrameInt();
|
clipping_rect cb = fClippingRegion->FrameInt();
|
||||||
fRasterizer->clip_box(cb.left, cb.top, cb.right + 1, cb.bottom + 1);
|
fRasterizer->clip_box(cb.left, cb.top, cb.right + 1, cb.bottom + 1);
|
||||||
}
|
}
|
||||||
// TODO: would be nice if we didn't need to copy a region
|
|
||||||
// for *each* drawing command...
|
|
||||||
//fBaseRenderer->set_clipping_region(const_cast<BRegion*>(region));
|
|
||||||
//fValidClipping = region->Frame().IsValid();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetHighColor
|
// SetHighColor
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ mutable agg::conv_curve<agg::path_storage> fCurve;
|
|||||||
bool fSubpixelPrecise;
|
bool fSubpixelPrecise;
|
||||||
|
|
||||||
float fPenSize;
|
float fPenSize;
|
||||||
BRegion* fClippingRegion;
|
const BRegion* fClippingRegion;
|
||||||
bool fValidClipping;
|
bool fValidClipping;
|
||||||
drawing_mode fDrawingMode;
|
drawing_mode fDrawingMode;
|
||||||
bool fDrawingText;
|
bool fDrawingText;
|
||||||
|
|||||||
@@ -69,6 +69,10 @@ is_white_space(uint32 charCode)
|
|||||||
|
|
||||||
#define DEFAULT_UNI_CODE_BUFFER_SIZE 2048
|
#define DEFAULT_UNI_CODE_BUFFER_SIZE 2048
|
||||||
|
|
||||||
|
// init default instance
|
||||||
|
AGGTextRenderer
|
||||||
|
AGGTextRenderer::sDefaultInstance;
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
AGGTextRenderer::AGGTextRenderer()
|
AGGTextRenderer::AGGTextRenderer()
|
||||||
: fFontEngine(gFreeTypeLibrary),
|
: fFontEngine(gFreeTypeLibrary),
|
||||||
@@ -97,6 +101,13 @@ AGGTextRenderer::~AGGTextRenderer()
|
|||||||
free(fUnicodeBuffer);
|
free(fUnicodeBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Default
|
||||||
|
/*static*/ AGGTextRenderer*
|
||||||
|
AGGTextRenderer::Default()
|
||||||
|
{
|
||||||
|
return &sDefaultInstance;
|
||||||
|
}
|
||||||
|
|
||||||
// SetFont
|
// SetFont
|
||||||
bool
|
bool
|
||||||
AGGTextRenderer::SetFont(const ServerFont &font)
|
AGGTextRenderer::SetFont(const ServerFont &font)
|
||||||
|
|||||||
@@ -21,6 +21,14 @@ class AGGTextRenderer {
|
|||||||
AGGTextRenderer();
|
AGGTextRenderer();
|
||||||
virtual ~AGGTextRenderer();
|
virtual ~AGGTextRenderer();
|
||||||
|
|
||||||
|
// NOTE: every Painter instance is using the same
|
||||||
|
// AGGTextRenderer instance, and the only thing that
|
||||||
|
// protects locking is the fact that every use of a
|
||||||
|
// ServerFont goes through a global lock... this will
|
||||||
|
// have to be changed. Maybe every ServerFont should
|
||||||
|
// have it's own AGGTextRenderer or something
|
||||||
|
static AGGTextRenderer* Default();
|
||||||
|
|
||||||
bool SetFont(const ServerFont &font);
|
bool SetFont(const ServerFont &font);
|
||||||
void Unset();
|
void Unset();
|
||||||
|
|
||||||
@@ -76,6 +84,8 @@ class AGGTextRenderer {
|
|||||||
bool fAntialias;
|
bool fAntialias;
|
||||||
bool fKerning;
|
bool fKerning;
|
||||||
Transformable fEmbeddedTransformation; // rotated or sheared font?
|
Transformable fEmbeddedTransformation; // rotated or sheared font?
|
||||||
|
|
||||||
|
static AGGTextRenderer sDefaultInstance;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AGG_TEXT_RENDERER_H
|
#endif // AGG_TEXT_RENDERER_H
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ UpdateQueue::_ExecuteUpdates()
|
|||||||
case B_OK:
|
case B_OK:
|
||||||
case B_TIMED_OUT:
|
case B_TIMED_OUT:
|
||||||
// execute updates
|
// execute updates
|
||||||
if (fInterface->ReadLock()) {
|
if (fInterface->LockParallelAccess()) {
|
||||||
int32 count = fUpdateRegion.CountRects();
|
int32 count = fUpdateRegion.CountRects();
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
for (int32 i = 0; i < count; i++) {
|
for (int32 i = 0; i < count; i++) {
|
||||||
@@ -93,7 +93,7 @@ UpdateQueue::_ExecuteUpdates()
|
|||||||
}
|
}
|
||||||
fUpdateRegion.MakeEmpty();
|
fUpdateRegion.MakeEmpty();
|
||||||
}
|
}
|
||||||
fInterface->ReadUnlock();
|
fInterface->UnlockParallelAccess();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case B_BAD_SEM_ID:
|
case B_BAD_SEM_ID:
|
||||||
|
|||||||
Reference in New Issue
Block a user