diff --git a/modules/juce_graphics/native/juce_RenderingHelpers.h b/modules/juce_graphics/native/juce_RenderingHelpers.h index 610a2d075c..dae758cf80 100644 --- a/modules/juce_graphics/native/juce_RenderingHelpers.h +++ b/modules/juce_graphics/native/juce_RenderingHelpers.h @@ -2270,6 +2270,14 @@ public: renderImage (sourceImage, trans, nullptr); } + static bool isOnlyTranslationAllowingError (const AffineTransform& t) + { + return (std::abs (t.mat01) < 0.002) + && (std::abs (t.mat10) < 0.002) + && (std::abs (t.mat00 - 1.0f) < 0.002) + && (std::abs (t.mat11 - 1.0f) < 0.002); + } + void renderImage (const Image& sourceImage, const AffineTransform& trans, const BaseRegionType* const tiledFillClipRegion) { @@ -2277,7 +2285,7 @@ public: const int alpha = fillType.colour.getAlpha(); - if (t.isOnlyTranslation()) + if (isOnlyTranslationAllowingError (t)) { // If our translation doesn't involve any distortion, just use a simple blit.. int tx = (int) (t.getTranslationX() * 256.0f); diff --git a/modules/juce_gui_basics/components/juce_Component.cpp b/modules/juce_gui_basics/components/juce_Component.cpp index 1919b48765..de4244ef5c 100644 --- a/modules/juce_gui_basics/components/juce_Component.cpp +++ b/modules/juce_gui_basics/components/juce_Component.cpp @@ -2023,7 +2023,8 @@ void Component::paintEntireComponent (Graphics& g, const bool ignoreAlphaLevel) scaledBounds.getWidth(), scaledBounds.getHeight(), ! flags.opaqueFlag); { Graphics g2 (effectImage); - g2.addTransform (AffineTransform::scale (scale)); + g2.addTransform (AffineTransform::scale (scaledBounds.getWidth() / (float) getWidth(), + scaledBounds.getHeight() / (float) getHeight())); paintComponentAndChildren (g2); } @@ -2058,7 +2059,7 @@ void Component::setPaintingIsUnclipped (const bool shouldPaintWithoutClipping) n //============================================================================== Image Component::createComponentSnapshot (const Rectangle& areaToGrab, - const bool clipImageToComponentBounds) + bool clipImageToComponentBounds, float scaleFactor) { Rectangle r (areaToGrab); @@ -2068,14 +2069,21 @@ Image Component::createComponentSnapshot (const Rectangle& areaToGrab, if (r.isEmpty()) return Image(); - Image componentImage (flags.opaqueFlag ? Image::RGB : Image::ARGB, - r.getWidth(), r.getHeight(), true); + const int w = roundToInt (scaleFactor * r.getWidth()); + const int h = roundToInt (scaleFactor * r.getHeight()); - Graphics imageContext (componentImage); - imageContext.setOrigin (-r.getPosition()); - paintEntireComponent (imageContext, true); + Image image (flags.opaqueFlag ? Image::RGB : Image::ARGB, w, h, true); - return componentImage; + Graphics g (image); + + if (w != getWidth() || h != getHeight()) + g.addTransform (AffineTransform::scale (w / (float) r.getWidth(), + h / (float) r.getHeight())); + g.setOrigin (-r.getPosition()); + + paintEntireComponent (g, true); + + return image; } void Component::setComponentEffect (ImageEffectFilter* const newEffect) diff --git a/modules/juce_gui_basics/components/juce_Component.h b/modules/juce_gui_basics/components/juce_Component.h index 99040403d8..df21f049ba 100644 --- a/modules/juce_gui_basics/components/juce_Component.h +++ b/modules/juce_gui_basics/components/juce_Component.h @@ -1010,7 +1010,8 @@ public: @see paintEntireComponent */ Image createComponentSnapshot (const Rectangle& areaToGrab, - bool clipImageToComponentBounds = true); + bool clipImageToComponentBounds = true, + float scaleFactor = 1.0f); /** Draws this component and all its subcomponents onto the specified graphics context. diff --git a/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp b/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp index 690ff0c802..efc952d865 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp +++ b/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp @@ -136,7 +136,6 @@ public: { public: ProxyComponent (Component& c) - : image (c.createComponentSnapshot (c.getLocalBounds())) { setBounds (c.getBounds()); setTransform (c.getTransform()); @@ -150,6 +149,8 @@ public: else jassertfalse; // seem to be trying to animate a component that's not visible.. + image = c.createComponentSnapshot (c.getLocalBounds(), false, getDesktopScaleFactor()); + setVisible (true); toBehind (&c); } diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index 684871c8c3..6f6f58422f 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -556,15 +556,12 @@ public: } } - void drawSelection (Graphics& g, const Range selected) const + void addSelection (RectangleList& area, const Range selected) const { - const int startX = roundToInt (indexToX (selected.getStart())); - const int endX = roundToInt (indexToX (selected.getEnd())); + const float startX = indexToX (selected.getStart()); + const float endX = indexToX (selected.getEnd()); - const int y = roundToInt (lineY); - const int nextY = roundToInt (lineY + lineHeight); - - g.fillRect (startX, y, endX - startX, nextY - y); + area.add (startX, lineY, endX - startX, lineHeight); } void drawUnderline (Graphics& g, const Range underline, const Colour colour) const @@ -1617,20 +1614,23 @@ void TextEditor::drawContent (Graphics& g) if (! selection.isEmpty()) { - g.setColour (findColour (highlightColourId).withMultipliedAlpha (hasKeyboardFocus (true) ? 1.0f : 0.5f)); - - selectedTextColour = findColour (highlightedTextColourId); - Iterator i2 (i); + RectangleList selectionArea; + while (i2.next() && i2.lineY < clip.getBottom()) { if (i2.lineY + i2.lineHeight >= clip.getY() && selection.intersects (Range (i2.indexInText, i2.indexInText + i2.atom->numChars))) { - i2.drawSelection (g, selection); + i2.addSelection (selectionArea, selection); } } + + g.setColour (findColour (highlightColourId).withMultipliedAlpha (hasKeyboardFocus (true) ? 1.0f : 0.5f)); + g.fillRectList (selectionArea); + + selectedTextColour = findColour (highlightedTextColourId); } const UniformTextSection* lastSection = nullptr; diff --git a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp index d1b47736e6..70b0a8f793 100644 --- a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp +++ b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp @@ -83,8 +83,8 @@ public: void getHighlightArea (RectangleList& area, float x, int y, int lineH, float characterWidth) const { if (highlightColumnStart < highlightColumnEnd) - area.addWithoutMerging (Rectangle (x + highlightColumnStart * characterWidth, (float) y, - (highlightColumnEnd - highlightColumnStart) * characterWidth, (float) lineH)); + area.add (Rectangle (x + highlightColumnStart * characterWidth - 1.0f, y - 0.5f, + (highlightColumnEnd - highlightColumnStart) * characterWidth + 1.5f, lineH + 1.0f)); } void draw (CodeEditorComponent& owner, Graphics& g, const Font& fontToUse, diff --git a/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp b/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp index f24f432f50..63128f06b0 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp @@ -272,8 +272,8 @@ OpenGLTextureFromImage::OpenGLTextureFromImage (const Image& image) texture->loadImage (image); textureID = texture->getTextureID(); - fullWidthProportion = imageWidth / (float) texture->getWidth(); - fullHeightProportion = imageHeight / (float) texture->getHeight(); + fullWidthProportion = (imageWidth - 0.5f) / texture->getWidth(); + fullHeightProportion = (imageHeight - 0.5f) / texture->getHeight(); } JUCE_CHECK_OPENGL_ERROR