The Android documentation, meanwhile, indicates that only one thread may every draw to a surface at any time, so it’s unlikely that there is any interfering code.
The keyword synchronized is used around the SurfaceHolder to make sure that no other code accesses this variable while drawing is going on. However, on an emulator with a large screen drawing was very fast, but this may be because my PC has a fast graphics card. On small screen devices I got high speeds (60 fps), while on larger screens the frame rate dropped dismayingly fast. On real devices, the speed of the drawing code seems to be directly relative to the screen resolution.Also, unlocking and posting the canvas was fast on an emulator for small screens (1 ms), very slow on an emulator for large screens (40 ms), and fast on all real devices that I have tested (Samsung Galaxy Tab, Lenovo P1c72, Samsung DUOS, Alcatel).On the other hand, on a Lenovo P1c72 (1920×1080) is was 1ms – it seems not to be related to the screen resolution. I’ve noticed that locking the canvas was very fast on different emulators (about 1 ms, from small screens to large screens), but on a real Samsung Galaxy Tab (1280×800) it’s about 9 ms.The results were surprising and may help you to understand why your game is slow under certain conditions: In the process of increasing the frame rate of my game, I implemented various timers to carefully check the speed of locking the canvas, updating the scene, drawing the scene, and unlocking/posting the canvas.
You can allow the drawing code to skip a frame once in a while, but you cannot allow the scene update code to do so.
Assuming that the update code is very fast (a few milliseconds per frame) compared to the drawing code, this may indeed be useful. After all, to give the game a consistent speed it’s necessary to update the scene at a stable frame rate (say, exactly 60 times per second) because moving objects that speed up or slow down hurt the player’s game experience. Some people separate the scene update code from the scene drawing code (in another thread).
This method repeatedly does the following: The dedicated thread for your game loop executes the run() method. There are lots of examples on the web of standard game loops, and they tend to look like this: public void run () Most likely, your game will have a game loop that runs as a separate thread. In this article on speeding up Canvas.drawBitmap, I’d like to point out some pitfalls you can avoid, based on my own experience developing an app with heavy canvas drawing. You’ll also find that your game runs fast on some devices, and slowly on others (in particular, phones versus tablets). You also may have noticed that as your number of bitmaps per frame increases, your framerate drops significantly, to the point of your game becoming unplayable.
Incudes our robust mac/pc compatible desktop software which features advanced drawing, playbook organization and custom printing tools.If you’re developing a game for Android that uses canvas drawing, you’re probably calling Canvas.drawBitmap to draw many bitmaps to the screen.
Backup your plays to the FastModel Sports cloud so your playbook is protected against hardware loss, upgrade and app re-installs. Our "Best Plays of the Week" subscription offers 5 new plays to add to your library each week. Take advantage of our free weekly subscription to supplement your own plays. Customize your court type and line markings for your team. Automatically move players when you start your next play frame. Adjust any line you draw, no more starting over.
Draw plays quickly with your finger, and watch as your lines automatically straighten out to produce professional-looking diagrams. Get proven ideas from the best minds in basketball including Larry Brown, George Karl and Tara VanDerveer.
Save and edit any play to help build your playbook. Access thousands of basketball plays within FastDraw. Build your playbook with exclusive access to over 4, 000 plays and drills from other professional and amateur FastDraw coaches. Easily draw, save, organize and share basketball plays. All 30 NBA teams and over 600 NCAA DI basketball programs use FastDraw to build their team's playbooks - now you can too.