mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Modernised a few RectangleList iterators
This commit is contained in:
parent
d5c019e983
commit
38d49a5ee7
12 changed files with 66 additions and 64 deletions
|
|
@ -365,8 +365,8 @@ void Graphics::fillRectList (const RectangleList<float>& rectangles) const
|
|||
|
||||
void Graphics::fillRectList (const RectangleList<int>& rects) const
|
||||
{
|
||||
for (const Rectangle<int>* r = rects.begin(), * const e = rects.end(); r != e; ++r)
|
||||
context.fillRect (*r, false);
|
||||
for (auto& r : rects)
|
||||
context.fillRect (r, false);
|
||||
}
|
||||
|
||||
void Graphics::setPixel (int x, int y) const
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ void LowLevelGraphicsPostScriptRenderer::writeClip()
|
|||
|
||||
int itemsOnLine = 0;
|
||||
|
||||
for (const Rectangle<int>* i = stateStack.getLast()->clip.begin(), * const e = stateStack.getLast()->clip.end(); i != e; ++i)
|
||||
for (auto& i : stateStack.getLast()->clip)
|
||||
{
|
||||
if (++itemsOnLine == 6)
|
||||
{
|
||||
|
|
@ -208,8 +208,8 @@ void LowLevelGraphicsPostScriptRenderer::writeClip()
|
|||
out << '\n';
|
||||
}
|
||||
|
||||
out << i->getX() << ' ' << -i->getY() << ' '
|
||||
<< i->getWidth() << ' ' << -i->getHeight() << " pr ";
|
||||
out << i.getX() << ' ' << -i.getY() << ' '
|
||||
<< i.getWidth() << ' ' << -i.getHeight() << " pr ";
|
||||
}
|
||||
|
||||
out << "endclip\n";
|
||||
|
|
@ -482,7 +482,7 @@ void LowLevelGraphicsPostScriptRenderer::drawImage (const Image& sourceImage, co
|
|||
out << "newpath ";
|
||||
int itemsOnLine = 0;
|
||||
|
||||
for (const Rectangle<int>* i = imageClip.begin(), * const e = imageClip.end(); i != e; ++i)
|
||||
for (auto& i : imageClip)
|
||||
{
|
||||
if (++itemsOnLine == 6)
|
||||
{
|
||||
|
|
@ -490,7 +490,7 @@ void LowLevelGraphicsPostScriptRenderer::drawImage (const Image& sourceImage, co
|
|||
itemsOnLine = 0;
|
||||
}
|
||||
|
||||
out << i->getX() << ' ' << i->getY() << ' ' << i->getWidth() << ' ' << i->getHeight() << " pr ";
|
||||
out << i.getX() << ' ' << i.getY() << ' ' << i.getWidth() << ' ' << i.getHeight() << " pr ";
|
||||
}
|
||||
|
||||
out << " clip newpath\n";
|
||||
|
|
|
|||
|
|
@ -133,13 +133,13 @@ EdgeTable::EdgeTable (const RectangleList<int>& rectanglesToAdd)
|
|||
allocate();
|
||||
clearLineSizes();
|
||||
|
||||
for (const Rectangle<int>* r = rectanglesToAdd.begin(), * const e = rectanglesToAdd.end(); r != e; ++r)
|
||||
for (auto& r : rectanglesToAdd)
|
||||
{
|
||||
const int x1 = r->getX() << 8;
|
||||
const int x2 = r->getRight() << 8;
|
||||
int y = r->getY() - bounds.getY();
|
||||
const int x1 = r.getX() << 8;
|
||||
const int x2 = r.getRight() << 8;
|
||||
int y = r.getY() - bounds.getY();
|
||||
|
||||
for (int j = r->getHeight(); --j >= 0;)
|
||||
for (int j = r.getHeight(); --j >= 0;)
|
||||
addEdgePointPair (x1, x2, y++, 255);
|
||||
}
|
||||
|
||||
|
|
@ -156,13 +156,13 @@ EdgeTable::EdgeTable (const RectangleList<float>& rectanglesToAdd)
|
|||
allocate();
|
||||
clearLineSizes();
|
||||
|
||||
for (const Rectangle<float>* r = rectanglesToAdd.begin(), * const e = rectanglesToAdd.end(); r != e; ++r)
|
||||
for (auto& r : rectanglesToAdd)
|
||||
{
|
||||
const int x1 = roundToInt (r->getX() * 256.0f);
|
||||
const int x2 = roundToInt (r->getRight() * 256.0f);
|
||||
const int x1 = roundToInt (r.getX() * 256.0f);
|
||||
const int x2 = roundToInt (r.getRight() * 256.0f);
|
||||
|
||||
const int y1 = roundToInt (r->getY() * 256.0f) - (bounds.getY() << 8);
|
||||
const int y2 = roundToInt (r->getBottom() * 256.0f) - (bounds.getY() << 8);
|
||||
const int y1 = roundToInt (r.getY() * 256.0f) - (bounds.getY() << 8);
|
||||
const int y2 = roundToInt (r.getBottom() * 256.0f) - (bounds.getY() << 8);
|
||||
|
||||
if (x2 <= x1 || y2 <= y1)
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -352,11 +352,11 @@ public:
|
|||
|
||||
for (int j = 0; j < rects.size(); ++j)
|
||||
{
|
||||
const RectangleType& rect = rects.getReference (j);
|
||||
auto& rect = rects.getReference (j);
|
||||
|
||||
for (const Rectangle<OtherValueType>* r = other.begin(), * const e = other.end(); r != e; ++r)
|
||||
for (auto& r : other)
|
||||
{
|
||||
RectangleType clipped (r->template toType<ValueType>());
|
||||
auto clipped = r.template toType<ValueType>();
|
||||
|
||||
if (rect.intersectRectangle (clipped))
|
||||
result.rects.add (clipped);
|
||||
|
|
@ -386,7 +386,7 @@ public:
|
|||
{
|
||||
for (int i = rects.size(); --i >= 0;)
|
||||
{
|
||||
RectangleType r (rects.getReference (i));
|
||||
auto r = rects.getReference (i);
|
||||
|
||||
if (rect.intersectRectangle (r))
|
||||
destRegion.rects.add (r);
|
||||
|
|
|
|||
|
|
@ -1605,8 +1605,8 @@ struct ClipRegions
|
|||
RectangleList<int> inverse (edgeTable.getMaximumBounds());
|
||||
|
||||
if (inverse.subtract (r))
|
||||
for (const Rectangle<int>* i = inverse.begin(), * const e = inverse.end(); i != e; ++i)
|
||||
edgeTable.excludeRectangle (*i);
|
||||
for (auto& i : inverse)
|
||||
edgeTable.excludeRectangle (i);
|
||||
|
||||
return edgeTable.isEmpty() ? nullptr : this;
|
||||
}
|
||||
|
|
@ -1845,14 +1845,14 @@ struct ClipRegions
|
|||
template <class Renderer>
|
||||
void iterate (Renderer& r) const noexcept
|
||||
{
|
||||
for (const Rectangle<int>* i = clip.begin(), * const e = clip.end(); i != e; ++i)
|
||||
for (auto& i : clip)
|
||||
{
|
||||
const int x = i->getX();
|
||||
const int w = i->getWidth();
|
||||
const int x = i.getX();
|
||||
const int w = i.getWidth();
|
||||
jassert (w > 0);
|
||||
const int bottom = i->getBottom();
|
||||
const int bottom = i.getBottom();
|
||||
|
||||
for (int y = i->getY(); y < bottom; ++y)
|
||||
for (int y = i.getY(); y < bottom; ++y)
|
||||
{
|
||||
r.setEdgeTableYPos (y);
|
||||
r.handleEdgeTableLineFull (x, w);
|
||||
|
|
@ -1872,9 +1872,9 @@ struct ClipRegions
|
|||
template <class Renderer>
|
||||
void iterate (Renderer& r) const noexcept
|
||||
{
|
||||
for (const Rectangle<int>* i = clip.begin(), * const e = clip.end(); i != e; ++i)
|
||||
for (auto& i : clip)
|
||||
{
|
||||
const Rectangle<int> rect (i->getIntersection (area));
|
||||
auto rect = i.getIntersection (area);
|
||||
|
||||
if (! rect.isEmpty())
|
||||
{
|
||||
|
|
@ -1912,12 +1912,12 @@ struct ClipRegions
|
|||
{
|
||||
const RenderingHelpers::FloatRectangleRasterisingInfo f (area);
|
||||
|
||||
for (const Rectangle<int>* i = clip.begin(), * const e = clip.end(); i != e; ++i)
|
||||
for (auto& i : clip)
|
||||
{
|
||||
const int clipLeft = i->getX();
|
||||
const int clipRight = i->getRight();
|
||||
const int clipTop = i->getY();
|
||||
const int clipBottom = i->getBottom();
|
||||
const int clipLeft = i.getX();
|
||||
const int clipRight = i.getRight();
|
||||
const int clipTop = i.getY();
|
||||
const int clipBottom = i.getBottom();
|
||||
|
||||
if (f.totalBottom > clipTop && f.totalTop < clipBottom
|
||||
&& f.totalRight > clipLeft && f.totalLeft < clipRight)
|
||||
|
|
@ -2066,8 +2066,8 @@ public:
|
|||
cloneClipIfMultiplyReferenced();
|
||||
RectangleList<int> scaledList;
|
||||
|
||||
for (const Rectangle<int>* i = r.begin(), * const e = r.end(); i != e; ++i)
|
||||
scaledList.add (transform.transformed (*i));
|
||||
for (auto& i : r)
|
||||
scaledList.add (transform.transformed (i));
|
||||
|
||||
clip = clip->clipToRectangleList (scaledList);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -249,8 +249,8 @@ bool CoreGraphicsContext::clipToRectangleListWithoutTest (const RectangleList<in
|
|||
HeapBlock<CGRect> rects (numRects);
|
||||
|
||||
int i = 0;
|
||||
for (const Rectangle<int>* r = clipRegion.begin(), * const e = clipRegion.end(); r != e; ++r)
|
||||
rects[i++] = CGRectMake (r->getX(), flipHeight - r->getBottom(), r->getWidth(), r->getHeight());
|
||||
for (auto& r : clipRegion)
|
||||
rects[i++] = CGRectMake (r.getX(), flipHeight - r.getBottom(), r.getWidth(), r.getHeight());
|
||||
|
||||
CGContextClipToRects (context, rects, numRects);
|
||||
lastClipRectIsValid = false;
|
||||
|
|
@ -559,8 +559,9 @@ void CoreGraphicsContext::fillRectList (const RectangleList<float>& list)
|
|||
HeapBlock<CGRect> rects ((size_t) list.getNumRectangles());
|
||||
|
||||
size_t num = 0;
|
||||
for (const Rectangle<float>* r = list.begin(), * const e = list.end(); r != e; ++r)
|
||||
rects[num++] = CGRectMake (r->getX(), flipHeight - r->getBottom(), r->getWidth(), r->getHeight());
|
||||
|
||||
for (auto& r : list)
|
||||
rects[num++] = CGRectMake (r.getX(), flipHeight - r.getBottom(), r.getWidth(), r.getHeight());
|
||||
|
||||
if (state->fillType.isColour())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -191,8 +191,8 @@ public:
|
|||
|
||||
void fillRectList (const RectangleList<float>& list)
|
||||
{
|
||||
for (const Rectangle<float>* r = list.begin(), * const e = list.end(); r != e; ++r)
|
||||
fillRect (*r);
|
||||
for (auto& r : list)
|
||||
fillRect (r);
|
||||
}
|
||||
|
||||
void fillPath (const Path& p, const AffineTransform& transform)
|
||||
|
|
|
|||
|
|
@ -777,8 +777,8 @@ public:
|
|||
void paint (Graphics& g) override
|
||||
{
|
||||
scale = g.getInternalContext().getPhysicalPixelScaleFactor();
|
||||
const Rectangle<int> compBounds (owner.getLocalBounds());
|
||||
const Rectangle<int> imageBounds (compBounds * scale);
|
||||
auto compBounds = owner.getLocalBounds();
|
||||
auto imageBounds = compBounds * scale;
|
||||
|
||||
if (image.isNull() || image.getBounds() != imageBounds)
|
||||
{
|
||||
|
|
@ -794,12 +794,12 @@ public:
|
|||
if (! validArea.containsRectangle (compBounds))
|
||||
{
|
||||
Graphics imG (image);
|
||||
LowLevelGraphicsContext& lg = imG.getInternalContext();
|
||||
auto& lg = imG.getInternalContext();
|
||||
|
||||
lg.addTransform (AffineTransform::scale (scale));
|
||||
|
||||
for (const Rectangle<int>* i = validArea.begin(), * const e = validArea.end(); i != e; ++i)
|
||||
lg.excludeClipRectangle (*i);
|
||||
for (auto& i : validArea)
|
||||
lg.excludeClipRectangle (i);
|
||||
|
||||
if (! owner.isOpaque())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2699,8 +2699,8 @@ private:
|
|||
adjustedList.offsetAll (-totalArea.getX(), -totalArea.getY());
|
||||
|
||||
if (peer.depth == 32)
|
||||
for (const Rectangle<int>* i = originalRepaintRegion.begin(), * const e = originalRepaintRegion.end(); i != e; ++i)
|
||||
image.clear (*i - totalArea.getPosition());
|
||||
for (auto& i : originalRepaintRegion)
|
||||
image.clear (i - totalArea.getPosition());
|
||||
|
||||
{
|
||||
ScopedPointer<LowLevelGraphicsContext> context (peer.getComponent().getLookAndFeel()
|
||||
|
|
@ -2709,9 +2709,10 @@ private:
|
|||
peer.handlePaint (*context);
|
||||
}
|
||||
|
||||
for (const Rectangle<int>* i = originalRepaintRegion.begin(), * const e = originalRepaintRegion.end(); i != e; ++i)
|
||||
for (auto& i : originalRepaintRegion)
|
||||
{
|
||||
XBitmapImage* xbitmap = static_cast<XBitmapImage*> (image.getPixelData());
|
||||
auto* xbitmap = static_cast<XBitmapImage*> (image.getPixelData());
|
||||
|
||||
#if JUCE_USE_XSHM
|
||||
if (xbitmap->isUsingXShm())
|
||||
++shmPaintsPending;
|
||||
|
|
@ -2719,10 +2720,10 @@ private:
|
|||
|
||||
|
||||
xbitmap->blitToWindow (peer.windowH,
|
||||
i->getX(), i->getY(),
|
||||
(unsigned int) i->getWidth(),
|
||||
(unsigned int) i->getHeight(),
|
||||
i->getX() - totalArea.getX(), i->getY() - totalArea.getY());
|
||||
i.getX(), i.getY(),
|
||||
(unsigned int) i.getWidth(),
|
||||
(unsigned int) i.getHeight(),
|
||||
i.getX() - totalArea.getX(), i.getY() - totalArea.getY());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -933,8 +933,8 @@ public:
|
|||
|
||||
void setNeedsDisplayRectangles()
|
||||
{
|
||||
for (const Rectangle<float>* i = deferredRepaints.begin(), *e = deferredRepaints.end(); i != e; ++i)
|
||||
[view setNeedsDisplayInRect: makeNSRect (*i)];
|
||||
for (auto& i : deferredRepaints)
|
||||
[view setNeedsDisplayInRect: makeNSRect (i)];
|
||||
|
||||
lastRepaintTime = Time::getMillisecondCounter();
|
||||
deferredRepaints.clear();
|
||||
|
|
|
|||
|
|
@ -199,9 +199,9 @@ public:
|
|||
cachedImageFrameBuffer.makeCurrentRenderingTarget();
|
||||
const int imageH = cachedImageFrameBuffer.getHeight();
|
||||
|
||||
for (const Rectangle<int>* i = list.begin(), * const e = list.end(); i != e; ++i)
|
||||
for (auto& r : list)
|
||||
{
|
||||
glScissor (i->getX(), imageH - i->getBottom(), i->getWidth(), i->getHeight());
|
||||
glScissor (r.getX(), imageH - r.getBottom(), r.getWidth(), r.getHeight());
|
||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1200,15 +1200,15 @@ struct StateHelpers
|
|||
|
||||
void add (const RectangleList<int>& list, const PixelARGB colour) noexcept
|
||||
{
|
||||
for (const Rectangle<int>* i = list.begin(), * const e = list.end(); i != e; ++i)
|
||||
add (*i, colour);
|
||||
for (auto& i : list)
|
||||
add (i, colour);
|
||||
}
|
||||
|
||||
void add (const RectangleList<int>& list, const Rectangle<int>& clip, const PixelARGB colour) noexcept
|
||||
{
|
||||
for (const Rectangle<int>* i = list.begin(), * const e = list.end(); i != e; ++i)
|
||||
for (auto& i : list)
|
||||
{
|
||||
const Rectangle<int> r (i->getIntersection (clip));
|
||||
auto r = i.getIntersection (clip);
|
||||
|
||||
if (! r.isEmpty())
|
||||
add (r, colour);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue