Browse Source

Added more unique_ptr use, for functions that create LowLevelGraphicsContext or ImageType objects.

tags/2021-05-28
jules 6 years ago
parent
commit
f58eacc135
16 changed files with 88 additions and 69 deletions
  1. +9
    -2
      modules/juce_audio_plugin_client/Unity/juce_Unity_Wrapper.cpp
  2. +2
    -2
      modules/juce_graphics/contexts/juce_GraphicsContext.cpp
  3. +1
    -1
      modules/juce_graphics/contexts/juce_GraphicsContext.h
  4. +16
    -13
      modules/juce_graphics/images/juce_Image.cpp
  5. +3
    -3
      modules/juce_graphics/images/juce_Image.h
  6. +1
    -1
      modules/juce_graphics/native/juce_RenderingHelpers.h
  7. +3
    -3
      modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm
  8. +4
    -3
      modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp
  9. +3
    -3
      modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h
  10. +20
    -13
      modules/juce_gui_basics/native/juce_android_Windowing.cpp
  11. +6
    -5
      modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp
  12. +2
    -2
      modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm
  13. +5
    -5
      modules/juce_gui_basics/native/juce_win32_Windowing.cpp
  14. +6
    -6
      modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp
  15. +5
    -5
      modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.h
  16. +2
    -2
      modules/juce_opengl/opengl/juce_OpenGLImage.cpp

+ 9
- 2
modules/juce_audio_plugin_client/Unity/juce_Unity_Wrapper.cpp View File

@@ -145,8 +145,15 @@ private:
{ {
} }
ImageType* createType() const override { return new SoftwareImageType(); }
LowLevelGraphicsContext* createLowLevelContext() override { return new LowLevelGraphicsSoftwareRenderer (Image (this)); }
std::unique_ptr<ImageType> createType() const override
{
return std::make_unique<SoftwareImageType>();
}
std::unique_ptr<LowLevelGraphicsContext> createLowLevelContext() override
{
return std::make_unique<LowLevelGraphicsSoftwareRenderer> (Image (this));
}
void initialiseBitmapData (Image::BitmapData& bitmap, int x, int y, Image::BitmapData::ReadWriteMode mode) override void initialiseBitmapData (Image::BitmapData& bitmap, int x, int y, Image::BitmapData::ReadWriteMode mode) override
{ {


+ 2
- 2
modules/juce_graphics/contexts/juce_GraphicsContext.cpp View File

@@ -51,8 +51,8 @@ LowLevelGraphicsContext::~LowLevelGraphicsContext() {}
//============================================================================== //==============================================================================
Graphics::Graphics (const Image& imageToDrawOnto) Graphics::Graphics (const Image& imageToDrawOnto)
: context (*imageToDrawOnto.createLowLevelContext()),
contextToDelete (&context)
: contextHolder (imageToDrawOnto.createLowLevelContext()),
context (*contextHolder)
{ {
jassert (imageToDrawOnto.isValid()); // Can't draw into a null image! jassert (imageToDrawOnto.isValid()); // Can't draw into a null image!
} }


+ 1
- 1
modules/juce_graphics/contexts/juce_GraphicsContext.h View File

@@ -741,8 +741,8 @@ public:
private: private:
//============================================================================== //==============================================================================
std::unique_ptr<LowLevelGraphicsContext> contextHolder;
LowLevelGraphicsContext& context; LowLevelGraphicsContext& context;
std::unique_ptr<LowLevelGraphicsContext> contextToDelete;
bool saveStatePending = false; bool saveStatePending = false;
void saveStateIfPending(); void saveStateIfPending();


+ 16
- 13
modules/juce_graphics/images/juce_Image.cpp View File

@@ -55,7 +55,7 @@ ImageType::~ImageType() {}
Image ImageType::convert (const Image& source) const Image ImageType::convert (const Image& source) const
{ {
if (source.isNull() || getTypeID() == (std::unique_ptr<ImageType> (source.getPixelData()->createType())->getTypeID()))
if (source.isNull() || getTypeID() == source.getPixelData()->createType()->getTypeID())
return source; return source;
const Image::BitmapData src (source, Image::BitmapData::readOnly); const Image::BitmapData src (source, Image::BitmapData::readOnly);
@@ -90,10 +90,10 @@ public:
imageData.allocate ((size_t) lineStride * (size_t) jmax (1, h), clearImage); imageData.allocate ((size_t) lineStride * (size_t) jmax (1, h), clearImage);
} }
LowLevelGraphicsContext* createLowLevelContext() override
std::unique_ptr<LowLevelGraphicsContext> createLowLevelContext() override
{ {
sendDataChangeMessage(); sendDataChangeMessage();
return new LowLevelGraphicsSoftwareRenderer (Image (*this));
return std::make_unique<LowLevelGraphicsSoftwareRenderer> (Image (*this));
} }
void initialiseBitmapData (Image::BitmapData& bitmap, int x, int y, Image::BitmapData::ReadWriteMode mode) override void initialiseBitmapData (Image::BitmapData& bitmap, int x, int y, Image::BitmapData::ReadWriteMode mode) override
@@ -114,7 +114,7 @@ public:
return *s; return *s;
} }
ImageType* createType() const override { return new SoftwareImageType(); }
std::unique_ptr<ImageType> createType() const override { return std::make_unique<SoftwareImageType>(); }
private: private:
HeapBlock<uint8> imageData; HeapBlock<uint8> imageData;
@@ -162,9 +162,9 @@ public:
{ {
} }
LowLevelGraphicsContext* createLowLevelContext() override
std::unique_ptr<LowLevelGraphicsContext> createLowLevelContext() override
{ {
LowLevelGraphicsContext* g = sourceImage->createLowLevelContext();
auto g = sourceImage->createLowLevelContext();
g->clipToRectangle (area); g->clipToRectangle (area);
g->setOrigin (area.getPosition()); g->setOrigin (area.getPosition());
return g; return g;
@@ -181,7 +181,7 @@ public:
ImagePixelData::Ptr clone() override ImagePixelData::Ptr clone() override
{ {
jassert (getReferenceCount() > 0); // (This method can't be used on an unowned pointer, as it will end up self-deleting) jassert (getReferenceCount() > 0); // (This method can't be used on an unowned pointer, as it will end up self-deleting)
const std::unique_ptr<ImageType> type (createType());
auto type = createType();
Image newImage (type->create (pixelFormat, area.getWidth(), area.getHeight(), pixelFormat != Image::RGB)); Image newImage (type->create (pixelFormat, area.getWidth(), area.getHeight(), pixelFormat != Image::RGB));
@@ -193,7 +193,7 @@ public:
return *newImage.getPixelData(); return *newImage.getPixelData();
} }
ImageType* createType() const override { return sourceImage->createType(); }
std::unique_ptr<ImageType> createType() const override { return sourceImage->createType(); }
/* as we always hold a reference to image, don't double count */ /* as we always hold a reference to image, don't double count */
int getSharedCount() const noexcept override { return getReferenceCount() + sourceImage->getSharedCount() - 1; } int getSharedCount() const noexcept override { return getReferenceCount() + sourceImage->getSharedCount() - 1; }
@@ -278,9 +278,12 @@ bool Image::isRGB() const noexcept { return getFormat() ==
bool Image::isSingleChannel() const noexcept { return getFormat() == SingleChannel; } bool Image::isSingleChannel() const noexcept { return getFormat() == SingleChannel; }
bool Image::hasAlphaChannel() const noexcept { return getFormat() != RGB; } bool Image::hasAlphaChannel() const noexcept { return getFormat() != RGB; }
LowLevelGraphicsContext* Image::createLowLevelContext() const
std::unique_ptr<LowLevelGraphicsContext> Image::createLowLevelContext() const
{ {
return image == nullptr ? nullptr : image->createLowLevelContext();
if (image != nullptr)
return image->createLowLevelContext();
return {};
} }
void Image::duplicateIfShared() void Image::duplicateIfShared()
@@ -302,7 +305,7 @@ Image Image::rescaled (int newWidth, int newHeight, Graphics::ResamplingQuality
if (image == nullptr || (image->width == newWidth && image->height == newHeight)) if (image == nullptr || (image->width == newWidth && image->height == newHeight))
return *this; return *this;
const std::unique_ptr<ImageType> type (image->createType());
auto type = image->createType();
Image newImage (type->create (image->pixelFormat, newWidth, newHeight, hasAlphaChannel())); Image newImage (type->create (image->pixelFormat, newWidth, newHeight, hasAlphaChannel()));
Graphics g (newImage); Graphics g (newImage);
@@ -319,7 +322,7 @@ Image Image::convertedToFormat (PixelFormat newFormat) const
auto w = image->width, h = image->height; auto w = image->width, h = image->height;
const std::unique_ptr<ImageType> type (image->createType());
auto type = image->createType();
Image newImage (type->create (newFormat, w, h, false)); Image newImage (type->create (newFormat, w, h, false));
if (newFormat == SingleChannel) if (newFormat == SingleChannel)
@@ -450,7 +453,7 @@ void Image::clear (const Rectangle<int>& area, Colour colourToClearTo)
{ {
if (image != nullptr) if (image != nullptr)
{ {
const std::unique_ptr<LowLevelGraphicsContext> g (image->createLowLevelContext());
auto g = image->createLowLevelContext();
g->setFill (colourToClearTo); g->setFill (colourToClearTo);
g->fillRect (area, true); g->fillRect (area, true);
} }


+ 3
- 3
modules/juce_graphics/images/juce_Image.h View File

@@ -398,7 +398,7 @@ public:
/** Creates a context suitable for drawing onto this image. /** Creates a context suitable for drawing onto this image.
Don't call this method directly! It's used internally by the Graphics class. Don't call this method directly! It's used internally by the Graphics class.
*/ */
LowLevelGraphicsContext* createLowLevelContext() const;
std::unique_ptr<LowLevelGraphicsContext> createLowLevelContext() const;
/** Returns the number of Image objects which are currently referring to the same internal /** Returns the number of Image objects which are currently referring to the same internal
shared image data. shared image data.
@@ -449,11 +449,11 @@ public:
using Ptr = ReferenceCountedObjectPtr<ImagePixelData>; using Ptr = ReferenceCountedObjectPtr<ImagePixelData>;
/** Creates a context that will draw into this image. */ /** Creates a context that will draw into this image. */
virtual LowLevelGraphicsContext* createLowLevelContext() = 0;
virtual std::unique_ptr<LowLevelGraphicsContext> createLowLevelContext() = 0;
/** Creates a copy of this image. */ /** Creates a copy of this image. */
virtual Ptr clone() = 0; virtual Ptr clone() = 0;
/** Creates an instance of the type of this image. */ /** Creates an instance of the type of this image. */
virtual ImageType* createType() const = 0;
virtual std::unique_ptr<ImageType> createType() const = 0;
/** Initialises a BitmapData object. */ /** Initialises a BitmapData object. */
virtual void initialiseBitmapData (Image::BitmapData&, int x, int y, Image::BitmapData::ReadWriteMode) = 0; virtual void initialiseBitmapData (Image::BitmapData&, int x, int y, Image::BitmapData::ReadWriteMode) = 0;
/** Returns the number of Image objects which are currently referring to the same internal /** Returns the number of Image objects which are currently referring to the same internal


+ 1
- 1
modules/juce_graphics/native/juce_RenderingHelpers.h View File

@@ -2504,7 +2504,7 @@ public:
{ {
auto layerBounds = clip->getClipBounds(); auto layerBounds = clip->getClipBounds();
const std::unique_ptr<LowLevelGraphicsContext> g (image.createLowLevelContext());
auto g = image.createLowLevelContext();
g->setOpacity (finishedLayerState.transparencyLayerAlpha); g->setOpacity (finishedLayerState.transparencyLayerAlpha);
g->drawImage (finishedLayerState.image, AffineTransform::translation (layerBounds.getPosition())); g->drawImage (finishedLayerState.image, AffineTransform::translation (layerBounds.getPosition()));
} }


+ 3
- 3
modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm View File

@@ -63,11 +63,11 @@ public:
CGContextRelease (context); CGContextRelease (context);
} }
LowLevelGraphicsContext* createLowLevelContext() override
std::unique_ptr<LowLevelGraphicsContext> createLowLevelContext() override
{ {
freeCachedImageRef(); freeCachedImageRef();
sendDataChangeMessage(); sendDataChangeMessage();
return new CoreGraphicsContext (context, height, 1.0f);
return std::make_unique<CoreGraphicsContext> (context, height, 1.0f);
} }
void initialiseBitmapData (Image::BitmapData& bitmap, int x, int y, Image::BitmapData::ReadWriteMode mode) override void initialiseBitmapData (Image::BitmapData& bitmap, int x, int y, Image::BitmapData::ReadWriteMode mode) override
@@ -91,7 +91,7 @@ public:
return *im; return *im;
} }
ImageType* createType() const override { return new NativeImageType(); }
std::unique_ptr<ImageType> createType() const override { return std::make_unique<NativeImageType>(); }
//============================================================================== //==============================================================================
static CGImageRef getCachedImageRef (const Image& juceImage, CGColorSpaceRef colourSpace) static CGImageRef getCachedImageRef (const Image& juceImage, CGColorSpaceRef colourSpace)


+ 4
- 3
modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp View File

@@ -168,10 +168,11 @@ MouseCursor LookAndFeel::getMouseCursorFor (Component& component)
return cursor; return cursor;
} }
LowLevelGraphicsContext* LookAndFeel::createGraphicsContext (const Image& imageToRenderOn, const Point<int>& origin,
const RectangleList<int>& initialClip)
std::unique_ptr<LowLevelGraphicsContext> LookAndFeel::createGraphicsContext (const Image& imageToRenderOn,
Point<int> origin,
RectangleList<int> initialClip)
{ {
return new LowLevelGraphicsSoftwareRenderer (imageToRenderOn, origin, initialClip);
return std::make_unique<LowLevelGraphicsSoftwareRenderer> (imageToRenderOn, origin, initialClip);
} }
//============================================================================== //==============================================================================


+ 3
- 3
modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h View File

@@ -196,9 +196,9 @@ public:
//============================================================================== //==============================================================================
/** Creates a new graphics context object. */ /** Creates a new graphics context object. */
virtual LowLevelGraphicsContext* createGraphicsContext (const Image& imageToRenderOn,
const Point<int>& origin,
const RectangleList<int>& initialClip);
virtual std::unique_ptr<LowLevelGraphicsContext> createGraphicsContext (const Image& imageToRenderOn,
Point<int> origin,
RectangleList<int> initialClip);
void setUsingNativeAlertWindows (bool shouldUseNativeAlerts); void setUsingNativeAlertWindows (bool shouldUseNativeAlerts);
bool isUsingNativeAlertWindows(); bool isUsingNativeAlertWindows();


+ 20
- 13
modules/juce_gui_basics/native/juce_android_Windowing.cpp View File

@@ -241,7 +241,7 @@ class AndroidComponentPeer : public ComponentPeer,
private Timer private Timer
{ {
public: public:
AndroidComponentPeer (Component& comp, const int windowStyleFlags, void* nativeViewHandle)
AndroidComponentPeer (Component& comp, int windowStyleFlags, void* nativeViewHandle)
: ComponentPeer (comp, windowStyleFlags), : ComponentPeer (comp, windowStyleFlags),
fullScreen (false), fullScreen (false),
navBarsHidden (false), navBarsHidden (false),
@@ -424,7 +424,7 @@ public:
class ViewMover : public CallbackMessage class ViewMover : public CallbackMessage
{ {
public: public:
ViewMover (const GlobalRef& v, const Rectangle<int>& boundsToUse) : view (v), bounds (boundsToUse) {}
ViewMover (const GlobalRef& v, Rectangle<int> boundsToUse) : view (v), bounds (boundsToUse) {}
void messageCallback() override void messageCallback() override
{ {
@@ -925,7 +925,7 @@ private:
struct PreallocatedImage : public ImagePixelData struct PreallocatedImage : public ImagePixelData
{ {
PreallocatedImage (const int width_, const int height_, jint* data_, bool hasAlpha_)
PreallocatedImage (int width_, int height_, jint* data_, bool hasAlpha_)
: ImagePixelData (Image::ARGB, width_, height_), data (data_), hasAlpha (hasAlpha_) : ImagePixelData (Image::ARGB, width_, height_), data (data_), hasAlpha (hasAlpha_)
{ {
if (hasAlpha_) if (hasAlpha_)
@@ -936,7 +936,7 @@ private:
{ {
if (hasAlpha) if (hasAlpha)
{ {
PixelARGB* pix = (PixelARGB*) data;
auto pix = (PixelARGB*) data;
for (int i = width * height; --i >= 0;) for (int i = width * height; --i >= 0;)
{ {
@@ -946,8 +946,15 @@ private:
} }
} }
ImageType* createType() const override { return new SoftwareImageType(); }
LowLevelGraphicsContext* createLowLevelContext() override { return new LowLevelGraphicsSoftwareRenderer (Image (this)); }
std::unique_ptr<ImageType> createType() const override
{
return std::make_unique<SoftwareImageType>();
}
std::unique_ptr<LowLevelGraphicsContext> createLowLevelContext() override
{
return std::make_unique<LowLevelGraphicsSoftwareRenderer> (Image (this));
}
void initialiseBitmapData (Image::BitmapData& bm, int x, int y, Image::BitmapData::ReadWriteMode /*mode*/) override void initialiseBitmapData (Image::BitmapData& bm, int x, int y, Image::BitmapData::ReadWriteMode /*mode*/) override
{ {
@@ -959,7 +966,7 @@ private:
ImagePixelData::Ptr clone() override ImagePixelData::Ptr clone() override
{ {
PreallocatedImage* s = new PreallocatedImage (width, height, 0, hasAlpha);
auto s = new PreallocatedImage (width, height, 0, hasAlpha);
s->allocatedData.malloc (sizeof (jint) * static_cast<size_t> (width * height)); s->allocatedData.malloc (sizeof (jint) * static_cast<size_t> (width * height));
s->data = s->allocatedData; s->data = s->allocatedData;
memcpy (s->data, data, sizeof (jint) * static_cast<size_t> (width * height)); memcpy (s->data, data, sizeof (jint) * static_cast<size_t> (width * height));
@@ -1060,7 +1067,7 @@ void MouseInputSource::setRawMousePosition (Point<float>)
} }
//============================================================================== //==============================================================================
bool KeyPress::isKeyCurrentlyDown (const int /*keyCode*/)
bool KeyPress::isKeyCurrentlyDown (int /*keyCode*/)
{ {
// TODO // TODO
return false; return false;
@@ -1242,7 +1249,7 @@ int JUCE_CALLTYPE NativeMessageBox::showYesNoBox (AlertWindow::AlertIconType /*i
//============================================================================== //==============================================================================
static bool androidScreenSaverEnabled = false; static bool androidScreenSaverEnabled = false;
void Desktop::setScreenSaverEnabled (const bool shouldEnable)
void Desktop::setScreenSaverEnabled (bool shouldEnable)
{ {
constexpr auto FLAG_KEEP_SCREEN_ON = 0x80; constexpr auto FLAG_KEEP_SCREEN_ON = 0x80;
@@ -1486,15 +1493,15 @@ Image juce_createIconForFile (const File& /*file*/)
} }
//============================================================================== //==============================================================================
void* CustomMouseCursorInfo::create() const { return nullptr; }
void* MouseCursor::createStandardMouseCursor (const MouseCursor::StandardCursorType) { return nullptr; }
void MouseCursor::deleteMouseCursor (void* const /*cursorHandle*/, const bool /*isStandard*/) {}
void* CustomMouseCursorInfo::create() const { return nullptr; }
void* MouseCursor::createStandardMouseCursor (MouseCursor::StandardCursorType) { return nullptr; }
void MouseCursor::deleteMouseCursor (void* /*cursorHandle*/, bool /*isStandard*/) {}
//============================================================================== //==============================================================================
void MouseCursor::showInWindow (ComponentPeer*) const {} void MouseCursor::showInWindow (ComponentPeer*) const {}
//============================================================================== //==============================================================================
bool DragAndDropContainer::performExternalDragDropOfFiles (const StringArray& /*files*/, const bool /*canMove*/,
bool DragAndDropContainer::performExternalDragDropOfFiles (const StringArray& /*files*/, bool /*canMove*/,
Component* /*srcComp*/, std::function<void()> /*callback*/) Component* /*srcComp*/, std::function<void()> /*callback*/)
{ {
jassertfalse; // no such thing on Android! jassertfalse; // no such thing on Android!


+ 6
- 5
modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp View File

@@ -620,10 +620,10 @@ public:
} }
} }
LowLevelGraphicsContext* createLowLevelContext() override
std::unique_ptr<LowLevelGraphicsContext> createLowLevelContext() override
{ {
sendDataChangeMessage(); sendDataChangeMessage();
return new LowLevelGraphicsSoftwareRenderer (Image (this));
return std::make_unique<LowLevelGraphicsSoftwareRenderer> (Image (this));
} }
void initialiseBitmapData (Image::BitmapData& bitmap, int x, int y, void initialiseBitmapData (Image::BitmapData& bitmap, int x, int y,
@@ -644,7 +644,7 @@ public:
return nullptr; return nullptr;
} }
ImageType* createType() const override { return new NativeImageType(); }
std::unique_ptr<ImageType> createType() const override { return std::make_unique<NativeImageType>(); }
void blitToWindow (Window window, int dx, int dy, void blitToWindow (Window window, int dx, int dy,
unsigned int dw, unsigned int dh, int sx, int sy) unsigned int dw, unsigned int dh, int sx, int sy)
@@ -2305,8 +2305,9 @@ private:
image.clear (i - totalArea.getPosition()); image.clear (i - totalArea.getPosition());
{ {
std::unique_ptr<LowLevelGraphicsContext> context (peer.getComponent().getLookAndFeel()
.createGraphicsContext (image, -totalArea.getPosition(), adjustedList));
auto context = peer.getComponent().getLookAndFeel()
.createGraphicsContext (image, -totalArea.getPosition(), adjustedList);
context->addTransform (AffineTransform::scale ((float) peer.currentScaleFactor)); context->addTransform (AffineTransform::scale ((float) peer.currentScaleFactor));
peer.handlePaint (*context); peer.handlePaint (*context);
} }


+ 2
- 2
modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm View File

@@ -876,8 +876,8 @@ public:
if (intScale != 1) if (intScale != 1)
clip.scaleAll (intScale); clip.scaleAll (intScale);
std::unique_ptr<LowLevelGraphicsContext> context (component.getLookAndFeel()
.createGraphicsContext (temp, offset * intScale, clip));
auto context = component.getLookAndFeel()
.createGraphicsContext (temp, offset * intScale, clip);
if (intScale != 1) if (intScale != 1)
context->addTransform (AffineTransform::scale (displayScale)); context->addTransform (AffineTransform::scale (displayScale));


+ 5
- 5
modules/juce_gui_basics/native/juce_win32_Windowing.cpp View File

@@ -763,12 +763,12 @@ public:
DeleteObject (hBitmap); DeleteObject (hBitmap);
} }
ImageType* createType() const override { return new NativeImageType(); }
std::unique_ptr<ImageType> createType() const override { return std::make_unique<NativeImageType>(); }
LowLevelGraphicsContext* createLowLevelContext() override
std::unique_ptr<LowLevelGraphicsContext> createLowLevelContext() override
{ {
sendDataChangeMessage(); sendDataChangeMessage();
return new LowLevelGraphicsSoftwareRenderer (Image (this));
return std::make_unique<LowLevelGraphicsSoftwareRenderer> (Image (this));
} }
void initialiseBitmapData (Image::BitmapData& bitmap, int x, int y, Image::BitmapData::ReadWriteMode mode) override void initialiseBitmapData (Image::BitmapData& bitmap, int x, int y, Image::BitmapData::ReadWriteMode mode) override
@@ -2441,8 +2441,8 @@ private:
offscreenImage.clear (i); offscreenImage.clear (i);
{ {
std::unique_ptr<LowLevelGraphicsContext> context (component.getLookAndFeel()
.createGraphicsContext (offscreenImage, Point<int> (-x, -y), contextClip));
auto context = component.getLookAndFeel()
.createGraphicsContext (offscreenImage, { -x, -y }, contextClip);
context->addTransform (AffineTransform::scale ((float) getPlatformScaleFactor())); context->addTransform (AffineTransform::scale ((float) getPlatformScaleFactor()));
handlePaint (*context); handlePaint (*context);


+ 6
- 6
modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp View File

@@ -1804,31 +1804,31 @@ static void clearOpenGLGlyphCacheCallback()
SavedState::GlyphCacheType::getInstance().reset(); SavedState::GlyphCacheType::getInstance().reset();
} }
static LowLevelGraphicsContext* createOpenGLContext (const Target& target)
static std::unique_ptr<LowLevelGraphicsContext> createOpenGLContext (const Target& target)
{ {
clearOpenGLGlyphCache = clearOpenGLGlyphCacheCallback; clearOpenGLGlyphCache = clearOpenGLGlyphCacheCallback;
if (target.context.areShadersAvailable()) if (target.context.areShadersAvailable())
return new ShaderContext (target);
return std::make_unique<ShaderContext> (target);
Image tempImage (Image::ARGB, target.bounds.getWidth(), target.bounds.getHeight(), true, SoftwareImageType()); Image tempImage (Image::ARGB, target.bounds.getWidth(), target.bounds.getHeight(), true, SoftwareImageType());
return new NonShaderContext (target, tempImage);
return std::make_unique<NonShaderContext> (target, tempImage);
} }
} }
//============================================================================== //==============================================================================
LowLevelGraphicsContext* createOpenGLGraphicsContext (OpenGLContext& context, int width, int height)
std::unique_ptr<LowLevelGraphicsContext> createOpenGLGraphicsContext (OpenGLContext& context, int width, int height)
{ {
return createOpenGLGraphicsContext (context, context.getFrameBufferID(), width, height); return createOpenGLGraphicsContext (context, context.getFrameBufferID(), width, height);
} }
LowLevelGraphicsContext* createOpenGLGraphicsContext (OpenGLContext& context, OpenGLFrameBuffer& target)
std::unique_ptr<LowLevelGraphicsContext> createOpenGLGraphicsContext (OpenGLContext& context, OpenGLFrameBuffer& target)
{ {
return OpenGLRendering::createOpenGLContext (OpenGLRendering::Target (context, target, {})); return OpenGLRendering::createOpenGLContext (OpenGLRendering::Target (context, target, {}));
} }
LowLevelGraphicsContext* createOpenGLGraphicsContext (OpenGLContext& context, unsigned int frameBufferID, int width, int height)
std::unique_ptr<LowLevelGraphicsContext> createOpenGLGraphicsContext (OpenGLContext& context, unsigned int frameBufferID, int width, int height)
{ {
return OpenGLRendering::createOpenGLContext (OpenGLRendering::Target (context, frameBufferID, width, height)); return OpenGLRendering::createOpenGLContext (OpenGLRendering::Target (context, frameBufferID, width, height));
} }


+ 5
- 5
modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.h View File

@@ -30,20 +30,20 @@ namespace juce
/** Creates a graphics context object that will render into the given OpenGL target. /** Creates a graphics context object that will render into the given OpenGL target.
The caller is responsible for deleting this object when no longer needed. The caller is responsible for deleting this object when no longer needed.
*/ */
LowLevelGraphicsContext* createOpenGLGraphicsContext (OpenGLContext&, int width, int height);
std::unique_ptr<LowLevelGraphicsContext> createOpenGLGraphicsContext (OpenGLContext&, int width, int height);
/** Creates a graphics context object that will render into the given OpenGL framebuffer. /** Creates a graphics context object that will render into the given OpenGL framebuffer.
The caller is responsible for deleting this object when no longer needed. The caller is responsible for deleting this object when no longer needed.
*/ */
LowLevelGraphicsContext* createOpenGLGraphicsContext (OpenGLContext&, OpenGLFrameBuffer&);
std::unique_ptr<LowLevelGraphicsContext> createOpenGLGraphicsContext (OpenGLContext&, OpenGLFrameBuffer&);
/** Creates a graphics context object that will render into the given OpenGL framebuffer, /** Creates a graphics context object that will render into the given OpenGL framebuffer,
with the given size. with the given size.
The caller is responsible for deleting this object when no longer needed. The caller is responsible for deleting this object when no longer needed.
*/ */
LowLevelGraphicsContext* createOpenGLGraphicsContext (OpenGLContext&,
unsigned int frameBufferID,
int width, int height);
std::unique_ptr<LowLevelGraphicsContext> createOpenGLGraphicsContext (OpenGLContext&,
unsigned int frameBufferID,
int width, int height);
//============================================================================== //==============================================================================


+ 2
- 2
modules/juce_opengl/opengl/juce_OpenGLImage.cpp View File

@@ -43,13 +43,13 @@ public:
return frameBuffer.initialise (context, width, height); return frameBuffer.initialise (context, width, height);
} }
LowLevelGraphicsContext* createLowLevelContext() override
std::unique_ptr<LowLevelGraphicsContext> createLowLevelContext() override
{ {
sendDataChangeMessage(); sendDataChangeMessage();
return createOpenGLGraphicsContext (context, frameBuffer); return createOpenGLGraphicsContext (context, frameBuffer);
} }
ImageType* createType() const override { return new OpenGLImageType(); }
std::unique_ptr<ImageType> createType() const override { return std::make_unique<OpenGLImageType>(); }
ImagePixelData::Ptr clone() override ImagePixelData::Ptr clone() override
{ {


Loading…
Cancel
Save