diff --git a/modules/juce_graphics/native/juce_RenderingHelpers.h b/modules/juce_graphics/native/juce_RenderingHelpers.h index bd54981eed..a03727d74f 100644 --- a/modules/juce_graphics/native/juce_RenderingHelpers.h +++ b/modules/juce_graphics/native/juce_RenderingHelpers.h @@ -230,48 +230,6 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GlyphCache) }; -template -void drawGlyphImpl (Context& context, int glyphNumber, const AffineTransform& trans) -{ - using EdgeTableRegionType = typename Context::EdgeTableRegionType; - - if (context.clip == nullptr) - return; - - if (trans.isOnlyTranslation() && ! context.transform.isRotated) - { - auto& cache = RenderingHelpers::GlyphCache::getInstance(); - const Point pos (trans.getTranslationX(), trans.getTranslationY()); - - if (context.transform.isOnlyTranslated) - { - cache.drawGlyph (context, context.font, glyphNumber, pos + context.transform.offset.toFloat()); - } - else - { - auto f = context.font; - f.setHeight (f.getHeight() * context.transform.complexTransform.mat11); - - auto xScale = context.transform.complexTransform.mat00 / context.transform.complexTransform.mat11; - - if (std::abs (xScale - 1.0f) > 0.01f) - f.setHorizontalScale (xScale); - - cache.drawGlyph (context, f, glyphNumber, context.transform.transformed (pos)); - } - } - else - { - const auto fontHeight = context.font.getHeight(); - const auto fontTransform = AffineTransform::scale (fontHeight * context.font.getHorizontalScale(), - fontHeight).followedBy (trans); - const auto fullTransform = context.transform.getTransformWith (fontTransform); - - if (auto et = rawToUniquePtr (context.font.getTypefacePtr()->getEdgeTableForGlyph (glyphNumber, fullTransform, fontHeight))) - context.fillShape (*new EdgeTableRegionType (*et), false); - } -} - //============================================================================== /** Calculates the alpha values and positions for rendering the edges of a non-pixel-aligned rectangle. @@ -2489,11 +2447,6 @@ public: } //============================================================================== - void drawGlyph (int glyphNumber, const AffineTransform& trans) - { - drawGlyphImpl (*this, glyphNumber, trans); - } - Rectangle getMaximumBounds() const { return image.getBounds(); } //============================================================================== @@ -2642,11 +2595,49 @@ public: void fillRectList (const RectangleList& list) override { stack->fillRectList (list); } void fillPath (const Path& path, const AffineTransform& t) override { stack->fillPath (path, t); } void drawImage (const Image& im, const AffineTransform& t) override { stack->drawImage (im, t); } - void drawGlyph (int i, const AffineTransform& t) override { stack->drawGlyph (i, t); } void drawLine (const Line& line) override { stack->drawLine (line); } void setFont (const Font& newFont) override { stack->font = newFont; } const Font& getFont() override { return stack->font; } + void drawGlyph (int glyphNumber, const AffineTransform& trans) override + { + if (stack->clip == nullptr) + return; + + if (trans.isOnlyTranslation() && ! stack->transform.isRotated) + { + auto& cache = RenderingHelpers::GlyphCache::getInstance(); + const Point pos (trans.getTranslationX(), trans.getTranslationY()); + + if (stack->transform.isOnlyTranslated) + { + cache.drawGlyph (*stack, stack->font, glyphNumber, pos + stack->transform.offset.toFloat()); + } + else + { + auto f = stack->font; + f.setHeight (f.getHeight() * stack->transform.complexTransform.mat11); + + auto xScale = stack->transform.complexTransform.mat00 / stack->transform.complexTransform.mat11; + + if (std::abs (xScale - 1.0f) > 0.01f) + f.setHorizontalScale (xScale); + + cache.drawGlyph (*stack, f, glyphNumber, stack->transform.transformed (pos)); + } + } + else + { + const auto fontHeight = stack->font.getHeight(); + const auto fontTransform = AffineTransform::scale (fontHeight * stack->font.getHorizontalScale(), + fontHeight).followedBy (trans); + const auto fullTransform = stack->transform.getTransformWith (fontTransform); + + if (auto et = rawToUniquePtr (stack->font.getTypefacePtr()->getEdgeTableForGlyph (glyphNumber, fullTransform, fontHeight))) + stack->fillShape (*new ClipRegions::EdgeTableRegion (*et), false); + } + } + protected: StackBasedLowLevelGraphicsContext (SavedStateType* initialState) : stack (initialState) {} StackBasedLowLevelGraphicsContext() = default; diff --git a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp index 6a49ee42c5..4dafbce29c 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp @@ -1753,49 +1753,6 @@ struct SavedState final : public RenderingHelpers::SavedStateBase } } - void drawGlyph (int glyphNumber, const AffineTransform& trans) - { - if (clip != nullptr) - { - if (trans.isOnlyTranslation() && ! transform.isRotated) - { - auto& cache = RenderingHelpers::GlyphCache::getInstance(); - Point pos (trans.getTranslationX(), trans.getTranslationY()); - - if (transform.isOnlyTranslated) - { - cache.drawGlyph (*this, font, glyphNumber, pos + transform.offset.toFloat()); - } - else - { - pos = transform.transformed (pos); - - Font f (font); - f.setHeight (font.getHeight() * transform.complexTransform.mat11); - - auto xScale = transform.complexTransform.mat00 / transform.complexTransform.mat11; - - if (std::abs (xScale - 1.0f) > 0.01f) - f.setHorizontalScale (xScale); - - cache.drawGlyph (*this, f, glyphNumber, pos); - } - } - else - { - auto fontHeight = font.getHeight(); - - auto t = transform.getTransformWith (AffineTransform::scale (fontHeight * font.getHorizontalScale(), fontHeight) - .followedBy (trans)); - - const std::unique_ptr et (font.getTypefacePtr()->getEdgeTableForGlyph (glyphNumber, t, fontHeight)); - - if (et != nullptr) - fillShape (*new EdgeTableRegionType (*et), false); - } - } - } - Rectangle getMaximumBounds() const { return state->target.bounds; } void setFillType (const FillType& newFill)