diff --git a/Libraries/nanovg b/Libraries/nanovg index b2af5ce79..7075c75f5 160000 --- a/Libraries/nanovg +++ b/Libraries/nanovg @@ -1 +1 @@ -Subproject commit b2af5ce796e31fc58ce91b1e6c12381c773f35da +Subproject commit 7075c75f5eb1f303ebac425b1c4d3e71921d61c8 diff --git a/Source/NVGSurface.cpp b/Source/NVGSurface.cpp index b84835c5d..6b8c7dd3e 100644 --- a/Source/NVGSurface.cpp +++ b/Source/NVGSurface.cpp @@ -212,7 +212,7 @@ void NVGSurface::updateBufferSize() if (fbWidth != scaledWidth || fbHeight != scaledHeight || !invalidFBO) { if (invalidFBO) nvgDeleteFramebuffer(invalidFBO); - invalidFBO = nvgCreateFramebuffer(nvg, scaledWidth, scaledHeight, NVG_IMAGE_PREMULTIPLIED); + invalidFBO = nvgCreateFramebuffer(nvg, scaledWidth, scaledHeight, 0); fbWidth = scaledWidth; fbHeight = scaledHeight; invalidArea = getLocalBounds(); diff --git a/Source/Utility/NVGGraphicsContext.cpp b/Source/Utility/NVGGraphicsContext.cpp index 6dc808950..6fb8ecb3a 100644 --- a/Source/Utility/NVGGraphicsContext.cpp +++ b/Source/Utility/NVGGraphicsContext.cpp @@ -97,7 +97,7 @@ void NVGGraphicsContext::clipToImageAlpha(juce::Image const& sourceImage, juce:: // Create a new Nanovg image from the bitmap data int const width = singleChannelImage.getWidth(); int const height = singleChannelImage.getHeight(); - auto const image = nvgCreateImageRGBA(nvg, width, height, 0, pixelData); + auto const image = nvgCreateImageARGB_sRGB(nvg, width, height, 0, pixelData); auto const paint = nvgImagePattern(nvg, 0, 0, width, height, 0, image, 1); nvgSave(nvg); @@ -566,24 +566,8 @@ int NVGGraphicsContext::getNvgImageId(juce::Image const& image) argbImage = argbImage.convertedToFormat(juce::Image::PixelFormat::ARGB); juce::Image::BitmapData const bitmap(argbImage, juce::Image::BitmapData::readOnly); - - for (int y = 0; y < argbImage.getHeight(); ++y) { - auto* scanLine = reinterpret_cast(bitmap.getLinePointer(y)); - - for (int x = 0; x < argbImage.getWidth(); ++x) { - juce::uint32 const argb = scanLine[x]; - - juce::uint8 const a = argb >> 24; - juce::uint8 const r = argb >> 16; - juce::uint8 const g = argb >> 8; - juce::uint8 const b = argb; - - // order bytes as abgr - scanLine[x] = a << 24 | b << 16 | g << 8 | r; - } - } - - id = nvgCreateImageRGBA(nvg, argbImage.getWidth(), argbImage.getHeight(), NVG_IMAGE_PREMULTIPLIED, bitmap.data); + + id = nvgCreateImageARGB(nvg, argbImage.getWidth(), argbImage.getHeight(), 0, bitmap.data); if (images.size() >= maxImageCacheSize) reduceImageCache(); diff --git a/Source/Utility/NVGUtils.cpp b/Source/Utility/NVGUtils.cpp index e09f55543..75327ad13 100644 --- a/Source/Utility/NVGUtils.cpp +++ b/Source/Utility/NVGUtils.cpp @@ -232,7 +232,7 @@ void NVGImage::loadJUCEImage(NVGcontext* context, Image const& image, int const flags |= withMipmaps ? NVG_IMAGE_GENERATE_MIPMAPS : 0; if (image.isARGB()) - subImage.imageId = nvgCreateImageARGB(nvg, totalWidth, totalHeight, flags | NVG_IMAGE_PREMULTIPLIED, imageData.data); + subImage.imageId = nvgCreateImageARGB_sRGB(nvg, totalWidth, totalHeight, flags, imageData.data); else if (image.isSingleChannel()) subImage.imageId = nvgCreateImageAlpha(nvg, totalWidth, totalHeight, flags, imageData.data); @@ -264,7 +264,7 @@ void NVGImage::loadJUCEImage(NVGcontext* context, Image const& image, int const flags |= withMipmaps ? NVG_IMAGE_GENERATE_MIPMAPS : 0; if (image.isARGB()) - subImage.imageId = nvgCreateImageARGB(nvg, w, h, flags | NVG_IMAGE_PREMULTIPLIED, imageData.data); + subImage.imageId = nvgCreateImageARGB_sRGB(nvg, w, h, flags, imageData.data); else if (image.isSingleChannel()) subImage.imageId = nvgCreateImageAlpha(nvg, w, h, flags, imageData.data); @@ -378,7 +378,7 @@ void NVGFramebuffer::bind(NVGcontext* ctx, int const width, int const height) nvg = ctx; if (fb) nvgDeleteFramebuffer(fb); - fb = nvgCreateFramebuffer(nvg, width, height, NVG_IMAGE_PREMULTIPLIED); + fb = nvgCreateFramebuffer(nvg, width, height, 0); fbWidth = width; fbHeight = height; }