Fixed a quit bug in ViewDriver

Slightly improved ServerScreen::SupportsResolution
Implemented a DPMS hack for ViewDriver and DirectDriver
Moved various supporting classes from DisplayDriver.cpp to DisplaySupport.cpp
Added server-side support for BWindow::SetSizeLimits


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8541 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2004-08-07 20:30:58 +00:00
parent 33cbe8bb6c
commit 4a10a4f0ea
12 changed files with 542 additions and 743 deletions
+7 -7
View File
@@ -203,7 +203,7 @@ void DirectDriver::InvertRect(const BRect &r)
index = start;
for(int32 i=0;i<height;i++)
{
// TODO: Where is the alpha bit
// TODO: Where is the alpha bit?
for(int32 j=0; j<width; j++)
index[j]^=0xFFFF;
index = (uint16 *)((uint8 *)index+framebuffer->BytesPerRow());
@@ -354,20 +354,20 @@ bool DirectDriver::DumpToFile(const char *path)
status_t DirectDriver::SetDPMSMode(const uint32 &state)
{
// TODO: Implement software DPMS
return B_ERROR;
// This is a hack, but should do enough to be ok for our purposes
return BScreen().SetDPMS(state);
}
uint32 DirectDriver::DPMSMode(void) const
{
// TODO: Implement software DPMS
return B_DPMS_ON;
// This is a hack, but should do enough to be ok for our purposes
return BScreen().DPMSState();
}
uint32 DirectDriver::DPMSCapabilities(void) const
{
// TODO: Implement software DPMS
return B_DPMS_ON;
// This is a hack, but should do enough to be ok for our purposes
return BScreen().DPMSCapabilites();
}
status_t DirectDriver::GetDeviceInfo(accelerant_device_info *info)
-497
View File
@@ -38,505 +38,8 @@
// handled by the public drawing functions.
// Add clipping and make sure public functions have Lock & Unlock.
class BezierCurve
{
public:
BezierCurve(BPoint* pts);
~BezierCurve();
BPoint* GetPointArray();
BList points;
private:
int GeneratePoints(int startPos);
BPoint* pointArray;
};
BezierCurve::BezierCurve(BPoint* pts)
{
int i;
pointArray = NULL;
for (i=0; i<4; i++)
points.AddItem(new BPoint(pts[i]));
GeneratePoints(0);
}
BezierCurve::~BezierCurve()
{
int i, numPoints;
numPoints = points.CountItems();
for (i=0; i<numPoints; i++)
delete (BPoint*)points.ItemAt(i);
if ( pointArray )
delete[] pointArray;
}
BPoint* BezierCurve::GetPointArray()
{
int i, numPoints;
if ( !pointArray )
{
numPoints = points.CountItems();
pointArray = new BPoint[numPoints];
for (i=0; i<numPoints; i++)
pointArray[i] = *((BPoint*)points.ItemAt(i));
}
return pointArray;
}
int BezierCurve::GeneratePoints(int startPos)
{
double slopeAB, slopeBC, slopeCD;
BPoint** pointList = (BPoint **)points.Items();
// TODO Check for more conditions where we can fudge the curve to a line
if ( (fabs(pointList[startPos]->x-pointList[startPos+3]->x) <= 1) &&
(fabs(pointList[startPos]->y-pointList[startPos+3]->y) <= 1) )
return 0;
if ( (pointList[startPos]->x == pointList[startPos+1]->x) &&
(pointList[startPos+1]->x == pointList[startPos+2]->x) &&
(pointList[startPos+2]->x == pointList[startPos+3]->x) )
return 0;
slopeAB = (pointList[startPos]->y-pointList[startPos+1]->y)/(pointList[startPos]->x-pointList[startPos+1]->x);
slopeBC = (pointList[startPos+1]->y-pointList[startPos+2]->y)/(pointList[startPos+1]->x-pointList[startPos+2]->x);
slopeCD = (pointList[startPos+2]->y-pointList[startPos+3]->y)/(pointList[startPos+2]->x-pointList[startPos+3]->x);
if ( (slopeAB == slopeBC) && (slopeBC == slopeCD) )
return 0;
BPoint *pointAB = new BPoint();
BPoint pointBC;
BPoint *pointCD = new BPoint();
BPoint *pointABC = new BPoint();
BPoint *pointBCD = new BPoint();
BPoint *curvePoint = new BPoint();
int lengthIncrement = 3;
pointAB->x = (pointList[startPos]->x + pointList[startPos+1]->x)/2;
pointAB->y = (pointList[startPos]->y + pointList[startPos+1]->y)/2;
pointBC.x = (pointList[startPos+1]->x + pointList[startPos+2]->x)/2;
pointBC.y = (pointList[startPos+1]->y + pointList[startPos+2]->y)/2;
pointCD->x = (pointList[startPos+2]->x + pointList[startPos+3]->x)/2;
pointCD->y = (pointList[startPos+2]->y + pointList[startPos+3]->y)/2;
pointABC->x = (pointAB->x + pointBC.x)/2;
pointABC->y = (pointAB->y + pointBC.y)/2;
pointBCD->x = (pointCD->x + pointBC.x)/2;
pointBCD->y = (pointCD->y + pointBC.y)/2;
curvePoint->x = (pointABC->x + pointBCD->x)/2;
curvePoint->y = (pointABC->y + pointBCD->y)/2;
delete pointList[startPos+1];
delete pointList[startPos+2];
pointList[startPos+1] = pointAB;
pointList[startPos+2] = pointCD;
points.AddItem(pointABC,startPos+2);
points.AddItem(curvePoint,startPos+3);
points.AddItem(pointBCD,startPos+4);
lengthIncrement += GeneratePoints(startPos);
lengthIncrement += GeneratePoints(startPos + lengthIncrement);
return lengthIncrement;
}
struct integer_rect
{
int32 x;
int32 y;
int32 w;
int32 h;
};
struct integer_scaling_info
{
int32 k;
};
static inline void BRect_to_integer_rect(BRect source_rect, integer_rect &dest_rect)
{
dest_rect.x = (int32)source_rect.left;
dest_rect.y = (int32)source_rect.top;
dest_rect.w = (int32)(source_rect.right - source_rect.left) + 1;
dest_rect.h = (int32)(source_rect.bottom - source_rect.top) + 1;
}
static inline integer_rect BRect_to_integer_rect(BRect source_rect)
{
integer_rect dest_rect;
dest_rect.x = (int32)source_rect.left;
dest_rect.y = (int32)source_rect.top;
dest_rect.w = (int32)(source_rect.right - source_rect.left) + 1;
dest_rect.h = (int32)(source_rect.bottom - source_rect.top) + 1;
return dest_rect;
}
class Blitter
{
public:
Blitter();
void draw_8_to_8(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor);
void draw_8_to_16(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor);
void draw_8_to_32(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor);
void draw_16_to_8(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor);
void draw_16_to_16(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor);
void draw_16_to_32(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor);
void draw_32_to_8(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor);
void draw_32_to_16(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor);
void draw_32_to_32(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor);
void draw_none(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor) {}
void Draw(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor);
void Select(int32 source_bits_per_pixel, int32 dest_bits_per_pixel);
drawing_mode GetDrawMode() const { return mode; }
void SetDrawMode(drawing_mode draw_mode) { mode = draw_mode; }
private:
void (Blitter::*DrawFunc)(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor);
drawing_mode mode;
};
static Blitter blitter;
Blitter::Blitter()
{
DrawFunc = &Blitter::draw_none;
}
void Blitter::draw_8_to_8(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor)
{
uint8 *s = (uint8 *)src;
uint8 *d = (uint8 *)dst;
while(width--)
{
*d++ = s[xscale_position >> 16];
xscale_position += xscale_factor;
}
}
void Blitter::draw_8_to_16(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor)
{
uint8 *s = (uint8 *)src;
uint16 *d = (uint16 *)dst;
while(width--)
{
*d++ = s[xscale_position >> 16];
xscale_position += xscale_factor;
}
}
void Blitter::draw_8_to_32(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor)
{
uint8 *s = (uint8 *)src;
uint32 *d = (uint32 *)dst;
while(width--)
{
*d++ = s[xscale_position >> 16];
xscale_position += xscale_factor;
}
}
void Blitter::draw_16_to_8(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor)
{
uint16 *s = (uint16 *)src;
uint8 *d = (uint8 *)dst;
while(width--)
{
*d++ = s[xscale_position >> 16];
xscale_position += xscale_factor;
}
}
void Blitter::draw_16_to_16(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor)
{
uint16 *s = (uint16 *)src;
uint16 *d = (uint16 *)dst;
while(width--)
{
*d++ = s[xscale_position >> 16];
xscale_position += xscale_factor;
}
}
void Blitter::draw_16_to_32(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor)
{
uint16 *s = (uint16 *)src;
uint32 *d = (uint32 *)dst;
while(width--)
{
*d++ = s[xscale_position >> 16];
xscale_position += xscale_factor;
}
}
void Blitter::draw_32_to_8(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor)
{
uint32 *s = (uint32 *)src;
uint8 *d = (uint8 *)dst;
while(width--)
{
*d++ = s[xscale_position >> 16];
xscale_position += xscale_factor;
}
}
void Blitter::draw_32_to_16(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor)
{
uint32 *s = (uint32 *)src;
uint16 *d = (uint16 *)dst;
while(width--)
{
*d++ = s[xscale_position >> 16];
xscale_position += xscale_factor;
}
}
void Blitter::draw_32_to_32(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor)
{
uint32 *s = (uint32 *)src;
uint32 *d = (uint32 *)dst;
while(width--)
{
*d++ = s[xscale_position >> 16];
xscale_position += xscale_factor;
}
}
void Blitter::Draw(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor)
{
(this->*DrawFunc)(src, dst, width, xscale_position, xscale_factor);
}
void Blitter::Select(int32 source_bits_per_pixel, int32 dest_bits_per_pixel)
{
if(source_bits_per_pixel == 8 && dest_bits_per_pixel == 8)
DrawFunc = &Blitter::draw_8_to_8;
else if(source_bits_per_pixel == 8 && dest_bits_per_pixel == 16)
DrawFunc = &Blitter::draw_8_to_16;
else if(source_bits_per_pixel == 8 && dest_bits_per_pixel == 32)
DrawFunc = &Blitter::draw_8_to_32;
else if(source_bits_per_pixel == 16 && dest_bits_per_pixel == 16)
DrawFunc = &Blitter::draw_16_to_16;
else if(source_bits_per_pixel == 16 && dest_bits_per_pixel == 8)
DrawFunc = &Blitter::draw_16_to_8;
else if(source_bits_per_pixel == 16 && dest_bits_per_pixel == 32)
DrawFunc = &Blitter::draw_16_to_32;
else if(source_bits_per_pixel == 32 && dest_bits_per_pixel == 32)
DrawFunc = &Blitter::draw_32_to_32;
else if(source_bits_per_pixel == 32 && dest_bits_per_pixel == 16)
DrawFunc = &Blitter::draw_32_to_16;
else if(source_bits_per_pixel == 32 && dest_bits_per_pixel == 8)
DrawFunc = &Blitter::draw_32_to_8;
else
DrawFunc = &Blitter::draw_none;
}
LineCalc::LineCalc()
{
}
LineCalc::LineCalc(const BPoint &pta, const BPoint &ptb)
{
start=pta;
end=ptb;
slope=(start.y-end.y)/(start.x-end.x);
offset=start.y-(slope * start.x);
minx = MIN(start.x,end.x);
maxx = MAX(start.x,end.x);
miny = MIN(start.y,end.y);
maxy = MAX(start.y,end.y);
}
void LineCalc::SetPoints(const BPoint &pta, const BPoint &ptb)
{
start=pta;
end=ptb;
slope=(start.y-end.y)/(start.x-end.x);
offset=start.y-(slope * start.x);
minx = MIN(start.x,end.x);
maxx = MAX(start.x,end.x);
miny = MIN(start.y,end.y);
maxy = MAX(start.y,end.y);
}
bool LineCalc::ClipToRect(const BRect& rect)
{
if ( (maxx < rect.left) || (minx > rect.right) || (miny < rect.top) || (maxy > rect.bottom) )
return false;
BPoint newStart(-1,-1);
BPoint newEnd(-1,-1);
if ( maxx == minx )
{
newStart.x = newEnd.x = minx;
if ( miny < rect.top )
newStart.y = rect.top;
else
newStart.y = miny;
if ( maxy > rect.bottom )
newEnd.y = rect.bottom;
else
newEnd.y = maxy;
}
else if ( maxy == miny )
{
newStart.y = newEnd.y = miny;
if ( minx < rect.left )
newStart.x = rect.left;
else
newStart.x = minx;
if ( maxx > rect.right )
newEnd.x = rect.right;
else
newEnd.x = maxx;
}
else
{
float leftInt, rightInt, topInt, bottomInt;
BPoint tempPoint;
leftInt = GetY(rect.left);
rightInt = GetY(rect.right);
topInt = GetX(rect.top);
bottomInt = GetX(rect.bottom);
if ( end.x < start.x )
{
tempPoint = start;
start = end;
end = tempPoint;
}
if ( start.x < rect.left )
{
if ( (leftInt >= rect.top) && (leftInt <= rect.bottom) )
{
newStart.x = rect.left;
newStart.y = leftInt;
}
if ( start.y < end.y )
{
if ( (topInt >= rect.left) && (topInt <= rect.right) )
{
newStart.x = topInt;
newStart.y = rect.top;
}
}
else
{
if ( (bottomInt >= rect.left) && (bottomInt <= rect.right) )
{
newStart.x = bottomInt;
newStart.y = rect.bottom;
}
}
}
else
{
if ( start.y < rect.top )
{
if ( (topInt >= rect.left) && (topInt <= rect.right) )
{
newStart.x = topInt;
newStart.y = rect.top;
}
}
else if ( start.y > rect.bottom )
{
if ( (bottomInt >= rect.left) && (bottomInt <= rect.right) )
{
newStart.x = bottomInt;
newStart.y = rect.bottom;
}
}
else
newStart = start;
}
if ( end.x > rect.right )
{
if ( (rightInt >= rect.top) && (rightInt <= rect.bottom) )
{
newEnd.x = rect.right;
newEnd.y = rightInt;
}
if ( start.y < end.y )
{
if ( (bottomInt >= rect.left) && (bottomInt <= rect.right) )
{
newEnd.x = bottomInt;
newEnd.y = rect.bottom;
}
}
else
{
if ( (topInt >= rect.left) && (topInt <= rect.right) )
{
newEnd.x = topInt;
newEnd.y = rect.top;
}
}
}
else
{
if ( end.y < rect.top )
{
if ( (topInt >= rect.left) && (topInt <= rect.right) )
{
newEnd.x = topInt;
newEnd.y = rect.top;
}
}
else if ( end.y > rect.bottom )
{
if ( (bottomInt >= rect.left) && (bottomInt <= rect.right) )
{
newEnd.x = bottomInt;
newEnd.y = rect.bottom;
}
}
else
newEnd = end;
}
}
if ( (newStart.x == -1) || (newStart.y == -1) || (newEnd.x == -1) || (newEnd.y == -1) )
return false;
SetPoints(newStart,newEnd);
return true;
}
void LineCalc::Swap(LineCalc &from)
{
BPoint pta, ptb;
pta = start;
ptb = end;
SetPoints(from.start,from.end);
from.SetPoints(pta,ptb);
}
float LineCalc::GetX(float y)
{
if (start.x == end.x)
return start.x;
return ( (y-offset)/slope );
}
float LineCalc::GetY(float x)
{
if ( start.x == end.x )
return start.y;
return ( (slope * x) + offset );
}
/*!
\brief Sets up internal variables needed by all DisplayDriver subclasses
+426
View File
@@ -0,0 +1,426 @@
#include "DisplaySupport.h"
BezierCurve::BezierCurve(BPoint* pts)
{
int i;
pointArray = NULL;
for (i=0; i<4; i++)
points.AddItem(new BPoint(pts[i]));
GeneratePoints(0);
}
BezierCurve::~BezierCurve()
{
int i, numPoints;
numPoints = points.CountItems();
for (i=0; i<numPoints; i++)
delete (BPoint*)points.ItemAt(i);
if ( pointArray )
delete[] pointArray;
}
BPoint* BezierCurve::GetPointArray()
{
int i, numPoints;
if ( !pointArray )
{
numPoints = points.CountItems();
pointArray = new BPoint[numPoints];
for (i=0; i<numPoints; i++)
pointArray[i] = *((BPoint*)points.ItemAt(i));
}
return pointArray;
}
int BezierCurve::GeneratePoints(int startPos)
{
double slopeAB, slopeBC, slopeCD;
BPoint** pointList = (BPoint **)points.Items();
// TODO Check for more conditions where we can fudge the curve to a line
if ( (fabs(pointList[startPos]->x-pointList[startPos+3]->x) <= 1) &&
(fabs(pointList[startPos]->y-pointList[startPos+3]->y) <= 1) )
return 0;
if ( (pointList[startPos]->x == pointList[startPos+1]->x) &&
(pointList[startPos+1]->x == pointList[startPos+2]->x) &&
(pointList[startPos+2]->x == pointList[startPos+3]->x) )
return 0;
slopeAB = (pointList[startPos]->y-pointList[startPos+1]->y)/(pointList[startPos]->x-pointList[startPos+1]->x);
slopeBC = (pointList[startPos+1]->y-pointList[startPos+2]->y)/(pointList[startPos+1]->x-pointList[startPos+2]->x);
slopeCD = (pointList[startPos+2]->y-pointList[startPos+3]->y)/(pointList[startPos+2]->x-pointList[startPos+3]->x);
if ( (slopeAB == slopeBC) && (slopeBC == slopeCD) )
return 0;
BPoint *pointAB = new BPoint();
BPoint pointBC;
BPoint *pointCD = new BPoint();
BPoint *pointABC = new BPoint();
BPoint *pointBCD = new BPoint();
BPoint *curvePoint = new BPoint();
int lengthIncrement = 3;
pointAB->x = (pointList[startPos]->x + pointList[startPos+1]->x)/2;
pointAB->y = (pointList[startPos]->y + pointList[startPos+1]->y)/2;
pointBC.x = (pointList[startPos+1]->x + pointList[startPos+2]->x)/2;
pointBC.y = (pointList[startPos+1]->y + pointList[startPos+2]->y)/2;
pointCD->x = (pointList[startPos+2]->x + pointList[startPos+3]->x)/2;
pointCD->y = (pointList[startPos+2]->y + pointList[startPos+3]->y)/2;
pointABC->x = (pointAB->x + pointBC.x)/2;
pointABC->y = (pointAB->y + pointBC.y)/2;
pointBCD->x = (pointCD->x + pointBC.x)/2;
pointBCD->y = (pointCD->y + pointBC.y)/2;
curvePoint->x = (pointABC->x + pointBCD->x)/2;
curvePoint->y = (pointABC->y + pointBCD->y)/2;
delete pointList[startPos+1];
delete pointList[startPos+2];
pointList[startPos+1] = pointAB;
pointList[startPos+2] = pointCD;
points.AddItem(pointABC,startPos+2);
points.AddItem(curvePoint,startPos+3);
points.AddItem(pointBCD,startPos+4);
lengthIncrement += GeneratePoints(startPos);
lengthIncrement += GeneratePoints(startPos + lengthIncrement);
return lengthIncrement;
}
Blitter::Blitter()
{
DrawFunc = &Blitter::draw_none;
}
void Blitter::draw_8_to_8(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor)
{
uint8 *s = (uint8 *)src;
uint8 *d = (uint8 *)dst;
while(width--)
{
*d++ = s[xscale_position >> 16];
xscale_position += xscale_factor;
}
}
void Blitter::draw_8_to_16(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor)
{
uint8 *s = (uint8 *)src;
uint16 *d = (uint16 *)dst;
while(width--)
{
*d++ = s[xscale_position >> 16];
xscale_position += xscale_factor;
}
}
void Blitter::draw_8_to_32(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor)
{
uint8 *s = (uint8 *)src;
uint32 *d = (uint32 *)dst;
while(width--)
{
*d++ = s[xscale_position >> 16];
xscale_position += xscale_factor;
}
}
void Blitter::draw_16_to_8(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor)
{
uint16 *s = (uint16 *)src;
uint8 *d = (uint8 *)dst;
while(width--)
{
*d++ = s[xscale_position >> 16];
xscale_position += xscale_factor;
}
}
void Blitter::draw_16_to_16(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor)
{
uint16 *s = (uint16 *)src;
uint16 *d = (uint16 *)dst;
while(width--)
{
*d++ = s[xscale_position >> 16];
xscale_position += xscale_factor;
}
}
void Blitter::draw_16_to_32(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor)
{
uint16 *s = (uint16 *)src;
uint32 *d = (uint32 *)dst;
while(width--)
{
*d++ = s[xscale_position >> 16];
xscale_position += xscale_factor;
}
}
void Blitter::draw_32_to_8(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor)
{
uint32 *s = (uint32 *)src;
uint8 *d = (uint8 *)dst;
while(width--)
{
*d++ = s[xscale_position >> 16];
xscale_position += xscale_factor;
}
}
void Blitter::draw_32_to_16(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor)
{
uint32 *s = (uint32 *)src;
uint16 *d = (uint16 *)dst;
while(width--)
{
*d++ = s[xscale_position >> 16];
xscale_position += xscale_factor;
}
}
void Blitter::draw_32_to_32(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor)
{
uint32 *s = (uint32 *)src;
uint32 *d = (uint32 *)dst;
while(width--)
{
*d++ = s[xscale_position >> 16];
xscale_position += xscale_factor;
}
}
void Blitter::Draw(uint8 *src, uint8 *dst, int32 width, int32 xscale_position, int32 xscale_factor)
{
(this->*DrawFunc)(src, dst, width, xscale_position, xscale_factor);
}
void Blitter::Select(int32 source_bits_per_pixel, int32 dest_bits_per_pixel)
{
if(source_bits_per_pixel == 8 && dest_bits_per_pixel == 8)
DrawFunc = &Blitter::draw_8_to_8;
else if(source_bits_per_pixel == 8 && dest_bits_per_pixel == 16)
DrawFunc = &Blitter::draw_8_to_16;
else if(source_bits_per_pixel == 8 && dest_bits_per_pixel == 32)
DrawFunc = &Blitter::draw_8_to_32;
else if(source_bits_per_pixel == 16 && dest_bits_per_pixel == 16)
DrawFunc = &Blitter::draw_16_to_16;
else if(source_bits_per_pixel == 16 && dest_bits_per_pixel == 8)
DrawFunc = &Blitter::draw_16_to_8;
else if(source_bits_per_pixel == 16 && dest_bits_per_pixel == 32)
DrawFunc = &Blitter::draw_16_to_32;
else if(source_bits_per_pixel == 32 && dest_bits_per_pixel == 32)
DrawFunc = &Blitter::draw_32_to_32;
else if(source_bits_per_pixel == 32 && dest_bits_per_pixel == 16)
DrawFunc = &Blitter::draw_32_to_16;
else if(source_bits_per_pixel == 32 && dest_bits_per_pixel == 8)
DrawFunc = &Blitter::draw_32_to_8;
else
DrawFunc = &Blitter::draw_none;
}
LineCalc::LineCalc()
{
}
LineCalc::LineCalc(const BPoint &pta, const BPoint &ptb)
{
start=pta;
end=ptb;
slope=(start.y-end.y)/(start.x-end.x);
offset=start.y-(slope * start.x);
minx = MIN(start.x,end.x);
maxx = MAX(start.x,end.x);
miny = MIN(start.y,end.y);
maxy = MAX(start.y,end.y);
}
void LineCalc::SetPoints(const BPoint &pta, const BPoint &ptb)
{
start=pta;
end=ptb;
slope=(start.y-end.y)/(start.x-end.x);
offset=start.y-(slope * start.x);
minx = MIN(start.x,end.x);
maxx = MAX(start.x,end.x);
miny = MIN(start.y,end.y);
maxy = MAX(start.y,end.y);
}
bool LineCalc::ClipToRect(const BRect& rect)
{
if ( (maxx < rect.left) || (minx > rect.right) || (miny < rect.top) || (maxy > rect.bottom) )
return false;
BPoint newStart(-1,-1);
BPoint newEnd(-1,-1);
if ( maxx == minx )
{
newStart.x = newEnd.x = minx;
if ( miny < rect.top )
newStart.y = rect.top;
else
newStart.y = miny;
if ( maxy > rect.bottom )
newEnd.y = rect.bottom;
else
newEnd.y = maxy;
}
else if ( maxy == miny )
{
newStart.y = newEnd.y = miny;
if ( minx < rect.left )
newStart.x = rect.left;
else
newStart.x = minx;
if ( maxx > rect.right )
newEnd.x = rect.right;
else
newEnd.x = maxx;
}
else
{
float leftInt, rightInt, topInt, bottomInt;
BPoint tempPoint;
leftInt = GetY(rect.left);
rightInt = GetY(rect.right);
topInt = GetX(rect.top);
bottomInt = GetX(rect.bottom);
if ( end.x < start.x )
{
tempPoint = start;
start = end;
end = tempPoint;
}
if ( start.x < rect.left )
{
if ( (leftInt >= rect.top) && (leftInt <= rect.bottom) )
{
newStart.x = rect.left;
newStart.y = leftInt;
}
if ( start.y < end.y )
{
if ( (topInt >= rect.left) && (topInt <= rect.right) )
{
newStart.x = topInt;
newStart.y = rect.top;
}
}
else
{
if ( (bottomInt >= rect.left) && (bottomInt <= rect.right) )
{
newStart.x = bottomInt;
newStart.y = rect.bottom;
}
}
}
else
{
if ( start.y < rect.top )
{
if ( (topInt >= rect.left) && (topInt <= rect.right) )
{
newStart.x = topInt;
newStart.y = rect.top;
}
}
else if ( start.y > rect.bottom )
{
if ( (bottomInt >= rect.left) && (bottomInt <= rect.right) )
{
newStart.x = bottomInt;
newStart.y = rect.bottom;
}
}
else
newStart = start;
}
if ( end.x > rect.right )
{
if ( (rightInt >= rect.top) && (rightInt <= rect.bottom) )
{
newEnd.x = rect.right;
newEnd.y = rightInt;
}
if ( start.y < end.y )
{
if ( (bottomInt >= rect.left) && (bottomInt <= rect.right) )
{
newEnd.x = bottomInt;
newEnd.y = rect.bottom;
}
}
else
{
if ( (topInt >= rect.left) && (topInt <= rect.right) )
{
newEnd.x = topInt;
newEnd.y = rect.top;
}
}
}
else
{
if ( end.y < rect.top )
{
if ( (topInt >= rect.left) && (topInt <= rect.right) )
{
newEnd.x = topInt;
newEnd.y = rect.top;
}
}
else if ( end.y > rect.bottom )
{
if ( (bottomInt >= rect.left) && (bottomInt <= rect.right) )
{
newEnd.x = bottomInt;
newEnd.y = rect.bottom;
}
}
else
newEnd = end;
}
}
if ( (newStart.x == -1) || (newStart.y == -1) || (newEnd.x == -1) || (newEnd.y == -1) )
return false;
SetPoints(newStart,newEnd);
return true;
}
void LineCalc::Swap(LineCalc &from)
{
BPoint pta, ptb;
pta = start;
ptb = end;
SetPoints(from.start,from.end);
from.SetPoints(pta,ptb);
}
float LineCalc::GetX(float y)
{
if (start.x == end.x)
return start.x;
return ( (y-offset)/slope );
}
float LineCalc::GetY(float x)
{
if ( start.x == end.x )
return start.y;
return ( (slope * x) + offset );
}
+1
View File
@@ -16,6 +16,7 @@ SharedLibrary appserver :
ColorSet.cpp
Decorator.cpp
DisplayDriver.cpp
DisplaySupport.cpp
FontFamily.cpp
LayerData.cpp
PatternHandler.cpp
+16 -3
View File
@@ -46,12 +46,25 @@ Screen::~Screen(void)
bool Screen::SupportsResolution(BPoint res, uint32 colorspace)
{
// TODO: remove/improve
// TODO: remove/improve
return true;
display_mode *dm = NULL;
uint32 count;
fDDriver->GetModeList(&dm, &count);
status_t err=fDDriver->GetModeList(&dm, &count);
if(err==B_UNSUPPORTED)
{
// We've run into quite a problem here! This is a function which is a requirement
// for a graphics module. The best thing that we can hope for is 640x480x8 without
// knowing anything else. While even this seems like insanity to assume that we
// can support this, the only lower mode supported is 640x400, but we shouldn't even
// bother with such a pathetic possibility.
if( (uint16)res.x == 640 && (uint16)res.y ==480 && colorspace==B_CMAP8)
return true;
else
return false;
}
for (uint32 i=0; i < count; i++)
{
@@ -61,7 +74,7 @@ bool Screen::SupportsResolution(BPoint res, uint32 colorspace)
return true;
}
delete dm;
delete [] dm;
return false;
}
-3
View File
@@ -38,8 +38,6 @@ public:
~Screen(void);
void SetID(int32 ID){ fID = ID; }
// TODO: get/set prototype methods for graphic card features
bool SupportsResolution(BPoint res, uint32 colorspace);
bool SetResolution(BPoint res, uint32 colorspace);
BPoint Resolution() const;
@@ -48,7 +46,6 @@ public:
DisplayDriver* DDriver() const { return fDDriver; }
private:
// TODO: members in which we should store data.
int32 fID;
DisplayDriver *fDDriver;
};
+38 -15
View File
@@ -843,11 +843,13 @@ void ServerWindow::DispatchMessage(int32 code)
// here we remove current layer from list.
cl->RemoveSelf();
// TODO: invalidate the region occupied by this view.
cl->PruneTree();
parent->Invalidate(cl->Frame());
#ifdef DEBUG_SERVERWINDOW
parent->PrintTree();
#endif
STRACE(("DONE: ServerWindow %s: Message AS_DELETE_LAYER: Parent: %s Layer: %s\n", fTitle.String(), parent->fName->String(), cl->fName->String()));
delete cl;
@@ -876,16 +878,18 @@ void ServerWindow::DispatchMessage(int32 code)
// these 4 are here because of a compiler warning. Maybe he's right... :-)
rgb_color hc, lc, vc; // high, low and view colors
uint64 patt; // current pattern as a uint64
uint64 patt;
ld = cl->fLayerData; // now we write fewer characters. :-)
hc = ld->highcolor.GetColor32();
lc = ld->lowcolor.GetColor32();
vc = ld->viewcolor.GetColor32();
patt = ld->patt.GetInt64();
ld = cl->fLayerData; // now we write fewer characters. :-)
hc = ld->highcolor.GetColor32();
lc = ld->lowcolor.GetColor32();
vc = ld->viewcolor.GetColor32();
patt = ld->patt.GetInt64();
// TODO: DW implement such a method in ServerFont class!
fSession->StartMessage(SERVER_TRUE);
// Attach font state
fSession->Attach<uint32>(0UL /*uint32 ld->font.GetFamAndStyle()*/);
fSession->Attach<float>(ld->font.Size());
fSession->Attach<float>(ld->font.Shear());
@@ -895,14 +899,13 @@ void ServerWindow::DispatchMessage(int32 code)
fSession->Attach<uint16>(ld->font.Face());
fSession->Attach<uint32>(ld->font.Flags());
// Attach view state
fSession->Attach<BPoint>(ld->penlocation);
fSession->Attach<float>(ld->pensize);
fSession->Attach(&hc, sizeof(rgb_color));
fSession->Attach(&lc, sizeof(rgb_color));
fSession->Attach(&vc, sizeof(rgb_color));
// TODO: fix this to use the templatized version
fSession->Attach(&patt,sizeof(pattern));
fSession->Attach<uint64>(patt);
fSession->Attach<BPoint>(ld->coordOrigin);
fSession->Attach<uint8>((uint8)(ld->draw_mode));
fSession->Attach<uint8>((uint8)(ld->lineCap));
@@ -949,7 +952,7 @@ void ServerWindow::DispatchMessage(int32 code)
fSession->Read<float>(&newWidth);
fSession->Read<float>(&newHeight);
// TODO: check for minimum alowed. WinBorder should provide such
// TODO: check for minimum allowed. WinBorder should provide such
// a method, based on its decorator.
cl->ResizeBy(newWidth, newHeight);
@@ -1636,6 +1639,27 @@ void ServerWindow::DispatchMessage(int32 code)
break;
}
case AS_SET_SIZE_LIMITS:
{
// Attached Data:
// 1) float minimum width
// 2) float maximum width
// 3) float minimum height
// 4) float maximum height
float wmin,wmax,hmin,hmax;
fSession->Read<float>(&wmin);
fSession->Read<float>(&wmax);
fSession->Read<float>(&hmin);
fSession->Read<float>(&hmax);
fWinBorder->SetSizeLimits(wmin,wmax,hmin,hmax);
fSession->StartMessage(SERVER_TRUE);
fSession->Flush();
break;
}
case B_MINIMIZE:
{
// TODO: Implement
@@ -1709,8 +1733,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer)
if (layer)
{
// TODO: fix!
//layerdata = layer->GetLayerData();
layerdata = layer->fLayerData;
LayerClipRegion.Set(layer->Frame());
LayerClipRegion.IntersectWith(&WindowClipRegion);
numRects = LayerClipRegion.CountRects();
@@ -1,142 +0,0 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: SessionStreamReader.cpp
// Author: DarkWyrm <[email protected]>
// Description: Reader for BSession message streams
//
//------------------------------------------------------------------------------
#include <stdio.h>
#include "SessionStreamReader.h"
SessionMessage::SessionMessage(void)
{
}
SessionMessage::SessionMessage(const int32 &code, void *buffer, size_t buffersize)
{
SetCode(code);
SetBuffer(buffer,buffersize);
}
SessionMessage::~SessionMessage(void)
{
}
void SessionMessage::SetData(const int32 &code, void *buffer, size_t buffersize)
{
SetCode(code);
SetBuffer(buffer,buffersize);
}
SessionStreamReader::SessionStreamReader(msg_dispatcher_func *func)
{
fBuffer=NULL;
fDispatcherFunc=func;
fMsgSize=0;
fMsgCode=0;
fCurrentBufferSize=0;
}
SessionStreamReader::~SessionStreamReader(void)
{
if(fBuffer)
{
printf("DEBUG: Deleting non-empty SessionStreamReader!\n");
delete fBuffer;
}
}
void SessionStreamReader::DispatchMessages(void *msgbuffer, size_t buffersize)
{
// This is the main functionality of the stream reader - it takes a BSession message buffer
// and reads as much as it can. The entire function centers around fBuffer. If fBuffer is
// NULL, then the stream reader is not waiting on the completion of a message.
if(!msgbuffer || buffersize==0)
return;
int8 *index=(int8*)msgbuffer;
// do we have a message waiting to be completed?
while(index<((int8*)msgbuffer+buffersize))
{
if(fBuffer)
{
// We need to see if the data we have received in this call
// will complete the message or not
if(fCurrentBufferSize+buffersize>fMsgSize)
{
// It will, so copy the data to the current location in the buffer (indicated by
// fCurrentBufferSize), call the Dispatch function, make the SSR empty, and iterate
memcpy(fBuffer+fCurrentBufferSize, msgbuffer, fMsgSize-fCurrentBufferSize);
index+=fMsgSize-fCurrentBufferSize;
fSessionMessage.SetData(fMsgCode,fBuffer,fMsgSize);
(*fDispatcherFunc)(&fSessionMessage);
delete fBuffer;
fBuffer=NULL;
fCurrentBufferSize=0;
fMsgSize=0;
fMsgCode=0;
continue;
}
else
{
// We will not be completing the message here, so simply copy the buffer and exit
memcpy(fBuffer+fCurrentBufferSize, msgbuffer, buffersize);
fCurrentBufferSize+=buffersize;
break;
}
}
else
{
// Get basic message data
fMsgCode=*((int32*)index); index+=sizeof(int32);
fMsgSize=*((int32*)index); index+=sizeof(int32);
// Now that we have basic stuff for the message, let's see if it is complete
if((index+fMsgSize)>((int8*)msgbuffer+buffersize))
{
// We have an incomplete message. Allocate a buffer to contain all attached
// data, copy it over, and exit
fBuffer=new int8[fMsgSize];
memcpy(fBuffer, msgbuffer, ((int8*)msgbuffer+buffersize)-index);
break;
}
else
{
// This message is complete, so set the appropriate SessionMessage data and
// call the Dispatch function
fSessionMessage.SetData(fMsgCode,index,fMsgSize);
(*fDispatcherFunc)(&fSessionMessage);
index+=fMsgSize;
}
}
}
}
@@ -1,58 +0,0 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: SessionStreamReader.h
// Author: DarkWyrm <[email protected]>
// Description: Reader for BSession message streams
//
//
//------------------------------------------------------------------------------
#ifndef SSREADER_H_
#define SSREADER_H_
#include <PortMessage.h>
typedef void *msg_dispatcher_func(PortMessage *msg);
class SessionMessage : public PortMessage
{
public:
SessionMessage(void);
SessionMessage(const int32 &code, void *buffer, size_t buffersize);
~SessionMessage(void);
void SetData(const int32 &code, void *buffer, size_t buffersize);
};
class SessionStreamReader
{
public:
SessionStreamReader(msg_dispatcher_func *func);
~SessionStreamReader(void);
void DispatchMessages(void *msgbuffer, size_t buffersize);
protected:
int8 *fBuffer;
uint32 fMsgSize,fMsgCode, fCurrentBufferSize;
msg_dispatcher_func *fDispatcherFunc;
SessionMessage fSessionMessage;
};
#endif
+22 -14
View File
@@ -426,10 +426,14 @@ bool VDWindow::QuitRequested(void)
{
port_id serverport=find_port(SERVER_PORT_NAME);
if(serverport!=B_NAME_NOT_FOUND)
if(serverport>=0)
{
write_port(serverport,B_QUIT_REQUESTED,NULL,0);
BPortLink link(serverport);
link.StartMessage(B_QUIT_REQUESTED);
link.Flush();
}
else
printf("ERROR: couldn't find the app_server's main port!");
// We actually have to perform the internal equivalent of calling Shutdown
// to eliminate a race condition. If a ServerWindow attempts to call a driver
@@ -897,20 +901,24 @@ status_t ViewDriver::SetDPMSMode(const uint32 &state)
if(!is_initialized)
return B_ERROR;
// TODO: Implement software DPMS
return B_ERROR;
// NOTE: Originally, this was a to-do item to implement software DPMS,
// but this driver will not be the official testing driver, so implementing
// this stuff the way it was intended -- blanking the server's screen but not
// the physical monitor -- is moot, but we will support blanking the
// actual monitor if it is supported.
return BScreen().SetDPMS(state);
}
uint32 ViewDriver::DPMSMode(void) const
{
// TODO: Implement software DPMS
return B_DPMS_ON;
// See note for SetDPMSMode if there are questions
return BScreen().DPMSState();
}
uint32 ViewDriver::DPMSCapabilities(void) const
{
// TODO: Implement software DPMS
return B_DPMS_ON;
// See note for SetDPMSMode if there are questions
return BScreen().DPMSCapabilites();
}
status_t ViewDriver::GetDeviceInfo(accelerant_device_info *info)
@@ -937,9 +945,11 @@ status_t ViewDriver::GetModeList(display_mode **modes, uint32 *count)
return B_ERROR;
screenwin->Lock();
// TODO: Figure out good timing values to be returned in each of the modes
// supported.
// DEPRECATED:
// NOTE: Originally, I was going to figure out good timing values to be
// returned in each of the modes supported, but I won't bother, being this
// won't be used much longer anyway.
*modes=new display_mode[13];
*count=13;
@@ -1019,11 +1029,9 @@ status_t ViewDriver::ProposeMode(display_mode *candidate, const display_mode *lo
if(!is_initialized)
return B_ERROR;
// TODO: Unhack
// We should be able to get away with this because we're not dealing with any
// specific hardware. This is a Good Thing(TM) because we can support any hardware
// we wish within reasbonable expectaions and programmer laziness. :P
// we wish within reasonable expectaions and programmer laziness. :P
return B_OK;
}
+26 -3
View File
@@ -377,21 +377,44 @@ void WinBorder::ResizeBy(float x, float y)
Layer::ResizeBy(x,y);
}
bool WinBorder::IsHidden() const{
bool WinBorder::IsHidden() const
{
if (fServerHidden)
return true;
return Layer::IsHidden();
}
void WinBorder::ServerHide(){
void WinBorder::ServerHide()
{
fServerHidden = true;
}
void WinBorder::ServerUnhide(){
void WinBorder::ServerUnhide()
{
fServerHidden = false;
}
void WinBorder::SetSizeLimits(float minwidth, float maxwidth, float minheight, float maxheight)
{
if(minwidth<0)
minwidth=0;
if(minheight<0)
minheight=0;
if(maxwidth<=minwidth)
maxwidth=minwidth+1;
if(maxheight<=minheight)
maxheight=minheight+1;
fMinWidth=minwidth;
fMaxWidth=maxwidth;
fMinHeight=minheight;
fMaxHeight=maxheight;
}
bool WinBorder::HasPoint(const BPoint& pt) const
{
return fFullVisible.Contains(pt);
+6 -1
View File
@@ -70,6 +70,8 @@ public:
void ServerHide();
void ServerUnhide();
void SetSizeLimits(float minwidth, float maxwidth, float minheight, float maxheight);
void MouseDown(PointerEvent& evt, bool sendMessage);
void MouseMoved(PointerEvent& evt);
void MouseUp(PointerEvent& evt);
@@ -94,7 +96,7 @@ public:
// Server "private" :-) - should not be used
void SetMainWinBorder(WinBorder *newMain);
protected:
friend class Layer;
friend class ServerWindow;
@@ -114,6 +116,9 @@ protected:
bool fIsClosing;
bool fIsMinimizing;
bool fIsZooming;
float fMinWidth, fMaxWidth;
float fMinHeight, fMaxHeight;
};
#endif