Qt: optimized TQtRegion.getClipRegion(), fixed bug inside SelectClipRgn() for UNIX ifdef - setting QtNoClip should be different only for QPaintEngineX11, not for others (like using QPaintEngineRaster on linux).

git-svn-id: trunk@23522 -
This commit is contained in:
zeljko 2010-01-21 15:59:50 +00:00
parent e8bfdf298f
commit a789d15c12
2 changed files with 22 additions and 32 deletions

View File

@ -376,6 +376,7 @@ type
procedure setRegion(ARegion: TQtRegion);
procedure drawImage(targetRect: PRect; image: QImageH; sourceRect: PRect;
mask: QImageH; maskRect: PRect; flags: QtImageConversionFlags = QtAutoColor);
function PaintEngine: QPaintEngineH;
procedure rotate(a: Double);
procedure setRenderHint(AHint: QPainterRenderHint; AValue: Boolean);
procedure save;
@ -1730,11 +1731,10 @@ begin
Result := NULLREGION
else
begin
R := getBoundingRect;
if QRegion_contains(Widget, PRect(@R)) then
Result := SIMPLEREGION
if IsPolyRegion or (QRegion_numRects(Widget) > 1) then
Result := COMPLEXREGION
else
Result := COMPLEXREGION;
Result := SIMPLEREGION;
end;
except
Result := ERROR;
@ -2742,8 +2742,7 @@ begin
Result := NULLREGION
else
begin
QRegion_boundingRect(ARegion, @R);
if QRegion_contains(ARegion, PRect(@R)) then
if QRegion_numRects(ARegion) = 1 then
Result := SIMPLEREGION
else
Result := COMPLEXREGION;
@ -2788,7 +2787,12 @@ end;
procedure TQtDeviceContext.setClipRegion(ARegion: QRegionH;
AOperation: QtClipOperation = QtReplaceClip);
begin
QPainter_SetClipRegion(Widget, ARegion, AOperation);
{with QPaintEngine11 QtNoClip & empty region makes disaster}
if (AOperation = QtNoClip) and QRegion_isEmpty(ARegion)
and (QPaintEngine_type(PaintEngine) = QPaintEngineX11) then
setClipping(False)
else
QPainter_SetClipRegion(Widget, ARegion, AOperation);
end;
{------------------------------------------------------------------------------
@ -2869,6 +2873,11 @@ begin
end;
end;
function TQtDeviceContext.PaintEngine: QPaintEngineH;
begin
Result := QPainter_paintEngine(Widget);
end;
{------------------------------------------------------------------------------
Function: TQtDeviceContext.rotate
Params: None

View File

@ -1517,18 +1517,13 @@ begin
QtDC.setClipRegion(Region);
QtDC.setClipping(True);
if QRegion_isEmpty(Region)
then
if QRegion_isEmpty(Region) then
Result := NULLREGION
else
begin
QRegion_boundingRect(Region, @R);
if QRegion_contains(Region, PRect(@R))
then
Result := SIMPLEREGION
else
Result := COMPLEXREGION;
end;
if QRegion_numRects(Region) = 1 then
Result := SIMPLEREGION
else
Result := COMPLEXREGION;
finally
QRegion_destroy(Region);
QRegion_destroy(ExRegion);
@ -4272,11 +4267,8 @@ end;
------------------------------------------------------------------------------}
function TQtWidgetSet.SelectClipRGN(DC: hDC; RGN: HRGN): Longint;
var
AIsPolyRegion: boolean = False;
QtDC: TQtDeviceContext;
{$IFNDEF UNIX}
EmptyRegion: QRegionH;
{$ENDIF}
begin
Result := ERROR;
if IsValidDC(DC) then
@ -4284,27 +4276,16 @@ begin
QtDC := TQtDeviceContext(DC);
if IsValidGDIObject(RGN) then
begin
AIsPolyRegion := TQtRegion(Rgn).IsPolyRegion;
if AIsPolyRegion or (TQtRegion(Rgn).numRects > 1) then
Result := COMPLEXREGION
else
Result := SIMPLEREGION;
Result := TQtRegion(Rgn).GetRegionType;
QtDC.setClipRegion(TQtRegion(Rgn).Widget);
end else
begin
{$IFDEF UNIX}
{looks like a qt bug, this helps to mac & linux}
QtDC.setClipping(False);
{$ELSE}
EmptyRegion := QRegion_create;
try
QtDC.setClipRegion(EmptyRegion, QtNoClip);
finally
QRegion_destroy(EmptyRegion);
end;
{$ENDIF}
Result := NULLREGION;
end;
end;