PDA

View Full Version : About TCustomLockableTexture.Lock



devchenxip
06-12-2018, 11:35 AM
function Lock(out Surface: TPixelSurface): Boolean; overload; inline;
---------------------------------------------------------------------------------------------------------------------

procedure TForm1.CacheTexture(const ATexture: TCustomLockableTexture);
var
LSurface: TPixelSurface;
begin
if not ATexture.Lock(LSurface) then //The code is optimized off the mobile platform TPixelSurface is a TObject?
begin
ShowMessage('lock failed');
Exit;
end else
ShowMessage('lock success');
//
try
if LSurface = nil then
ShowMessage('surface is null');
finally
ATexture.Unlock;
end;
end;

----------print----------
--surface is null
--lock success

devchenxip
06-12-2018, 11:42 AM
procedure TForm1.CacheTexture(const ATexture: TCustomLockableTexture);
var
LPixels: TLockedPixels;
begin
if not ATexture.Lock(LPixels) then
begin
ShowMessage('lock failed');
Exit;
end else
ShowMessage('lock success');
//
try
if not LPixels.valid then
ShowMessage('invalid pixels');
finally
ATexture.Unlock;
end;
end;

----------print----------
--lock success

LP
30-12-2018, 05:32 PM
Thanks, but can you please explain what is the purpose of above code?

I suppose you are getting the issue when using Delphi's ARC, right?