mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-01 03:10:06 +00:00
The first working check-in of an iPhone build! Added an iPhone project for the normal juce demo, which runs.. although it isn't exactly designed for a hand-held form factor!
Also in this check-in is support for creation of custom Mac MIDI input and output devices, and an option to load URLs with the QuickTimeComponent
This commit is contained in:
parent
6c66134173
commit
d779fa9759
56 changed files with 3074 additions and 1166 deletions
|
|
@ -33,23 +33,25 @@ BEGIN_JUCE_NAMESPACE
|
|||
const int juce_edgeTableDefaultEdgesPerLine = 32;
|
||||
|
||||
//==============================================================================
|
||||
EdgeTable::EdgeTable (const int top_, const int height_,
|
||||
EdgeTable::EdgeTable (const Rectangle& bounds_,
|
||||
const Path& path, const AffineTransform& transform) throw()
|
||||
: top (top_),
|
||||
height (height_),
|
||||
: bounds (bounds_),
|
||||
maxEdgesPerLine (juce_edgeTableDefaultEdgesPerLine),
|
||||
lineStrideElements ((juce_edgeTableDefaultEdgesPerLine << 1) + 1)
|
||||
{
|
||||
table = (int*) juce_malloc (height_ * lineStrideElements * sizeof (int));
|
||||
table = (int*) juce_malloc ((bounds.getHeight() + 1) * lineStrideElements * sizeof (int));
|
||||
int* t = table;
|
||||
for (int i = height_; --i >= 0;)
|
||||
for (int i = bounds.getHeight(); --i >= 0;)
|
||||
{
|
||||
*t = 0;
|
||||
t += lineStrideElements;
|
||||
}
|
||||
|
||||
const int topLimit = top << 8;
|
||||
const int bottomLimit = height << 8;
|
||||
const int topLimit = bounds.getY() << 8;
|
||||
const int heightLimit = bounds.getHeight() << 8;
|
||||
const int leftLimit = bounds.getX() << 8;
|
||||
const int rightLimit = bounds.getRight() << 8;
|
||||
|
||||
PathFlatteningIterator iter (path, transform);
|
||||
|
||||
while (iter.next())
|
||||
|
|
@ -62,33 +64,41 @@ EdgeTable::EdgeTable (const int top_, const int height_,
|
|||
y1 -= topLimit;
|
||||
y2 -= topLimit;
|
||||
|
||||
const double startX = 256.0f * iter.x1;
|
||||
const int startY = y1;
|
||||
const double multiplier = (iter.x2 - iter.x1) / (iter.y2 - iter.y1);
|
||||
int winding = -1;
|
||||
int direction = -1;
|
||||
|
||||
if (y1 > y2)
|
||||
{
|
||||
swapVariables (y1, y2);
|
||||
winding = 1;
|
||||
direction = 1;
|
||||
}
|
||||
|
||||
if (y1 < 0)
|
||||
y1 = 0;
|
||||
|
||||
if (y2 > bottomLimit)
|
||||
y2 = bottomLimit;
|
||||
if (y2 > heightLimit)
|
||||
y2 = heightLimit;
|
||||
|
||||
const int stepSize = jlimit (1, 256, 256 / (1 + (int) fabs (multiplier)));
|
||||
|
||||
while (y1 < y2)
|
||||
if (y1 < y2)
|
||||
{
|
||||
const int step = jmin (stepSize, y2 - y1, 256 - (y1 & 255));
|
||||
const double startX = 256.0f * iter.x1;
|
||||
const double multiplier = (iter.x2 - iter.x1) / (iter.y2 - iter.y1);
|
||||
const int stepSize = jlimit (1, 256, 256 / (1 + (int) fabs (multiplier)));
|
||||
|
||||
addEdgePoint (roundDoubleToInt (startX + multiplier * (y1 - startY)),
|
||||
y1 >> 8, winding * step);
|
||||
do
|
||||
{
|
||||
const int step = jmin (stepSize, y2 - y1, 256 - (y1 & 255));
|
||||
int x = roundDoubleToInt (startX + multiplier * (y1 - startY));
|
||||
|
||||
y1 += step;
|
||||
if (x < leftLimit)
|
||||
x = leftLimit;
|
||||
else if (x >= rightLimit)
|
||||
x = rightLimit - 1;
|
||||
|
||||
addEdgePoint (x, y1 >> 8, direction * step);
|
||||
y1 += step;
|
||||
}
|
||||
while (y1 < y2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -97,7 +107,7 @@ EdgeTable::EdgeTable (const int top_, const int height_,
|
|||
{
|
||||
int* lineStart = table;
|
||||
|
||||
for (int i = height; --i >= 0;)
|
||||
for (int i = bounds.getHeight(); --i >= 0;)
|
||||
{
|
||||
int* line = lineStart;
|
||||
lineStart += lineStrideElements;
|
||||
|
|
@ -125,14 +135,11 @@ EdgeTable::EdgeTable (const int top_, const int height_,
|
|||
}
|
||||
|
||||
EdgeTable::EdgeTable (const Rectangle& rectangleToAdd) throw()
|
||||
: top (rectangleToAdd.getY()),
|
||||
height (jmax (1, rectangleToAdd.getHeight())),
|
||||
: bounds (rectangleToAdd),
|
||||
maxEdgesPerLine (juce_edgeTableDefaultEdgesPerLine),
|
||||
lineStrideElements ((juce_edgeTableDefaultEdgesPerLine << 1) + 1)
|
||||
{
|
||||
jassert (! rectangleToAdd.isEmpty());
|
||||
|
||||
table = (int*) juce_malloc (height * lineStrideElements * sizeof (int));
|
||||
table = (int*) juce_malloc (jmax (1, bounds.getHeight()) * lineStrideElements * sizeof (int));
|
||||
*table = 0;
|
||||
|
||||
const int x1 = rectangleToAdd.getX();
|
||||
|
|
@ -160,12 +167,11 @@ const EdgeTable& EdgeTable::operator= (const EdgeTable& other) throw()
|
|||
{
|
||||
juce_free (table);
|
||||
|
||||
top = other.top;
|
||||
height = other.height;
|
||||
bounds = other.bounds;
|
||||
maxEdgesPerLine = other.maxEdgesPerLine;
|
||||
lineStrideElements = other.lineStrideElements;
|
||||
|
||||
const int tableSize = height * lineStrideElements * sizeof (int);
|
||||
const int tableSize = jmax (1, bounds.getHeight()) * lineStrideElements * sizeof (int);
|
||||
table = (int*) juce_malloc (tableSize);
|
||||
memcpy (table, other.table, tableSize);
|
||||
|
||||
|
|
@ -184,10 +190,11 @@ void EdgeTable::remapTableForNumEdges (const int newNumEdgesPerLine) throw()
|
|||
{
|
||||
maxEdgesPerLine = newNumEdgesPerLine;
|
||||
|
||||
jassert (bounds.getHeight() > 0);
|
||||
const int newLineStrideElements = maxEdgesPerLine * 2 + 1;
|
||||
int* const newTable = (int*) juce_malloc (height * newLineStrideElements * sizeof (int));
|
||||
int* const newTable = (int*) juce_malloc (bounds.getHeight() * newLineStrideElements * sizeof (int));
|
||||
|
||||
for (int i = 0; i < height; ++i)
|
||||
for (int i = 0; i < bounds.getHeight(); ++i)
|
||||
{
|
||||
const int* srcLine = table + lineStrideElements * i;
|
||||
int* dstLine = newTable + newLineStrideElements * i;
|
||||
|
|
@ -210,90 +217,229 @@ void EdgeTable::optimiseTable() throw()
|
|||
{
|
||||
int maxLineElements = 0;
|
||||
|
||||
for (int i = height; --i >= 0;)
|
||||
maxLineElements = jmax (maxLineElements,
|
||||
table [i * lineStrideElements]);
|
||||
for (int i = bounds.getHeight(); --i >= 0;)
|
||||
maxLineElements = jmax (maxLineElements, table [i * lineStrideElements]);
|
||||
|
||||
remapTableForNumEdges (maxLineElements);
|
||||
}
|
||||
|
||||
void EdgeTable::addEdgePoint (const int x, const int y, const int winding) throw()
|
||||
{
|
||||
jassert (y >= 0 && y < height)
|
||||
jassert (y >= 0 && y < bounds.getHeight());
|
||||
|
||||
int* lineStart = table + lineStrideElements * y;
|
||||
int n = lineStart[0];
|
||||
int* line = table + lineStrideElements * y;
|
||||
const int numPoints = line[0];
|
||||
int n = line[0] << 1;
|
||||
|
||||
if (n >= maxEdgesPerLine)
|
||||
if (n > 0)
|
||||
{
|
||||
remapTableForNumEdges (maxEdgesPerLine + juce_edgeTableDefaultEdgesPerLine);
|
||||
jassert (n < maxEdgesPerLine);
|
||||
lineStart = table + lineStrideElements * y;
|
||||
while (n > 0)
|
||||
{
|
||||
const int cx = line [n - 1];
|
||||
|
||||
if (cx <= x)
|
||||
{
|
||||
if (cx == x)
|
||||
{
|
||||
line [n] += winding;
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
n -= 2;
|
||||
}
|
||||
|
||||
if (numPoints >= maxEdgesPerLine)
|
||||
{
|
||||
remapTableForNumEdges (maxEdgesPerLine + juce_edgeTableDefaultEdgesPerLine);
|
||||
jassert (numPoints < maxEdgesPerLine);
|
||||
line = table + lineStrideElements * y;
|
||||
}
|
||||
|
||||
memmove (line + (n + 3), line + (n + 1), sizeof (int) * ((numPoints << 1) - n));
|
||||
}
|
||||
|
||||
n <<= 1;
|
||||
|
||||
int* const line = lineStart + 1;
|
||||
|
||||
while (n > 0)
|
||||
{
|
||||
const int cx = line [n - 2];
|
||||
|
||||
if (cx <= x)
|
||||
break;
|
||||
|
||||
line [n] = cx;
|
||||
line [n + 1] = line [n - 1];
|
||||
n -= 2;
|
||||
}
|
||||
|
||||
line [n] = x;
|
||||
line [n + 1] = winding;
|
||||
|
||||
lineStart[0]++;
|
||||
line [n + 1] = x;
|
||||
line [n + 2] = winding;
|
||||
line[0]++;
|
||||
}
|
||||
|
||||
void EdgeTable::clearLineSection (const int y, int minX, int maxX) throw()
|
||||
{
|
||||
// int* line = table + lineStrideElements * y;
|
||||
jassert (y >= 0 && y < bounds.getHeight());
|
||||
jassert (maxX > minX);
|
||||
|
||||
int* lineStart = table + lineStrideElements * y;
|
||||
const int totalPoints = *lineStart;
|
||||
int* line = lineStart;
|
||||
int level = 0;
|
||||
int num = totalPoints;
|
||||
|
||||
while (--num >= 0)
|
||||
{
|
||||
int x = *++line;
|
||||
|
||||
if (x < minX)
|
||||
{
|
||||
level += *++line;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (x > maxX)
|
||||
{
|
||||
if (level != 0)
|
||||
{
|
||||
addEdgePoint (minX, y, -level);
|
||||
addEdgePoint (maxX, y, level);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (level != 0)
|
||||
{
|
||||
const int oldLevel = level;
|
||||
level += line[1];
|
||||
line[0] = minX;
|
||||
line[1] = -oldLevel;
|
||||
line += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
++num;
|
||||
}
|
||||
|
||||
int* cutPoint = line;
|
||||
int numToDelete = 0;
|
||||
|
||||
while (--num >= 0)
|
||||
{
|
||||
x = *line++;
|
||||
|
||||
if (x <= maxX)
|
||||
{
|
||||
level += *line++;
|
||||
++numToDelete;
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (num < 0)
|
||||
{
|
||||
lineStart[0] -= numToDelete;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (--numToDelete > 0)
|
||||
{
|
||||
char* startOfSrcSection = (char*) (cutPoint + numToDelete * 2);
|
||||
memmove (cutPoint, startOfSrcSection,
|
||||
((char*) (lineStart + (1 + 2 * totalPoints))) - startOfSrcSection);
|
||||
|
||||
lineStart[0] -= numToDelete;
|
||||
}
|
||||
|
||||
if (numToDelete < 0)
|
||||
{
|
||||
addEdgePoint (maxX, y, level);
|
||||
}
|
||||
else
|
||||
{
|
||||
cutPoint[0] = maxX;
|
||||
cutPoint[1] = level;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void EdgeTable::intersectWithEdgeTableLine (const int y, const int* otherLine) throw()
|
||||
{
|
||||
// int otherNum = otherLine[0];
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void EdgeTable::clipToRectangle (const Rectangle& r) throw()
|
||||
/*void EdgeTable::clipToRectangle (const Rectangle& r) throw()
|
||||
{
|
||||
const int rectTop = jmax (0, r.getY() - top);
|
||||
const int rectBottom = jmin (height, r.getBottom() - top);
|
||||
const Rectangle clipped (r.getIntersection (bounds));
|
||||
|
||||
for (int i = rectTop - 1; --i >= 0;)
|
||||
table [lineStrideElements * i] = 0;
|
||||
|
||||
for (int i = rectBottom; i < height; ++i)
|
||||
table [lineStrideElements * i] = 0;
|
||||
|
||||
for (int i = rectTop; i < rectBottom; ++i)
|
||||
if (clipped.isEmpty())
|
||||
{
|
||||
clearLineSection (i, -INT_MAX, r.getX());
|
||||
clearLineSection (i, r.getRight(), INT_MAX);
|
||||
bounds.setHeight (0);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int top = clipped.getY() - bounds.getY();
|
||||
const int bottom = clipped.getBottom() - bounds.getY();
|
||||
|
||||
if (bottom < bounds.getHeight())
|
||||
bounds.setHeight (bottom);
|
||||
|
||||
if (clipped.getRight() < bounds.getRight())
|
||||
bounds.setRight (clipped.getRight());
|
||||
|
||||
for (int i = top; --i >= 0;)
|
||||
table [lineStrideElements * i] = 0;
|
||||
|
||||
if (clipped.getX() > bounds.getX())
|
||||
for (int i = top; i < bottom; ++i)
|
||||
clearLineSection (i, bounds.getX(), clipped.getX());
|
||||
}
|
||||
}
|
||||
|
||||
void EdgeTable::excludeRectangle (const Rectangle& r) throw()
|
||||
{
|
||||
const int rectTop = jmax (0, r.getY() - top);
|
||||
const int rectBottom = jmin (height, r.getBottom() - top);
|
||||
const Rectangle clipped (r.getIntersection (bounds));
|
||||
|
||||
for (int i = rectTop; i < rectBottom; ++i)
|
||||
clearLineSection (i, r.getX(), r.getRight());
|
||||
if (! clipped.isEmpty())
|
||||
{
|
||||
const int top = clipped.getY() - bounds.getY();
|
||||
const int bottom = clipped.getBottom() - bounds.getY();
|
||||
|
||||
for (int i = top; i < bottom; ++i)
|
||||
clearLineSection (i, clipped.getX(), clipped.getRight());
|
||||
}
|
||||
}
|
||||
|
||||
void EdgeTable::clipToEdgeTable (const EdgeTable& other)
|
||||
{
|
||||
const Rectangle clipped (other.bounds.getIntersection (bounds));
|
||||
|
||||
if (clipped.isEmpty())
|
||||
{
|
||||
bounds.setHeight (0);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int top = clipped.getY() - bounds.getY();
|
||||
const int bottom = clipped.getBottom() - bounds.getY();
|
||||
|
||||
if (bottom < bounds.getHeight())
|
||||
bounds.setHeight (bottom);
|
||||
|
||||
if (clipped.getRight() < bounds.getRight())
|
||||
bounds.setRight (clipped.getRight());
|
||||
|
||||
for (int i = top; --i >= 0;)
|
||||
table [lineStrideElements * i] = 0;
|
||||
|
||||
const int* otherLine = other.table + other.lineStrideElements * (top + (bounds.getY() - other.bounds.getY()));
|
||||
|
||||
for (int i = top; i < bottom; ++i)
|
||||
{
|
||||
intersectWithEdgeTableLine (i, otherLine);
|
||||
otherLine += other.lineStrideElements;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EdgeTable::clipToImageAlpha (Image& image, int x, int y) throw()
|
||||
{
|
||||
}
|
||||
|
||||
*/
|
||||
END_JUCE_NAMESPACE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue