Fix handling of filled rectangles with transforms.

The DrawingEngine didn't properly make a distinction between the
rectangle being filled and the damaged region on screen. This led to
unexpected results when using BAffineTransform.
This commit is contained in:
Adrien Destugues
2014-05-19 14:18:56 +02:00
parent 66bce8233a
commit 79eb23a82d
+26 -8
View File
@@ -963,13 +963,24 @@ DrawingEngine::FillRect(BRect r)
ASSERT_PARALLEL_LOCKED(); ASSERT_PARALLEL_LOCKED();
make_rect_valid(r); make_rect_valid(r);
r = fPainter->TransformAlignAndClipRect(r); r.left = floorf(r.left);
if (!r.IsValid()) r.top = floorf(r.top);
r.right = ceilf(r.right);
r.bottom = ceilf(r.bottom);
BRect dirty = fPainter->TransformAndClipRect(r);
if (!dirty.IsValid())
return; return;
AutoFloatingOverlaysHider overlaysHider(fGraphicsCard, r); AutoFloatingOverlaysHider overlaysHider(fGraphicsCard, r);
bool doInSoftware = true; bool doInSoftware = true;
if (fPainter->IsIdentityTransform())
{
// TODO the accelerated code path may also be used for transforms that
// only scale and translate (but don't shear or rotate).
if ((r.Width() + 1) * (r.Height() + 1) > 100.0) { if ((r.Width() + 1) * (r.Height() + 1) > 100.0) {
// try hardware optimized version first // try hardware optimized version first
// if the rect is large enough // if the rect is large enough
@@ -993,7 +1004,8 @@ DrawingEngine::FillRect(BRect r)
} }
} }
if (doInSoftware && (fAvailableHWAccleration & HW_ACC_INVERT_REGION) != 0 if (doInSoftware
&& (fAvailableHWAccleration & HW_ACC_INVERT_REGION) != 0
&& fPainter->Pattern() == B_SOLID_HIGH && fPainter->Pattern() == B_SOLID_HIGH
&& fPainter->DrawingMode() == B_OP_INVERT) { && fPainter->DrawingMode() == B_OP_INVERT) {
BRegion region(r); BRegion region(r);
@@ -1001,11 +1013,12 @@ DrawingEngine::FillRect(BRect r)
fGraphicsCard->InvertRegion(region); fGraphicsCard->InvertRegion(region);
doInSoftware = false; doInSoftware = false;
} }
}
if (doInSoftware) if (doInSoftware)
fPainter->FillRect(r); fPainter->FillRect(r);
_CopyToFront(r); _CopyToFront(dirty);
} }
@@ -1015,15 +1028,20 @@ DrawingEngine::FillRect(BRect r, const BGradient& gradient)
ASSERT_PARALLEL_LOCKED(); ASSERT_PARALLEL_LOCKED();
make_rect_valid(r); make_rect_valid(r);
r = fPainter->TransformAlignAndClipRect(r); r.left = floorf(r.left);
if (!r.IsValid()) r.top = floorf(r.top);
r.right = ceilf(r.right);
r.bottom = ceilf(r.bottom);
BRect dirty = fPainter->TransformAndClipRect(r);
if (!dirty.IsValid())
return; return;
AutoFloatingOverlaysHider overlaysHider(fGraphicsCard, r); AutoFloatingOverlaysHider overlaysHider(fGraphicsCard, dirty);
fPainter->FillRect(r, gradient); fPainter->FillRect(r, gradient);
_CopyToFront(r); _CopyToFront(dirty);
} }