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

Frame rate too low #2

Open
Luncher opened this issue Nov 13, 2015 · 6 comments
Open

Frame rate too low #2

Luncher opened this issue Nov 13, 2015 · 6 comments

Comments

@Luncher
Copy link

Luncher commented Nov 13, 2015

Hi man, I have some questions to ask you, you use the animation on your phone will feel a low frame rate it? You have done and the official spine js runtime contrast it? About optimization you have any suggestions?

@flyover
Copy link
Owner

flyover commented Nov 13, 2015

If the phone doesn't support the WebGL context, it will render using the Canvas2D context. This can be much slower, especially if the animation includes meshes. Can you provide an example and a spec for the phone you are using?

@Luncher
Copy link
Author

Luncher commented Nov 16, 2015

case 'region':          
var bone = spine_pose.bones[slot.bone_key];             
ctxApplySpace(ctx, bone.world_space);           
ctxApplySpace(ctx, attachment.local_space);             
ctxApplyAtlasSitePosition(ctx, site);           
ctx.scale(attachment.width/2, attachment.height/2);             
ctxDrawImageMesh(ctx, render.region_vertex_triangle, render.region_vertex_position, render.region_vertex_texcoord, image, site, page);          
break;

When I did not use mesh function, the picture is packed with texturepacker before. Every big picture when rendering are drawn once (ctx.drawImage (image, 0, 0);). This position can not optimize?

@flyover
Copy link
Owner

flyover commented Nov 16, 2015

Yes, this could be simplified to a call to ctx.drawImage, provided an atlas is not being used or an atlas site without rotation is being used. I left it this way, since it supports the most cases. Thanks for the feedback.

@Luncher
Copy link
Author

Luncher commented Nov 17, 2015

I directly replace ctxDrawImageMesh into drawImage can it? Thank you, I went to try.

@flyover
Copy link
Owner

flyover commented Nov 17, 2015

In the region draw case, you would nee to replace this:

            ctxDrawImageMesh(ctx, render.region_vertex_triangle, render.region_vertex_position, render.region_vertex_texcoord, image, site, page);

with this:

            if (site)
            {
                if (site.rotate)
                {
                    ctxDrawImageMesh(ctx, render.region_vertex_triangle, render.region_vertex_position, render.region_vertex_texcoord, image, site, page);
                }
                else
                {
                    ctx.scale(1, -1);
                    ctx.drawImage(image, site.x, site.y, site.w, site.h, -1, -1, 2, 2);
                }
            }
            else
            {
                ctx.scale(1, -1);
                ctx.drawImage(image, -1, -1, 2, 2);
            }

@Luncher
Copy link
Author

Luncher commented Nov 17, 2015

We can not only convert a small map it? Rather than make a bigger change it? That is the ctxDrawImageMesh optimize it. I think this will greatly improve efficiency. thanks~~

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

2 participants