25 #ifndef JUCE_RENDERINGHELPERS_H_INCLUDED 26 #define JUCE_RENDERINGHELPERS_H_INCLUDED 29 #pragma warning (push) 30 #pragma warning (disable: 4127) // "expression is constant" warning 78 const int tx = (int) (t.getTranslationX() * 256.0f);
79 const int ty = (int) (t.getTranslationY() * 256.0f);
81 if (((tx | ty) & 0xf8) == 0)
119 template <
typename RectangleOrPo
int>
126 template <
typename Type>
140 template <
class CachedGlyphType,
class RenderTargetType>
151 getSingletonPointer() =
nullptr;
169 addNewGlyphSlots (120);
178 glyph->lastAccessCount = ++accessCounter;
179 glyph->draw (target, pos);
187 if (CachedGlyphType* g = findExistingGlyph (font, glyphNumber))
194 CachedGlyphType* g = getGlyphForReuse();
196 g->generate (font, glyphNumber);
206 CachedGlyphType* findExistingGlyph (
const Font& font,
int glyphNumber)
const 208 for (
int i = 0; i < glyphs.size(); ++i)
210 CachedGlyphType*
const g = glyphs.getUnchecked (i);
212 if (g->glyph == glyphNumber && g->font == font)
219 CachedGlyphType* getGlyphForReuse()
221 if (hits.
value + misses.
value > glyphs.size() * 16)
224 addNewGlyphSlots (32);
230 if (CachedGlyphType* g = findLeastRecentlyUsedGlyph())
233 addNewGlyphSlots (32);
234 return glyphs.getLast();
237 void addNewGlyphSlots (
int num)
239 glyphs.ensureStorageAllocated (glyphs.size() + num);
242 glyphs.add (
new CachedGlyphType());
245 CachedGlyphType* findLeastRecentlyUsedGlyph() const
noexcept 247 CachedGlyphType* oldest =
nullptr;
248 int oldestCounter = std::numeric_limits<int>::max();
250 for (
int i = glyphs.size() - 1; --i >= 0;)
252 CachedGlyphType*
const glyph = glyphs.getUnchecked(i);
254 if (glyph->lastAccessCount <= oldestCounter
255 && glyph->getReferenceCount() == 1)
257 oldestCounter = glyph->lastAccessCount;
276 template <
class RendererType>
284 if (snapToIntegerCoordinate)
285 pos.
x = std::floor (pos.
x + 0.5f);
287 if (edgeTable !=
nullptr)
288 state.fillEdgeTable (*edgeTable, pos.
x,
roundToInt (pos.
y));
295 snapToIntegerCoordinate = typeface->
isHinted();
298 const float fontHeight = font.
getHeight();
301 fontHeight), fontHeight);
321 right (
roundToInt (256.0f * area.getRight())),
322 bottom (
roundToInt (256.0f * area.getBottom()))
324 if ((top >> 8) == (bottom >> 8))
326 topAlpha = bottom - top;
329 totalBottom = bottom = top = totalTop + 1;
333 if ((top & 255) == 0)
336 top = totalTop = (top >> 8);
340 topAlpha = 255 - (top & 255);
341 totalTop = (top >> 8);
345 bottomAlpha = bottom & 255;
347 totalBottom = bottom + (bottomAlpha != 0 ? 1 : 0);
350 if ((left >> 8) == (right >> 8))
352 leftAlpha = right - left;
354 totalLeft = (left >> 8);
355 totalRight = right = left = totalLeft + 1;
359 if ((left & 255) == 0)
362 left = totalLeft = (left >> 8);
366 leftAlpha = 255 - (left & 255);
367 totalLeft = (left >> 8);
368 left = totalLeft + 1;
371 rightAlpha = right & 255;
373 totalRight = right + (rightAlpha != 0 ? 1 : 0);
377 template <
class Callback>
380 if (topAlpha != 0) callback (totalLeft, totalTop, totalRight - totalLeft, 1, topAlpha);
381 if (bottomAlpha != 0) callback (totalLeft, bottom, totalRight - totalLeft, 1, bottomAlpha);
382 if (leftAlpha != 0) callback (totalLeft, totalTop, 1, totalBottom - totalTop, leftAlpha);
383 if (rightAlpha != 0) callback (right, totalTop, 1, totalBottom - totalTop, rightAlpha);
385 callback (left, top, right - left, bottom - top, 255);
396 int left,
top, right, bottom;
403 namespace GradientPixelIterators
410 const PixelARGB*
const colours,
const int numColours)
411 : lookupTable (colours),
412 numEntries (numColours)
430 vertical = std::abs (p1.
x - p2.
x) < 0.001f;
431 horizontal = std::abs (p1.
y - p2.
y) < 0.001f;
435 scale =
roundToInt ((numEntries << (
int) numScaleBits) / (
double) (p2.
y - p1.
y));
440 scale =
roundToInt ((numEntries << (
int) numScaleBits) / (
double) (p2.
x - p1.
x));
445 grad = (p2.
getY() - p1.
y) / (
double) (p1.
x - p2.
x);
446 yTerm = p1.
getY() - p1.
x / grad;
447 scale =
roundToInt ((numEntries << (
int) numScaleBits) / (yTerm * grad - (p2.
y * grad - p2.
x)));
455 linePix = lookupTable [
jlimit (0, numEntries, (y * scale - start) >> (
int) numScaleBits)];
456 else if (! horizontal)
462 return vertical ? linePix
463 : lookupTable [
jlimit (0, numEntries, (x * scale - start) >> (
int) numScaleBits)];
468 const int numEntries;
472 bool vertical, horizontal;
473 enum { numScaleBits = 12 };
484 const PixelARGB*
const colours,
const int numColours)
485 : lookupTable (colours),
486 numEntries (numColours),
487 gx1 (gradient.point1.x),
488 gy1 (gradient.point1.y)
492 maxDist = diff.
x * diff.
x + diff.
y * diff.
y;
493 invScale = numEntries / std::sqrt (maxDist);
509 return lookupTable [x >= maxDist ? numEntries :
roundToInt (std::sqrt (x) * invScale)];
527 const PixelARGB*
const colours,
const int numColours)
528 :
Radial (gradient, transform, colours, numColours),
529 inverseTransform (transform.inverted())
531 tM10 = inverseTransform.mat10;
532 tM00 = inverseTransform.mat00;
537 const float floatY = (float) y;
538 lineYM01 = inverseTransform.mat01 * floatY + inverseTransform.mat02 - gx1;
539 lineYM11 = inverseTransform.mat11 * floatY + inverseTransform.mat12 - gy1;
545 const double y = tM10 * x + lineYM11;
546 x = tM00 * x + lineYM01;
551 return lookupTable [numEntries];
553 return lookupTable [
jmin (numEntries,
roundToInt (std::sqrt (x) * invScale))];
557 double tM10, tM00, lineYM01, lineYM11;
564 #define JUCE_PERFORM_PIXEL_OP_LOOP(op) \ 566 const int destStride = destData.pixelStride; \ 567 do { dest->op; dest = addBytesToPointer (dest, destStride); } while (--width > 0); \ 572 namespace EdgeTableFillers
575 template <
class PixelType,
bool replaceExisting = false>
580 : destData (image), sourceColour (colour)
582 if (
sizeof (PixelType) == 3 && destData.pixelStride == sizeof (PixelType))
584 areRGBComponentsEqual = sourceColour.getRed() == sourceColour.getGreen()
585 && sourceColour.getGreen() == sourceColour.getBlue();
586 filler[0].set (sourceColour);
587 filler[1].set (sourceColour);
588 filler[2].set (sourceColour);
589 filler[3].set (sourceColour);
593 areRGBComponentsEqual =
false;
599 linePixels = (PixelType*) destData.getLinePointer (y);
605 getPixel (x)->set (sourceColour);
607 getPixel (x)->blend (sourceColour, (
uint32) alphaLevel);
613 getPixel (x)->set (sourceColour);
615 getPixel (x)->blend (sourceColour);
623 PixelType* dest = getPixel (x);
625 if (replaceExisting || p.
getAlpha() >= 0xff)
626 replaceLine (dest, p, width);
628 blendLine (dest, p, width);
633 PixelType* dest = getPixel (x);
635 if (replaceExisting || sourceColour.getAlpha() >= 0xff)
636 replaceLine (dest, sourceColour, width);
638 blendLine (dest, sourceColour, width);
643 PixelType* linePixels;
646 bool areRGBComponentsEqual;
653 inline void blendLine (PixelType* dest,
const PixelARGB colour,
int width)
const noexcept 662 if (areRGBComponentsEqual)
664 memset (dest, colour.
getRed(), (size_t) width * 3);
670 const int*
const intFiller =
reinterpret_cast<const int*
> (filler);
681 int* d =
reinterpret_cast<int*
> (dest);
685 dest =
reinterpret_cast<PixelRGB*
> (d);
706 memset (dest, colour.
getAlpha(), (size_t) width);
721 template <
class PixelType,
class GradientType>
726 const PixelARGB*
const colours,
const int numColours)
727 : GradientType (gradient, transform, colours, numColours - 1),
734 linePixels = (PixelType*) destData.getLinePointer (y);
735 GradientType::setY (y);
740 getPixel (x)->blend (GradientType::getPixel (x), (
uint32) alphaLevel);
745 getPixel (x)->blend (GradientType::getPixel (x));
750 PixelType* dest = getPixel (x);
752 if (alphaLevel < 0xff)
760 PixelType* dest = getPixel (x);
766 PixelType* linePixels;
778 template <
class DestPixelType,
class SrcPixelType,
bool repeatPattern>
783 const int alpha,
const int x,
const int y)
786 extraAlpha (alpha + 1),
794 linePixels = (DestPixelType*) destData.getLinePointer (y);
803 sourceLineStart = (SrcPixelType*) srcData.getLinePointer (y);
808 alphaLevel = (alphaLevel * extraAlpha) >> 8;
810 getDestPixel (x)->blend (*getSrcPixel (repeatPattern ? ((x - xOffset) % srcData.width) : (x - xOffset)), (
uint32) alphaLevel);
815 getDestPixel (x)->blend (*getSrcPixel (repeatPattern ? ((x - xOffset) % srcData.width) : (x - xOffset)), (
uint32) extraAlpha);
820 DestPixelType* dest = getDestPixel (x);
821 alphaLevel = (alphaLevel * extraAlpha) >> 8;
826 if (alphaLevel < 0xfe)
833 jassert (x >= 0 && x + width <= srcData.width);
835 if (alphaLevel < 0xfe)
838 copyRow (dest, getSrcPixel (x), width);
844 DestPixelType* dest = getDestPixel (x);
849 if (extraAlpha < 0xfe)
856 jassert (x >= 0 && x + width <= srcData.width);
858 if (extraAlpha < 0xfe)
861 copyRow (dest, getSrcPixel (x), width);
867 jassert (x - xOffset >= 0 && x + width - xOffset <= srcData.width);
868 SrcPixelType* s = (SrcPixelType*) srcData.getLinePointer (y - yOffset);
871 if (
sizeof (SrcPixelType) ==
sizeof (
PixelARGB))
880 const int extraAlpha, xOffset, yOffset;
881 DestPixelType* linePixels;
882 SrcPixelType* sourceLineStart;
894 forcedinline void copyRow (DestPixelType* dest, SrcPixelType
const* src,
int width)
const noexcept 899 if (destStride == srcStride
903 memcpy (dest, src, (
size_t) (width * srcStride));
912 }
while (--width > 0);
921 template <
class DestPixelType,
class SrcPixelType,
bool repeatPattern>
927 : interpolator (transform,
928 q !=
Graphics::lowResamplingQuality ? 0.5f : 0.0f,
929 q !=
Graphics::lowResamplingQuality ? -128 : 0),
932 extraAlpha (alpha + 1),
934 maxX (src.width - 1),
935 maxY (src.height - 1),
938 scratchBuffer.malloc (scratchSize);
944 linePixels = (DestPixelType*) destData.getLinePointer (newY);
952 getDestPixel (x)->blend (p, (
uint32) (alphaLevel * extraAlpha) >> 8);
960 getDestPixel (x)->blend (p, (
uint32) extraAlpha);
965 if (width > (
int) scratchSize)
967 scratchSize = (size_t) width;
968 scratchBuffer.malloc (scratchSize);
971 SrcPixelType* span = scratchBuffer;
972 generate (span, x, width);
974 DestPixelType* dest = getDestPixel (x);
975 alphaLevel *= extraAlpha;
978 if (alphaLevel < 0xfe)
986 handleEdgeTableLine (x, width, 255);
991 if (width > (
int) scratchSize)
993 scratchSize = (size_t) width;
994 scratchBuffer.malloc (scratchSize);
998 generate (scratchBuffer.getData(), x, width);
1001 reinterpret_cast<uint8*> (scratchBuffer.getData()) + SrcPixelType::indexA,
1002 sizeof (SrcPixelType), width);
1012 template <
class PixelType>
1013 void generate (PixelType* dest,
const int x,
int numPixels)
noexcept 1015 this->interpolator.setStartOfLine ((
float) x, (
float) y, numPixels);
1020 this->interpolator.next (hiResX, hiResY);
1022 int loResX = hiResX >> 8;
1023 int loResY = hiResY >> 8;
1038 render4PixelAverage (dest, this->srcData.getPixelPointer (loResX, loResY),
1039 hiResX & 255, hiResY & 255);
1044 if (! repeatPattern)
1048 render2PixelAverageX (dest, this->srcData.getPixelPointer (loResX, 0), hiResX & 255);
1050 render2PixelAverageX (dest, this->srcData.getPixelPointer (loResX, maxY), hiResX & 255);
1062 render2PixelAverageY (dest, this->srcData.getPixelPointer (0, loResY), hiResY & 255);
1064 render2PixelAverageY (dest, this->srcData.getPixelPointer (maxX, loResY), hiResY & 255);
1072 if (! repeatPattern)
1074 if (loResX < 0) loResX = 0;
1075 if (loResY < 0) loResY = 0;
1076 if (loResX > maxX) loResX = maxX;
1077 if (loResY > maxY) loResY = maxY;
1080 dest->set (*(
const PixelType*) this->srcData.getPixelPointer (loResX, loResY));
1083 }
while (--numPixels > 0);
1087 void render4PixelAverage (
PixelARGB*
const dest,
const uint8* src,
const int subPixelX,
const int subPixelY)
noexcept 1089 uint32 c[4] = { 256 * 128, 256 * 128, 256 * 128, 256 * 128 };
1091 uint32 weight = (
uint32) ((256 - subPixelX) * (256 - subPixelY));
1092 c[0] += weight * src[0];
1093 c[1] += weight * src[1];
1094 c[2] += weight * src[2];
1095 c[3] += weight * src[3];
1097 src += this->srcData.pixelStride;
1099 weight = (
uint32) (subPixelX * (256 - subPixelY));
1100 c[0] += weight * src[0];
1101 c[1] += weight * src[1];
1102 c[2] += weight * src[2];
1103 c[3] += weight * src[3];
1105 src += this->srcData.lineStride;
1107 weight = (
uint32) (subPixelX * subPixelY);
1108 c[0] += weight * src[0];
1109 c[1] += weight * src[1];
1110 c[2] += weight * src[2];
1111 c[3] += weight * src[3];
1113 src -= this->srcData.pixelStride;
1115 weight = (
uint32) ((256 - subPixelX) * subPixelY);
1116 c[0] += weight * src[0];
1117 c[1] += weight * src[1];
1118 c[2] += weight * src[2];
1119 c[3] += weight * src[3];
1129 uint32 c[4] = { 128, 128, 128, 128 };
1131 uint32 weight = 256 - subPixelX;
1132 c[0] += weight * src[0];
1133 c[1] += weight * src[1];
1134 c[2] += weight * src[2];
1135 c[3] += weight * src[3];
1137 src += this->srcData.pixelStride;
1140 c[0] += weight * src[0];
1141 c[1] += weight * src[1];
1142 c[2] += weight * src[2];
1143 c[3] += weight * src[3];
1153 uint32 c[4] = { 128, 128, 128, 128 };
1155 uint32 weight = 256 - subPixelY;
1156 c[0] += weight * src[0];
1157 c[1] += weight * src[1];
1158 c[2] += weight * src[2];
1159 c[3] += weight * src[3];
1161 src += this->srcData.lineStride;
1164 c[0] += weight * src[0];
1165 c[1] += weight * src[1];
1166 c[2] += weight * src[2];
1167 c[3] += weight * src[3];
1178 uint32 c[3] = { 256 * 128, 256 * 128, 256 * 128 };
1180 uint32 weight = (256 - subPixelX) * (256 - subPixelY);
1181 c[0] += weight * src[0];
1182 c[1] += weight * src[1];
1183 c[2] += weight * src[2];
1185 src += this->srcData.pixelStride;
1187 weight = subPixelX * (256 - subPixelY);
1188 c[0] += weight * src[0];
1189 c[1] += weight * src[1];
1190 c[2] += weight * src[2];
1192 src += this->srcData.lineStride;
1194 weight = subPixelX * subPixelY;
1195 c[0] += weight * src[0];
1196 c[1] += weight * src[1];
1197 c[2] += weight * src[2];
1199 src -= this->srcData.pixelStride;
1201 weight = (256 - subPixelX) * subPixelY;
1202 c[0] += weight * src[0];
1203 c[1] += weight * src[1];
1204 c[2] += weight * src[2];
1214 uint32 c[3] = { 128, 128, 128 };
1216 const uint32 weight = 256 - subPixelX;
1217 c[0] += weight * src[0];
1218 c[1] += weight * src[1];
1219 c[2] += weight * src[2];
1221 src += this->srcData.pixelStride;
1223 c[0] += subPixelX * src[0];
1224 c[1] += subPixelX * src[1];
1225 c[2] += subPixelX * src[2];
1235 uint32 c[3] = { 128, 128, 128 };
1237 const uint32 weight = 256 - subPixelY;
1238 c[0] += weight * src[0];
1239 c[1] += weight * src[1];
1240 c[2] += weight * src[2];
1242 src += this->srcData.lineStride;
1244 c[0] += subPixelY * src[0];
1245 c[1] += subPixelY * src[1];
1246 c[2] += subPixelY * src[2];
1258 c += src[0] * ((256 - subPixelX) * (256 - subPixelY));
1259 src += this->srcData.pixelStride;
1260 c += src[1] * (subPixelX * (256 - subPixelY));
1261 src += this->srcData.lineStride;
1262 c += src[1] * (subPixelX * subPixelY);
1263 src -= this->srcData.pixelStride;
1265 c += src[0] * ((256 - subPixelX) * subPixelY);
1273 c += src[0] * (256 - subPixelX);
1274 src += this->srcData.pixelStride;
1275 c += src[0] * subPixelX;
1282 c += src[0] * (256 - subPixelY);
1283 src += this->srcData.lineStride;
1284 c += src[0] * subPixelY;
1289 class TransformedImageSpanInterpolator
1293 const float offsetFloat,
const int offsetInt)
noexcept 1294 : inverseTransform (transform.
inverted()),
1295 pixelOffset (offsetFloat), pixelOffsetInt (offsetInt)
1298 void setStartOfLine (
float sx,
float sy,
const int numPixels)
noexcept 1304 float x1 = sx, y1 = sy;
1305 sx += (float) numPixels;
1306 inverseTransform.transformPoints (x1, y1, sx, sy);
1308 xBresenham.set ((
int) (x1 * 256.0f), (
int) (sx * 256.0f), numPixels, pixelOffsetInt);
1309 yBresenham.set ((
int) (y1 * 256.0f), (
int) (sy * 256.0f), numPixels, pixelOffsetInt);
1312 void next (
int& px,
int& py)
noexcept 1314 px = xBresenham.n; xBresenham.stepToNext();
1315 py = yBresenham.n; yBresenham.stepToNext();
1319 class BresenhamInterpolator
1322 BresenhamInterpolator()
noexcept {}
1324 void set (
const int n1,
const int n2,
const int steps,
const int offsetInt)
noexcept 1327 step = (n2 - n1) / numSteps;
1328 remainder = modulo = (n2 - n1) % numSteps;
1334 remainder += numSteps;
1343 modulo += remainder;
1356 int numSteps, step, modulo, remainder;
1360 BresenhamInterpolator xBresenham, yBresenham;
1361 const float pixelOffset;
1362 const int pixelOffsetInt;
1368 TransformedImageSpanInterpolator interpolator;
1371 const int extraAlpha;
1373 const int maxX, maxY;
1375 DestPixelType* linePixels;
1384 template <
class Iterator>
1446 template <
class Iterator>
1507 template <
class Iterator,
class DestPixelType>
1510 if (replaceContents)
1522 template <
class Iterator,
class DestPixelType>
1524 const PixelARGB*
const lookupTable,
const int numLookupEntries,
const bool isIdentity, DestPixelType*)
1531 iter.iterate (renderer);
1536 iter.iterate (renderer);
1542 iter.iterate (renderer);
1548 template <
class SavedStateType>
1559 virtual Ptr clone()
const = 0;
1560 virtual Ptr applyClipTo (
const Ptr& target)
const = 0;
1566 virtual Ptr clipToEdgeTable (
const EdgeTable& et) = 0;
1570 virtual bool clipRegionIntersects (
const Rectangle<int>&)
const = 0;
1573 virtual void fillRectWithColour (SavedStateType&,
const Rectangle<int>&,
const PixelARGB colour,
bool replaceContents)
const = 0;
1575 virtual void fillAllWithColour (SavedStateType&,
const PixelARGB colour,
bool replaceContents)
const = 0;
1596 Ptr
applyClipTo (
const Ptr& target)
const {
return target->clipToEdgeTable (edgeTable); }
1600 edgeTable.clipToRectangle (r);
1601 return edgeTable.isEmpty() ?
nullptr :
this;
1608 if (inverse.subtract (r))
1609 for (
const Rectangle<int>* i = inverse.begin(), *
const e = inverse.end(); i != e; ++i)
1610 edgeTable.excludeRectangle (*i);
1617 edgeTable.excludeRectangle (r);
1618 return edgeTable.isEmpty() ?
nullptr :
this;
1623 EdgeTable et (edgeTable.getMaximumBounds(), p, transform);
1625 return edgeTable.isEmpty() ?
nullptr :
this;
1630 edgeTable.clipToEdgeTable (et);
1631 return edgeTable.isEmpty() ?
nullptr :
this;
1646 const int imageX = ((tx + 128) >> 8);
1647 const int imageY = ((ty + 128) >> 8);
1650 straightClipImage (srcData, imageX, imageY, (
PixelARGB*) 0);
1652 straightClipImage (srcData, imageX, imageY, (
PixelAlpha*) 0);
1654 return edgeTable.isEmpty() ?
nullptr :
this;
1664 EdgeTable et2 (edgeTable.getMaximumBounds(), p, transform);
1668 if (! edgeTable.isEmpty())
1671 transformedClipImage (srcData, transform, quality, (
PixelARGB*) 0);
1673 transformedClipImage (srcData, transform, quality, (
PixelAlpha*) 0);
1676 return edgeTable.isEmpty() ?
nullptr :
this;
1681 edgeTable.translate ((
float) delta.
x, delta.
y);
1686 return edgeTable.getMaximumBounds().intersects (r);
1691 return edgeTable.getMaximumBounds();
1699 if (! clipped.isEmpty())
1703 state.fillWithSolidColour (et.
edgeTable, colour, replaceContents);
1712 if (! clipped.isEmpty())
1716 state.fillWithSolidColour (et.
edgeTable, colour,
false);
1722 state.fillWithSolidColour (edgeTable, colour, replaceContents);
1727 state.fillWithGradient (edgeTable, gradient, transform, isIdentity);
1732 state.renderImageTransformed (edgeTable, src, alpha, transform, quality, tiledFill);
1737 state.renderImageUntransformed (edgeTable, src, alpha, x, y, tiledFill);
1743 template <
class SrcPixelType>
1753 template <
class SrcPixelType>
1754 void straightClipImage (
const Image::BitmapData& srcData,
int imageX,
int imageY,
const SrcPixelType*)
1779 Ptr
applyClipTo (
const Ptr& target)
const {
return target->clipToRectangleList (clip); }
1784 return clip.isEmpty() ?
nullptr :
this;
1790 return clip.isEmpty() ?
nullptr :
this;
1796 return clip.isEmpty() ?
nullptr :
this;
1804 return toEdgeTable()->clipToImageAlpha (image, transform, quality);
1813 SubRectangleIterator iter (clip, area);
1814 state.fillWithSolidColour (iter, colour, replaceContents);
1819 SubRectangleIteratorFloat iter (clip, area);
1820 state.fillWithSolidColour (iter, colour,
false);
1825 state.fillWithSolidColour (*
this, colour, replaceContents);
1830 state.fillWithGradient (*
this, gradient, transform, isIdentity);
1835 state.renderImageTransformed (*
this, src, alpha, transform, quality, tiledFill);
1840 state.renderImageUntransformed (*
this, src, alpha, x, y, tiledFill);
1846 template <
class Renderer>
1851 const int x = i->getX();
1852 const int w = i->getWidth();
1854 const int bottom = i->getBottom();
1856 for (
int y = i->getY(); y < bottom; ++y)
1858 r.setEdgeTableYPos (y);
1859 r.handleEdgeTableLineFull (x, w);
1866 class SubRectangleIterator
1870 : clip (clipList), area (clipBounds)
1873 template <
class Renderer>
1874 void iterate (Renderer& r)
const noexcept 1880 if (! rect.isEmpty())
1882 const int x = rect.
getX();
1883 const int w = rect.getWidth();
1884 const int bottom = rect.getBottom();
1886 for (
int y = rect.getY(); y < bottom; ++y)
1888 r.setEdgeTableYPos (y);
1889 r.handleEdgeTableLineFull (x, w);
1903 class SubRectangleIteratorFloat
1907 : clip (clipList), area (clipBounds)
1911 template <
class Renderer>
1912 void iterate (Renderer& r)
const noexcept 1918 const int clipLeft = i->getX();
1919 const int clipRight = i->getRight();
1920 const int clipTop = i->getY();
1921 const int clipBottom = i->getBottom();
1934 const int endY =
jmin (f.
bottom, clipBottom);
1935 for (
int y =
jmax (clipTop, f.
top); y < endY; ++y)
1937 r.setEdgeTableYPos (y);
1938 r.handleEdgeTablePixelFull (f.
left);
1943 r.setEdgeTableYPos (f.
bottom);
1949 const int clippedLeft =
jmax (f.
left, clipLeft);
1950 const int clippedWidth =
jmin (f.
right, clipRight) - clippedLeft;
1959 if (clippedWidth > 0) r.handleEdgeTableLine (clippedLeft, clippedWidth, f.
topAlpha);
1963 const int endY =
jmin (f.
bottom, clipBottom);
1964 for (
int y =
jmax (clipTop, f.
top); y < endY; ++y)
1966 r.setEdgeTableYPos (y);
1969 if (clippedWidth > 0) r.handleEdgeTableLineFull (clippedLeft, clippedWidth);
1975 r.setEdgeTableYPos (f.
bottom);
1978 if (clippedWidth > 0) r.handleEdgeTableLine (clippedLeft, clippedWidth, f.
bottomAlpha);
2000 template <
class SavedStateType>
2009 : clip (new RectangleListRegionType (initialClip)), transform (
Point<int>()),
2010 interpolationQuality (
Graphics::mediumResamplingQuality), transparencyLayerAlpha (1.0f)
2015 : clip (new RectangleListRegionType (clipList)), transform (origin),
2016 interpolationQuality (
Graphics::mediumResamplingQuality), transparencyLayerAlpha (1.0f)
2021 : clip (other.clip), transform (other.transform), fillType (other.fillType),
2022 interpolationQuality (other.interpolationQuality),
2023 transparencyLayerAlpha (other.transparencyLayerAlpha)
2031 if (clip !=
nullptr)
2033 if (transform.isOnlyTranslated)
2035 cloneClipIfMultiplyReferenced();
2036 clip = clip->clipToRectangle (transform.translated (r));
2038 else if (! transform.isRotated)
2040 cloneClipIfMultiplyReferenced();
2041 clip = clip->clipToRectangle (transform.transformed (r));
2051 return clip !=
nullptr;
2056 if (clip !=
nullptr)
2058 if (transform.isOnlyTranslated)
2060 cloneClipIfMultiplyReferenced();
2062 offsetList.
offsetAll (transform.offset.x, transform.offset.y);
2063 clip = clip->clipToRectangleList (offsetList);
2065 else if (! transform.isRotated)
2067 cloneClipIfMultiplyReferenced();
2071 scaledList.
add (transform.transformed (*i));
2073 clip = clip->clipToRectangleList (scaledList);
2081 return clip !=
nullptr;
2086 const int x1 = (int) std::ceil (r.
getX());
2087 const int y1 = (int) std::ceil (r.
getY());
2088 const int x2 = (int) std::floor (r.
getRight());
2089 const int y2 = (int) std::floor (r.
getBottom());
2096 if (clip !=
nullptr)
2098 cloneClipIfMultiplyReferenced();
2100 if (transform.isOnlyTranslated)
2102 clip = clip->excludeClipRectangle (getLargestIntegerWithin (transform.translated (r.
toFloat())));
2104 else if (! transform.isRotated)
2106 clip = clip->excludeClipRectangle (getLargestIntegerWithin (transform.transformed (r.
toFloat())));
2119 return clip !=
nullptr;
2124 if (clip !=
nullptr)
2126 cloneClipIfMultiplyReferenced();
2127 clip = clip->clipToPath (p, transform.getTransformWith (t));
2133 if (clip !=
nullptr)
2137 cloneClipIfMultiplyReferenced();
2138 clip = clip->clipToImageAlpha (sourceImage, transform.getTransformWith (t), interpolationQuality);
2151 if (clip !=
nullptr)
2153 if (transform.isOnlyTranslated)
2154 return clip->clipRegionIntersects (transform.translated (r));
2156 return getClipBounds().intersects (r);
2164 return clip !=
nullptr ? transform.deviceSpaceToUserSpace (clip->getClipBounds())
2175 if (fillType.isColour())
2177 clip->fillRectWithColour (getThis(), r, fillType.colour.getPixelARGB(), replaceContents);
2181 const Rectangle<int> clipped (clip->getClipBounds().getIntersection (r));
2183 if (! clipped.isEmpty())
2184 fillShape (
new RectangleListRegionType (clipped),
false);
2190 if (fillType.isColour())
2192 clip->fillRectWithColour (getThis(), r, fillType.colour.getPixelARGB());
2196 const Rectangle<float> clipped (clip->getClipBounds().toFloat().getIntersection (r));
2198 if (! clipped.isEmpty())
2199 fillShape (
new EdgeTableRegionType (clipped),
false);
2203 template <
typename CoordType>
2213 if (clip !=
nullptr)
2215 if (transform.isOnlyTranslated)
2217 fillTargetRect (transform.translated (r), replaceContents);
2219 else if (! transform.isRotated)
2221 fillTargetRect (transform.transformed (r), replaceContents);
2233 if (clip !=
nullptr)
2235 if (transform.isOnlyTranslated)
2236 fillTargetRect (transform.translated (r));
2237 else if (! transform.isRotated)
2238 fillTargetRect (transform.transformed (r));
2246 if (clip !=
nullptr)
2248 if (! transform.isRotated)
2252 if (transform.isOnlyTranslated)
2253 transformed.
offsetAll (transform.offset.toFloat());
2257 fillShape (
new EdgeTableRegionType (transformed),
false);
2268 if (clip !=
nullptr)
2269 fillShape (
new EdgeTableRegionType (clip->getClipBounds(), path, transform.getTransformWith (t)),
false);
2274 if (clip !=
nullptr)
2276 EdgeTableRegionType* edgeTableClip =
new EdgeTableRegionType (edgeTable);
2279 if (fillType.isColour())
2281 float brightness = fillType.colour.getBrightness() - 0.5f;
2283 if (brightness > 0.0f)
2287 fillShape (edgeTableClip,
false);
2300 if (clip !=
nullptr && ! fillType.colour.isTransparent())
2301 renderImage (sourceImage, trans,
nullptr);
2306 return (std::abs (t.
mat01) < 0.002)
2307 && (std::abs (t.
mat10) < 0.002)
2308 && (std::abs (t.
mat00 - 1.0f) < 0.002)
2309 && (std::abs (t.
mat11 - 1.0f) < 0.002);
2313 const BaseRegionType*
const tiledFillClipRegion)
2317 const int alpha = fillType.colour.getAlpha();
2319 if (isOnlyTranslationAllowingError (t))
2322 int tx = (int) (t.getTranslationX() * 256.0f);
2323 int ty = (int) (t.getTranslationY() * 256.0f);
2327 tx = ((tx + 128) >> 8);
2328 ty = ((ty + 128) >> 8);
2330 if (tiledFillClipRegion !=
nullptr)
2341 c->renderImageUntransformed (getThis(), sourceImage, alpha, tx, ty,
false);
2348 if (! t.isSingularity())
2350 if (tiledFillClipRegion !=
nullptr)
2352 tiledFillClipRegion->
renderImageTransformed (getThis(), sourceImage, alpha, t, interpolationQuality,
true);
2360 c = c->clipToPath (p, t);
2363 c->renderImageTransformed (getThis(), sourceImage, alpha, t, interpolationQuality,
false);
2372 shapeToFill = clip->applyClipTo (shapeToFill);
2374 if (shapeToFill !=
nullptr)
2376 if (fillType.isGradient())
2382 AffineTransform t (transform.getTransformWith (fillType.transform).translated (-0.5f, -0.5f));
2394 shapeToFill->fillAllWithGradient (getThis(), g2, t, isIdentity);
2396 else if (fillType.isTiledImage())
2398 renderImage (fillType.image, fillType.transform, shapeToFill);
2402 shapeToFill->fillAllWithColour (getThis(), fillType.colour.getPixelARGB(), replaceContents);
2409 if (clip->getReferenceCount() > 1)
2410 clip = clip->clone();
2427 : BaseClass (clipBounds), image (im)
2432 : BaseClass (clipList, origin), image (im)
2437 : BaseClass (other), image (other.image), font (other.font)
2445 if (clip !=
nullptr)
2453 s->
clip->translate (-layerBounds.getPosition());
2461 if (clip !=
nullptr)
2475 GlyphCacheType::getInstance().reset();
2481 if (clip !=
nullptr)
2485 GlyphCacheType& cache = GlyphCacheType::getInstance();
2489 if (transform.isOnlyTranslated)
2491 cache.
drawGlyph (*
this, font, glyphNumber, pos + transform.offset.toFloat());
2495 pos = transform.transformed (pos);
2500 const float xScale = transform.complexTransform.mat00 / transform.complexTransform.mat11;
2501 if (std::abs (xScale - 1.0f) > 0.01f)
2504 cache.
drawGlyph (*
this, f, glyphNumber, pos);
2509 const float fontHeight = font.
getHeight();
2512 .followedBy (trans)));
2525 template <
typename IteratorType>
2533 template <
typename IteratorType>
2541 template <
typename IteratorType>
2554 template <
typename IteratorType>
2559 jassert (numLookupEntries > 0);
2580 template <
class StateObjectType>
2585 : currentState (initialState)
2592 currentState = state;
2600 stack.add (
new StateObjectType (*currentState));
2605 if (StateObjectType*
const top = stack.getLast())
2608 stack.removeLast (1,
false);
2619 currentState = currentState->beginTransparencyLayer (opacity);
2626 currentState->endTransparencyLayer (*finishedTransparencyLayer);
2637 template <
class SavedStateType>
2658 void setOpacity (
float newOpacity)
override { stack->fillType.setOpacity (newOpacity); }
2667 void setFont (
const Font& newFont)
override { stack->font = newFont; }
2680 #pragma warning (pop) 2683 #endif // JUCE_RENDERINGHELPERS_H_INCLUDED void translate(float dx, int dy) noexcept
Definition: juce_EdgeTable.cpp:456
void fillRectWithColour(SavedStateType &state, const Rectangle< int > &area, const PixelARGB colour, bool replaceContents) const
Definition: juce_RenderingHelpers.h:1811
const double gy1
Definition: juce_RenderingHelpers.h:515
Graphics::ResamplingQuality interpolationQuality
Definition: juce_RenderingHelpers.h:2416
SoftwareRendererSavedState(const Image &im, const Rectangle< int > &clipBounds)
Definition: juce_RenderingHelpers.h:2426
int getBottomRightCornerAlpha() const noexcept
Definition: juce_RenderingHelpers.h:393
Ptr clone() const
Definition: juce_RenderingHelpers.h:1778
bool clipRegionIntersects(const Rectangle< int > &r) const
Definition: juce_RenderingHelpers.h:1684
SoftwareRendererSavedState(const Image &im, const RectangleList< int > &clipList, Point< int > origin)
Definition: juce_RenderingHelpers.h:2431
Base()
Definition: juce_RenderingHelpers.h:1554
static bool isOnlyTranslationAllowingError(const AffineTransform &t)
Definition: juce_RenderingHelpers.h:2304
static GlyphCache & getInstance()
Definition: juce_RenderingHelpers.h:154
ValueType getWidth() const noexcept
Definition: juce_Rectangle.h:113
GlyphCache< CachedGlyphEdgeTable< SoftwareRendererSavedState >, SoftwareRendererSavedState > GlyphCacheType
Definition: juce_RenderingHelpers.h:2471
void reset()
Definition: juce_RenderingHelpers.h:165
void setHeight(float newHeight)
Definition: juce_Font.cpp:455
Definition: juce_Image.h:311
void save()
Definition: juce_RenderingHelpers.h:2598
void drawGlyph(RenderTargetType &target, const Font &font, const int glyphNumber, Point< float > pos)
Definition: juce_RenderingHelpers.h:174
void drawImage(const Image &sourceImage, const AffineTransform &trans)
Definition: juce_RenderingHelpers.h:2298
Definition: juce_graphics.h:45
void drawLine(const Line< float > &line)
Definition: juce_RenderingHelpers.h:2291
Definition: juce_EdgeTable.h:35
Ptr clipToImageAlpha(const Image &image, const AffineTransform &transform, const Graphics::ResamplingQuality quality)
Definition: juce_RenderingHelpers.h:1802
ValueType getY() const noexcept
Definition: juce_Point.h:68
bool hasAlphaChannel() const noexcept
Definition: juce_Image.cpp:266
GlyphCache()
Definition: juce_RenderingHelpers.h:144
int pointer_sized_int
Definition: juce_MathsFunctions.h:86
int getTopRightCornerAlpha() const noexcept
Definition: juce_RenderingHelpers.h:391
ValueType getRight() const noexcept
Definition: juce_Rectangle.h:119
forcedinline void handleEdgeTablePixel(const int x, const int alphaLevel) const noexcept
Definition: juce_RenderingHelpers.h:602
Definition: juce_PixelFormats.h:566
bool clipRegionIntersects(const Rectangle< int > &r) override
Definition: juce_RenderingHelpers.h:2647
ResamplingQuality
Definition: juce_GraphicsContext.h:465
void beginTransparencyLayer(float opacity) override
Definition: juce_RenderingHelpers.h:2655
Definition: juce_Font.h:39
RenderingHelpers::TranslationOrTransform transform
Definition: juce_RenderingHelpers.h:2414
void fillAllWithColour(SavedStateType &state, const PixelARGB colour, bool replaceContents) const
Definition: juce_RenderingHelpers.h:1720
void offsetAll(Point< ValueType > offset) noexcept
Definition: juce_RectangleList.h:597
Ptr clipToRectangleList(const RectangleList< int > &r)
Definition: juce_RenderingHelpers.h:1604
forcedinline void setEdgeTableYPos(int y) noexcept
Definition: juce_RenderingHelpers.h:792
void setUsingNonZeroWinding(bool isNonZeroWinding) noexcept
Definition: juce_Path.cpp:211
bool excludeClipRectangle(const Rectangle< int > &r)
Definition: juce_RenderingHelpers.h:2094
void fillShape(typename BaseRegionType::Ptr shapeToFill, const bool replaceContents)
Definition: juce_RenderingHelpers.h:2368
double maxDist
Definition: juce_RenderingHelpers.h:516
void beginTransparencyLayer(float opacity)
Definition: juce_RenderingHelpers.h:2616
void multiplyLevels(float factor)
Definition: juce_EdgeTable.cpp:477
ReferenceCountedObjectPtr< Base > Ptr
Definition: juce_RenderingHelpers.h:1557
Definition: juce_RenderingHelpers.h:2581
bool clipToRectangle(const Rectangle< int > &r) override
Definition: juce_RenderingHelpers.h:2648
Definition: juce_Line.h:44
int totalLeft
Definition: juce_RenderingHelpers.h:397
PixelARGB getPixel(const int x) const noexcept
Definition: juce_RenderingHelpers.h:460
#define noexcept
Definition: juce_CompilerSupport.h:141
ValueType getX() const noexcept
Definition: juce_graphics.h:108
int getWidth() const noexcept
Definition: juce_Image.cpp:259
void endTransparencyLayer() override
Definition: juce_RenderingHelpers.h:2656
void handleEdgeTableLine(int x, int width, const int alphaLevel) const noexcept
Definition: juce_RenderingHelpers.h:748
Gradient(const Image::BitmapData &dest, const ColourGradient &gradient, const AffineTransform &transform, const PixelARGB *const colours, const int numColours)
Definition: juce_RenderingHelpers.h:725
virtual bool isHinted() const
Definition: juce_Typeface.h:123
void setFill(const FillType &fillType) override
Definition: juce_RenderingHelpers.h:2657
virtual void renderImageTransformed(SavedStateType &, const Image &, const int alpha, const AffineTransform &, Graphics::ResamplingQuality, bool tiledFill) const =0
void restoreState() override
Definition: juce_RenderingHelpers.h:2654
static Rectangle< int > getLargestIntegerWithin(Rectangle< float > r)
Definition: juce_RenderingHelpers.h:2084
SavedStateBase(const RectangleList< int > &clipList, Point< int > origin)
Definition: juce_RenderingHelpers.h:2014
EdgeTableRegion(const RectangleList< float > &r)
Definition: juce_RenderingHelpers.h:1589
ValueType getX() const noexcept
Definition: juce_Rectangle.h:107
Definition: juce_RenderingHelpers.h:316
#define JUCE_PERFORM_PIXEL_OP_LOOP(op)
Definition: juce_RenderingHelpers.h:564
Typeface * getTypeface() const
Definition: juce_Font.cpp:395
void multiplyOpacity(float multiplier) noexcept
Definition: juce_ColourGradient.cpp:90
ValueType getWidth() const noexcept
Definition: juce_graphics.h:114
ValueType getHeight() const noexcept
Definition: juce_Rectangle.h:116
int getTopLeftCornerAlpha() const noexcept
Definition: juce_RenderingHelpers.h:390
Type jmin(const Type a, const Type b)
Definition: juce_core.h:113
Definition: juce_ScopedLock.h:59
ClipRegions< SavedStateType >::RectangleListRegion RectangleListRegionType
Definition: juce_RenderingHelpers.h:2006
void fillTargetRect(const Rectangle< float > &r)
Definition: juce_RenderingHelpers.h:2188
forcedinline void multiplyAlpha(int multiplier) noexcept
Definition: juce_PixelFormats.h:219
Definition: juce_GraphicsContext.h:467
void set(Type newValue) noexcept
Definition: juce_Atomic.h:79
forcedinline void setY(const int y) noexcept
Definition: juce_RenderingHelpers.h:452
bool isPositiveAndBelow(Type valueToTest, Type upperLimit) noexcept
Definition: juce_core.h:238
PixelFormat pixelFormat
Definition: juce_Image.h:349
Definition: juce_RenderingHelpers.h:406
void renderImage(const Image &sourceImage, const AffineTransform &trans, const BaseRegionType *const tiledFillClipRegion)
Definition: juce_RenderingHelpers.h:2312
Ptr clone() const
Definition: juce_RenderingHelpers.h:1595
ClipRegions< SavedStateType >::EdgeTableRegion EdgeTableRegionType
Definition: juce_RenderingHelpers.h:2005
Definition: juce_PixelFormats.h:309
forcedinline void setEdgeTableYPos(const int y) noexcept
Definition: juce_RenderingHelpers.h:597
StackBasedLowLevelGraphicsContext()
Definition: juce_RenderingHelpers.h:2672
void initialise(StateObjectType *state)
Definition: juce_RenderingHelpers.h:2590
Definition: juce_DeletedAtShutdown.h:40
forcedinline void handleEdgeTablePixelFull(const int x) const noexcept
Definition: juce_RenderingHelpers.h:813
void clipEdgeTableLine(EdgeTable &et, int x, int y, int width)
Definition: juce_RenderingHelpers.h:865
int roundToInt(const FloatType value) noexcept
Definition: juce_core.h:418
void drawLine(const Line< float > &line) override
Definition: juce_RenderingHelpers.h:2666
forcedinline void handleEdgeTableLineFull(const int x, const int width) const noexcept
Definition: juce_RenderingHelpers.h:631
EdgeTableRegion(const EdgeTable &e)
Definition: juce_RenderingHelpers.h:1585
Type * addBytesToPointer(Type *basePointer, IntegerType bytes) noexcept
Definition: juce_Memory.h:53
int rightAlpha
Definition: juce_RenderingHelpers.h:398
int totalRight
Definition: juce_RenderingHelpers.h:397
int getBottomLeftCornerAlpha() const noexcept
Definition: juce_RenderingHelpers.h:392
Definition: juce_Image.h:63
void clipToImageAlpha(const Image &sourceImage, const AffineTransform &t)
Definition: juce_RenderingHelpers.h:2131
Rectangle< float > toFloat() const noexcept
Definition: juce_Rectangle.h:792
void iterate(Renderer &r) const noexcept
Definition: juce_RenderingHelpers.h:1847
virtual void setOpacity(float)=0
Ptr excludeClipRectangle(const Rectangle< int > &r)
Definition: juce_RenderingHelpers.h:1615
SavedStateBase(const Rectangle< int > &initialClip)
Definition: juce_RenderingHelpers.h:2008
Definition: juce_ColourGradient.h:35
void setFont(const Font &newFont) override
Definition: juce_RenderingHelpers.h:2667
Definition: juce_RenderingHelpers.h:722
void fillWithGradient(IteratorType &iter, ColourGradient &gradient, const AffineTransform &trans, bool isIdentity) const
Definition: juce_RenderingHelpers.h:2555
Definition: juce_PixelFormats.h:566
void drawGlyph(int glyphNumber, const AffineTransform &t) override
Definition: juce_RenderingHelpers.h:2665
Definition: juce_RenderingHelpers.h:2001
Point< float > point2
Definition: juce_ColourGradient.h:145
void setInterpolationQuality(Graphics::ResamplingQuality quality) override
Definition: juce_RenderingHelpers.h:2659
RectangleListRegion(const RectangleList< int > &r)
Definition: juce_RenderingHelpers.h:1773
RectangleList< int > clip
Definition: juce_RenderingHelpers.h:1843
EdgeTableRegion(const Rectangle< int > &bounds, const Path &p, const AffineTransform &t)
Definition: juce_RenderingHelpers.h:1590
void fillRect(const Rectangle< int > &r, bool replace) override
Definition: juce_RenderingHelpers.h:2660
void renderGradient(Iterator &iter, const Image::BitmapData &destData, const ColourGradient &g, const AffineTransform &transform, const PixelARGB *const lookupTable, const int numLookupEntries, const bool isIdentity, DestPixelType *)
Definition: juce_RenderingHelpers.h:1523
forcedinline void handleEdgeTablePixel(const int x, int alphaLevel) const noexcept
Definition: juce_RenderingHelpers.h:806
FloatRectangleRasterisingInfo(const Rectangle< float > &area)
Definition: juce_RenderingHelpers.h:318
StateObjectType & operator*() const noexcept
Definition: juce_RenderingHelpers.h:2596
Definition: juce_graphics.h:63
Rectangle< int > getMaximumBounds() const
Definition: juce_RenderingHelpers.h:2522
int left
Definition: juce_RenderingHelpers.h:396
ReferenceCountedObjectPtr< CachedGlyphType > findOrCreateGlyph(const Font &font, int glyphNumber)
Definition: juce_RenderingHelpers.h:183
Definition: juce_RenderingHelpers.h:1549
void transformAll(const AffineTransform &transform) noexcept
Definition: juce_RectangleList.h:621
Ptr clipToRectangle(const Rectangle< int > &r)
Definition: juce_RenderingHelpers.h:1781
forcedinline void handleEdgeTablePixelFull(const int x) const noexcept
Definition: juce_RenderingHelpers.h:743
ValueType getBottom() const noexcept
Definition: juce_Rectangle.h:122
Ptr clipToEdgeTable(const EdgeTable &et)
Definition: juce_RenderingHelpers.h:1628
forcedinline void set(const Pixel &src) noexcept
Definition: juce_PixelFormats.h:443
CachedGlyphEdgeTable()
Definition: juce_RenderingHelpers.h:280
Definition: juce_RenderingHelpers.h:480
Definition: juce_ReferenceCountedObject.h:65
void fillRectAsPath(const Rectangle< CoordType > &r)
Definition: juce_RenderingHelpers.h:2204
const int numEntries
Definition: juce_RenderingHelpers.h:514
Definition: juce_CriticalSection.h:47
void clipToPath(const Path &p, const AffineTransform &t)
Definition: juce_RenderingHelpers.h:2122
Definition: juce_Image.h:313
Definition: juce_Typeface.h:44
void clipToPath(const Path &path, const AffineTransform &t) override
Definition: juce_RenderingHelpers.h:2651
SolidColour(const Image::BitmapData &image, const PixelARGB colour)
Definition: juce_RenderingHelpers.h:579
Definition: juce_Rectangle.h:36
Rectangle< int > getClipBounds() const
Definition: juce_RenderingHelpers.h:2162
void setARGB(const uint8 a, const uint8 r, const uint8 g, const uint8 b) noexcept
Definition: juce_PixelFormats.h:137
RectangleListRegion(const RectangleListRegion &other)
Definition: juce_RenderingHelpers.h:1774
void iterate(Callback &callback) const
Definition: juce_RenderingHelpers.h:378
bool isOnePixelWide() const noexcept
Definition: juce_RenderingHelpers.h:388
int leftAlpha
Definition: juce_RenderingHelpers.h:398
Point transformedBy(const AffineTransform &transform) const noexcept
Definition: juce_Point.h:203
void fillRect(const Rectangle< float > &r) override
Definition: juce_RenderingHelpers.h:2661
SoftwareRendererSavedState(const SoftwareRendererSavedState &other)
Definition: juce_RenderingHelpers.h:2436
void renderImageTransformed(SavedStateType &state, const Image &src, const int alpha, const AffineTransform &transform, Graphics::ResamplingQuality quality, bool tiledFill) const
Definition: juce_RenderingHelpers.h:1730
void drawImage(const Image &im, const AffineTransform &t) override
Definition: juce_RenderingHelpers.h:2664
int width
Definition: juce_Image.h:352
void saveState() override
Definition: juce_RenderingHelpers.h:2653
void addRectangle(float x, float y, float width, float height)
Definition: juce_Path.cpp:399
Definition: juce_Path.h:62
Point< float > toFloat() const noexcept
Definition: juce_Point.h:214
void fillPath(const Path &path, const AffineTransform &t) override
Definition: juce_RenderingHelpers.h:2663
const RectangleType * begin() const noexcept
Definition: juce_RectangleList.h:641
int top
Definition: juce_RenderingHelpers.h:396
FillType fillType
Definition: juce_RenderingHelpers.h:2415
Linear(const ColourGradient &gradient, const AffineTransform &transform, const PixelARGB *const colours, const int numColours)
Definition: juce_RenderingHelpers.h:409
Definition: juce_graphics.h:55
Rectangle< int > getBounds() const noexcept
Definition: juce_Image.cpp:261
unsigned int uint32
Definition: juce_MathsFunctions.h:51
Ptr clipToRectangleList(const RectangleList< int > &r)
Definition: juce_RenderingHelpers.h:1787
void cloneClipIfMultiplyReferenced()
Definition: juce_RenderingHelpers.h:2407
void fillAllWithColour(SavedStateType &state, const PixelARGB colour, bool replaceContents) const
Definition: juce_RenderingHelpers.h:1823
Ptr excludeClipRectangle(const Rectangle< int > &r)
Definition: juce_RenderingHelpers.h:1793
Ptr clipToRectangle(const Rectangle< int > &r)
Definition: juce_RenderingHelpers.h:1598
void renderImageUntransformed(SavedStateType &state, const Image &src, const int alpha, int x, int y, bool tiledFill) const
Definition: juce_RenderingHelpers.h:1838
SavedStateStack() noexcept
Definition: juce_RenderingHelpers.h:2588
void fillRect(const Rectangle< float > &r)
Definition: juce_RenderingHelpers.h:2231
Definition: juce_PixelFormats.h:610
virtual EdgeTable * getEdgeTableForGlyph(int glyphNumber, const AffineTransform &transform, float fontHeight)
Definition: juce_Typeface.cpp:119
PixelFormat getFormat() const noexcept
Definition: juce_Image.cpp:262
void fillAllWithGradient(SavedStateType &state, ColourGradient &gradient, const AffineTransform &transform, bool isIdentity) const
Definition: juce_RenderingHelpers.h:1828
Definition: juce_Image.h:64
void drawGlyph(int glyphNumber, const AffineTransform &trans)
Definition: juce_RenderingHelpers.h:2479
EdgeTableRegion(const Rectangle< float > &r)
Definition: juce_RenderingHelpers.h:1587
void renderImageUntransformed(SavedStateType &state, const Image &src, const int alpha, int x, int y, bool tiledFill) const
Definition: juce_RenderingHelpers.h:1735
void restore()
Definition: juce_RenderingHelpers.h:2603
forcedinline void setEdgeTableYPos(const int y) noexcept
Definition: juce_RenderingHelpers.h:732
void clipToImageAlpha(const Image &im, const AffineTransform &t) override
Definition: juce_RenderingHelpers.h:2652
void endTransparencyLayer()
Definition: juce_RenderingHelpers.h:2622
void handleEdgeTableLine(int x, int width, int alphaLevel) const noexcept
Definition: juce_RenderingHelpers.h:818
Definition: juce_ReferenceCountedObject.h:227
bool isEmpty() const noexcept
Definition: juce_RectangleList.h:82
IntegerType negativeAwareModulo(IntegerType dividend, const IntegerType divisor) noexcept
Definition: juce_MathsFunctions.h:531
ScopedPointer< EdgeTable > edgeTable
Definition: juce_RenderingHelpers.h:305
bool clipToRectangleList(const RectangleList< int > &r)
Definition: juce_RenderingHelpers.h:2054
void generate(const Font &newFont, const int glyphNumber)
Definition: juce_RenderingHelpers.h:291
Definition: juce_RenderingHelpers.h:576
void draw(RendererType &state, Point< float > pos) const
Definition: juce_RenderingHelpers.h:282
Type jmax(const Type a, const Type b)
Definition: juce_core.h:101
forcedinline uint8 getRed() const noexcept
Definition: juce_PixelFormats.h:107
const RectangleType * end() const noexcept
Definition: juce_RectangleList.h:643
volatile Type value
Definition: juce_Atomic.h:153
StateObjectType * operator->() const noexcept
Definition: juce_RenderingHelpers.h:2595
ResamplingQuality
Definition: juce_graphics.h:466
void fillRectWithColour(SavedStateType &state, const Rectangle< int > &area, const PixelARGB colour, bool replaceContents) const
Definition: juce_RenderingHelpers.h:1694
Image image
Definition: juce_RenderingHelpers.h:2572
Rectangle< int > getClipBounds() const override
Definition: juce_RenderingHelpers.h:2645
const PixelARGB *const lookupTable
Definition: juce_RenderingHelpers.h:513
Definition: juce_PixelFormats.h:566
void add(const RectangleType &rect)
Definition: juce_RectangleList.h:108
int bottomAlpha
Definition: juce_RenderingHelpers.h:398
int topAlpha
Definition: juce_RenderingHelpers.h:398
int totalBottom
Definition: juce_RenderingHelpers.h:397
Definition: juce_PixelFormats.h:309
Rectangle< int > getClipBounds() const
Definition: juce_RenderingHelpers.h:1809
Definition: juce_graphics.h:40
Font font
Definition: juce_RenderingHelpers.h:2573
ValueType getHeight() const noexcept
Definition: juce_graphics.h:117
ImageFill(const Image::BitmapData &dest, const Image::BitmapData &src, const int alpha, const int x, const int y)
Definition: juce_RenderingHelpers.h:782
void renderImageUntransformed(Iterator &iter, const Image::BitmapData &destData, const Image::BitmapData &srcData, const int alpha, int x, int y, bool tiledFill)
Definition: juce_RenderingHelpers.h:1447
Rectangle< int > getClipBounds() const
Definition: juce_RenderingHelpers.h:1689
Radial(const ColourGradient &gradient, const AffineTransform &, const PixelARGB *const colours, const int numColours)
Definition: juce_RenderingHelpers.h:483
void fillPath(const Path &path, const AffineTransform &t)
Definition: juce_RenderingHelpers.h:2266
SavedStateStack(StateObjectType *const initialState) noexcept
Definition: juce_RenderingHelpers.h:2584
int height
Definition: juce_Image.h:352
void handleEdgeTableLineFull(int x, int width) const noexcept
Definition: juce_RenderingHelpers.h:842
Path toPath() const
Definition: juce_RectangleList.h:629
void renderImageTransformed(IteratorType &iter, const Image &src, const int alpha, const AffineTransform &trans, Graphics::ResamplingQuality quality, bool tiledFill) const
Definition: juce_RenderingHelpers.h:2526
Definition: juce_FillType.h:38
void applyTransform(const AffineTransform &transform) noexcept
Definition: juce_graphics.h:201
Definition: juce_ContainerDeletePolicy.h:44
void fillEdgeTable(const EdgeTable &edgeTable, const float x, const int y)
Definition: juce_RenderingHelpers.h:2272
Point< ValueType > getPointAlongLine(ValueType distanceFromStart) const noexcept
Definition: juce_Line.h:200
Base::Ptr Ptr
Definition: juce_RenderingHelpers.h:1593
Type jlimit(const Type lowerLimit, const Type upperLimit, const Type valueToConstrain) noexcept
Definition: juce_MathsFunctions.h:220
void renderImageUntransformed(IteratorType &iter, const Image &src, const int alpha, int x, int y, bool tiledFill) const
Definition: juce_RenderingHelpers.h:2534
void applyTransform(const AffineTransform &transform) noexcept
Definition: juce_Point.h:200
Ptr clipToImageAlpha(const Image &image, const AffineTransform &transform, const Graphics::ResamplingQuality quality)
Definition: juce_RenderingHelpers.h:1634
int getHeight() const noexcept
Definition: juce_Image.cpp:260
Definition: juce_PixelFormats.h:56
void renderSolidFill(Iterator &iter, const Image::BitmapData &destData, const PixelARGB fillColour, const bool replaceContents, DestPixelType *)
Definition: juce_RenderingHelpers.h:1508
EdgeTableRegion(const EdgeTableRegion &other)
Definition: juce_RenderingHelpers.h:1591
SavedStateType & getThis() noexcept
Definition: juce_RenderingHelpers.h:2027
StackBasedLowLevelGraphicsContext(SavedStateType *initialState)
Definition: juce_RenderingHelpers.h:2671
EdgeTable edgeTable
Definition: juce_RenderingHelpers.h:1740
void translate(Point< int > delta)
Definition: juce_RenderingHelpers.h:1807
Definition: juce_Image.h:306
int totalTop
Definition: juce_RenderingHelpers.h:397
static void clearGlyphCache()
Definition: juce_RenderingHelpers.h:2473
void fillRect(const Rectangle< int > &r, const bool replaceContents)
Definition: juce_RenderingHelpers.h:2211
void clipToRectangle(const Rectangle< int > &r)
Definition: juce_EdgeTable.cpp:673
void addTransform(const AffineTransform &t) override
Definition: juce_RenderingHelpers.h:2643
ValueType getY() const noexcept
Definition: juce_Rectangle.h:110
~GlyphCache()
Definition: juce_RenderingHelpers.h:149
forcedinline void handleEdgeTablePixel(const int x, const int alphaLevel) const noexcept
Definition: juce_RenderingHelpers.h:738
void fillWithSolidColour(IteratorType &iter, const PixelARGB colour, bool replaceContents) const
Definition: juce_RenderingHelpers.h:2542
Definition: juce_GraphicsContext.h:42
void setFillType(const FillType &newFill)
Definition: juce_RenderingHelpers.h:2168
void translate(Point< int > delta)
Definition: juce_RenderingHelpers.h:1679
Definition: juce_Image.h:54
Definition: juce_PixelFormats.h:309
RenderingHelpers::SavedStateStack< SavedStateType > stack
Definition: juce_RenderingHelpers.h:2674
EdgeTableRegion(const Rectangle< int > &r)
Definition: juce_RenderingHelpers.h:1586
Base::Ptr Ptr
Definition: juce_RenderingHelpers.h:1776
int pixelStride
Definition: juce_Image.h:351
bool isClipEmpty() const override
Definition: juce_RenderingHelpers.h:2646
Definition: juce_LowLevelGraphicsContext.h:43
Definition: juce_RenderingHelpers.h:1551
void fillTargetRect(const Rectangle< int > &r, const bool replaceContents)
Definition: juce_RenderingHelpers.h:2173
void endTransparencyLayer(SoftwareRendererSavedState &finishedLayerState)
Definition: juce_RenderingHelpers.h:2459
void setARGB(const uint8, const uint8 red, const uint8 green, const uint8 blue) noexcept
Definition: juce_PixelFormats.h:451
Ptr applyClipTo(const Ptr &target) const
Definition: juce_RenderingHelpers.h:1779
BaseRegionType::Ptr clip
Definition: juce_RenderingHelpers.h:2413
void fillRectList(const RectangleList< float > &list) override
Definition: juce_RenderingHelpers.h:2662
void setHorizontalScale(float scaleFactor)
Definition: juce_Font.cpp:558
Definition: juce_PixelFormats.h:309
void setOrigin(Point< int > o) override
Definition: juce_RenderingHelpers.h:2642
void applyTransform(const AffineTransform &transform) noexcept
Definition: juce_Path.cpp:916
#define nullptr
Definition: juce_CompilerSupport.h:151
Definition: juce_RenderingHelpers.h:779
virtual ~Base()
Definition: juce_RenderingHelpers.h:1555
int lastAccessCount
Definition: juce_RenderingHelpers.h:306
Rectangle getIntersection(const Rectangle &other) const noexcept
Definition: juce_Rectangle.h:609
void addLineSegment(const Line< float > &line, float lineThickness)
Definition: juce_Path.cpp:674
void renderImageTransformed(Iterator &iter, const Image::BitmapData &destData, const Image::BitmapData &srcData, const int alpha, const AffineTransform &transform, Graphics::ResamplingQuality quality, bool tiledFill)
Definition: juce_RenderingHelpers.h:1385
bool clipToRectangleList(const RectangleList< int > &r) override
Definition: juce_RenderingHelpers.h:2649
JUCE_API String translate(const String &text)
Definition: juce_core.cpp:198
Definition: juce_RenderingHelpers.h:33
Definition: juce_RenderingHelpers.h:1769
void handleEdgeTableLineFull(int x, int width) const noexcept
Definition: juce_RenderingHelpers.h:758
void excludeClipRectangle(const Rectangle< int > &r) override
Definition: juce_RenderingHelpers.h:2650
Definition: juce_RenderingHelpers.h:141
int createLookupTable(const AffineTransform &transform, HeapBlock< PixelARGB > &resultLookupTable) const
Definition: juce_ColourGradient.cpp:181
const Font & getFont() override
Definition: juce_RenderingHelpers.h:2668
bool isVectorDevice() const override
Definition: juce_RenderingHelpers.h:2641
void fillRectList(const RectangleList< float > &list)
Definition: juce_RenderingHelpers.h:2244
bool snapToIntegerCoordinate
Definition: juce_RenderingHelpers.h:307
Definition: juce_RenderingHelpers.h:2638
Ptr clipToPath(const Path &p, const AffineTransform &transform)
Definition: juce_RenderingHelpers.h:1621
void fillRectWithColour(SavedStateType &state, const Rectangle< float > &area, const PixelARGB colour) const
Definition: juce_RenderingHelpers.h:1817
float getPhysicalPixelScaleFactor() override
Definition: juce_RenderingHelpers.h:2644
void setOpacity(float newOpacity) override
Definition: juce_RenderingHelpers.h:2658
void renderImageTransformed(SavedStateType &state, const Image &src, const int alpha, const AffineTransform &transform, Graphics::ResamplingQuality quality, bool tiledFill) const
Definition: juce_RenderingHelpers.h:1833
SavedStateBase(const SavedStateBase &other)
Definition: juce_RenderingHelpers.h:2020
virtual void renderImageUntransformed(SavedStateType &, const Image &, const int alpha, int x, int y, bool tiledFill) const =0
ValueType getY() const noexcept
Definition: juce_graphics.h:111
forcedinline void setY(const int y) noexcept
Definition: juce_RenderingHelpers.h:497
Definition: juce_RenderingHelpers.h:2421
Definition: juce_graphics.h:39
Definition: juce_ReferenceCountedObject.h:144
unsigned char uint8
Definition: juce_MathsFunctions.h:43
PixelARGB getPixel(const int px) const noexcept
Definition: juce_RenderingHelpers.h:503
void clipToEdgeTable(const EdgeTable &)
Definition: juce_EdgeTable.cpp:733
ClipRegions< SavedStateType >::Base BaseRegionType
Definition: juce_RenderingHelpers.h:2004
bool clipRegionIntersects(const Rectangle< int > &r) const
Definition: juce_RenderingHelpers.h:1808
forcedinline void handleEdgeTablePixelFull(const int x) const noexcept
Definition: juce_RenderingHelpers.h:610
bool clipRegionIntersects(const Rectangle< int > &r) const
Definition: juce_RenderingHelpers.h:2149
forcedinline void handleEdgeTableLine(const int x, const int width, const int alphaLevel) const noexcept
Definition: juce_RenderingHelpers.h:618
float getHeight() const noexcept
Definition: juce_Font.cpp:625
Ptr clipToEdgeTable(const EdgeTable &et)
Definition: juce_RenderingHelpers.h:1800
void fillRectWithColour(SavedStateType &state, const Rectangle< float > &area, const PixelARGB colour) const
Definition: juce_RenderingHelpers.h:1707
bool isRadial
Definition: juce_ColourGradient.h:152
float getHorizontalScale() const noexcept
Definition: juce_Font.cpp:565
const Rectangle< int > & getMaximumBounds() const noexcept
Definition: juce_EdgeTable.h:79
Point< float > point1
Definition: juce_ColourGradient.h:145
bool clipToRectangle(const Rectangle< int > &r)
Definition: juce_RenderingHelpers.h:2029
forcedinline uint8 getAlpha() const noexcept
Definition: juce_PixelFormats.h:106
Ptr applyClipTo(const Ptr &target) const
Definition: juce_RenderingHelpers.h:1596
EdgeTableRegion(const RectangleList< int > &r)
Definition: juce_RenderingHelpers.h:1588
float transparencyLayerAlpha
Definition: juce_RenderingHelpers.h:2417
void fillAllWithGradient(SavedStateType &state, ColourGradient &gradient, const AffineTransform &transform, bool isIdentity) const
Definition: juce_RenderingHelpers.h:1725
RectangleListRegion(const Rectangle< int > &r)
Definition: juce_RenderingHelpers.h:1772
ValueType x
Definition: juce_Point.h:226
Definition: juce_RenderingHelpers.h:277
Definition: juce_PixelFormats.h:361
int right
Definition: juce_RenderingHelpers.h:396
int bottom
Definition: juce_RenderingHelpers.h:396
ValueType y
Definition: juce_Point.h:227
Font font
Definition: juce_RenderingHelpers.h:304
Definition: juce_RenderingHelpers.h:1582
SoftwareRendererSavedState * beginTransparencyLayer(float opacity)
Definition: juce_RenderingHelpers.h:2441
void clipLineToMask(int x, int y, const uint8 *mask, int maskStride, int numPixels)
Definition: juce_EdgeTable.cpp:768
Ptr clipToPath(const Path &p, const AffineTransform &transform)
Definition: juce_RenderingHelpers.h:1799
bool isEmpty() const noexcept
Definition: juce_Rectangle.h:101