Google I/O 2011, Android Accelerated Rendering

Senior Staff Software Engineer at Google
May. 12, 2011
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
1 of 119

More Related Content

What's hot

Android JNIAndroid JNI
Android JNISiva Ramakrishna kv
Android Binder IPC for LinuxAndroid Binder IPC for Linux
Android Binder IPC for LinuxYu-Hsin Hung
Android internals 07 - Android graphics (rev_1.1)Android internals 07 - Android graphics (rev_1.1)
Android internals 07 - Android graphics (rev_1.1)Egor Elizarov
Binder: Android IPCBinder: Android IPC
Binder: Android IPCShaul Rosenzwieg
Android InternalsAndroid Internals
Android InternalsOpersys inc.
Introduction of android trebleIntroduction of android treble
Introduction of android trebleBin Yang

Viewers also liked

Meet HenryMeet Henry
Meet HenryEthos3
Odoo - Create themes for websiteOdoo - Create themes for website
Odoo - Create themes for websiteOdoo
Means of transportationMeans of transportation
Means of transportationfengchuishaster
faradays law and its applications pptfaradays law and its applications ppt
faradays law and its applications pptIndira Kundu
Classification of yarn   yarn classification. Textile yarn. Yarn count. Classification of yarn   yarn classification. Textile yarn. Yarn count.
Classification of yarn yarn classification. Textile yarn. Yarn count. Vaibhav Mathankar
Visual CryptographyVisual Cryptography
Visual CryptographyEcaterina Moraru (Valica)

Recently uploaded

UiPath Connector Corner:  How Microsoft Teams Powers Automation CollaborationUiPath Connector Corner:  How Microsoft Teams Powers Automation Collaboration
UiPath Connector Corner: How Microsoft Teams Powers Automation CollaborationDianaGray10
Charity Navigator Masterclass - Accountability and Finance BeaconCharity Navigator Masterclass - Accountability and Finance Beacon
Charity Navigator Masterclass - Accountability and Finance BeaconOnBoard
Improve Employee Experiences on Cisco RoomOS Devices, Webex, and Microsoft Te...Improve Employee Experiences on Cisco RoomOS Devices, Webex, and Microsoft Te...
Improve Employee Experiences on Cisco RoomOS Devices, Webex, and Microsoft Te...ThousandEyes
BuilderAI Proposal_MalesniakBuilderAI Proposal_Malesniak
BuilderAI Proposal_MalesniakMichael Lesniak
September 2023 State of Enterprise Tech Spending September 2023 State of Enterprise Tech Spending
September 2023 State of Enterprise Tech Spending Battery Ventures
New Approaches - University Chapter.pdfNew Approaches - University Chapter.pdf
New Approaches - University Chapter.pdfThomasHeinrichs1

Recently uploaded(20)

Google I/O 2011, Android Accelerated Rendering

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. Since Android 1.0: hardware OpenGL ES 1.x and 2.x support\nWindows composition\nGames\nRich media (live wallpapers)\n
  5. But the UI remains in software\n
  6. Aren’t we done?\nFaster CPUs, multi-cores, etc.\n
  7. New, richer experiences\nMore smoother animations\nMore and more pixels (tablets, hdpi screens)\n
  8. Software cannot keep up\nGraph from 2008 to 2011\nYellow bar increase at the same rate or faster rate\n
  9. Android 3.0 has many new features\nFavorite new UI toolkit feature: GPU support\nAll 2D ops run with OpenGL on the GPU\nAll standard apps run on the GPU\n
  10. Android 3.0 has many new features\nFavorite new UI toolkit feature: GPU support\nAll 2D ops run with OpenGL on the GPU\nAll standard apps run on the GPU\n
  11. Android 3.0 has many new features\nFavorite new UI toolkit feature: GPU support\nAll 2D ops run with OpenGL on the GPU\nAll standard apps run on the GPU\n
  12. Android 3.0 has many new features\nFavorite new UI toolkit feature: GPU support\nAll 2D ops run with OpenGL on the GPU\nAll standard apps run on the GPU\n
  13. Android 3.0 has many new features\nFavorite new UI toolkit feature: GPU support\nAll 2D ops run with OpenGL on the GPU\nAll standard apps run on the GPU\n
  14. How does it work?\nHere’s the software rendering pipeline (pre-3.0 or apps without h/w in 3.0+)\n
  15. The new hw accelerated pipeline translates Canvas calls to OpenGL\nOpenGL primitives are rasterized by the GPU\n
  16. We have points, lines, triangles and textures\nEach draw call is a combo of those\nHere is a ListView, you can notice the fades at top/bottom\n
  17. A simple button, 9patches are great in OpenGL\nResult is a simple mesh + texture\n
  18. A path is rendered using a combination of geometry (quad) and an alpha texture\nColor is applied in the fragment shader\nText is drawn in a similar way\n
  19. A path is rendered using a combination of geometry (quad) and an alpha texture\nColor is applied in the fragment shader\nText is drawn in a similar way\n
  20. A path is rendered using a combination of geometry (quad) and an alpha texture\nColor is applied in the fragment shader\nText is drawn in a similar way\n
  21. A path is rendered using a combination of geometry (quad) and an alpha texture\nColor is applied in the fragment shader\nText is drawn in a similar way\n
  22. A path is rendered using a combination of geometry (quad) and an alpha texture\nColor is applied in the fragment shader\nText is drawn in a similar way\n
  23. A path is rendered using a combination of geometry (quad) and an alpha texture\nColor is applied in the fragment shader\nText is drawn in a similar way\n
  24. A path is rendered using a combination of geometry (quad) and an alpha texture\nColor is applied in the fragment shader\nText is drawn in a similar way\n
  25. Here’s an example of the vertex shader used to draw text filled with a gradient\nShaders are generated at runtime by the pipeline\nSeveral millions of shaders can be thus generated\n
  26. Drawing text with a gradient requires 2 textures:\n- an alpha texture for text\n- the gradient texture\n
  27. To enable 2D h/w acceleration, put this in AndroidManifest.xml\nThat’s all you need to do\n
  28. To enable 2D h/w acceleration, put this in AndroidManifest.xml\nThat’s all you need to do\n
  29. Hardware acceleration can be enabled/disabled at several levels\nLet’s see how it can be done at each level\n
  30. Here, enabled for the app, disabled for an activity\n
  31. It can also be enabled for a specific window\n(for instance in Activity.onCreate())\n
  32. H/w acceleration can be disabled per View\nWe’ll talk more about layers later\n
  33. If you write custom views, checking the hw accel. status might be important\nCanvas.isHardwareAccelerated() is the preferred method\nView.isHA() && !Canvas.isHA() is possible (e.g. bitmap cache)\n
  34. Because of the nature of the 2D API and what GL can do, not everything will work\nSome features are missing, some are limited\nAll standard views/drawables will work\n
  35. Some ops will be supported in future releases (drawPoints for instance)\nIf these ops are needed, draw in a Bitmap, or use a software layer\n
  36. Some limitations will be lifted in future releases (AA lines for instance)\n
  37. ComposeShaders are very useful\nCurrent constraints\n
  38. An easy workaround is to use a software layer\nYou can also use a Bitmap, or Canvas.isHardwareAccelerated()\n
  39. The new rendering pipeline changes the way rendering works\nIt’s still an immediate mode\nBut with a special kind of caching\n
  40. In the old model, invalidate()ing a View meant redrawing each parent\nThis executes a lot of Java code\nBut the logic remains the same for the parents!\nExpensive!\n
  41. In the old model, invalidate()ing a View meant redrawing each parent\nThis executes a lot of Java code\nBut the logic remains the same for the parents!\nExpensive!\n
  42. In the old model, invalidate()ing a View meant redrawing each parent\nThis executes a lot of Java code\nBut the logic remains the same for the parents!\nExpensive!\n
  43. In the old model, invalidate()ing a View meant redrawing each parent\nThis executes a lot of Java code\nBut the logic remains the same for the parents!\nExpensive!\n
  44. In the old model, invalidate()ing a View meant redrawing each parent\nThis executes a lot of Java code\nBut the logic remains the same for the parents!\nExpensive!\n
  45. In the old model, invalidate()ing a View meant redrawing each parent\nThis executes a lot of Java code\nBut the logic remains the same for the parents!\nExpensive!\n
  46. In the old model, invalidate()ing a View meant redrawing each parent\nThis executes a lot of Java code\nBut the logic remains the same for the parents!\nExpensive!\n
  47. In the old model, invalidate()ing a View meant redrawing each parent\nThis executes a lot of Java code\nBut the logic remains the same for the parents!\nExpensive!\n
  48. In the old model, invalidate()ing a View meant redrawing each parent\nThis executes a lot of Java code\nBut the logic remains the same for the parents!\nExpensive!\n
  49. In the old model, invalidate()ing a View meant redrawing each parent\nThis executes a lot of Java code\nBut the logic remains the same for the parents!\nExpensive!\n
  50. In the old model, invalidate()ing a View meant redrawing each parent\nThis executes a lot of Java code\nBut the logic remains the same for the parents!\nExpensive!\n
  51. In the old model, invalidate()ing a View meant redrawing each parent\nThis executes a lot of Java code\nBut the logic remains the same for the parents!\nExpensive!\n
  52. In the old model, invalidate()ing a View meant redrawing each parent\nThis executes a lot of Java code\nBut the logic remains the same for the parents!\nExpensive!\n
  53. In the old model, invalidate()ing a View meant redrawing each parent\nThis executes a lot of Java code\nBut the logic remains the same for the parents!\nExpensive!\n
  54. In the old model, invalidate()ing a View meant redrawing each parent\nThis executes a lot of Java code\nBut the logic remains the same for the parents!\nExpensive!\n
  55. In the old model, invalidate()ing a View meant redrawing each parent\nThis executes a lot of Java code\nBut the logic remains the same for the parents!\nExpensive!\n
  56. In the old model, invalidate()ing a View meant redrawing each parent\nThis executes a lot of Java code\nBut the logic remains the same for the parents!\nExpensive!\n
  57. In the old model, invalidate()ing a View meant redrawing each parent\nThis executes a lot of Java code\nBut the logic remains the same for the parents!\nExpensive!\n
  58. In the old model, invalidate()ing a View meant redrawing each parent\nThis executes a lot of Java code\nBut the logic remains the same for the parents!\nExpensive!\n
  59. In the old model, invalidate()ing a View meant redrawing each parent\nThis executes a lot of Java code\nBut the logic remains the same for the parents!\nExpensive!\n
  60. DisplayList are simplified lists of drawing commands\nOne DisplayList per View, cached when a View changes\nTo redraw a View, we just re-issue its DisplayList\n
  61. Here is an example of a DisplayList: this draws a button\nSeveral 100s of lines of Java code are required to produce this\n
  62. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  63. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  64. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  65. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  66. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  67. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  68. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  69. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  70. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  71. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  72. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  73. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  74. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  75. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  76. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  77. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  78. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  79. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  80. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  81. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  82. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  83. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  84. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  85. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  86. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  87. A DisplayList can reference other DisplayLists\nNote that only one DisplayList is rebuilt, nothing else is touched!\nMuch less code is executed\nDrawing a display list = native code only\n\n
  88. Let’s examine what happens when enabling WiFi in Settings\nWe’re going to tap the Wi-Fi list item and look at what happens in both models\n\n
  89. Let’s examine what happens when enabling WiFi in Settings\nWe’re going to tap the Wi-Fi list item and look at what happens in both models\n\n
  90. Let’s examine what happens when enabling WiFi in Settings\nWe’re going to tap the Wi-Fi list item and look at what happens in both models\n\n
  91. Let’s examine what happens when enabling WiFi in Settings\nWe’re going to tap the Wi-Fi list item and look at what happens in both models\n\n
  92. Let’s examine what happens when enabling WiFi in Settings\nWe’re going to tap the Wi-Fi list item and look at what happens in both models\n\n
  93. When the selector turns blue, here are all the views that need to redraw\nEach View executes all of its Java drawing logic\nLot of code!\n
  94. With the new model, only one piece of Java code is executed\nDrawing display lists is done in native\nOnly a series of draw calls, no logic whatsoever\n
  95. If you change a View, call invalidate() on it\nDO NOT rely on calling invalidate() on a parent or sibling\nIt may have worked before, it won’t anymore\nIt was incorrect before, but worked anyway\n
  96. In the old model, invalidate()ing a View meant redrawing intersecting Views (children for instance)\nNotice how both leaves are drawn even though they are not dirty\n
  97. In the old model, invalidate()ing a View meant redrawing intersecting Views (children for instance)\nNotice how both leaves are drawn even though they are not dirty\n
  98. In the old model, invalidate()ing a View meant redrawing intersecting Views (children for instance)\nNotice how both leaves are drawn even though they are not dirty\n
  99. In the old model, invalidate()ing a View meant redrawing intersecting Views (children for instance)\nNotice how both leaves are drawn even though they are not dirty\n
  100. In the old model, invalidate()ing a View meant redrawing intersecting Views (children for instance)\nNotice how both leaves are drawn even though they are not dirty\n
  101. In the old model, invalidate()ing a View meant redrawing intersecting Views (children for instance)\nNotice how both leaves are drawn even though they are not dirty\n
  102. In the old model, invalidate()ing a View meant redrawing intersecting Views (children for instance)\nNotice how both leaves are drawn even though they are not dirty\n
  103. In the old model, invalidate()ing a View meant redrawing intersecting Views (children for instance)\nNotice how both leaves are drawn even though they are not dirty\n
  104. In the old model, invalidate()ing a View meant redrawing intersecting Views (children for instance)\nNotice how both leaves are drawn even though they are not dirty\n
  105. In the old model, invalidate()ing a View meant redrawing intersecting Views (children for instance)\nNotice how both leaves are drawn even though they are not dirty\n
  106. In the old model, invalidate()ing a View meant redrawing intersecting Views (children for instance)\nNotice how both leaves are drawn even though they are not dirty\n
  107. In the old model, invalidate()ing a View meant redrawing intersecting Views (children for instance)\nNotice how both leaves are drawn even though they are not dirty\n
  108. In the old model, invalidate()ing a View meant redrawing intersecting Views (children for instance)\nNotice how both leaves are drawn even though they are not dirty\n
  109. In the old model, invalidate()ing a View meant redrawing intersecting Views (children for instance)\nNotice how both leaves are drawn even though they are not dirty\n
  110. In the old model, invalidate()ing a View meant redrawing intersecting Views (children for instance)\nNotice how both leaves are drawn even though they are not dirty\n
  111. In the old model, invalidate()ing a View meant redrawing intersecting Views (children for instance)\nNotice how both leaves are drawn even though they are not dirty\n
  112. In the new model, invalidating a parent redraws that parent only\nNote how the children are not redrawn\n\n
  113. In the new model, invalidating a parent redraws that parent only\nNote how the children are not redrawn\n\n
  114. In the new model, invalidating a parent redraws that parent only\nNote how the children are not redrawn\n\n
  115. In the new model, invalidating a parent redraws that parent only\nNote how the children are not redrawn\n\n
  116. In the new model, invalidating a parent redraws that parent only\nNote how the children are not redrawn\n\n
  117. In the new model, invalidating a parent redraws that parent only\nNote how the children are not redrawn\n\n
  118. In the new model, invalidating a parent redraws that parent only\nNote how the children are not redrawn\n\n
  119. In the new model, invalidating a parent redraws that parent only\nNote how the children are not redrawn\n\n
  120. In the new model, invalidating a parent redraws that parent only\nNote how the children are not redrawn\n\n
  121. In the new model, invalidating a parent redraws that parent only\nNote how the children are not redrawn\n\n
  122. In the new model, invalidating a parent redraws that parent only\nNote how the children are not redrawn\n\n
  123. In the new model, invalidating a parent redraws that parent only\nNote how the children are not redrawn\n\n
  124. In the new model, invalidating a parent redraws that parent only\nNote how the children are not redrawn\n\n
  125. In the new model, invalidating a parent redraws that parent only\nNote how the children are not redrawn\n\n
  126. In the new model, invalidating a parent redraws that parent only\nNote how the children are not redrawn\n\n
  127. In the new model, invalidating a parent redraws that parent only\nNote how the children are not redrawn\n\n
  128. In the new model, invalidating a parent redraws that parent only\nNote how the children are not redrawn\n\n
  129. We briefly mentioned layers earlier, for compatibility\nBut layers can do much more, they are very useful and efficient\nThe option Paint can be used to control compositing\n
  130. Even with display lists, drawing is expensive\nA display list can have many operations\nAnimating a View requires to rerun these operations on every frame\nAnimating complex Views can be more efficient\n
  131. With a layer (or offscreen cache/bitmap), drawing happens once (or when the view invalidates)\nOnly the layer is drawn on screen, it’s just a texture\nIt’s *very* efficient, especially for the GPU\nAnd layers have other advantages too\n
  132. The type of layer LAYER_TYPE_NONE disables caching\nDefault value, View is not backed by an off-screen buffer\n
  133. The View is rendered into a Bitmap, just like setDrawingCacheEnabled(true)\nForces software rendering, good for compatibility\nExpensive to refresh a software layer (sw rendering + texture upload)\nUse only if necessary! (costs Dalvik heap memory!!!!)\n\n
  134. The View is rendered into an FBO, using OpenGL/HW acceleration\nReally fast, costs only GPU memory\nOptimized for blending\n
  135. Hardware layers render View into a hardware texture\nDrawing code runs only when View.invalidate() is called\nSome animations are applied directly onto the layer\n
  136. Perf comparison of \nDrawing a hardware layer is much faster, recommended when animating a complex View\nBut layers cost memory and refreshing a layer costs 2x the fillrate\n
  137. Use the optional Paint to apply visual treatments:\nopacity, color filter, blending modes etc.\nYou can tint a view, make it grayscale, etc.\n
  138. Launcher modified to display the icons in gray\nThe pages of icons are backed by hardware layers\nVery easy to do\n
  139. Here is the code used in the previous screenshot\nJust sets a ColorFilter on the paint used by the hardware layer\nEasy!\n
  140. Forces a View to render in software\nWorkaround for hw limitations or GL pipeline limitations\n
  141. Related to performance, but worth talking about in detail\nSome View properties affect layers directly, which make them very cheap\n
  142. When changing one of these properties, the View does not invalidate\nThe layer is not redrawn, instead the parent’s DisplayList is updated\nThis is a very efficient way to animate Views\nThese properties are also DisplayLists friendly\n
  143. When setting one of these properties, the parent is invalidated, and the parent’s DisplayList is dirtied\nRebuilding the parent’s display list is usually very cheap, since it refers to DisplayLists/Layers\n
  144. When setting one of these properties, the parent is invalidated, and the parent’s DisplayList is dirtied\nRebuilding the parent’s display list is usually very cheap, since it refers to DisplayLists/Layers\n
  145. When setting one of these properties, the parent is invalidated, and the parent’s DisplayList is dirtied\nRebuilding the parent’s display list is usually very cheap, since it refers to DisplayLists/Layers\n
  146. When setting one of these properties, the parent is invalidated, and the parent’s DisplayList is dirtied\nRebuilding the parent’s display list is usually very cheap, since it refers to DisplayLists/Layers\n
  147. When setting one of these properties, the parent is invalidated, and the parent’s DisplayList is dirtied\nRebuilding the parent’s display list is usually very cheap, since it refers to DisplayLists/Layers\n
  148. When setting one of these properties, the parent is invalidated, and the parent’s DisplayList is dirtied\nRebuilding the parent’s display list is usually very cheap, since it refers to DisplayLists/Layers\n
  149. Here is a simplified version of the parent’s display list\nDoes NOT execute() viewB.draw()\n
  150. Here is a simplified version of the parent’s display list\nDoes NOT execute() viewB.draw()\n
  151. Here is a simplified version of the parent’s display list\nDoes NOT execute() viewB.draw()\n
  152. If you want to animated a complex View (a ListView for instance), use layers\nThis is an example of a 3D rotation optimized with layers\nBut layers are costly to maintain (memory, refresh/fillrate)\n
  153. Keep layers only for the duration of the animation\nEasy to do with an AnimatorListener\nSaves time and space\n
  154. The new rendering pipeline changes the way rendering works\nIt’s still an immediate mode\nBut with a special kind of caching\n
  155. The more views you have, the longer is takes to draw\nViewGroups in particular are very costly\nKeep your hierarchy flat\n
  156. Changing the alpha of a View costs 2x the fillrate, if you are not using layers\nAvoid it on large views (half the size of the screen) or make sure you use hardware layers\n
  157. Do NOT create Paints, Bitmaps, Shaders, etc. in draw methods\nCreating new ones is costly and will defeat internal caches and optimizations\nIt also avoids unnecessary GCs\n
  158. Changing a Bitmap, even one pixel, is expensive\nIt will cause a texture upload, which is a copy to GPU memory\nAvoid doing it if you can\n
  159. Paths are rendered using texture\nChanging a path causes the generation of an offscreen bitmap, software rasterization and texture upload\n
  160. On current hardware, no more than 2.5x times the entire screen\nRemove obscured views (useless background bitmap for instance)\n
  161. Profile profile profile\nWe’ve spent weeks profiling our code to optimize it on tablets\nNasty surprises sometimes (new bitmaps created on every frame, etc.)\nAlways profile your code before blaming someone else!\n
  162. \n
  163. \n
  164. \n