TurboPower_iPro: new attempt to reduce the number of repaints. Issue #38204, patch by serbod.

git-svn-id: trunk@64337 -
This commit is contained in:
wp 2021-01-05 18:56:01 +00:00
parent 5ea010dc3a
commit 97260cafb3
2 changed files with 82 additions and 53 deletions

View File

@ -1947,6 +1947,7 @@ type
FDocCharset: string; FDocCharset: string;
FHasBOM: boolean; FHasBOM: boolean;
FTabList: TIpHtmlTabList; FTabList: TIpHtmlTabList;
FNeedResize: Boolean;
protected protected
CharStream : TStream; CharStream : TStream;
CurToken : TIpHtmlToken; CurToken : TIpHtmlToken;
@ -2254,6 +2255,7 @@ type
property FactBAParag: Real read FFactBAParag write FFactBAParag; property FactBAParag: Real read FFactBAParag write FFactBAParag;
property MouseLastPoint : TPoint read FMouseLastPoint; property MouseLastPoint : TPoint read FMouseLastPoint;
property RenderDevice: TIpHtmlRenderDevice read FRenderDev; property RenderDevice: TIpHtmlRenderDevice read FRenderDev;
property NeedResize: Boolean read FNeedResize write FNeedResize;
end; end;
TIpHtmlInternalPanel = class; TIpHtmlInternalPanel = class;
@ -2314,6 +2316,7 @@ type
InPrint: Integer; InPrint: Integer;
{$ENDIF} {$ENDIF}
SettingPageRect : Boolean; SettingPageRect : Boolean;
FPaintingLock: Integer;
MouseDownX, MouseDownY : Integer; MouseDownX, MouseDownY : Integer;
HaveSelection, HaveSelection,
MouseIsDown, MouseIsDown,
@ -2347,7 +2350,7 @@ type
procedure DoCurElementChange; procedure DoCurElementChange;
procedure DoHotInvoke; procedure DoHotInvoke;
procedure DoClick; procedure DoClick;
procedure Resize; override; procedure DoOnResize; override;
procedure ScrollInView(R : TRect); procedure ScrollInView(R : TRect);
procedure ScrollInViewRaw(R : TRect); procedure ScrollInViewRaw(R : TRect);
function PagePtToScreen(const Pt : TPoint): TPoint; function PagePtToScreen(const Pt : TPoint): TPoint;
@ -7696,6 +7699,7 @@ begin
//FixedTypeface := 'Courier New'; //FixedTypeface := 'Courier New';
FBgColor := clNone; FBgColor := clNone;
FFactBAParag := 1; FFactBAParag := 1;
NeedResize := True;
end; end;
function TIpHtml.LinkVisited(const URL : string): Boolean; function TIpHtml.LinkVisited(const URL : string): Boolean;
@ -8221,9 +8225,10 @@ begin
AggressiveDrawing := False; AggressiveDrawing := False;
{$ENDIF} {$ENDIF}
for i := 0 to Pred(FControlList.Count) do for i := 0 to Pred(FControlList.Count) do
TIpHtmlNode(FControlList[i]).UnmarkControl; TIpHtmlNode(FControlList[i]).UnmarkControl;
SetDefaultProps; if NeedResize then
SetDefaultProps;
FPageViewRect := TargetPageRect; FPageViewRect := TargetPageRect;
{ Note: In Preview mode the page is tiled of "mini-pages" sized PageViewRect. { Note: In Preview mode the page is tiled of "mini-pages" sized PageViewRect.
The lower end of the "real" page is given by PageViewBottom. We set here The lower end of the "real" page is given by PageViewBottom. We set here
@ -10115,7 +10120,8 @@ begin
FHot := Value; FHot := Value;
if FAreaList.Count = 0 then if FAreaList.Count = 0 then
BuildAreaList; BuildAreaList;
SetProps(Props); if FOwner.NeedResize then
SetProps(Props);
for i := 0 to Pred(FAreaList.Count) do for i := 0 to Pred(FAreaList.Count) do
if PageRectToScreen(PRect(FAreaList[i])^, R) then if PageRectToScreen(PRect(FAreaList[i])^, R) then
Owner.InvalidateRect(R); Owner.InvalidateRect(R);
@ -10440,10 +10446,13 @@ begin
end; end;
// set TR color, Render override them anyway if TD/TH have own settings // set TR color, Render override them anyway if TD/TH have own settings
Props.BGColor := TrBgColor; if FOwner.NeedResize then
Props.FontColor := TrTextColor; begin
Props.BGColor := TrBgColor;
Props.FontColor := TrTextColor;
Props.VAlignment := Al; Props.VAlignment := Al;
end;
Render(Props); Render(Props);
{paint left rule if selected} {paint left rule if selected}
case Rules of case Rules of
@ -11795,6 +11804,8 @@ begin
begin begin
FControl.Hint := Alt; FControl.Hint := Alt;
FControl.ShowHint:=True; FControl.ShowHint:=True;
if (FControl is TEdit) then
FControl.ControlStyle:=FControl.ControlStyle + [csOpaque];
end; end;
aCanvas.Font.Size := iCurFontSize; aCanvas.Font.Size := iCurFontSize;
end; end;
@ -13647,31 +13658,42 @@ procedure TIpHtmlInternalPanel.Paint;
var var
CR: TRect; CR: TRect;
begin begin
CR := GetClientRect; if FPaintingLock > 0 then
if not ScaleBitmaps {printing} and (Hyper <> nil) then exit;
begin inc(FPaintingLock);
// update layout
GetPageRect; try
// render if Assigned(HTMLPanel.OnPaint) then HTMLPanel.OnPaint(HTMLPanel);
Hyper.Render(Canvas,
Rect( CR := GetClientRect;
ViewLeft, ViewTop, if not ScaleBitmaps {printing} and (Hyper <> nil) then
ViewLeft + (CR.Right - CR.Left), begin
ViewTop + (CR.Bottom - CR.Top) // update layout
), GetPageRect;
ViewTop, // render
ViewTop + (CR.Bottom - CR.Top), Hyper.Render(Canvas,
HTMLPanel.UsePaintBuffer, Rect(
Point(0, 0) ViewLeft, ViewTop,
) ViewLeft + (CR.Right - CR.Left),
end ViewTop + (CR.Bottom - CR.Top)
else ),
Canvas.FillRect(CR); ViewTop,
//debugln(['TIpHtmlInternalPanel.Paint ',dbgs(CR)]); ViewTop + (CR.Bottom - CR.Top),
{$IFDEF IP_LAZARUS_DBG} HTMLPanel.UsePaintBuffer,
DebugBox(Canvas, CR, clYellow); Point(0, 0)
Debugbox(Canvas, Canvas.ClipRect, clLime, true); );
{$ENDIF} FHyper.NeedResize := False;
end
else
Canvas.FillRect(CR);
//debugln(['TIpHtmlInternalPanel.Paint ',dbgs(CR)]);
{$IFDEF IP_LAZARUS_DBG}
DebugBox(Canvas, CR, clYellow);
Debugbox(Canvas, Canvas.ClipRect, clLime, true);
{$ENDIF}
finally
dec(FPaintingLock);
end;
end; end;
{$IFDEF Html_Print} {$IFDEF Html_Print}
@ -13875,13 +13897,16 @@ end;
procedure TIpHtmlInternalPanel.InvalidateSize; procedure TIpHtmlInternalPanel.InvalidateSize;
begin begin
FPageRectValid:=false; FPageRectValid:=false;
Invalidate; if FPaintingLock = 0 then
Invalidate;
end; end;
procedure TIpHtmlInternalPanel.Resize; procedure TIpHtmlInternalPanel.DoOnResize;
begin begin
inherited; inherited;
InvalidateSize; InvalidateSize;
if Assigned(FHyper) then
FHyper.NeedResize := True;
end; end;
function TIpHtmlInternalPanel.PagePtToScreen(const Pt : TPoint): TPoint; function TIpHtmlInternalPanel.PagePtToScreen(const Pt : TPoint): TPoint;

View File

@ -1381,7 +1381,7 @@ end;
procedure TIpNodeBlockLayouter.Render(RenderProps: TIpHtmlProps); procedure TIpNodeBlockLayouter.Render(RenderProps: TIpHtmlProps);
begin begin
if not RenderProps.IsEqualTo(Props) then if FOwner.Owner.NeedResize and (not RenderProps.IsEqualTo(Props)) then
begin begin
Props.Assign(RenderProps); Props.Assign(RenderProps);
FOwner.LoadAndApplyCSSProps; FOwner.LoadAndApplyCSSProps;
@ -1491,26 +1491,29 @@ procedure TIpNodeTableElemLayouter.Render(RenderProps: TIpHtmlProps);
var var
R : TRect; R : TRect;
begin begin
Props.Assign(RenderProps); if FOwner.Owner.NeedResize then
Props.DelayCache:=True;
FOwner.LoadAndApplyCSSProps;
//DebugLn('td :', IntToStr(Integer(Props.Alignment)));
if FTableElemOwner.BgColor <> clNone then
Props.BgColor := FTableElemOwner.BgColor;
if FTableElemOwner.Align <> haDefault then
Props.Alignment := FTableElemOwner.Align
else if Props.Alignment = haDefault then
begin begin
Props.Assign(RenderProps);
Props.DelayCache:=True;
FOwner.LoadAndApplyCSSProps;
//DebugLn('td :', IntToStr(Integer(Props.Alignment)));
if FTableElemOwner.BgColor <> clNone then
Props.BgColor := FTableElemOwner.BgColor;
if FTableElemOwner.Align <> haDefault then
Props.Alignment := FTableElemOwner.Align
else if Props.Alignment = haDefault then
begin
if FOwner is TIpHtmlNodeTH then
Props.Alignment := haCenter
else
Props.Alignment := haLeft;
end;
if FOwner is TIpHtmlNodeTH then if FOwner is TIpHtmlNodeTH then
Props.Alignment := haCenter Props.FontStyle := Props.FontStyle + [fsBold];
else Props.VAlignment := FTableElemOwner.VAlign;
Props.Alignment := haLeft; if FTableElemOwner.NoWrap then
Props.NoBreak := True;
end; end;
if FOwner is TIpHtmlNodeTH then
Props.FontStyle := Props.FontStyle + [fsBold];
Props.VAlignment := FTableElemOwner.VAlign;
if FTableElemOwner.NoWrap then
Props.NoBreak := True;
{$IFDEF IP_LAZARUS_DBG} {$IFDEF IP_LAZARUS_DBG}
DebugBox(Owner.Target, PadRect, clYellow, True); DebugBox(Owner.Target, PadRect, clYellow, True);
{$ENDIF} {$ENDIF}
@ -1523,7 +1526,8 @@ begin
end else end else
FIpHtml.Target.Brush.Style := bsClear; FIpHtml.Target.Brush.Style := bsClear;
end; end;
Props.DelayCache:=False; if FOwner.Owner.NeedResize then
Props.DelayCache:=False;
inherited Render(Props); inherited Render(Props);
end; end;