相关疑难解决方法(0)

是否更优化使用本地功能或全局功能?

我想知道是否更优化使用本地函数(在下面的例子中_drawBitmap)只需要3个参数不能内联,因为函数访问一些所有者过程变量,或者使用可以内联全局函数(但是它会真正内联吗?)并且需要5个参数.

也不知道它是否重要,但这段代码主要用于android/ios编译

代码具有本地功能:

procedure TMyObject.onPaint(Sender: TObject; Canvas: TCanvas; const ARect: TRectF);

  function _drawBitmap(const aBitmap: {$IFDEF _USE_TEXTURE}TTexture{$ELSE}Tbitmap{$ENDIF}; const aTopLeft: TpointF; Const aOpacity: Single): boolean;
  var aDestRect: TrectF;
  begin
    Result := False;
    if aBitmap <> nil then begin

      //calculate aDestRect
      aDestRect := canvas.AlignToPixel(
                     TRectF.Create(
                        aTopLeft,
                        aBitmap.Width/ScreenScale,
                        aBitmap.Height/ScreenScale));

      //if the aBitmap is visible
      if ARect.IntersectsWith(aDestRect) then begin

        Result := True;

        {$IFDEF _USE_TEXTURE}
        TCustomCanvasGpu(Canvas).DrawTexture(aDestRect, // ATexRect
                                             TRectF.Create(0,
                                                           0,
                                                           aBitmap.Width,
                                                           aBitmap.Height), …
Run Code Online (Sandbox Code Playgroud)

delphi

2
推荐指数
2
解决办法
217
查看次数

标签 统计

delphi ×1