diff --git a/.rive_head b/.rive_head index 27941d26..dadbd9f9 100644 --- a/.rive_head +++ b/.rive_head @@ -1 +1 @@ -55de8286c5ba680de950a3a0aac26e13bb890d6b +714b8894f37ab931a1df4b27d63c1e0991a97e3a diff --git a/Source/Renderer/PlatformCGImage.mm b/Source/Renderer/PlatformCGImage.mm index 35542590..50e6a2ee 100644 --- a/Source/Renderer/PlatformCGImage.mm +++ b/Source/Renderer/PlatformCGImage.mm @@ -49,40 +49,17 @@ bool PlatformCGImageDecode(const uint8_t* encodedBytes, break; } - // Now create a drawing context to produce RGBA pixels - - const size_t bitsPerComponent = 8; - CGBitmapInfo cgInfo = kCGBitmapByteOrder32Big; // rgba - if (isOpaque) - { - cgInfo |= kCGImageAlphaNoneSkipLast; - } - else - { - cgInfo |= kCGImageAlphaPremultipliedLast; // premul - } + CFDataRef dataRef = CGDataProviderCopyData(CGImageGetDataProvider(image)); + const UInt8* pixelData = CFDataGetBytePtr(dataRef); const size_t width = CGImageGetWidth(image); const size_t height = CGImageGetHeight(image); const size_t rowBytes = width * 4; // 4 bytes per pixel const size_t size = rowBytes * height; - std::vector pixels; - pixels.resize(size); - - AutoCF cs = CGColorSpaceCreateDeviceRGB(); - AutoCF cg = - CGBitmapContextCreate(pixels.data(), width, height, bitsPerComponent, rowBytes, cs, cgInfo); - if (!cg) - { - return false; - } - - CGContextSetBlendMode(cg, kCGBlendModeCopy); - CGContextDrawImage(cg, CGRectMake(0, 0, width, height), image); - platformImage->width = rive::castTo(width); platformImage->height = rive::castTo(height); platformImage->opaque = isOpaque; - platformImage->pixels = std::move(pixels); + platformImage->pixels = std::vector(pixelData, pixelData + size); + CFRelease(dataRef); return true; }