* Adopt the code to handle the case that even a HWInterface instance with
hardware accelerated functions could be double buffered. * Align the rectangle used for arc drawing like those for ellipsis. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26544 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -526,8 +526,11 @@ DrawingEngine::CopyRegion(/*const*/ BRegion* region,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// trigger the HW accelerated version if is was available
|
// trigger the HW accelerated version if is was available
|
||||||
if (sortedRectList)
|
if (sortedRectList) {
|
||||||
fGraphicsCard->CopyRegion(sortedRectList, count, xOffset, yOffset);
|
fGraphicsCard->CopyRegion(sortedRectList, count, xOffset, yOffset);
|
||||||
|
if (fGraphicsCard->IsDoubleBuffered())
|
||||||
|
fGraphicsCard->Invalidate(region->Frame());
|
||||||
|
}
|
||||||
|
|
||||||
delete[] sortedRectList;
|
delete[] sortedRectList;
|
||||||
}
|
}
|
||||||
@@ -540,19 +543,21 @@ DrawingEngine::InvertRect(BRect r)
|
|||||||
|
|
||||||
make_rect_valid(r);
|
make_rect_valid(r);
|
||||||
r = fPainter->ClipRect(r);
|
r = fPainter->ClipRect(r);
|
||||||
if (r.IsValid()) {
|
if (!r.IsValid())
|
||||||
AutoFloatingOverlaysHider _(fGraphicsCard, r);
|
return;
|
||||||
|
|
||||||
// try hardware optimized version first
|
AutoFloatingOverlaysHider _(fGraphicsCard, r);
|
||||||
if (fAvailableHWAccleration & HW_ACC_INVERT_REGION) {
|
|
||||||
BRegion region(r);
|
|
||||||
region.IntersectWith(fPainter->ClippingRegion());
|
|
||||||
fGraphicsCard->InvertRegion(region);
|
|
||||||
} else {
|
|
||||||
fPainter->InvertRect(r);
|
|
||||||
|
|
||||||
|
// try hardware optimized version first
|
||||||
|
if (fAvailableHWAccleration & HW_ACC_INVERT_REGION) {
|
||||||
|
BRegion region(r);
|
||||||
|
region.IntersectWith(fPainter->ClippingRegion());
|
||||||
|
fGraphicsCard->InvertRegion(region);
|
||||||
|
if (fGraphicsCard->IsDoubleBuffered())
|
||||||
_CopyToFront(r);
|
_CopyToFront(r);
|
||||||
}
|
} else {
|
||||||
|
fPainter->InvertRect(r);
|
||||||
|
_CopyToFront(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -575,16 +580,20 @@ DrawingEngine::DrawBitmap(ServerBitmap *bitmap,
|
|||||||
|
|
||||||
// DrawArc
|
// DrawArc
|
||||||
void
|
void
|
||||||
DrawingEngine::DrawArc(BRect r, const float &angle,
|
DrawingEngine::DrawArc(BRect r, const float &angle, const float &span,
|
||||||
const float &span, bool filled)
|
bool filled)
|
||||||
{
|
{
|
||||||
CRASH_IF_NOT_LOCKED
|
CRASH_IF_NOT_LOCKED
|
||||||
|
|
||||||
make_rect_valid(r);
|
make_rect_valid(r);
|
||||||
|
fPainter->AlignEllipseRect(&r, filled);
|
||||||
BRect clipped(r);
|
BRect clipped(r);
|
||||||
|
|
||||||
if (!filled)
|
if (!filled)
|
||||||
extend_by_stroke_width(clipped, fPainter->PenSize());
|
extend_by_stroke_width(clipped, fPainter->PenSize());
|
||||||
|
|
||||||
clipped = fPainter->ClipRect(r);
|
clipped = fPainter->ClipRect(r);
|
||||||
|
|
||||||
if (clipped.IsValid()) {
|
if (clipped.IsValid()) {
|
||||||
AutoFloatingOverlaysHider _(fGraphicsCard, clipped);
|
AutoFloatingOverlaysHider _(fGraphicsCard, clipped);
|
||||||
|
|
||||||
@@ -731,21 +740,23 @@ DrawingEngine::FillRect(BRect r, const rgb_color& color)
|
|||||||
// gut feeling.
|
// gut feeling.
|
||||||
make_rect_valid(r);
|
make_rect_valid(r);
|
||||||
r = fPainter->ClipRect(r);
|
r = fPainter->ClipRect(r);
|
||||||
if (r.IsValid()) {
|
if (!r.IsValid())
|
||||||
AutoFloatingOverlaysHider overlaysHider(fGraphicsCard, r);
|
return;
|
||||||
|
|
||||||
// try hardware optimized version first
|
AutoFloatingOverlaysHider overlaysHider(fGraphicsCard, r);
|
||||||
if (fAvailableHWAccleration & HW_ACC_FILL_REGION) {
|
|
||||||
BRegion region(r);
|
|
||||||
region.IntersectWith(fPainter->ClippingRegion());
|
|
||||||
fGraphicsCard->FillRegion(region, color,
|
|
||||||
fSuspendSyncLevel == 0
|
|
||||||
|| overlaysHider.WasHidden());
|
|
||||||
} else {
|
|
||||||
fPainter->FillRect(r, color);
|
|
||||||
|
|
||||||
|
// try hardware optimized version first
|
||||||
|
if (fAvailableHWAccleration & HW_ACC_FILL_REGION) {
|
||||||
|
BRegion region(r);
|
||||||
|
region.IntersectWith(fPainter->ClippingRegion());
|
||||||
|
fGraphicsCard->FillRegion(region, color,
|
||||||
|
fSuspendSyncLevel == 0 || overlaysHider.WasHidden());
|
||||||
|
|
||||||
|
if (fGraphicsCard->IsDoubleBuffered())
|
||||||
_CopyToFront(r);
|
_CopyToFront(r);
|
||||||
}
|
} else {
|
||||||
|
fPainter->FillRect(r, color);
|
||||||
|
_CopyToFront(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -778,11 +789,12 @@ DrawingEngine::FillRegion(BRegion& r, const rgb_color& color)
|
|||||||
&& frame.Width() * frame.Height() > 100) {
|
&& frame.Width() * frame.Height() > 100) {
|
||||||
fGraphicsCard->FillRegion(r, color, fSuspendSyncLevel == 0
|
fGraphicsCard->FillRegion(r, color, fSuspendSyncLevel == 0
|
||||||
|| overlaysHider.WasHidden());
|
|| overlaysHider.WasHidden());
|
||||||
|
if (fGraphicsCard->IsDoubleBuffered())
|
||||||
|
_CopyToFront(frame);
|
||||||
} else {
|
} else {
|
||||||
int32 count = r.CountRects();
|
int32 count = r.CountRects();
|
||||||
for (int32 i = 0; i < count; i++) {
|
for (int32 i = 0; i < count; i++)
|
||||||
fPainter->FillRectNoClipping(r.RectAtInt(i), color);
|
fPainter->FillRectNoClipping(r.RectAtInt(i), color);
|
||||||
}
|
|
||||||
|
|
||||||
_CopyToFront(frame);
|
_CopyToFront(frame);
|
||||||
}
|
}
|
||||||
@@ -817,50 +829,51 @@ DrawingEngine::FillRect(BRect r)
|
|||||||
|
|
||||||
make_rect_valid(r);
|
make_rect_valid(r);
|
||||||
r = fPainter->AlignAndClipRect(r);
|
r = fPainter->AlignAndClipRect(r);
|
||||||
if (r.IsValid()) {
|
if (!r.IsValid())
|
||||||
AutoFloatingOverlaysHider overlaysHider(fGraphicsCard, r);
|
return;
|
||||||
|
|
||||||
bool doInSoftware = true;
|
AutoFloatingOverlaysHider overlaysHider(fGraphicsCard, r);
|
||||||
if ((r.Width() + 1) * (r.Height() + 1) > 100.0) {
|
|
||||||
// try hardware optimized version first
|
bool doInSoftware = true;
|
||||||
// if the rect is large enough
|
if ((r.Width() + 1) * (r.Height() + 1) > 100.0) {
|
||||||
if ((fAvailableHWAccleration & HW_ACC_FILL_REGION) != 0) {
|
// try hardware optimized version first
|
||||||
if (fPainter->Pattern() == B_SOLID_HIGH
|
// if the rect is large enough
|
||||||
&& (fPainter->DrawingMode() == B_OP_COPY
|
if ((fAvailableHWAccleration & HW_ACC_FILL_REGION) != 0) {
|
||||||
|| fPainter->DrawingMode() == B_OP_OVER)) {
|
if (fPainter->Pattern() == B_SOLID_HIGH
|
||||||
BRegion region(r);
|
&& (fPainter->DrawingMode() == B_OP_COPY
|
||||||
region.IntersectWith(fPainter->ClippingRegion());
|
|| fPainter->DrawingMode() == B_OP_OVER)) {
|
||||||
fGraphicsCard->FillRegion(region, fPainter->HighColor(),
|
BRegion region(r);
|
||||||
fSuspendSyncLevel == 0
|
region.IntersectWith(fPainter->ClippingRegion());
|
||||||
|| overlaysHider.WasHidden());
|
fGraphicsCard->FillRegion(region, fPainter->HighColor(),
|
||||||
doInSoftware = false;
|
fSuspendSyncLevel == 0
|
||||||
} else if (fPainter->Pattern() == B_SOLID_LOW
|
|| overlaysHider.WasHidden());
|
||||||
&& fPainter->DrawingMode() == B_OP_COPY) {
|
doInSoftware = false;
|
||||||
BRegion region(r);
|
} else if (fPainter->Pattern() == B_SOLID_LOW
|
||||||
region.IntersectWith(fPainter->ClippingRegion());
|
&& fPainter->DrawingMode() == B_OP_COPY) {
|
||||||
fGraphicsCard->FillRegion(region, fPainter->LowColor(),
|
BRegion region(r);
|
||||||
fSuspendSyncLevel == 0
|
region.IntersectWith(fPainter->ClippingRegion());
|
||||||
|| overlaysHider.WasHidden());
|
fGraphicsCard->FillRegion(region, fPainter->LowColor(),
|
||||||
doInSoftware = false;
|
fSuspendSyncLevel == 0
|
||||||
}
|
|| overlaysHider.WasHidden());
|
||||||
|
doInSoftware = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doInSoftware && fAvailableHWAccleration & HW_ACC_INVERT_REGION
|
|
||||||
&& fPainter->Pattern() == B_SOLID_HIGH
|
|
||||||
&& fPainter->DrawingMode() == B_OP_INVERT) {
|
|
||||||
BRegion region(r);
|
|
||||||
region.IntersectWith(fPainter->ClippingRegion());
|
|
||||||
fGraphicsCard->InvertRegion(region);
|
|
||||||
doInSoftware = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doInSoftware) {
|
|
||||||
fPainter->FillRect(r);
|
|
||||||
|
|
||||||
_CopyToFront(r);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (doInSoftware && fAvailableHWAccleration & HW_ACC_INVERT_REGION
|
||||||
|
&& fPainter->Pattern() == B_SOLID_HIGH
|
||||||
|
&& fPainter->DrawingMode() == B_OP_INVERT) {
|
||||||
|
BRegion region(r);
|
||||||
|
region.IntersectWith(fPainter->ClippingRegion());
|
||||||
|
fGraphicsCard->InvertRegion(region);
|
||||||
|
doInSoftware = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doInSoftware)
|
||||||
|
fPainter->FillRect(r);
|
||||||
|
|
||||||
|
if (fGraphicsCard->IsDoubleBuffered())
|
||||||
|
_CopyToFront(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -870,50 +883,51 @@ DrawingEngine::FillRegion(BRegion& r)
|
|||||||
CRASH_IF_NOT_LOCKED
|
CRASH_IF_NOT_LOCKED
|
||||||
|
|
||||||
BRect clipped = fPainter->ClipRect(r.Frame());
|
BRect clipped = fPainter->ClipRect(r.Frame());
|
||||||
if (clipped.IsValid()) {
|
if (!clipped.IsValid())
|
||||||
AutoFloatingOverlaysHider overlaysHider(fGraphicsCard, clipped);
|
return;
|
||||||
|
|
||||||
bool doInSoftware = true;
|
AutoFloatingOverlaysHider overlaysHider(fGraphicsCard, clipped);
|
||||||
// try hardware optimized version first
|
|
||||||
if ((fAvailableHWAccleration & HW_ACC_FILL_REGION) != 0) {
|
|
||||||
if (fPainter->Pattern() == B_SOLID_HIGH
|
|
||||||
&& (fPainter->DrawingMode() == B_OP_COPY
|
|
||||||
|| fPainter->DrawingMode() == B_OP_OVER)) {
|
|
||||||
r.IntersectWith(fPainter->ClippingRegion());
|
|
||||||
fGraphicsCard->FillRegion(r, fPainter->HighColor(),
|
|
||||||
fSuspendSyncLevel == 0
|
|
||||||
|| overlaysHider.WasHidden());
|
|
||||||
doInSoftware = false;
|
|
||||||
} else if (fPainter->Pattern() == B_SOLID_LOW
|
|
||||||
&& fPainter->DrawingMode() == B_OP_COPY) {
|
|
||||||
r.IntersectWith(fPainter->ClippingRegion());
|
|
||||||
fGraphicsCard->FillRegion(r, fPainter->LowColor(),
|
|
||||||
fSuspendSyncLevel == 0
|
|
||||||
|| overlaysHider.WasHidden());
|
|
||||||
doInSoftware = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doInSoftware && fAvailableHWAccleration & HW_ACC_INVERT_REGION
|
bool doInSoftware = true;
|
||||||
&& fPainter->Pattern() == B_SOLID_HIGH
|
// try hardware optimized version first
|
||||||
&& fPainter->DrawingMode() == B_OP_INVERT) {
|
if ((fAvailableHWAccleration & HW_ACC_FILL_REGION) != 0) {
|
||||||
|
if (fPainter->Pattern() == B_SOLID_HIGH
|
||||||
|
&& (fPainter->DrawingMode() == B_OP_COPY
|
||||||
|
|| fPainter->DrawingMode() == B_OP_OVER)) {
|
||||||
r.IntersectWith(fPainter->ClippingRegion());
|
r.IntersectWith(fPainter->ClippingRegion());
|
||||||
fGraphicsCard->InvertRegion(r);
|
fGraphicsCard->FillRegion(r, fPainter->HighColor(),
|
||||||
|
fSuspendSyncLevel == 0
|
||||||
|
|| overlaysHider.WasHidden());
|
||||||
|
doInSoftware = false;
|
||||||
|
} else if (fPainter->Pattern() == B_SOLID_LOW
|
||||||
|
&& fPainter->DrawingMode() == B_OP_COPY) {
|
||||||
|
r.IntersectWith(fPainter->ClippingRegion());
|
||||||
|
fGraphicsCard->FillRegion(r, fPainter->LowColor(),
|
||||||
|
fSuspendSyncLevel == 0
|
||||||
|
|| overlaysHider.WasHidden());
|
||||||
doInSoftware = false;
|
doInSoftware = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doInSoftware) {
|
|
||||||
|
|
||||||
BRect touched = fPainter->FillRect(r.RectAt(0));
|
|
||||||
|
|
||||||
int32 count = r.CountRects();
|
|
||||||
for (int32 i = 1; i < count; i++) {
|
|
||||||
touched = touched | fPainter->FillRect(r.RectAt(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
_CopyToFront(touched);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (doInSoftware && fAvailableHWAccleration & HW_ACC_INVERT_REGION
|
||||||
|
&& fPainter->Pattern() == B_SOLID_HIGH
|
||||||
|
&& fPainter->DrawingMode() == B_OP_INVERT) {
|
||||||
|
r.IntersectWith(fPainter->ClippingRegion());
|
||||||
|
fGraphicsCard->InvertRegion(r);
|
||||||
|
doInSoftware = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doInSoftware) {
|
||||||
|
|
||||||
|
BRect touched = fPainter->FillRect(r.RectAt(0));
|
||||||
|
|
||||||
|
int32 count = r.CountRects();
|
||||||
|
for (int32 i = 1; i < count; i++)
|
||||||
|
touched = touched | fPainter->FillRect(r.RectAt(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fGraphicsCard->IsDoubleBuffered())
|
||||||
|
_CopyToFront(r.Frame());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user