Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There are some performance issues when use mask/effect... #790

Open
wanqingrongruo opened this issue Apr 13, 2022 · 0 comments
Open

There are some performance issues when use mask/effect... #790

wanqingrongruo opened this issue Apr 13, 2022 · 0 comments

Comments

@wanqingrongruo
Copy link

wanqingrongruo commented Apr 13, 2022

we should not handle mask/effect by this way:

func renderToImage(bounds: Rect, inset: Double = 0, coloringMode: ColoringMode = .rgb) -> MImage? {
        let screenScale: CGFloat = MMainScreen()?.mScale ?? 1.0
        MGraphicsBeginImageContextWithOptions(CGSize(width: bounds.w + inset, height: bounds.h + inset), false, screenScale)
        let tempContext = MGraphicsGetCurrentContext()!

        // flip y-axis and leave space for the blur
        tempContext.translateBy(x: CGFloat(inset / 2 - bounds.x), y: CGFloat(bounds.h + inset / 2 + bounds.y))
        tempContext.scaleBy(x: 1, y: -1)
        directRender(in: tempContext, force: false, opacity: 1.0, coloringMode: coloringMode)

        let img = MGraphicsGetImageFromCurrentImageContext()
        MGraphicsEndImageContext()
        return img
    }

when we have many effects,mask, us operations would get stuck...
Image processing is very consumptive performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant