Carbon: Optimize TCarbonControlContext drawing. Issue #21767, patch from David Jenkins & AlexeyT.

git-svn-id: trunk@54602 -
This commit is contained in:
juha 2017-04-10 20:09:35 +00:00
parent 57f917a297
commit de867c7b05
2 changed files with 23 additions and 15 deletions

View File

@ -186,12 +186,14 @@ type
TCarbonControlContext = class(TCarbonDeviceContext)
private
FOwner: TCarbonWidget; // owner widget
FClipShapeRef: HIShapeRef;
protected
function GetSize: TPoint; override;
public
constructor Create(AOwner: TCarbonWidget);
function IsInClipRegion(ARect: TRect): Boolean;
property Owner: TCarbonWidget read FOwner;
property ClipShapeRef: HIShapeRef read FClipShapeRef write FClipShapeRef;
end;
{ TCarbonBitmapContext }
@ -1303,12 +1305,12 @@ end;
{------------------------------------------------------------------------------
Method: TCarbonDeviceContext.PolyBezier
Params: Points - Points defining the cubic Bézier curve
Params: Points - Points defining the cubic Bézier curve
NumPts - Number of points passed
Filled - Fill the drawed shape
Continous - Connect Bézier curves
Continous - Connect Bézier curves
Draws a cubic Bézier curves. The first curve is drawn from the first point to
Draws a cubic Bézier curves. The first curve is drawn from the first point to
the fourth point with the second and third points being the control points.
------------------------------------------------------------------------------}
procedure TCarbonDeviceContext.PolyBezier(Points: PPoint; NumPts: Integer;
@ -1744,6 +1746,13 @@ begin
Reset;
end;
function TCarbonControlContext.IsInClipRegion(ARect: TRect): Boolean;
begin
Result := True;
if ClipShapeRef <> nil then
Result := HIShapeIntersectsRect(ClipShapeRef, RectToCGRect(ARect));
end;
{ TCarbonBitmapContext }
{------------------------------------------------------------------------------

View File

@ -50,8 +50,8 @@ var
AStruct : PPaintStruct;
Win : WindowRef;
Content : HIViewRef;
Hnd : RgnHandle;
mr : MacOSAll.Rect;
ClpShape: HIShapeRef;
mr : CGRect;
invr : TRect;
begin
if isRepaint then
@ -74,18 +74,17 @@ begin
SizeOf(CGContextRef), nil, @(AWidget.Context.CGContext)),
'CarbonCommon_Draw', SGetEvent, 'kEventParamCGContextRef') then Exit;
if GetEventParameter(AEvent, kEventParamRgnHandle, typeQDRgnHandle, nil,
SizeOf(Hnd), nil, @Hnd)=noErr then
if GetEventParameter(AEvent, kEventParamShape, typeHIShapeRef, nil,
SizeOf(ClpShape), nil, @ClpShape)=noErr then
begin
GetRegionBounds(RgnHandle(Hnd), mr{%H-});
invr.Left:=mr.left;
invr.Top:=mr.top;
invr.Right:=mr.right;
invr.Bottom:=mr.bottom;
HIShapeGetBounds(ClpShape, mr);
invr := CGRectToRect(mr);
TCarbonControlContext(AWidget.Context).ClipShapeRef := ClpShape;
end
else
else begin
AWidget.GetBounds(invr);
TCarbonControlContext(AWidget.Context).ClipShapeRef := nil;
end;
AWidget.Context.Reset;