Ignore:
Timestamp:
Apr 6, 2021, 7:19:02 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Optimized help water sign drawing.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/Help.pas

    r331 r346  
    111111    procedure WaterSign(x0, y0, iix: Integer);
    112112    procedure Search(SearchString: string);
    113     procedure OnScroll(var m: TMessage); message WM_VSCROLL;
     113    procedure OnScroll(var Msg: TMessage); message WM_VSCROLL;
    114114    procedure OnMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;
    115115  public
     
    351351end;
    352352
    353 procedure THelpDlg.OnScroll(var m: TMessage);
     353procedure THelpDlg.OnScroll(var Msg: TMessage);
    354354begin
    355355  { TODO: Handled by MouseWheel event
    356   if ScrollBar.Process(m) then begin
     356  if ScrollBar.Process(Msg) then begin
    357357    Sel := -1;
    358358    SmartUpdateContent(true)
     
    452452  MaxSum = 9 * 9 * 255 * 75 div 100;
    453453var
    454   x, y, dx, dy, xSrc, ySrc, sum, xx: integer;
     454  x, y, dx, dy, xSrc, ySrc, Sum, xx: integer;
    455455  Heaven: array [0..nHeaven] of integer;
    456   PaintPtr, CoalPtr: TPixelPointer;
     456  PaintPtr: TPixelPointer;
     457  CoalPtr: TPixelPointer;
    457458  ImpPtr: array [-1..1] of TPixelPointer;
    458459begin
     
    466467  xSrc := iix mod 7 * xSizeBig;
    467468  ySrc := (iix div 7 + 1) * ySizeBig;
    468   for y := 0 to ScaleToNative(ySizeBig) * 2 - 1 do
     469  PaintPtr := PixelPointer(OffScreen, ScaleToNative(x0), ScaleToNative(y0));
     470  CoalPtr := PixelPointer(Templates.Data, ScaleToNative(xCoal), ScaleToNative(yCoal));
     471  for dy := -1 to 1 do
     472    ImpPtr[dy] := PixelPointer(BigImp, ScaleToNative(xSrc), ScaleToNative(ySrc));
     473  for y := 0 to ScaleToNative(ySizeBig) * 2 - 1 do begin
    469474    if ((ScaleToNative(y0) + y) >= 0) and ((ScaleToNative(y0) + y) < ScaleToNative(InnerHeight)) then begin
    470       PaintPtr := PixelPointer(OffScreen, 0, ScaleToNative(y0) + y);
    471       CoalPtr := PixelPointer(Templates.Data, 0, ScaleToNative(yCoal) + y);
    472475      for dy := -1 to 1 do
    473476        if ((Max(y + ScaleToNative(dy), 0) shr 1) >= 0) and ((Max(y + ScaleToNative(dy), 0) shr 1) < ScaleToNative(ySizeBig)) then
    474           ImpPtr[dy] := PixelPointer(BigImp, 0, ScaleToNative(ySrc) + (Max(y + ScaleToNative(dy), 0) shr 1));
    475       for x := 0 to ScaleToNative(xSizeBig) * 2 - 1 do begin
    476         sum := 0;
     477          ImpPtr[dy].SetXY(0, Max(y + ScaleToNative(dy), 0) shr 1);
     478      for x := 0 to ScaleToNative(xSizeBig * 2) - 1 do begin
     479        Sum := 0;
    477480        for dx := -1 to 1 do begin
    478           xx := ScaleToNative(xSrc) + Max((x + ScaleToNative(dx)), 0) shr 1;
     481          xx := Max((x + ScaleToNative(dx)), 0) shr 1;
    479482          for dy := -1 to 1 do begin
    480483            ImpPtr[dy].SetX(xx);
     
    483486              ((y + ScaleToNative(dy)) shr 1 < ScaleToNative(nHeaven)) and
    484487              (ImpPtr[dy].Pixel^.B shl 16 + ImpPtr[dy].Pixel^.G shl 8 +
    485               ImpPtr[dy].Pixel^.R = Heaven[(ScaleFromNative(y) + dy) shr 1]) then
    486               sum := sum + 9 * 255
     488              ImpPtr[dy].Pixel^.R = Heaven[(ScaleFromNative(y + ScaleToNative(dy))) shr 1]) then
     489              Sum := Sum + 9 * 255
    487490            else
    488               sum := sum + ImpPtr[dy].Pixel^.B + 5 * ImpPtr[dy].Pixel^.G + 3 *
     491              Sum := Sum + ImpPtr[dy].Pixel^.B + 5 * ImpPtr[dy].Pixel^.G + 3 *
    489492                ImpPtr[dy].Pixel^.R;
    490493          end;
    491494        end;
    492         if sum < MaxSum then begin // no saturation
    493           CoalPtr.SetX(ScaleToNative(xCoal) + x);
    494           sum := 1 shl 22 - (MaxSum - sum) * (256 - CoalPtr.Pixel^.B * 2);
    495           PaintPtr.SetX(x0 + x);
    496           PaintPtr.Pixel^.B := PaintPtr.Pixel^.B * sum shr 22;
    497           PaintPtr.Pixel^.G := PaintPtr.Pixel^.G * sum shr 22;
    498           PaintPtr.Pixel^.R := PaintPtr.Pixel^.R * sum shr 22;
     495        if Sum < MaxSum then begin // no saturation
     496          Sum := 1 shl 22 - (MaxSum - Sum) * (256 - CoalPtr.Pixel^.B * 2);
     497          PaintPtr.Pixel^.B := Min(PaintPtr.Pixel^.B * Sum shr 22, 255);
     498          PaintPtr.Pixel^.G := Min(PaintPtr.Pixel^.G * Sum shr 22, 255);
     499          PaintPtr.Pixel^.R := Min(PaintPtr.Pixel^.R * Sum shr 22, 255);
    499500        end;
     501        PaintPtr.NextPixel;
     502        CoalPtr.NextPixel;
    500503      end;
    501504    end;
     505    PaintPtr.NextLine;
     506    CoalPtr.NextLine;
     507  end;
    502508  Offscreen.EndUpdate;
    503509  BigImp.EndUpdate;
Note: See TracChangeset for help on using the changeset viewer.