Delphi 有人能解释我在TTexture.assign中的这种奇怪行为吗
为什么在执行ttexture.assign(aTBitmap)时,如果设置了TCanvasStyle.NeedGPUSurface,则不会在纹理中复制位图数据。如果我们对TBitmapSurface执行相同的操作,那么数据将被复制。。。为什么会有如此奇怪的行为Delphi 有人能解释我在TTexture.assign中的这种奇怪行为吗,delphi,Delphi,为什么在执行ttexture.assign(aTBitmap)时,如果设置了TCanvasStyle.NeedGPUSurface,则不会在纹理中复制位图数据。如果我们对TBitmapSurface执行相同的操作,那么数据将被复制。。。为什么会有如此奇怪的行为 procedure TTexture.Assign(Source: TPersistent); var M: TBitmapData; begin if Source is TBitmap then begin if
procedure TTexture.Assign(Source: TPersistent);
var
M: TBitmapData;
begin
if Source is TBitmap then
begin
if FHandle <> 0 then
TContextManager.DefaultContextClass.FinalizeTexture(Self);
FPixelFormat := TBitmap(Source).PixelFormat;
FStyle := [TTextureStyle.Dynamic];
FTextureScale := TBitmap(Source).BitmapScale;
SetSize(TBitmap(Source).Width, TBitmap(Source).Height);
if not (TCanvasStyle.NeedGPUSurface in TBitmap(Source).CanvasClass.GetCanvasStyle) then
begin
if TBitmap(Source).Map(TMapAccess.Read, M) then
try
UpdateTexture(M.Data, M.Pitch);
finally
TBitmap(Source).Unmap(M);
end;
end;
end else if Source is TBitmapSurface then
begin
if FHandle <> 0 then
TContextManager.DefaultContextClass.FinalizeTexture(Self);
FStyle := [TTextureStyle.Dynamic];
SetSize(TBitmapSurface(Source).Width, TBitmapSurface(Source).Height);
UpdateTexture(TBitmapSurface(Source).Bits, TBitmapSurface(Source).Pitch);
end else
inherited ;
end;
程序TTexture.Assign(来源:TPersistent);
变量
M:TBitmapData;
开始
如果源是TBitmap,则
开始
如果FHandle为0,则
TContextManager.DefaultContextClass.FinalizeTexture(Self);
FPixelFormat:=TBitmap(源).PixelFormat;
FStyle:=[TTextureStyle.Dynamic];
FTextureScale:=TBitmap(源).BitmapScale;
设置大小(TBitmap(源)。宽度,TBitmap(源)。高度);
如果不是(TBitmap(Source.CanvasClass.GetCanvasStyle)中的TCanvasStyle.NeedGPUSurface),则
开始
如果是TBitmap(Source).Map(TMapAccess.Read,M),则
尝试
UpdateTexture(M.Data,M.Pitch);
最后
TBitmap(来源)。取消映射(M);
结束;
结束;
如果源为TBitmapSurface,则结束else
开始
如果FHandle为0,则
TContextManager.DefaultContextClass.FinalizeTexture(Self);
FStyle:=[TTextureStyle.Dynamic];
设置大小(TBitmapSurface(源)。宽度,TBitmapSurface(源)。高度);
UpdateTexture(TBitmapSurface(源).Bits,TBitmapSurface(源).Pitch);
结束其他
继承;
结束;
没人有主意吗?