We are trying to create a text animation like Transition and Zoom on the Video.
We are not able to get Smooth transition and the effect is so jerky. Then we understood sub pixel rendering is not possible in android.
What alternatives can we think of? Can we solve this problem in OpenGL?
Ok... I would like to add more to my question....We are actually trying to implement text animations on top of a video which is played by a native player on a surface view.
We tried to achieve the text animations using the android Canvas APIs to scale, translate etc and draw the text. This works but the output is not so smooth. We have verified that its not a performance issue. Even if we refresh the frames at more than 30fps, the
jerkiness is seen.
Then, we tried to use android Views to get these animations and observed that the animations are buttery smooth when Hardware acceleration is turned on. But even the android View system animation fails to give good quality scale animations when hardware acceleration is turned OFF.
This again is not a performance issue since we have tried to dump each frame into a bitmap and checked each frame on PC.
So, it seems that SKIA graphics library used to draw on Canvas when hardware acceleration is turned off, is not capable of sub pixel rendering or something of that sort. For example, when i am running a slow scale animation (a scale of about 0.15 in about 6 seconds), the scale updates happen by 1 pixel in around 3 frames.
But if the same animation is run on a hardware accelerated view, each frames updates a fraction of a pixel and the scale animation looks
very smooth.
I can sure use the view animations while previewing. But I need to get these animation buffers and encode them along with the video. Any inputs on getting these buffers, with hardware acceleration turned ON would help. I have tried Drawing cache, but that seems to be drawn using software rendering pipeline and not hardware.
Smooth transistions and jerky animations have nothing to do with subpixel rendering.
The problem sounds like you're not correctly timing your rendering function. Do not use a interval timer to trigger rendering of a frame. You should put the rendering and animation into your programs event loop idle handler and measure the time it takes to render a frame. Then advance the animation by that time.
Related
i have a simple fading and rotating animation done through a object animator. Nothing fancy but to increase
performance with caching i wanted to use a hardware layer on the view itself. so before the animation begins
i call setLayerType(View.LAYER_TYPE_HARDWARE,null);
and after the animation is cancelled i call setLayerType(View.LAYER_TYPE_NONE,null);.
My question is what if the user does not have a GPU to render the animation for me ? will my app crash, this
animation is for my splash screen so its very important that it never crashes.
I found the answer from the docs:
LAYER_TYPE_HARDWARE: The view is rendered in hardware into a hardware
texture if the application is hardware accelerated. If the application
is not hardware accelerated, this layer type behaves the same as
LAYER_TYPE_SOFTWARE.
i'm making my first 2d sidescroller game using a surfaceview and a canvas to draw things on (a lot of primitives put in different path objects).
my game loop uses fixed timesteps with linear interpolation. i don't create any objects during the game. i've been improving my code for 3 weeks now, but my animation is still not all the time smooth. it's ok, but every few seconds there are a lot of little hicks for about 1 or 2 seconds.
what i recognized is when i move my player (this means touching the screen), the little hicks disappear for as long as i touch the screen and move my player.
this means as long as ontouchevent of the surfaceview is called, the animation is smooth.
i dont understand this and i want a smooth animation. can somebody help me?
This sounds like a known issue on certain devices. See e.g.:
Android SurfaceView slows if no touch events occur
Animation glitches while rendering on SurfaceView
Android thread performance/priority on Galaxy Note 2 when screen is touched/released
The problem is that the system is aggressively reducing clock speeds to save power when it doesn't detect interaction with the user. (Qualcomm in particular seems fond of this.) The workaround is to drop frames when necessary. See this article on game loops, and a Choreographer-based trick demonstrated in Grafika's "record GL app" activity (in doFrame()).
I'm trying to solve this problem but so far the only thing i've found is disabling the hardware acceleration. It actually works but it makes the scroll laggy is there a way to solve this problem but keeping the hardware acceleration on?
So the only solution was using software rendering and optimizing the code so it can scroll smoothly. In my case I was drawing the curve in the onDraw method and it was called everytime I scrolled redrawing the curve several times per second, this was fast using hardware acceleration but really slow on software. Now I draw the curve in a bitmap only once and set the bitmap as background of the view redrawing only the pointer onscroll making the scroll smooth even without software acceleration. I hope this can help anybody with the a similar problem!
I'm having some trouble using a sprite as background for my scene. I'm setting the background as follows:
Sprite bg = new Sprite(SCENE_WIDTH/2 , SCENE_HEIGHT/2, this.mParallaxBackRegion,getVertexBufferObjectManager());
bg.setCullingEnabled(true);
mScene.setBackground(new SpriteBackground(bg));
Loading of the texture:
this.mParallaxBack = new AssetBitmapTexture(this.getTextureManager(), this.getAssets(), "gfx/_fixed.png", TextureOptions.BILINEAR);
this.mParallaxBackRegion = TextureRegionFactory.extractFromTexture(this.mParallaxBack);
this.mParallaxBack.load();
The png I'm loading is a completely black 960x640 image (same as my scene size), for testing purposes. However, setting the background causes my fps to drop from 60 (when not using the background) to 45 on my HTC Desire. I've tried multiple ways of setting the background, but all seem to be causing the same performance hit. Why does this affect the performance so drastically, and is there something I can do about this?
That is strange that you should get such a big performance hit. But here's one thing to try. Since i seems you likely have other things drawn to the screen besides this background, add the background to the same Texture. OpenGL works faster when there are fewer textures. When openGL has to draw from another texture its switches context *(citation needed) which is a slow operation. So having all your sprites on a single texture makes GL draw calls more efficient.
This alone is not likely to explain the performance problem.
It could also be your antialiasing setting: TextureOptions.BILINEAR.
Bilinear is the highest quality setting. Try using DEFAULT or NEAREST_PREMULTIPLYALPHA and see if that doesn't help.
Also, set your background to ignore updates.
One last thought:
The HTC desire is a fairly old phone at this date (released in 2010) the performance will be in part due to it being an old phone with an old version of android. I test on an HTC incredible, about the same vintage, and you have to be very conservative with your image sizes on that device.
Did you know that you can make your andengine native size 1/2 of the screen size and scale it up using a RatioResolutionPolicy? I used that approach for my first andengine (GLES1) project and had great success on that generation of devices.https://play.google.com/store/apps/details?id=com.plonzogame&hl=en
I am working on some Android animation effects. On one screen there are several background images fading in/out constantly, and there is also a text marquee. The problem is that the text marquee is kind of choppy. When the image fade in/out is disabled, the marquee is smooth, so it is likely the 2 animations are affecting each other.
I am wondering if there is a way out other than writing my own animation by using Canvas or SurfaceView.
I took a look at AnimationSet, but that is only good for combining animations for the same view.
It has been a while but here are the things I have found along the way:
To achieve smooth text scrolling animation, it needs about 50 frames per second. So it really stretches the CPU out. I tried to use a surfaceView to do both the image and text animation, and managed to get to 35 frames per second but that was not enough, the text scrolling is still a little jumpy. I read a little opengl and it looks like OpenGL ES 2.0 should be able to handle the image fade in/out in parallel ways. But did not really go through with it. Hope this helps.