Added mutexes to the GC and made tip buildable again on linux

This commit is contained in:
bart@bartbes.ath.cx
2010-05-20 17:31:07 +02:00
parent d48c28adec
commit 3d726b0dd9
4 changed files with 64 additions and 56 deletions
+23 -22
View File
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2006-2010 LOVE Development Team
*
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
@@ -22,17 +22,18 @@
#include "ImageRasterizer.h"
#include <common/Exception.h>
#include <string.h>
namespace love
{
namespace font
{
inline bool equal(const love::image::pixel& a, const love::image::pixel& b)
{
return (a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a);
}
ImageRasterizer::ImageRasterizer(love::image::ImageData * data, unsigned short * glyphs, int length)
: imageData(data), glyphs(glyphs), length(length)
{
@@ -80,53 +81,53 @@ namespace font
}
return g;
}
void ImageRasterizer::load()
{
love::image::pixel * pixels = (love::image::pixel *)(imageData->getData());
unsigned imgw = (unsigned)imageData->getWidth();
unsigned imgh = (unsigned)imageData->getHeight();
unsigned imgs = imgw*imgh;
// Set the only metric that matters
metrics.height = imgh;
// Reading texture data begins
love::image::pixel spacer = pixels[0];
unsigned int start = 0;
unsigned int end = 0;
for(unsigned int i = 0; i < length; ++i)
{
if(i >= MAX_CHARS)
break;
start = end;
// Finds out where the first character starts
while(start < imgw && equal(pixels[start], spacer))
++start;
if(i > 0)
spacing[glyphs[i - 1]] = (start > end) ? (start - end) : 0;
end = start;
// Find where glyph ends.
while(end < imgw && !equal(pixels[end], spacer))
++end;
if(start >= end)
break;
unsigned c = glyphs[i];
positions[c] = start;
widths[c] = (end - start);
}
// Replace spacer color with an empty pixel
for(unsigned int i = 0; i < imgs; ++i)
{
@@ -139,11 +140,11 @@ namespace font
}
}
}
int ImageRasterizer::getNumGlyphs() const
{
return length;
}
} // font
} // love
} // love