* some cleanup (removed unsued functions, regrouped others)
* FillRect() doesn't use the HW acceleration if the rects are too small (< 100 pixel area, about the sweet spot on my box) -> the same change should be used for FillRegion as well. (4x speed up of rendering large amounts of small rects) * replaced dynamic allocation and freeing of blit_params and fill_rect_params in the accalerant based HWInterfaces on the heap with caching to make using the accelerated functions a little less expensive * fixed a bug in bypassing Painter for B_OP_OVER when the pattern was B_SOLID_LOW (nothing should be rendered) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16841 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
af3ac4e80f
commit
8e56a3ff2e
@ -92,48 +92,40 @@ public:
|
|||||||
BRect bounds, const DrawState *d,
|
BRect bounds, const DrawState *d,
|
||||||
bool filled, bool closed);
|
bool filled, bool closed);
|
||||||
|
|
||||||
// this version used by Decorator
|
// these RGBColor versions are used internally by the server
|
||||||
|
void StrokePoint(const BPoint& pt,
|
||||||
|
const RGBColor& color);
|
||||||
void StrokeRect(BRect r, const RGBColor &color);
|
void StrokeRect(BRect r, const RGBColor &color);
|
||||||
void FillRect(BRect r, const RGBColor &color);
|
void FillRect(BRect r, const RGBColor &color);
|
||||||
|
void FillRegion(BRegion& r, const RGBColor& color);
|
||||||
|
|
||||||
void StrokeRect(BRect r, const DrawState *d);
|
void StrokeRect(BRect r, const DrawState *d);
|
||||||
void FillRect(BRect r, const DrawState *d);
|
void FillRect(BRect r, const DrawState *d);
|
||||||
|
|
||||||
// for debugging purposes?
|
void FillRegion(BRegion& r, const DrawState *d);
|
||||||
// void StrokeRegion(BRegion &r, const DrawState *d);
|
|
||||||
|
|
||||||
void FillRegion(BRegion &r, const DrawState *d);
|
|
||||||
void FillRegion(BRegion &r, const RGBColor& color);
|
|
||||||
|
|
||||||
void DrawRoundRect(BRect r, float xrad,
|
void DrawRoundRect(BRect r, float xrad,
|
||||||
float yrad, const DrawState *d,
|
float yrad, const DrawState *d,
|
||||||
bool filled);
|
bool filled);
|
||||||
|
|
||||||
void DrawShape(const BRect &bounds,
|
void DrawShape(const BRect& bounds,
|
||||||
int32 opcount, const uint32 *oplist,
|
int32 opcount, const uint32* oplist,
|
||||||
int32 ptcount, const BPoint *ptlist,
|
int32 ptcount, const BPoint* ptlist,
|
||||||
const DrawState *d, bool filled);
|
const DrawState* d, bool filled);
|
||||||
|
|
||||||
void DrawTriangle(BPoint *pts, const BRect &bounds,
|
void DrawTriangle(BPoint* pts, const BRect& bounds,
|
||||||
const DrawState *d, bool filled);
|
const DrawState* d, bool filled);
|
||||||
|
|
||||||
// this version used by Decorator
|
// this version used by Decorator
|
||||||
void StrokeLine(const BPoint &start,
|
void StrokeLine(const BPoint& start,
|
||||||
const BPoint &end, const RGBColor &color);
|
const BPoint& end, const RGBColor& color);
|
||||||
|
|
||||||
void StrokeLine(const BPoint &start,
|
void StrokeLine(const BPoint& start,
|
||||||
const BPoint &end, DrawState *d);
|
const BPoint& end, DrawState* d);
|
||||||
|
|
||||||
void StrokeLineArray(int32 numlines,
|
void StrokeLineArray(int32 numlines,
|
||||||
const LineArrayData *data,
|
const LineArrayData* data,
|
||||||
const DrawState *d);
|
const DrawState* d);
|
||||||
|
|
||||||
// this version used by Decorator
|
|
||||||
void StrokePoint(const BPoint &pt,
|
|
||||||
const RGBColor &color);
|
|
||||||
|
|
||||||
void StrokePoint(const BPoint &pt,
|
|
||||||
DrawState *d);
|
|
||||||
|
|
||||||
// -------- text related calls
|
// -------- text related calls
|
||||||
|
|
||||||
|
@ -58,6 +58,8 @@ operator==(const display_mode& a, const display_mode& b)
|
|||||||
return memcmp(&a, &b, sizeof(display_mode)) == 0;
|
return memcmp(&a, &b, sizeof(display_mode)) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int32 kDefaultParamsCount = 64;
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
AccelerantHWInterface::AccelerantHWInterface()
|
AccelerantHWInterface::AccelerantHWInterface()
|
||||||
: HWInterface(),
|
: HWInterface(),
|
||||||
@ -97,7 +99,12 @@ AccelerantHWInterface::AccelerantHWInterface()
|
|||||||
fModeList(NULL),
|
fModeList(NULL),
|
||||||
|
|
||||||
fBackBuffer(NULL),
|
fBackBuffer(NULL),
|
||||||
fFrontBuffer(new(nothrow) AccelerantBuffer())
|
fFrontBuffer(new (nothrow) AccelerantBuffer()),
|
||||||
|
|
||||||
|
fRectParams(new (nothrow) fill_rect_params[kDefaultParamsCount]),
|
||||||
|
fRectParamsCount(kDefaultParamsCount),
|
||||||
|
fBlitParams(new (nothrow) blit_params[kDefaultParamsCount]),
|
||||||
|
fBlitParamsCount(kDefaultParamsCount)
|
||||||
{
|
{
|
||||||
fDisplayMode.virtual_width = 640;
|
fDisplayMode.virtual_width = 640;
|
||||||
fDisplayMode.virtual_height = 480;
|
fDisplayMode.virtual_height = 480;
|
||||||
@ -114,6 +121,10 @@ AccelerantHWInterface::~AccelerantHWInterface()
|
|||||||
{
|
{
|
||||||
delete fBackBuffer;
|
delete fBackBuffer;
|
||||||
delete fFrontBuffer;
|
delete fFrontBuffer;
|
||||||
|
|
||||||
|
delete[] fRectParams;
|
||||||
|
delete[] fBlitParams;
|
||||||
|
|
||||||
delete[] fModeList;
|
delete[] fModeList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,6 +137,10 @@ status_t
|
|||||||
AccelerantHWInterface::Initialize()
|
AccelerantHWInterface::Initialize()
|
||||||
{
|
{
|
||||||
status_t ret = HWInterface::Initialize();
|
status_t ret = HWInterface::Initialize();
|
||||||
|
|
||||||
|
if (!fRectParams || !fBlitParams)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
if (ret >= B_OK) {
|
if (ret >= B_OK) {
|
||||||
for (int32 i = 1; fCardFD != B_ENTRY_NOT_FOUND; i++) {
|
for (int32 i = 1; fCardFD != B_ENTRY_NOT_FOUND; i++) {
|
||||||
fCardFD = _OpenGraphicsDevice(i);
|
fCardFD = _OpenGraphicsDevice(i);
|
||||||
@ -677,22 +692,33 @@ AccelerantHWInterface::CopyRegion(const clipping_rect* sortedRectList,
|
|||||||
if (fAccScreenBlit && fAccAcquireEngine) {
|
if (fAccScreenBlit && fAccAcquireEngine) {
|
||||||
if (fAccAcquireEngine(B_2D_ACCELERATION, 0xff, &fSyncToken, &fEngineToken) >= B_OK) {
|
if (fAccAcquireEngine(B_2D_ACCELERATION, 0xff, &fSyncToken, &fEngineToken) >= B_OK) {
|
||||||
|
|
||||||
|
// make sure the blit_params cache is large enough
|
||||||
|
if (fBlitParamsCount < count) {
|
||||||
|
fBlitParamsCount = (count / kDefaultParamsCount + 1) * kDefaultParamsCount;
|
||||||
|
// NOTE: realloc() could be used instead...
|
||||||
|
blit_params* params = new (nothrow) blit_params[fBlitParamsCount];
|
||||||
|
if (params) {
|
||||||
|
delete[] fBlitParams;
|
||||||
|
fBlitParams = params;
|
||||||
|
} else {
|
||||||
|
count = fBlitParamsCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
// convert the rects
|
// convert the rects
|
||||||
blit_params* params = new blit_params[count];
|
|
||||||
for (uint32 i = 0; i < count; i++) {
|
for (uint32 i = 0; i < count; i++) {
|
||||||
params[i].src_left = (uint16)sortedRectList[i].left;
|
fBlitParams[i].src_left = (uint16)sortedRectList[i].left;
|
||||||
params[i].src_top = (uint16)sortedRectList[i].top;
|
fBlitParams[i].src_top = (uint16)sortedRectList[i].top;
|
||||||
|
|
||||||
params[i].dest_left = (uint16)sortedRectList[i].left + xOffset;
|
fBlitParams[i].dest_left = (uint16)sortedRectList[i].left + xOffset;
|
||||||
params[i].dest_top = (uint16)sortedRectList[i].top + yOffset;
|
fBlitParams[i].dest_top = (uint16)sortedRectList[i].top + yOffset;
|
||||||
|
|
||||||
// NOTE: width and height are expressed as distance, not pixel count!
|
// NOTE: width and height are expressed as distance, not pixel count!
|
||||||
params[i].width = (uint16)(sortedRectList[i].right - sortedRectList[i].left);
|
fBlitParams[i].width = (uint16)(sortedRectList[i].right - sortedRectList[i].left);
|
||||||
params[i].height = (uint16)(sortedRectList[i].bottom - sortedRectList[i].top);
|
fBlitParams[i].height = (uint16)(sortedRectList[i].bottom - sortedRectList[i].top);
|
||||||
}
|
}
|
||||||
|
|
||||||
// go
|
// go
|
||||||
fAccScreenBlit(fEngineToken, params, count);
|
fAccScreenBlit(fEngineToken, fBlitParams, count);
|
||||||
|
|
||||||
// done
|
// done
|
||||||
if (fAccReleaseEngine)
|
if (fAccReleaseEngine)
|
||||||
@ -701,8 +727,6 @@ AccelerantHWInterface::CopyRegion(const clipping_rect* sortedRectList,
|
|||||||
// sync
|
// sync
|
||||||
if (fAccSyncToToken)
|
if (fAccSyncToToken)
|
||||||
fAccSyncToToken(&fSyncToken);
|
fAccSyncToToken(&fSyncToken);
|
||||||
|
|
||||||
delete[] params;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -716,11 +740,10 @@ AccelerantHWInterface::FillRegion(/*const*/ BRegion& region, const RGBColor& col
|
|||||||
|
|
||||||
// convert the region
|
// convert the region
|
||||||
uint32 count;
|
uint32 count;
|
||||||
fill_rect_params* fillParams;
|
_RegionToRectParams(®ion, &count);
|
||||||
_RegionToRectParams(®ion, &fillParams, &count);
|
|
||||||
|
|
||||||
// go
|
// go
|
||||||
fAccFillRect(fEngineToken, _NativeColor(color), fillParams, count);
|
fAccFillRect(fEngineToken, _NativeColor(color), fRectParams, count);
|
||||||
|
|
||||||
// done
|
// done
|
||||||
if (fAccReleaseEngine)
|
if (fAccReleaseEngine)
|
||||||
@ -729,8 +752,6 @@ AccelerantHWInterface::FillRegion(/*const*/ BRegion& region, const RGBColor& col
|
|||||||
// sync
|
// sync
|
||||||
if (fAccSyncToToken)
|
if (fAccSyncToToken)
|
||||||
fAccSyncToToken(&fSyncToken);
|
fAccSyncToToken(&fSyncToken);
|
||||||
|
|
||||||
delete[] fillParams;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -744,11 +765,10 @@ AccelerantHWInterface::InvertRegion(/*const*/ BRegion& region)
|
|||||||
|
|
||||||
// convert the region
|
// convert the region
|
||||||
uint32 count;
|
uint32 count;
|
||||||
fill_rect_params* fillParams;
|
_RegionToRectParams(®ion, &count);
|
||||||
_RegionToRectParams(®ion, &fillParams, &count);
|
|
||||||
|
|
||||||
// go
|
// go
|
||||||
fAccInvertRect(fEngineToken, fillParams, count);
|
fAccInvertRect(fEngineToken, fRectParams, count);
|
||||||
|
|
||||||
// done
|
// done
|
||||||
if (fAccReleaseEngine)
|
if (fAccReleaseEngine)
|
||||||
@ -757,8 +777,6 @@ AccelerantHWInterface::InvertRegion(/*const*/ BRegion& region)
|
|||||||
// sync
|
// sync
|
||||||
if (fAccSyncToToken)
|
if (fAccSyncToToken)
|
||||||
fAccSyncToToken(&fSyncToken);
|
fAccSyncToToken(&fSyncToken);
|
||||||
|
|
||||||
delete[] fillParams;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -844,18 +862,27 @@ AccelerantHWInterface::_DrawCursor(BRect area) const
|
|||||||
// _RegionToRectParams
|
// _RegionToRectParams
|
||||||
void
|
void
|
||||||
AccelerantHWInterface::_RegionToRectParams(/*const*/ BRegion* region,
|
AccelerantHWInterface::_RegionToRectParams(/*const*/ BRegion* region,
|
||||||
fill_rect_params** params,
|
|
||||||
uint32* count) const
|
uint32* count) const
|
||||||
{
|
{
|
||||||
*count = region->CountRects();
|
*count = region->CountRects();
|
||||||
*params = new fill_rect_params[*count];
|
if (fRectParamsCount < *count) {
|
||||||
|
fRectParamsCount = (*count / kDefaultParamsCount + 1) * kDefaultParamsCount;
|
||||||
|
// NOTE: realloc() could be used instead...
|
||||||
|
fill_rect_params* params = new (nothrow) fill_rect_params[fRectParamsCount];
|
||||||
|
if (params) {
|
||||||
|
delete[] fRectParams;
|
||||||
|
fRectParams = params;
|
||||||
|
} else {
|
||||||
|
*count = fRectParamsCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (uint32 i = 0; i < *count; i++) {
|
for (uint32 i = 0; i < *count; i++) {
|
||||||
clipping_rect r = region->RectAtInt(i);
|
clipping_rect r = region->RectAtInt(i);
|
||||||
(*params)[i].left = (uint16)r.left;
|
fRectParams[i].left = (uint16)r.left;
|
||||||
(*params)[i].top = (uint16)r.top;
|
fRectParams[i].top = (uint16)r.top;
|
||||||
(*params)[i].right = (uint16)r.right;
|
fRectParams[i].right = (uint16)r.right;
|
||||||
(*params)[i].bottom = (uint16)r.bottom;
|
fRectParams[i].bottom = (uint16)r.bottom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,6 @@ private:
|
|||||||
status_t _UpdateModeList();
|
status_t _UpdateModeList();
|
||||||
status_t _UpdateFrameBufferConfig();
|
status_t _UpdateFrameBufferConfig();
|
||||||
void _RegionToRectParams(/*const*/ BRegion* region,
|
void _RegionToRectParams(/*const*/ BRegion* region,
|
||||||
fill_rect_params** params,
|
|
||||||
uint32* count) const;
|
uint32* count) const;
|
||||||
uint32 _NativeColor(const RGBColor& color) const;
|
uint32 _NativeColor(const RGBColor& color) const;
|
||||||
|
|
||||||
@ -138,6 +137,11 @@ private:
|
|||||||
AccelerantBuffer *fFrontBuffer;
|
AccelerantBuffer *fFrontBuffer;
|
||||||
|
|
||||||
display_mode fDisplayMode;
|
display_mode fDisplayMode;
|
||||||
|
|
||||||
|
mutable fill_rect_params* fRectParams;
|
||||||
|
mutable uint32 fRectParamsCount;
|
||||||
|
mutable blit_params* fBlitParams;
|
||||||
|
mutable uint32 fBlitParamsCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ACCELERANT_HW_INTERFACE_H
|
#endif // ACCELERANT_HW_INTERFACE_H
|
||||||
|
@ -283,6 +283,8 @@ DWindow::FrameMoved(BPoint newOffset)
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
const int32 kDefaultParamsCount = 64;
|
||||||
|
|
||||||
DWindowHWInterface::DWindowHWInterface()
|
DWindowHWInterface::DWindowHWInterface()
|
||||||
: HWInterface(),
|
: HWInterface(),
|
||||||
fFrontBuffer(new DWindowBuffer()),
|
fFrontBuffer(new DWindowBuffer()),
|
||||||
@ -316,7 +318,12 @@ DWindowHWInterface::DWindowHWInterface()
|
|||||||
fAccScreenBlit(NULL),
|
fAccScreenBlit(NULL),
|
||||||
fAccSetCursorShape(NULL),
|
fAccSetCursorShape(NULL),
|
||||||
fAccMoveCursor(NULL),
|
fAccMoveCursor(NULL),
|
||||||
fAccShowCursor(NULL)
|
fAccShowCursor(NULL),
|
||||||
|
|
||||||
|
fRectParams(new (nothrow) fill_rect_params[kDefaultParamsCount]),
|
||||||
|
fRectParamsCount(kDefaultParamsCount),
|
||||||
|
fBlitParams(new (nothrow) blit_params[kDefaultParamsCount]),
|
||||||
|
fBlitParamsCount(kDefaultParamsCount)
|
||||||
{
|
{
|
||||||
fDisplayMode.virtual_width = 800;
|
fDisplayMode.virtual_width = 800;
|
||||||
fDisplayMode.virtual_height = 600;
|
fDisplayMode.virtual_height = 600;
|
||||||
@ -333,6 +340,9 @@ DWindowHWInterface::~DWindowHWInterface()
|
|||||||
fWindow->Quit();
|
fWindow->Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete[] fRectParams;
|
||||||
|
delete[] fBlitParams;
|
||||||
|
|
||||||
delete fFrontBuffer;
|
delete fFrontBuffer;
|
||||||
|
|
||||||
be_app->Lock();
|
be_app->Lock();
|
||||||
@ -345,6 +355,10 @@ status_t
|
|||||||
DWindowHWInterface::Initialize()
|
DWindowHWInterface::Initialize()
|
||||||
{
|
{
|
||||||
status_t ret = HWInterface::Initialize();
|
status_t ret = HWInterface::Initialize();
|
||||||
|
|
||||||
|
if (!fRectParams || !fBlitParams)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
if (ret >= B_OK) {
|
if (ret >= B_OK) {
|
||||||
for (int32 i = 1; fCardFD != B_ENTRY_NOT_FOUND; i++) {
|
for (int32 i = 1; fCardFD != B_ENTRY_NOT_FOUND; i++) {
|
||||||
fCardFD = _OpenGraphicsDevice(i);
|
fCardFD = _OpenGraphicsDevice(i);
|
||||||
@ -889,22 +903,33 @@ DWindowHWInterface::CopyRegion(const clipping_rect* sortedRectList,
|
|||||||
if (fAccScreenBlit && fAccAcquireEngine) {
|
if (fAccScreenBlit && fAccAcquireEngine) {
|
||||||
if (fAccAcquireEngine(B_2D_ACCELERATION, 0xff, &fSyncToken, &fEngineToken) >= B_OK) {
|
if (fAccAcquireEngine(B_2D_ACCELERATION, 0xff, &fSyncToken, &fEngineToken) >= B_OK) {
|
||||||
|
|
||||||
|
// make sure the blit_params cache is large enough
|
||||||
|
if (fBlitParamsCount < count) {
|
||||||
|
fBlitParamsCount = (count / kDefaultParamsCount + 1) * kDefaultParamsCount;
|
||||||
|
// NOTE: realloc() could be used instead...
|
||||||
|
blit_params* params = new (nothrow) blit_params[fBlitParamsCount];
|
||||||
|
if (params) {
|
||||||
|
delete[] fBlitParams;
|
||||||
|
fBlitParams = params;
|
||||||
|
} else {
|
||||||
|
count = fBlitParamsCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
// convert the rects
|
// convert the rects
|
||||||
blit_params* params = new blit_params[count];
|
|
||||||
for (uint32 i = 0; i < count; i++) {
|
for (uint32 i = 0; i < count; i++) {
|
||||||
params[i].src_left = (uint16)sortedRectList[i].left + fXOffset;
|
fBlitParams[i].src_left = (uint16)sortedRectList[i].left + fXOffset;
|
||||||
params[i].src_top = (uint16)sortedRectList[i].top + fYOffset;
|
fBlitParams[i].src_top = (uint16)sortedRectList[i].top + fYOffset;
|
||||||
|
|
||||||
params[i].dest_left = (uint16)sortedRectList[i].left + xOffset + fXOffset;
|
fBlitParams[i].dest_left = (uint16)sortedRectList[i].left + xOffset + fXOffset;
|
||||||
params[i].dest_top = (uint16)sortedRectList[i].top + yOffset + fYOffset;
|
fBlitParams[i].dest_top = (uint16)sortedRectList[i].top + yOffset + fYOffset;
|
||||||
|
|
||||||
// NOTE: width and height are expressed as distance, not pixel count!
|
// NOTE: width and height are expressed as distance, not pixel count!
|
||||||
params[i].width = (uint16)(sortedRectList[i].right - sortedRectList[i].left);
|
fBlitParams[i].width = (uint16)(sortedRectList[i].right - sortedRectList[i].left);
|
||||||
params[i].height = (uint16)(sortedRectList[i].bottom - sortedRectList[i].top);
|
fBlitParams[i].height = (uint16)(sortedRectList[i].bottom - sortedRectList[i].top);
|
||||||
}
|
}
|
||||||
|
|
||||||
// go
|
// go
|
||||||
fAccScreenBlit(fEngineToken, params, count);
|
fAccScreenBlit(fEngineToken, fBlitParams, count);
|
||||||
|
|
||||||
// done
|
// done
|
||||||
if (fAccReleaseEngine)
|
if (fAccReleaseEngine)
|
||||||
@ -913,8 +938,6 @@ DWindowHWInterface::CopyRegion(const clipping_rect* sortedRectList,
|
|||||||
// sync
|
// sync
|
||||||
if (fAccSyncToToken)
|
if (fAccSyncToToken)
|
||||||
fAccSyncToToken(&fSyncToken);
|
fAccSyncToToken(&fSyncToken);
|
||||||
|
|
||||||
delete[] params;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -928,11 +951,10 @@ DWindowHWInterface::FillRegion(/*const*/ BRegion& region, const RGBColor& color)
|
|||||||
|
|
||||||
// convert the region
|
// convert the region
|
||||||
uint32 count;
|
uint32 count;
|
||||||
fill_rect_params* fillParams;
|
_RegionToRectParams(®ion, &count);
|
||||||
_RegionToRectParams(®ion, &fillParams, &count);
|
|
||||||
|
|
||||||
// go
|
// go
|
||||||
fAccFillRect(fEngineToken, _NativeColor(color), fillParams, count);
|
fAccFillRect(fEngineToken, _NativeColor(color), fRectParams, count);
|
||||||
|
|
||||||
// done
|
// done
|
||||||
if (fAccReleaseEngine)
|
if (fAccReleaseEngine)
|
||||||
@ -941,8 +963,6 @@ DWindowHWInterface::FillRegion(/*const*/ BRegion& region, const RGBColor& color)
|
|||||||
// sync
|
// sync
|
||||||
if (fAccSyncToToken)
|
if (fAccSyncToToken)
|
||||||
fAccSyncToToken(&fSyncToken);
|
fAccSyncToToken(&fSyncToken);
|
||||||
|
|
||||||
delete[] fillParams;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -956,11 +976,10 @@ DWindowHWInterface::InvertRegion(/*const*/ BRegion& region)
|
|||||||
|
|
||||||
// convert the region
|
// convert the region
|
||||||
uint32 count;
|
uint32 count;
|
||||||
fill_rect_params* fillParams;
|
_RegionToRectParams(®ion, &count);
|
||||||
_RegionToRectParams(®ion, &fillParams, &count);
|
|
||||||
|
|
||||||
// go
|
// go
|
||||||
fAccInvertRect(fEngineToken, fillParams, count);
|
fAccInvertRect(fEngineToken, fRectParams, count);
|
||||||
|
|
||||||
// done
|
// done
|
||||||
if (fAccReleaseEngine)
|
if (fAccReleaseEngine)
|
||||||
@ -970,7 +989,6 @@ DWindowHWInterface::InvertRegion(/*const*/ BRegion& region)
|
|||||||
if (fAccSyncToToken)
|
if (fAccSyncToToken)
|
||||||
fAccSyncToToken(&fSyncToken);
|
fAccSyncToToken(&fSyncToken);
|
||||||
|
|
||||||
delete[] fillParams;
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "AcquireEngine failed!\n");
|
fprintf(stderr, "AcquireEngine failed!\n");
|
||||||
}
|
}
|
||||||
@ -1027,18 +1045,27 @@ DWindowHWInterface::SetOffset(int32 left, int32 top)
|
|||||||
// _RegionToRectParams
|
// _RegionToRectParams
|
||||||
void
|
void
|
||||||
DWindowHWInterface::_RegionToRectParams(/*const*/ BRegion* region,
|
DWindowHWInterface::_RegionToRectParams(/*const*/ BRegion* region,
|
||||||
fill_rect_params** params,
|
|
||||||
uint32* count) const
|
uint32* count) const
|
||||||
{
|
{
|
||||||
*count = region->CountRects();
|
*count = region->CountRects();
|
||||||
*params = new fill_rect_params[*count];
|
if (fRectParamsCount < *count) {
|
||||||
|
fRectParamsCount = (*count / kDefaultParamsCount + 1) * kDefaultParamsCount;
|
||||||
|
// NOTE: realloc() could be used instead...
|
||||||
|
fill_rect_params* params = new (nothrow) fill_rect_params[fRectParamsCount];
|
||||||
|
if (params) {
|
||||||
|
delete[] fRectParams;
|
||||||
|
fRectParams = params;
|
||||||
|
} else {
|
||||||
|
*count = fRectParamsCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (uint32 i = 0; i < *count; i++) {
|
for (uint32 i = 0; i < *count; i++) {
|
||||||
clipping_rect r = region->RectAtInt(i);
|
clipping_rect r = region->RectAtInt(i);
|
||||||
(*params)[i].left = (uint16)(r.left + fXOffset);
|
fRectParams[i].left = (uint16)r.left + fXOffset;
|
||||||
(*params)[i].top = (uint16)(r.top + fYOffset);
|
fRectParams[i].top = (uint16)r.top + fYOffset;
|
||||||
(*params)[i].right = (uint16)(r.right + fXOffset);
|
fRectParams[i].right = (uint16)r.right + fXOffset;
|
||||||
(*params)[i].bottom = (uint16)(r.bottom + fYOffset);
|
fRectParams[i].bottom = (uint16)r.bottom + fYOffset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,6 @@ class DWindowHWInterface : public HWInterface {
|
|||||||
status_t _UpdateFrameBufferConfig();
|
status_t _UpdateFrameBufferConfig();
|
||||||
|
|
||||||
void _RegionToRectParams(/*const*/ BRegion* region,
|
void _RegionToRectParams(/*const*/ BRegion* region,
|
||||||
fill_rect_params** params,
|
|
||||||
uint32* count) const;
|
uint32* count) const;
|
||||||
uint32 _NativeColor(const RGBColor& color) const;
|
uint32 _NativeColor(const RGBColor& color) const;
|
||||||
|
|
||||||
@ -124,6 +123,11 @@ class DWindowHWInterface : public HWInterface {
|
|||||||
frame_buffer_config fFrameBufferConfig;
|
frame_buffer_config fFrameBufferConfig;
|
||||||
|
|
||||||
BString fCardNameInDevFS;
|
BString fCardNameInDevFS;
|
||||||
|
|
||||||
|
mutable fill_rect_params* fRectParams;
|
||||||
|
mutable uint32 fRectParamsCount;
|
||||||
|
mutable blit_params* fBlitParams;
|
||||||
|
mutable uint32 fBlitParamsCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // D_WINDOW_HW_INTERACE_H
|
#endif // D_WINDOW_HW_INTERACE_H
|
||||||
|
@ -549,8 +549,15 @@ DrawingEngine::DrawPolygon(BPoint* ptlist, int32 numpts,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// StrokeRect
|
// #pragma mark - RGBColor
|
||||||
//
|
|
||||||
|
void
|
||||||
|
DrawingEngine::StrokePoint(const BPoint& pt, const RGBColor &color)
|
||||||
|
{
|
||||||
|
StrokeLine(pt, pt, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// this function is used to draw a one pixel wide rect
|
// this function is used to draw a one pixel wide rect
|
||||||
void
|
void
|
||||||
DrawingEngine::StrokeRect(BRect r, const RGBColor &color)
|
DrawingEngine::StrokeRect(BRect r, const RGBColor &color)
|
||||||
@ -578,7 +585,7 @@ DrawingEngine::StrokeRect(BRect r, const RGBColor &color)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FillRect
|
|
||||||
void
|
void
|
||||||
DrawingEngine::FillRect(BRect r, const RGBColor& color)
|
DrawingEngine::FillRect(BRect r, const RGBColor& color)
|
||||||
{
|
{
|
||||||
@ -609,7 +616,42 @@ DrawingEngine::FillRect(BRect r, const RGBColor& color)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// StrokeRect
|
|
||||||
|
void
|
||||||
|
DrawingEngine::FillRegion(BRegion& r, const RGBColor& color)
|
||||||
|
{
|
||||||
|
// NOTE: Write locking because we might use HW acceleration.
|
||||||
|
// This needs to be investigated, I'm doing this because of
|
||||||
|
// gut feeling.
|
||||||
|
// NOTE: region expected to be already clipped correctly!!
|
||||||
|
if (WriteLock()) {
|
||||||
|
fGraphicsCard->HideSoftwareCursor(r.Frame());
|
||||||
|
|
||||||
|
bool doInSoftware = true;
|
||||||
|
// try hardware optimized version first
|
||||||
|
if ((fAvailableHWAccleration & HW_ACC_FILL_REGION) != 0) {
|
||||||
|
fGraphicsCard->FillRegion(r, color);
|
||||||
|
doInSoftware = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doInSoftware) {
|
||||||
|
|
||||||
|
int32 count = r.CountRects();
|
||||||
|
for (int32 i = 0; i < count; i++) {
|
||||||
|
fPainter->FillRectNoClipping(r.RectAt(i), color.GetColor32());
|
||||||
|
}
|
||||||
|
|
||||||
|
fGraphicsCard->Invalidate(r.Frame());
|
||||||
|
}
|
||||||
|
|
||||||
|
fGraphicsCard->ShowSoftwareCursor();
|
||||||
|
|
||||||
|
WriteUnlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// #pragma mark - DrawState
|
||||||
|
|
||||||
void
|
void
|
||||||
DrawingEngine::StrokeRect(BRect r, const DrawState *d)
|
DrawingEngine::StrokeRect(BRect r, const DrawState *d)
|
||||||
{
|
{
|
||||||
@ -634,7 +676,7 @@ DrawingEngine::StrokeRect(BRect r, const DrawState *d)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FillRect
|
|
||||||
void
|
void
|
||||||
DrawingEngine::FillRect(BRect r, const DrawState *d)
|
DrawingEngine::FillRect(BRect r, const DrawState *d)
|
||||||
{
|
{
|
||||||
@ -648,20 +690,24 @@ DrawingEngine::FillRect(BRect r, const DrawState *d)
|
|||||||
fGraphicsCard->HideSoftwareCursor(r);
|
fGraphicsCard->HideSoftwareCursor(r);
|
||||||
|
|
||||||
bool doInSoftware = true;
|
bool doInSoftware = true;
|
||||||
// try hardware optimized version first
|
if ((r.Width() + 1) * (r.Height() + 1) > 100.0) {
|
||||||
if ((fAvailableHWAccleration & HW_ACC_FILL_REGION) != 0
|
// try hardware optimized version first
|
||||||
&& (d->GetDrawingMode() == B_OP_COPY
|
// if the rect is large enough
|
||||||
|| d->GetDrawingMode() == B_OP_OVER)) {
|
if ((fAvailableHWAccleration & HW_ACC_FILL_REGION) != 0) {
|
||||||
if (d->GetPattern() == B_SOLID_HIGH) {
|
if (d->GetPattern() == B_SOLID_HIGH
|
||||||
BRegion region(r);
|
&& (d->GetDrawingMode() == B_OP_COPY
|
||||||
region.IntersectWith(fPainter->ClippingRegion());
|
|| d->GetDrawingMode() == B_OP_OVER)) {
|
||||||
fGraphicsCard->FillRegion(region, d->HighColor());
|
BRegion region(r);
|
||||||
doInSoftware = false;
|
region.IntersectWith(fPainter->ClippingRegion());
|
||||||
} else if (d->GetPattern() == B_SOLID_LOW) {
|
fGraphicsCard->FillRegion(region, d->HighColor());
|
||||||
BRegion region(r);
|
doInSoftware = false;
|
||||||
region.IntersectWith(fPainter->ClippingRegion());
|
} else if (d->GetPattern() == B_SOLID_LOW
|
||||||
fGraphicsCard->FillRegion(region, d->LowColor());
|
&& d->GetDrawingMode() == B_OP_COPY) {
|
||||||
doInSoftware = false;
|
BRegion region(r);
|
||||||
|
region.IntersectWith(fPainter->ClippingRegion());
|
||||||
|
fGraphicsCard->FillRegion(region, d->LowColor());
|
||||||
|
doInSoftware = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (doInSoftware) {
|
if (doInSoftware) {
|
||||||
@ -677,36 +723,8 @@ DrawingEngine::FillRect(BRect r, const DrawState *d)
|
|||||||
WriteUnlock();
|
WriteUnlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
// StrokeRegion
|
|
||||||
void
|
|
||||||
DrawingEngine::StrokeRegion(BRegion& r, const DrawState *d)
|
|
||||||
{
|
|
||||||
if (Lock()) {
|
|
||||||
BRect clipped(r.Frame());
|
|
||||||
extend_by_stroke_width(clipped, d);
|
|
||||||
clipped = fPainter->ClipRect(clipped);
|
|
||||||
if (clipped.IsValid()) {
|
|
||||||
fGraphicsCard->HideSoftwareCursor(clipped);
|
|
||||||
|
|
||||||
fPainter->SetDrawState(d);
|
|
||||||
|
|
||||||
BRect touched = fPainter->StrokeRect(r.RectAt(0));
|
|
||||||
|
|
||||||
int32 count = r.CountRects();
|
|
||||||
for (int32 i = 1; i < count; i++) {
|
|
||||||
touched = touched | fPainter->StrokeRect(r.RectAt(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
fGraphicsCard->Invalidate(touched);
|
|
||||||
fGraphicsCard->ShowSoftwareCursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
Unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// FillRegion
|
|
||||||
void
|
void
|
||||||
DrawingEngine::FillRegion(BRegion& r, const DrawState *d)
|
DrawingEngine::FillRegion(BRegion& r, const DrawState *d)
|
||||||
{
|
{
|
||||||
@ -720,14 +738,15 @@ DrawingEngine::FillRegion(BRegion& r, const DrawState *d)
|
|||||||
|
|
||||||
bool doInSoftware = true;
|
bool doInSoftware = true;
|
||||||
// try hardware optimized version first
|
// try hardware optimized version first
|
||||||
if ((fAvailableHWAccleration & HW_ACC_FILL_REGION) != 0
|
if ((fAvailableHWAccleration & HW_ACC_FILL_REGION) != 0) {
|
||||||
&& (d->GetDrawingMode() == B_OP_COPY
|
if (d->GetPattern() == B_SOLID_HIGH
|
||||||
|| d->GetDrawingMode() == B_OP_OVER)) {
|
&& (d->GetDrawingMode() == B_OP_COPY
|
||||||
if (d->GetPattern() == B_SOLID_HIGH) {
|
|| d->GetDrawingMode() == B_OP_OVER)) {
|
||||||
r.IntersectWith(fPainter->ClippingRegion());
|
r.IntersectWith(fPainter->ClippingRegion());
|
||||||
fGraphicsCard->FillRegion(r, d->HighColor());
|
fGraphicsCard->FillRegion(r, d->HighColor());
|
||||||
doInSoftware = false;
|
doInSoftware = false;
|
||||||
} else if (d->GetPattern() == B_SOLID_LOW) {
|
} else if (d->GetPattern() == B_SOLID_LOW
|
||||||
|
&& d->GetDrawingMode() == B_OP_COPY) {
|
||||||
r.IntersectWith(fPainter->ClippingRegion());
|
r.IntersectWith(fPainter->ClippingRegion());
|
||||||
fGraphicsCard->FillRegion(r, d->LowColor());
|
fGraphicsCard->FillRegion(r, d->LowColor());
|
||||||
doInSoftware = false;
|
doInSoftware = false;
|
||||||
@ -755,42 +774,6 @@ DrawingEngine::FillRegion(BRegion& r, const DrawState *d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// FillRegion
|
|
||||||
void
|
|
||||||
DrawingEngine::FillRegion(BRegion& r, const RGBColor& color)
|
|
||||||
{
|
|
||||||
// NOTE: Write locking because we might use HW acceleration.
|
|
||||||
// This needs to be investigated, I'm doing this because of
|
|
||||||
// gut feeling.
|
|
||||||
// NOTE: region expected to be already clipped correctly!!
|
|
||||||
if (WriteLock()) {
|
|
||||||
fGraphicsCard->HideSoftwareCursor(r.Frame());
|
|
||||||
|
|
||||||
bool doInSoftware = true;
|
|
||||||
// try hardware optimized version first
|
|
||||||
if ((fAvailableHWAccleration & HW_ACC_FILL_REGION) != 0) {
|
|
||||||
fGraphicsCard->FillRegion(r, color);
|
|
||||||
doInSoftware = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doInSoftware) {
|
|
||||||
|
|
||||||
int32 count = r.CountRects();
|
|
||||||
for (int32 i = 0; i < count; i++) {
|
|
||||||
fPainter->FillRectNoClipping(r.RectAt(i), color.GetColor32());
|
|
||||||
}
|
|
||||||
BRect touched = r.Frame();
|
|
||||||
|
|
||||||
fGraphicsCard->Invalidate(touched);
|
|
||||||
}
|
|
||||||
|
|
||||||
fGraphicsCard->ShowSoftwareCursor();
|
|
||||||
|
|
||||||
WriteUnlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DrawingEngine::DrawRoundRect(BRect r, float xrad, float yrad,
|
DrawingEngine::DrawRoundRect(BRect r, float xrad, float yrad,
|
||||||
const DrawState* d, bool filled)
|
const DrawState* d, bool filled)
|
||||||
@ -970,25 +953,8 @@ DrawingEngine::StrokeLineArray(int32 numLines,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// StrokePoint
|
|
||||||
//
|
|
||||||
// * this function is only used by Decorators
|
|
||||||
void
|
|
||||||
DrawingEngine::StrokePoint(const BPoint& pt, const RGBColor &color)
|
|
||||||
{
|
|
||||||
StrokeLine(pt, pt, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
// StrokePoint
|
|
||||||
void
|
|
||||||
DrawingEngine::StrokePoint(const BPoint& pt, DrawState *context)
|
|
||||||
{
|
|
||||||
StrokeLine(pt, pt, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
// DrawString
|
|
||||||
BPoint
|
BPoint
|
||||||
DrawingEngine::DrawString(const char* string, int32 length,
|
DrawingEngine::DrawString(const char* string, int32 length,
|
||||||
const BPoint& pt, DrawState* d,
|
const BPoint& pt, DrawState* d,
|
||||||
|
Loading…
Reference in New Issue
Block a user