gtk intf: fixed realign masks, LCL TBitmap: added CHangingAll to avoid overhead when changing the whole bitmap

git-svn-id: trunk@9642 -
This commit is contained in:
mattias 2006-07-20 19:20:43 +00:00
parent c75d21e68f
commit 69a6edd9a9
4 changed files with 17 additions and 7 deletions

View File

@ -1117,6 +1117,7 @@ type
protected
procedure Changed(Sender: TObject); override;
procedure Changing(Sender: TObject); virtual;
procedure ChangingAll(Sender: TObject);
procedure Draw(DestCanvas: TCanvas; const DestRect: TRect); override;
function GetEmpty: Boolean; override;
function GetHeight: Integer; override;

View File

@ -195,7 +195,7 @@ procedure WriteRawImageBits(TheData: PByte; const Position: TRawImagePosition;
BitsPerPixel, Prec, Shift: cardinal;
BitOrder: TRawImageBitOrder; Bits: word);
procedure ReAlignRawImageLines(var Data: Pointer; var Size: PtrUInt;
Width, Height: cardinal;
Width, Height, BitsPerPixel: cardinal;
var OldLineEnd: TRawImageLineEnd; NewLineEnd: TRawImageLineEnd);
var
@ -761,7 +761,7 @@ begin
end;
procedure ReAlignRawImageLines(var Data: Pointer; var Size: PtrUInt;
Width, Height: cardinal;
Width, Height, BitsPerPixel: cardinal;
var OldLineEnd: TRawImageLineEnd; NewLineEnd: TRawImageLineEnd);
var
OldBytesPerLine: PtrUInt;
@ -774,11 +774,11 @@ var
begin
if OldLineEnd=NewLineEnd then exit;
if (Width=0) or (Height=0) then exit;
OldBytesPerLine:=GetBytesPerLine(Width,Height,OldLineEnd);
OldBytesPerLine:=GetBytesPerLine(Width,BitsPerPixel,OldLineEnd);
OldSize:=OldBytesPerLine*PtrUInt(Height);
if OldSize<>Size then
RaiseGDBException('ReAlignRawImageLines OldSize<>Size');
NewBytesPerLine:=GetBytesPerLine(Width,Height,OldLineEnd);
NewBytesPerLine:=GetBytesPerLine(Width,BitsPerPixel,NewLineEnd);
NewSize:=NewBytesPerLine*PtrUInt(Height);
// enlarge before

View File

@ -52,7 +52,7 @@ var
begin
if Source=Self then exit;
if Source is TBitmap then begin
Changing(Self);
ChangingAll(Self);
//DebugLn('TBitMap.Assign ',ClassName,' ',Source.ClassName);
// TBitmap can share image data
// -> check if already shared
@ -72,7 +72,7 @@ begin
//DebugLn('TBitMap.Assign B ',Width,',',Height,' ',HandleAllocated,' RefCount=',FImage.RefCount);
Changed(Self);
end else if Source is TFPCustomImage then begin
Changing(Self);
ChangingAll(Self);
SrcFPImage:=TFPCustomImage(Source);
IntfImage:=TLazIntfImage.Create(0,0);
try
@ -101,7 +101,9 @@ var
SrcDC: hDC;
DestDC: hDC;
begin
if (DestRect.Right<=DestRect.Left) or (DestRect.Bottom<=DestRect.Top)
if (DestRect.Left>=Width) or (DestRect.Right<=0)
or (DestRect.Top>=Height) or (DestRect.Bottom<=0)
or (DestRect.Right<=DestRect.Left) or (DestRect.Bottom<=DestRect.Top)
or (Width=0) or (Height=0) then exit;
HandleNeeded;
if HandleAllocated then begin
@ -359,6 +361,12 @@ begin
FreeSaveStream;
end;
procedure TBitmap.ChangingAll(Sender: TObject);
begin
UnshareImage(false);
Changing(Sender);
end;
procedure TBitMap.HandleNeeded;
var
n : integer;

View File

@ -2857,6 +2857,7 @@ begin
// re align data
ReAlignRawImageLines(RawImage.Mask,RawImage.MaskSize,
RawImage.Description.Width,RawImage.Description.Height,
RawImage.Description.AlphaBitsPerPixel,
RawImage.Description.AlphaLineEnd,rileByteBoundary);
end;