mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
LowLevelGraphicsContext: Add preferred image type for temporary images
Co-authored-by: Matt Gonzalez <matt@echoaudio.com>
This commit is contained in:
parent
bf940ae42a
commit
250abe9cf4
6 changed files with 40 additions and 1 deletions
|
|
@ -137,6 +137,16 @@ public:
|
|||
Span<const Point<float>>,
|
||||
const AffineTransform&) = 0;
|
||||
|
||||
/** Returns the optimal ImageType for creating temporary images in this GraphicsContext.
|
||||
|
||||
While this typically matches the GraphicsContext's native ImageType, certain scenarios
|
||||
may benefit from using a different format for temporary operations (e.g., for
|
||||
performance, memory efficiency, or specific rendering requirements).
|
||||
|
||||
@return A unique_ptr to the recommended ImageType instance for temporary images
|
||||
*/
|
||||
virtual std::unique_ptr<ImageType> getPreferredImageTypeForTemporaryImages() const = 0;
|
||||
|
||||
virtual void drawRoundedRectangle (const Rectangle<float>& r, float cornerSize, float lineThickness)
|
||||
{
|
||||
Path p;
|
||||
|
|
|
|||
|
|
@ -59,6 +59,11 @@ public:
|
|||
/** Destructor. */
|
||||
~LowLevelGraphicsSoftwareRenderer() override;
|
||||
|
||||
std::unique_ptr<ImageType> getPreferredImageTypeForTemporaryImages() const override
|
||||
{
|
||||
return std::make_unique<SoftwareImageType>();
|
||||
}
|
||||
|
||||
private:
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LowLevelGraphicsSoftwareRenderer)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -99,6 +99,11 @@ public:
|
|||
|
||||
uint64_t getFrameId() const override { return 0; }
|
||||
|
||||
std::unique_ptr<ImageType> getPreferredImageTypeForTemporaryImages() const override
|
||||
{
|
||||
return std::make_unique<NativeImageType>();
|
||||
}
|
||||
|
||||
void drawEllipse (const Rectangle<float>& area, float lineThickness) override;
|
||||
void fillEllipse (const Rectangle<float>& area) override;
|
||||
|
||||
|
|
|
|||
|
|
@ -106,6 +106,11 @@ public:
|
|||
|
||||
uint64_t getFrameId() const override { return frame; }
|
||||
|
||||
std::unique_ptr<ImageType> getPreferredImageTypeForTemporaryImages() const override
|
||||
{
|
||||
return std::make_unique<NativeImageType>();
|
||||
}
|
||||
|
||||
Direct2DMetrics::Ptr metrics;
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -729,6 +729,10 @@ std::unique_ptr<LowLevelGraphicsContext> Direct2DPixelData::createLowLevelContex
|
|||
void drawGlyphs (Span<const uint16_t>, Span<const Point<float>>, const AffineTransform&) override {}
|
||||
uint64_t getFrameId() const override { return 0; }
|
||||
Font font { FontOptions{} };
|
||||
std::unique_ptr<ImageType> getPreferredImageTypeForTemporaryImages() const override
|
||||
{
|
||||
return std::make_unique<NativeImageType>();
|
||||
}
|
||||
};
|
||||
|
||||
return std::make_unique<InertContext>();
|
||||
|
|
|
|||
|
|
@ -1839,6 +1839,11 @@ struct ShaderContext final : public RenderingHelpers::StackBasedLowLevelGraphics
|
|||
static_cast<SavedState&> (*stack).fillRectWithCustomShader (shader, area);
|
||||
}
|
||||
|
||||
std::unique_ptr<ImageType> getPreferredImageTypeForTemporaryImages() const override
|
||||
{
|
||||
return std::make_unique<OpenGLImageType>();
|
||||
}
|
||||
|
||||
GLState glState;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ShaderContext)
|
||||
|
|
@ -1850,7 +1855,7 @@ struct NonShaderContext final : public LowLevelGraphicsSoftwareRenderer
|
|||
: LowLevelGraphicsSoftwareRenderer (im), target (t), image (im)
|
||||
{}
|
||||
|
||||
~NonShaderContext()
|
||||
~NonShaderContext() override
|
||||
{
|
||||
JUCE_CHECK_OPENGL_ERROR
|
||||
auto previousFrameBufferTarget = OpenGLFrameBuffer::getCurrentFrameBufferTarget();
|
||||
|
|
@ -1883,6 +1888,11 @@ struct NonShaderContext final : public LowLevelGraphicsSoftwareRenderer
|
|||
JUCE_CHECK_OPENGL_ERROR
|
||||
}
|
||||
|
||||
std::unique_ptr<ImageType> getPreferredImageTypeForTemporaryImages() const noexcept override
|
||||
{
|
||||
return std::make_unique<OpenGLImageType>();
|
||||
}
|
||||
|
||||
private:
|
||||
Target target;
|
||||
Image image;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue