--- a/hedgewars/uRenderUtils.pas Sun Nov 11 16:53:16 2012 +0100
+++ b/hedgewars/uRenderUtils.pas Sun Nov 11 17:15:19 2012 +0100
@@ -68,7 +68,7 @@
r.y:= rect^.y + 2;
r.w:= rect^.w - 2;
r.h:= rect^.h - 4;
- SDL_FillRect(Surface, @r, FillColor)
+ SDL_FillRect(Surface, @r, FillColor);
end;
(*
function WriteInRoundRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring): TSDL_Rect;
@@ -115,6 +115,7 @@
pixels: PLongWordArray;
begin
TryDo(Surface^.format^.BytesPerPixel = 4, 'flipSurface failed, expecting 32 bit surface', true);
+ SDL_LockSurface(Surface);
pixels:= Surface^.pixels;
if Vertical then
for y := 0 to (Surface^.h div 2) - 1 do
@@ -136,6 +137,7 @@
pixels^[i]:= pixels^[j];
pixels^[j]:= tmpPixel;
end;
+ SDL_UnlockSurface(Surface);
end;
procedure copyToXY(src, dest: PSDL_Surface; destX, destY: LongInt); inline;
@@ -150,6 +152,10 @@
begin
maxDest:= (dest^.pitch div 4) * dest^.h;
maxSrc:= (src^.pitch div 4) * src^.h;
+
+ SDL_LockSurface(src);
+ SDL_LockSurface(dest);
+
srcPixels:= src^.pixels;
destPixels:= dest^.pixels;
@@ -169,6 +175,9 @@
destPixels^[i]:= SDL_MapRGBA(dest^.format, r0, g0, b0, a0);
end;
end;
+
+ SDL_UnlockSurface(src);
+ SDL_UnlockSurface(dest);
end;
procedure DrawSprite2Surf(sprite: TSprite; dest: PSDL_Surface; x,y: LongInt); inline;
@@ -199,6 +208,9 @@
begin
//max:= (dest^.pitch div 4) * dest^.h;
yMax:= dest^.pitch div 4;
+
+ SDL_LockSurface(dest);
+
destPixels:= dest^.pixels;
dx:= abs(x1-x0);
@@ -225,7 +237,8 @@
err:= err + dx;
y0:=y0+sy
end;
- end;
+ end;
+ SDL_UnlockSurface(dest);
end;
procedure copyRotatedSurface(src, dest: PSDL_Surface); // this is necessary since width/height are read only in SDL, apparently
@@ -235,6 +248,9 @@
TryDo(src^.format^.BytesPerPixel = 4, 'rotateSurface failed, expecting 32 bit surface', true);
TryDo(dest^.format^.BytesPerPixel = 4, 'rotateSurface failed, expecting 32 bit surface', true);
+ SDL_LockSurface(src);
+ SDL_LockSurface(dest);
+
srcPixels:= src^.pixels;
destPixels:= dest^.pixels;
@@ -246,6 +262,10 @@
destPixels^[j]:= srcPixels^[i];
inc(j)
end;
+
+ SDL_UnlockSurface(src);
+ SDL_UnlockSurface(dest);
+
end;
function RenderStringTex(s: ansistring; Color: Longword; font: THWFont): PTexture;
@@ -282,11 +302,11 @@
var textWidth, textHeight, x, y, w, h, i, j, pos, prevpos, line, numLines, edgeWidth, edgeHeight, cornerWidth, cornerHeight: LongInt;
finalSurface, tmpsurf, rotatedEdge: PSDL_Surface;
rect: TSDL_Rect;
- chars: set of char = [#9,' ',';',':','?','!',','];
+ //chars: set of char = [#9,' ',';',':','?','!',','];
substr: shortstring;
edge, corner, tail: TSPrite;
begin
- case SpeechType of
+ case SpeechType of
1: begin;
edge:= sprSpeechEdge;
corner:= sprSpeechCorner;
@@ -326,7 +346,7 @@
begin
w:= 0;
i:= round(Sqrt(length(s)) * 2);
- s:= WrapText(s, #1, chars, i);
+ // s:= WrapText(s, #1, chars, i);
pos:= 1; prevpos:= 0; line:= 0;
// Find the longest line for the purposes of centring the text. Font dependant.
while pos <= length(s) do
@@ -463,6 +483,7 @@
SDL_FreeSurface(rotatedEdge);
SDL_FreeSurface(finalSurface);
+
end;
end.