Changeset 19 for trunk/Forms


Ignore:
Timestamp:
Jan 21, 2018, 11:33:15 PM (7 years ago)
Author:
chronos
Message:
  • Added: Locking of video memory because it is accessed by main thread and also application threads.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r18 r19  
    200200  SizeY: Integer;
    201201begin
    202 {  var
    203     X, Y: Integer;
    204     PixelPtr: PInteger;
    205     PixelRowPtr: PInteger;
    206     RawImage: TRawImage;
    207     BytePerPixel: Integer;
    208     SourcePixelPtr: Integer;
    209   begin
    210     try
    211       Bitmap.BeginUpdate;
    212       RawImage := Bitmap.RawImage;
    213       PixelRowPtr := PInteger(RawImage.Data);
    214       BytePerPixel := RawImage.Description.BitsPerPixel div 8;
    215       for Y := 0 to Bitmap.Height - 1 do begin
    216         PixelPtr := PixelRowPtr;
    217         for X := 0 to Bitmap.Width - 1 do begin
    218           SourcePixelPtr := TMatter(Matter[Surface.ItemsXY[Trunc(X / Bitmap.Width * Surface.Count.X),
    219               Trunc(Y / Bitmap.Height * Surface.Count.Y)]]).Color;
    220           PixelPtr^ := SwapBRComponent(SourcePixelPtr);
    221           Inc(PByte(PixelPtr), BytePerPixel);
    222         end;
    223         Inc(PByte(PixelRowPtr), RawImage.Description.BytesPerLine);
    224       end;
    225     finally
    226       Bitmap.EndUpdate;
    227     end;
    228 }
    229202  try
    230203    TempBitmap.SetSize(VideoDevice.VideoMode.Size.X, VideoDevice.VideoMode.Size.Y);
     
    234207    DestBytePerPixel := RawImage.Description.BitsPerPixel div 8;
    235208    DestBytePerLine := RawImage.Description.BytesPerLine;
     209    VideoDevice.Lock.Acquire;
    236210    if Assigned(VideoDevice.VideoMemory) then begin
    237211      SourceBytePerPixel := VideoDevice.VideoMode.GetBytesPerPixel;
     
    252226      end;
    253227    end;
     228    VideoDevice.Lock.Release;
    254229  finally
    255230    TempBitmap.EndUpdate;
     
    266241  VideoMode.Size := TPoint.Create(Width, Height);
    267242  VideoDevice.VideoMode := VideoMode;
     243  VideoMode.Free;
    268244end;
    269245
Note: See TracChangeset for help on using the changeset viewer.