diff --git a/modules/juce_graphics/contexts/juce_GraphicsContext.cpp b/modules/juce_graphics/contexts/juce_GraphicsContext.cpp index 19301240d1..cd5d224352 100644 --- a/modules/juce_graphics/contexts/juce_GraphicsContext.cpp +++ b/modules/juce_graphics/contexts/juce_GraphicsContext.cpp @@ -697,7 +697,7 @@ void Graphics::drawImageTransformed (const Image& imageToDraw, } else { - context->drawImage (imageToDraw, transform, false); + context->drawImage (imageToDraw, transform); } } } diff --git a/modules/juce_graphics/contexts/juce_LowLevelGraphicsContext.h b/modules/juce_graphics/contexts/juce_LowLevelGraphicsContext.h index 72650b2f05..ce4d51e372 100644 --- a/modules/juce_graphics/contexts/juce_LowLevelGraphicsContext.h +++ b/modules/juce_graphics/contexts/juce_LowLevelGraphicsContext.h @@ -94,7 +94,7 @@ public: virtual void fillRect (const Rectangle& r, bool replaceExistingContents) = 0; virtual void fillPath (const Path& path, const AffineTransform& transform) = 0; - virtual void drawImage (const Image& sourceImage, const AffineTransform& transform, bool fillEntireClipAsTiles) = 0; + virtual void drawImage (const Image& sourceImage, const AffineTransform& transform) = 0; virtual void drawLine (const Line & line) = 0; virtual void drawVerticalLine (int x, float top, float bottom) = 0; diff --git a/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp b/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp index 11c31deeec..ab3d124fdc 100644 --- a/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp +++ b/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp @@ -464,7 +464,7 @@ void LowLevelGraphicsPostScriptRenderer::writeImage (const Image& im, out << "\n>}\n"; } -void LowLevelGraphicsPostScriptRenderer::drawImage (const Image& sourceImage, const AffineTransform& transform, const bool /*fillEntireClipAsTiles*/) +void LowLevelGraphicsPostScriptRenderer::drawImage (const Image& sourceImage, const AffineTransform& transform) { const int w = sourceImage.getWidth(); const int h = sourceImage.getHeight(); diff --git a/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h b/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h index 0afb338b3b..6c436ce6dd 100644 --- a/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h +++ b/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h @@ -77,7 +77,7 @@ public: void fillRect (const Rectangle& r, bool replaceExistingContents); void fillPath (const Path& path, const AffineTransform& transform); - void drawImage (const Image& sourceImage, const AffineTransform& transform, bool fillEntireClipAsTiles); + void drawImage (const Image& sourceImage, const AffineTransform& transform); void drawLine (const Line & line); diff --git a/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp b/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp index 541113c904..1fd6726e55 100644 --- a/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp +++ b/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp @@ -1854,7 +1854,7 @@ public: const ScopedPointer g (image.createLowLevelContext()); g->setOpacity (finishedLayerState.transparencyLayerAlpha); g->drawImage (finishedLayerState.image, AffineTransform::translation ((float) layerBounds.getX(), - (float) layerBounds.getY()), false); + (float) layerBounds.getY())); } //============================================================================== @@ -2183,9 +2183,9 @@ void LowLevelGraphicsSoftwareRenderer::fillPath (const Path& path, const AffineT savedState->fillPath (path, transform); } -void LowLevelGraphicsSoftwareRenderer::drawImage (const Image& sourceImage, const AffineTransform& transform, const bool fillEntireClipAsTiles) +void LowLevelGraphicsSoftwareRenderer::drawImage (const Image& sourceImage, const AffineTransform& transform) { - savedState->renderImage (sourceImage, transform, fillEntireClipAsTiles ? savedState->clip : 0); + savedState->renderImage (sourceImage, transform, nullptr); } void LowLevelGraphicsSoftwareRenderer::drawLine (const Line & line) diff --git a/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h b/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h index d535ff7b21..41b18e8469 100644 --- a/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h +++ b/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h @@ -80,7 +80,7 @@ public: void fillRect (const Rectangle& r, bool replaceExistingContents); void fillPath (const Path& path, const AffineTransform& transform); - void drawImage (const Image& sourceImage, const AffineTransform& transform, bool fillEntireClipAsTiles); + void drawImage (const Image& sourceImage, const AffineTransform& transform); void drawLine (const Line & line); diff --git a/modules/juce_graphics/geometry/juce_Path.cpp b/modules/juce_graphics/geometry/juce_Path.cpp index abf74ad11f..6dde964e59 100644 --- a/modules/juce_graphics/geometry/juce_Path.cpp +++ b/modules/juce_graphics/geometry/juce_Path.cpp @@ -26,7 +26,7 @@ BEGIN_JUCE_NAMESPACE // tests that some co-ords aren't NaNs -#define CHECK_COORDS_ARE_VALID(x, y) \ +#define JUCE_CHECK_COORDS_ARE_VALID(x, y) \ jassert (x == x && y == y); //============================================================================== @@ -168,12 +168,12 @@ void Path::clear() noexcept void Path::swapWithPath (Path& other) noexcept { data.swapWith (other.data); - swapVariables (numElements, other.numElements); - swapVariables (pathXMin, other.pathXMin); - swapVariables (pathXMax, other.pathXMax); - swapVariables (pathYMin, other.pathYMin); - swapVariables (pathYMax, other.pathYMax); - swapVariables (useNonZeroWinding, other.useNonZeroWinding); + std::swap (numElements, other.numElements); + std::swap (pathXMin, other.pathXMin); + std::swap (pathXMax, other.pathXMax); + std::swap (pathYMin, other.pathYMin); + std::swap (pathYMax, other.pathYMax); + std::swap (useNonZeroWinding, other.useNonZeroWinding); } //============================================================================== @@ -227,7 +227,7 @@ Rectangle Path::getBoundsTransformed (const AffineTransform& transform) c //============================================================================== void Path::startNewSubPath (const float x, const float y) { - CHECK_COORDS_ARE_VALID (x, y); + JUCE_CHECK_COORDS_ARE_VALID (x, y); if (numElements == 0) { @@ -256,7 +256,7 @@ void Path::startNewSubPath (const Point& start) void Path::lineTo (const float x, const float y) { - CHECK_COORDS_ARE_VALID (x, y); + JUCE_CHECK_COORDS_ARE_VALID (x, y); if (numElements == 0) startNewSubPath (0, 0); @@ -281,8 +281,8 @@ void Path::lineTo (const Point& end) void Path::quadraticTo (const float x1, const float y1, const float x2, const float y2) { - CHECK_COORDS_ARE_VALID (x1, y1); - CHECK_COORDS_ARE_VALID (x2, y2); + JUCE_CHECK_COORDS_ARE_VALID (x1, y1); + JUCE_CHECK_COORDS_ARE_VALID (x2, y2); if (numElements == 0) startNewSubPath (0, 0); @@ -312,9 +312,9 @@ void Path::cubicTo (const float x1, const float y1, const float x2, const float y2, const float x3, const float y3) { - CHECK_COORDS_ARE_VALID (x1, y1); - CHECK_COORDS_ARE_VALID (x2, y2); - CHECK_COORDS_ARE_VALID (x3, y3); + JUCE_CHECK_COORDS_ARE_VALID (x1, y1); + JUCE_CHECK_COORDS_ARE_VALID (x2, y2); + JUCE_CHECK_COORDS_ARE_VALID (x3, y3); if (numElements == 0) startNewSubPath (0, 0); @@ -383,11 +383,8 @@ void Path::addRectangle (const float x, const float y, { float x1 = x, y1 = y, x2 = x + w, y2 = y + h; - if (w < 0) - swapVariables (x1, x2); - - if (h < 0) - swapVariables (y1, y2); + if (w < 0) std::swap (x1, x2); + if (h < 0) std::swap (y1, y2); data.ensureAllocatedSize ((int) numElements + 13); @@ -962,29 +959,25 @@ AffineTransform Path::getTransformToScaleToFit (const float x, const float y, float newXCentre = x; float newYCentre = y; - if (justification.testFlags (Justification::left)) - newXCentre += newW * 0.5f; - else if (justification.testFlags (Justification::right)) - newXCentre += w - newW * 0.5f; - else - newXCentre += w * 0.5f; + if (justification.testFlags (Justification::left)) newXCentre += newW * 0.5f; + else if (justification.testFlags (Justification::right)) newXCentre += w - newW * 0.5f; + else newXCentre += w * 0.5f; - if (justification.testFlags (Justification::top)) - newYCentre += newH * 0.5f; - else if (justification.testFlags (Justification::bottom)) - newYCentre += h - newH * 0.5f; - else - newYCentre += h * 0.5f; + if (justification.testFlags (Justification::top)) newYCentre += newH * 0.5f; + else if (justification.testFlags (Justification::bottom)) newYCentre += h - newH * 0.5f; + else newYCentre += h * 0.5f; - return AffineTransform::translation (bounds.getWidth() * -0.5f - bounds.getX(), + return AffineTransform::translation (bounds.getWidth() * -0.5f - bounds.getX(), bounds.getHeight() * -0.5f - bounds.getY()) - .scaled (newW / bounds.getWidth(), newH / bounds.getHeight()) + .scaled (newW / bounds.getWidth(), + newH / bounds.getHeight()) .translated (newXCentre, newYCentre); } else { return AffineTransform::translation (-bounds.getX(), -bounds.getY()) - .scaled (w / bounds.getWidth(), h / bounds.getHeight()) + .scaled (w / bounds.getWidth(), + h / bounds.getHeight()) .translated (x, y); } } @@ -1042,7 +1035,7 @@ Line Path::getClippedLine (const Line& line, const bool keepSectio { Line result (line); const bool startInside = contains (line.getStart()); - const bool endInside = contains (line.getEnd()); + const bool endInside = contains (line.getEnd()); if (startInside == endInside) { @@ -1162,8 +1155,8 @@ Path Path::createPathWithRoundedCorners (const float cornerRadius) const { startX = data.elements [n - 8]; startY = data.elements [n - 7]; - joinX = data.elements [n - 5]; - joinY = data.elements [n - 4]; + joinX = data.elements [n - 5]; + joinY = data.elements [n - 4]; } } else @@ -1175,8 +1168,8 @@ Path Path::createPathWithRoundedCorners (const float cornerRadius) const { startX = data.elements [n - 6]; startY = data.elements [n - 5]; - joinX = data.elements [n - 3]; - joinY = data.elements [n - 2]; + joinX = data.elements [n - 3]; + joinY = data.elements [n - 2]; } } @@ -1592,5 +1585,6 @@ bool Path::Iterator::next() return false; } +#undef JUCE_CHECK_COORDS_ARE_VALID END_JUCE_NAMESPACE diff --git a/modules/juce_graphics/native/juce_android_GraphicsContext.cpp b/modules/juce_graphics/native/juce_android_GraphicsContext.cpp index 71929aa15d..f96f168c6c 100644 --- a/modules/juce_graphics/native/juce_android_GraphicsContext.cpp +++ b/modules/juce_graphics/native/juce_android_GraphicsContext.cpp @@ -450,7 +450,7 @@ public: getCurrentPaint()); } - void drawImage (const Image& sourceImage, const AffineTransform& transform, bool fillEntireClipAsTiles) + void drawImage (const Image& sourceImage, const AffineTransform& transform) { AndroidImage* androidImage = dynamic_cast (sourceImage.getSharedImage()); @@ -502,7 +502,7 @@ public: { saveState(); addTransform (transform); - drawImage (sourceImage, AffineTransform::identity, fillEntireClipAsTiles); + drawImage (sourceImage, AffineTransform::identity); restoreState(); } } diff --git a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.h b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.h index dfa3c63b88..03b9ab3102 100644 --- a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.h +++ b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.h @@ -63,7 +63,7 @@ public: void fillRect (const Rectangle& r, const bool replaceExistingContents); void fillCGRect (const CGRect& cgRect, const bool replaceExistingContents); void fillPath (const Path& path, const AffineTransform& transform); - void drawImage (const Image& sourceImage, const AffineTransform& transform, const bool fillEntireClipAsTiles); + void drawImage (const Image& sourceImage, const AffineTransform& transform); //============================================================================== void drawLine (const Line& line); @@ -111,6 +111,7 @@ private: void createPath (const Path& path, const AffineTransform& transform) const; void flip() const; void applyTransform (const AffineTransform& transform) const; + void drawImage (const Image& sourceImage, const AffineTransform& transform, bool fillEntireClipAsTiles); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CoreGraphicsContext); }; diff --git a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm index 811b1d8cbd..e6a7ecea5e 100644 --- a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm +++ b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm @@ -436,6 +436,11 @@ void CoreGraphicsContext::fillPath (const Path& path, const AffineTransform& tra CGContextRestoreGState (context); } +void CoreGraphicsContext::drawImage (const Image& sourceImage, const AffineTransform& transform) +{ + drawImage (sourceImage, transform, false); +} + void CoreGraphicsContext::drawImage (const Image& sourceImage, const AffineTransform& transform, const bool fillEntireClipAsTiles) { const int iw = sourceImage.getWidth(); diff --git a/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp b/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp index 6dd07e197b..44b37a2a24 100644 --- a/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp +++ b/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp @@ -223,7 +223,7 @@ public: renderingTarget->FillGeometry (geometry, currentState->currentBrush); } - void drawImage (const Image& image, const AffineTransform& transform, bool fillEntireClipAsTiles) + void drawImage (const Image& image, const AffineTransform& transform) { const int x = currentState->origin.getX(); const int y = currentState->origin.getY();