Skip to content

Commit

Permalink
app_sever: Fix more mixups of transformed clipping bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
stippi committed May 23, 2014
1 parent 81507fa commit d30a0a6
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions src/servers/app/drawing/DrawingEngine.cpp
Expand Up @@ -974,8 +974,7 @@ DrawingEngine::FillRect(BRect r)

bool doInSoftware = true;

if (fPainter->IsIdentityTransform())
{
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).

Expand Down Expand Up @@ -1052,32 +1051,36 @@ DrawingEngine::FillRegion(BRegion& r)
AutoFloatingOverlaysHider overlaysHider(fGraphicsCard, clipped);

bool doInSoftware = true;
// 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) {

if (fPainter->IsIdentityTransform()) {
// 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) != 0
&& fPainter->Pattern() == B_SOLID_HIGH
&& fPainter->DrawingMode() == B_OP_INVERT) {
r.IntersectWith(fPainter->ClippingRegion());
fGraphicsCard->FillRegion(r, fPainter->LowColor(),
fSuspendSyncLevel == 0 || overlaysHider.WasHidden());
fGraphicsCard->InvertRegion(r);
doInSoftware = false;
}
}

if (doInSoftware && (fAvailableHWAccleration & HW_ACC_INVERT_REGION) != 0
&& 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));

Expand All @@ -1095,7 +1098,7 @@ DrawingEngine::FillRegion(BRegion& r, const BGradient& gradient)
{
ASSERT_PARALLEL_LOCKED();

BRect clipped = fPainter->ClipRect(r.Frame());
BRect clipped = fPainter->TransformAndClipRect(r.Frame());
if (!clipped.IsValid())
return;

Expand Down Expand Up @@ -1172,7 +1175,7 @@ DrawingEngine::DrawShape(const BRect& bounds, int32 opCount,
// BRect clipped(bounds);
// if (!filled)
// extend_by_stroke_width(clipped, fPainter->PenSize());
// clipped = fPainter->ClipRect(bounds);
// clipped = fPainter->TransformAndClipRect(bounds);
//
// clipped.left = floorf(clipped.left);
// clipped.top = floorf(clipped.top);
Expand Down Expand Up @@ -1201,7 +1204,7 @@ DrawingEngine::FillShape(const BRect& bounds, int32 opCount,
ASSERT_PARALLEL_LOCKED();

// TODO: bounds probably does not take curves and arcs into account...
// BRect clipped = fPainter->ClipRect(bounds);
// BRect clipped = fPainter->TransformAndClipRect(bounds);
//
// clipped.left = floorf(clipped.left);
// clipped.top = floorf(clipped.top);
Expand Down Expand Up @@ -1347,7 +1350,8 @@ DrawingEngine::DrawString(const char* string, int32 length,
BPoint penLocation = pt;

// try a fast clipping path
if (fPainter->ClippingRegion() && fPainter->Font().Rotation() == 0.0f
if (fPainter->ClippingRegion() != NULL
&& fPainter->Font().Rotation() == 0.0f
&& fPainter->IsIdentityTransform()) {
float fontSize = fPainter->Font().Size();
BRect clippingFrame = fPainter->ClippingRegion()->Frame();
Expand Down

0 comments on commit d30a0a6

Please sign in to comment.