| @@ -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 | |||
| { | |||
| @@ -51,8 +51,8 @@ LowLevelGraphicsContext::~LowLevelGraphicsContext() {} | |||
| //============================================================================== | |||
| 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! | |||
| } | |||
| @@ -741,8 +741,8 @@ public: | |||
| private: | |||
| //============================================================================== | |||
| std::unique_ptr<LowLevelGraphicsContext> contextHolder; | |||
| LowLevelGraphicsContext& context; | |||
| std::unique_ptr<LowLevelGraphicsContext> contextToDelete; | |||
| bool saveStatePending = false; | |||
| void saveStateIfPending(); | |||
| @@ -55,7 +55,7 @@ ImageType::~ImageType() {} | |||
| 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; | |||
| const Image::BitmapData src (source, Image::BitmapData::readOnly); | |||
| @@ -90,10 +90,10 @@ public: | |||
| imageData.allocate ((size_t) lineStride * (size_t) jmax (1, h), clearImage); | |||
| } | |||
| LowLevelGraphicsContext* createLowLevelContext() override | |||
| std::unique_ptr<LowLevelGraphicsContext> createLowLevelContext() override | |||
| { | |||
| 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 | |||
| @@ -114,7 +114,7 @@ public: | |||
| return *s; | |||
| } | |||
| ImageType* createType() const override { return new SoftwareImageType(); } | |||
| std::unique_ptr<ImageType> createType() const override { return std::make_unique<SoftwareImageType>(); } | |||
| private: | |||
| 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->setOrigin (area.getPosition()); | |||
| return g; | |||
| @@ -181,7 +181,7 @@ public: | |||
| ImagePixelData::Ptr clone() override | |||
| { | |||
| 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)); | |||
| @@ -193,7 +193,7 @@ public: | |||
| 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 */ | |||
| 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::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() | |||
| @@ -302,7 +305,7 @@ Image Image::rescaled (int newWidth, int newHeight, Graphics::ResamplingQuality | |||
| if (image == nullptr || (image->width == newWidth && image->height == newHeight)) | |||
| return *this; | |||
| const std::unique_ptr<ImageType> type (image->createType()); | |||
| auto type = image->createType(); | |||
| Image newImage (type->create (image->pixelFormat, newWidth, newHeight, hasAlphaChannel())); | |||
| Graphics g (newImage); | |||
| @@ -319,7 +322,7 @@ Image Image::convertedToFormat (PixelFormat newFormat) const | |||
| 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)); | |||
| if (newFormat == SingleChannel) | |||
| @@ -450,7 +453,7 @@ void Image::clear (const Rectangle<int>& area, Colour colourToClearTo) | |||
| { | |||
| if (image != nullptr) | |||
| { | |||
| const std::unique_ptr<LowLevelGraphicsContext> g (image->createLowLevelContext()); | |||
| auto g = image->createLowLevelContext(); | |||
| g->setFill (colourToClearTo); | |||
| g->fillRect (area, true); | |||
| } | |||
| @@ -398,7 +398,7 @@ public: | |||
| /** Creates a context suitable for drawing onto this image. | |||
| 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 | |||
| shared image data. | |||
| @@ -449,11 +449,11 @@ public: | |||
| using Ptr = ReferenceCountedObjectPtr<ImagePixelData>; | |||
| /** 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. */ | |||
| virtual Ptr clone() = 0; | |||
| /** 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. */ | |||
| 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 | |||
| @@ -2504,7 +2504,7 @@ public: | |||
| { | |||
| auto layerBounds = clip->getClipBounds(); | |||
| const std::unique_ptr<LowLevelGraphicsContext> g (image.createLowLevelContext()); | |||
| auto g = image.createLowLevelContext(); | |||
| g->setOpacity (finishedLayerState.transparencyLayerAlpha); | |||
| g->drawImage (finishedLayerState.image, AffineTransform::translation (layerBounds.getPosition())); | |||
| } | |||
| @@ -63,11 +63,11 @@ public: | |||
| CGContextRelease (context); | |||
| } | |||
| LowLevelGraphicsContext* createLowLevelContext() override | |||
| std::unique_ptr<LowLevelGraphicsContext> createLowLevelContext() override | |||
| { | |||
| freeCachedImageRef(); | |||
| 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 | |||
| @@ -91,7 +91,7 @@ public: | |||
| 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) | |||
| @@ -168,10 +168,11 @@ MouseCursor LookAndFeel::getMouseCursorFor (Component& component) | |||
| 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); | |||
| } | |||
| //============================================================================== | |||
| @@ -196,9 +196,9 @@ public: | |||
| //============================================================================== | |||
| /** 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); | |||
| bool isUsingNativeAlertWindows(); | |||
| @@ -241,7 +241,7 @@ class AndroidComponentPeer : public ComponentPeer, | |||
| private Timer | |||
| { | |||
| public: | |||
| AndroidComponentPeer (Component& comp, const int windowStyleFlags, void* nativeViewHandle) | |||
| AndroidComponentPeer (Component& comp, int windowStyleFlags, void* nativeViewHandle) | |||
| : ComponentPeer (comp, windowStyleFlags), | |||
| fullScreen (false), | |||
| navBarsHidden (false), | |||
| @@ -424,7 +424,7 @@ public: | |||
| class ViewMover : public CallbackMessage | |||
| { | |||
| 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 | |||
| { | |||
| @@ -925,7 +925,7 @@ private: | |||
| 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_) | |||
| { | |||
| if (hasAlpha_) | |||
| @@ -936,7 +936,7 @@ private: | |||
| { | |||
| if (hasAlpha) | |||
| { | |||
| PixelARGB* pix = (PixelARGB*) data; | |||
| auto pix = (PixelARGB*) data; | |||
| 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 | |||
| { | |||
| @@ -959,7 +966,7 @@ private: | |||
| 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->data = s->allocatedData; | |||
| 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 | |||
| return false; | |||
| @@ -1242,7 +1249,7 @@ int JUCE_CALLTYPE NativeMessageBox::showYesNoBox (AlertWindow::AlertIconType /*i | |||
| //============================================================================== | |||
| static bool androidScreenSaverEnabled = false; | |||
| void Desktop::setScreenSaverEnabled (const bool shouldEnable) | |||
| void Desktop::setScreenSaverEnabled (bool shouldEnable) | |||
| { | |||
| 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 {} | |||
| //============================================================================== | |||
| bool DragAndDropContainer::performExternalDragDropOfFiles (const StringArray& /*files*/, const bool /*canMove*/, | |||
| bool DragAndDropContainer::performExternalDragDropOfFiles (const StringArray& /*files*/, bool /*canMove*/, | |||
| Component* /*srcComp*/, std::function<void()> /*callback*/) | |||
| { | |||
| jassertfalse; // no such thing on Android! | |||
| @@ -620,10 +620,10 @@ public: | |||
| } | |||
| } | |||
| LowLevelGraphicsContext* createLowLevelContext() override | |||
| std::unique_ptr<LowLevelGraphicsContext> createLowLevelContext() override | |||
| { | |||
| sendDataChangeMessage(); | |||
| return new LowLevelGraphicsSoftwareRenderer (Image (this)); | |||
| return std::make_unique<LowLevelGraphicsSoftwareRenderer> (Image (this)); | |||
| } | |||
| void initialiseBitmapData (Image::BitmapData& bitmap, int x, int y, | |||
| @@ -644,7 +644,7 @@ public: | |||
| 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, | |||
| unsigned int dw, unsigned int dh, int sx, int sy) | |||
| @@ -2305,8 +2305,9 @@ private: | |||
| 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)); | |||
| peer.handlePaint (*context); | |||
| } | |||
| @@ -876,8 +876,8 @@ public: | |||
| if (intScale != 1) | |||
| 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) | |||
| context->addTransform (AffineTransform::scale (displayScale)); | |||
| @@ -763,12 +763,12 @@ public: | |||
| 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(); | |||
| 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 | |||
| @@ -2441,8 +2441,8 @@ private: | |||
| 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())); | |||
| handlePaint (*context); | |||
| @@ -1804,31 +1804,31 @@ static void clearOpenGLGlyphCacheCallback() | |||
| SavedState::GlyphCacheType::getInstance().reset(); | |||
| } | |||
| static LowLevelGraphicsContext* createOpenGLContext (const Target& target) | |||
| static std::unique_ptr<LowLevelGraphicsContext> createOpenGLContext (const Target& target) | |||
| { | |||
| clearOpenGLGlyphCache = clearOpenGLGlyphCacheCallback; | |||
| 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()); | |||
| 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); | |||
| } | |||
| LowLevelGraphicsContext* createOpenGLGraphicsContext (OpenGLContext& context, OpenGLFrameBuffer& target) | |||
| std::unique_ptr<LowLevelGraphicsContext> createOpenGLGraphicsContext (OpenGLContext& context, OpenGLFrameBuffer& 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)); | |||
| } | |||
| @@ -30,20 +30,20 @@ namespace juce | |||
| /** 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. | |||
| */ | |||
| 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. | |||
| 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, | |||
| with the given size. | |||
| 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); | |||
| //============================================================================== | |||
| @@ -43,13 +43,13 @@ public: | |||
| return frameBuffer.initialise (context, width, height); | |||
| } | |||
| LowLevelGraphicsContext* createLowLevelContext() override | |||
| std::unique_ptr<LowLevelGraphicsContext> createLowLevelContext() override | |||
| { | |||
| sendDataChangeMessage(); | |||
| 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 | |||
| { | |||