SlideShare a Scribd company logo
1 of 119
Android
Rendering
Romain Guy                   @romainguy
Chet Haase                   @chethaase
May 11, 2011


Feedback goo.gl/wI57L
Hashtags #io2011, #Android
Android Accelerated
Rendering
Romain Guy                   @romainguy
Chet Haase                   @chethaase
May 11, 2011


Feedback goo.gl/wI57L
Hashtags #io2011, #Android
Hardware OpenGL
Why now?
memcpy (MiB/s)
                          Pixel count
1100




 825




 550




 275




   0
       G1   Droid   N1   NS         XOOM
UI on the GPU
on the
 GPU UI
Software rendering
Hardware rendering
Drawing a list
Drawing a list
Drawing a button
Drawing a button
Drawing a path
Drawing a path
Drawing a path
attribute vec4 position;
attribute vec2 texCoords;
uniform mat4 transform;
uniform mat4 screenSpace;
varying vec2 outTexCoords;
varying vec2 linear;

void main(void) {
    outTexCoords = texCoords;
    linear = vec2((screenSpace * position).x, 0.5);
    gl_Position = transform * position;
}



        Text+gradient vertex shader
precision mediump float;

varying   vec2 outTexCoords;
varying   vec2 linear;
uniform   sampler2D sampler;
uniform   sampler2D gradientSampler;

void main(void) {
    lowp vec4 color;
    vec4 gradient = texture2D(gradientSampler, linear);
    color = gradient * texture2D(sampler, outTexCoords).a;
    gl_FragColor = color;
}



            Text+gradient fragment shader
?
android:hardwareAccelerated="true"
Hardware acceleration control
1   <application android:hardwareAccelerated="true">
2       <activity ... />
3       <activity android:hardwareAccelerated="false" />
4   </application>
getWindow().setFlags(
    WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
    WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
View.isHardwareAccelerated();
Canvas.isHardwareAccelerated();




    GPU aware code
Caveats
Canvas   clipPath
         clipRegion
         drawPicture
         drawPoints
         drawPosText
         drawTextOnPath
         drawVertices

Paint    setLinearText
         setMaskFilter
         setRasterizer

Unsupported operations
3D transforms, XOR, Diff,
Canvas   clipRect             ReverseDiff ignored

         drawBitmapMesh       Colors array ignored

         drawLines            No anti-aliasing

         setDrawFilter        Ignored




Paint    setDither            Ignored

         setFilterBitmap      Filtering always on

         setShadowLayer       Works with text only




                Limitations
ComposeShader   Cannot contain another ComposeShader

                Cannot contain two shaders of the
                same type




                Limitations
view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);




                 Workaround
New drawing model
ViewRoot




       ViewGroup




View               View




  Old model
ViewRoot




       ViewGroup




View                  View


                  invalidate()




  Old model
ViewRoot




       ViewGroup




View                  View


                  invalidate()




  Old model
ViewRoot




       ViewGroup

                             invalidate()


View                  View


                  invalidate()




  Old model
ViewRoot




       ViewGroup

                             invalidate()


View                  View


                  invalidate()




  Old model
ViewRoot



                         invalidate()

       ViewGroup

                             invalidate()


View                  View


                  invalidate()




  Old model
ViewRoot



                         invalidate()

       ViewGroup

                             invalidate()


View                  View


                  invalidate()




  Old model
ViewRoot




       ViewGroup




View               View




  Old model
ViewRoot



                      draw()

       ViewGroup




View               View




  Old model
ViewRoot



                      draw()

       ViewGroup




View               View




  Old model
ViewRoot



                      draw()

       ViewGroup

                          draw()


View               View




  Old model
ViewRoot



                      draw()

       ViewGroup

                          draw()


View               View




  Old model
• No logic!
• List of drawing commands
• Cached when a View changes




         DisplayList
Save 3
DrawPatch
Save 3
ClipRect 20.00, 4.00, 99.00, 44.00, 1
Translate 20.00, 12.00
DrawText 9, 18, 9, 0.00, 19.00, 0x17e898
Restore
RestoreToCount 0




  DisplayList to draw a Button
ViewRoot




         ViewGroup                                    DisplayList




View A               View B           DisplayList B                 DisplayList A




                              New model
ViewRoot




         ViewGroup                                      DisplayList




View A                 View B           DisplayList B                 DisplayList A


                    invalidate()




                                New model
ViewRoot




         ViewGroup                                              DisplayList




View A                 View B                   DisplayList B                 DisplayList A

                                   mark dirty
                    invalidate()




                                New model
ViewRoot




         ViewGroup                                              DisplayList




View A                 View B                   DisplayList B                 DisplayList A

                                   mark dirty
                    invalidate()




                                New model
ViewRoot




         ViewGroup                                                DisplayList

                                invalidate()


View A                 View B                     DisplayList B                 DisplayList A

                                     mark dirty
                    invalidate()




                                New model
ViewRoot



                           invalidate()
         ViewGroup                                                DisplayList

                                invalidate()


View A                 View B                     DisplayList B                 DisplayList A

                                     mark dirty
                    invalidate()




                                New model
rebuild
         ViewRoot




         ViewGroup                                       DisplayList




View A               View B              DisplayList B                 DisplayList A




                              New model
rebuild
         ViewRoot




         ViewGroup                       rebuild             DisplayList




View A               View B                  DisplayList B                 DisplayList A




                              New model
ViewRoot




         ViewGroup                                    DisplayList




View A               View B           DisplayList B                 DisplayList A




                              New model
draw()
         ViewRoot




         ViewGroup                                      DisplayList




View A               View B             DisplayList B                 DisplayList A




                              New model
1   background.draw();
2   panel.draw();
3   selector.draw();
4   wifi.draw();
5   turnOnWifi.draw();
6   checkBox.draw();


       Old model
1   selector.draw();
2   drawDisplayLists();




       New model
Old model    New model


View.invalidate()

Intersects a dirty
      View



           When does View.draw() run?
ViewRoot




       ViewGroup




View               View




  Old model
ViewRoot




       ViewGroup   invalidate()



View               View




  Old model
ViewRoot




       ViewGroup   invalidate()



View               View




  Old model
ViewRoot



                      invalidate()

       ViewGroup   invalidate()



View               View




  Old model
ViewRoot



                      invalidate()

       ViewGroup   invalidate()



View               View




  Old model
ViewRoot




       ViewGroup




View               View




  Old model
ViewRoot



                      draw()

       ViewGroup




View               View




  Old model
ViewRoot



                      draw()

       ViewGroup




View               View




  Old model
ViewRoot



                               draw()

                ViewGroup
draw()


         View               View




           Old model
ViewRoot



                               draw()

                ViewGroup
draw()                             draw()


         View               View




           Old model
ViewRoot




         ViewGroup                                    DisplayList




View A               View B           DisplayList B                 DisplayList A




                              New model
ViewRoot




invalidate()     ViewGroup                                    DisplayList




        View A               View B           DisplayList B                 DisplayList A




                                      New model
ViewRoot




invalidate()     ViewGroup                                           DisplayList
                                        mark dirty



        View A               View B                  DisplayList B                 DisplayList A




                                      New model
ViewRoot




invalidate()     ViewGroup                                           DisplayList
                                        mark dirty



        View A               View B                  DisplayList B                 DisplayList A




                                      New model
ViewRoot



                                 invalidate()

invalidate()     ViewGroup                                      DisplayList




        View A               View B             DisplayList B                 DisplayList A




                                      New model
ViewRoot



                                 draw()

invalidate()     ViewGroup                                    DisplayList




        View A               View B           DisplayList B                 DisplayList A




                                      New model
ViewRoot




invalidate()     ViewGroup                                        DisplayList
                                        rebuild



        View A               View B               DisplayList B                 DisplayList A




                                      New model
ViewRoot




invalidate()     ViewGroup                                        DisplayList
                                        rebuild



        View A               View B               DisplayList B                 DisplayList A




                                      New model
View.setLayerType(int type, Paint p)
Button


                    draw()
DisplayList                  Display




                Save



              DrawPatch



              ClipRect



              Translate



              DrawText



               Restore
Button


              draw()              draw()
DisplayList               Layer            Display




                Save



              DrawPatch



              ClipRect



              Translate



              DrawText



               Restore
view.setLayerType(View.LAYER_TYPE_NONE, null)




             3 types of layers
view.setLayerType(View.LAYER_TYPE_SOFTWARE, null)




                Software layer
view.setLayerType(View.LAYER_TYPE_HARDWARE, null)




               Hardware layer
1. Performance
 Hardware layers
Drawing a ListView

                              Hardware layer                           DisplayList   Software


 Time in ms                             0.009                             2.1          10.3




Measured when drawing a ListView with Android 3.0 on a Motorola XOOM
2. Visual effects
Hardware and software layers
ColorMatrix m = new ColorMatrix();
m.setSaturation(0.0f);

Paint p = new Paint();
p.setColorFilter(new ColorMatrixColorFilter(m));

page.setLayerType(LAYER_TYPE_HARDWARE, p);
3. Compatibility
 Software layers
4. Animations
Hardware and software layers
Opacity    Position       Size    Orientation   Origin
 alpha         x         scaleX    rotation     pivotX
               y         scaleY    rotationX    pivotY
          translationX             rotationY
          translationY



           Layers-friendly properties
ViewRoot




         ViewGroup                          DisplayList




View A               View B       Layer B                 DisplayList A




               Layers-friendly properties
ViewRoot




         ViewGroup                          DisplayList




View A               View B       Layer B                 DisplayList A



              setRotationY(45)




               Layers-friendly properties
ViewRoot




         ViewGroup                                     DisplayList

                              invalidate()


View A               View B                  Layer B                 DisplayList A



              setRotationY(45)




               Layers-friendly properties
ViewRoot


                                   mark dirty

         ViewGroup                                        DisplayList

                              invalidate()


View A               View B                     Layer B                 DisplayList A



              setRotationY(45)




               Layers-friendly properties
ViewRoot


                                   mark dirty

         ViewGroup                                        DisplayList

                              invalidate()


View A               View B                     Layer B                 DisplayList A



              setRotationY(45)




               Layers-friendly properties
Save 3
DrawDisplayList A
DrawLayer B
Restore




           Parent DisplayList
viewB.setRotationY(45)



Save 3
DrawDisplayList A
DrawLayer B
Restore




           Parent DisplayList
viewB.setRotationY(45)



Save 3                          Save 3
DrawDisplayList A               DrawDisplayList A
DrawLayer B                     Rotate 0.0, 45.0, 0.0
Restore                         DrawLayer B
                                Restore




           Parent DisplayList
view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
ObjectAnimator.ofFloat(view, "rotationY", 180).start();




     Animating a complex View efficiently
view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
ObjectAnimator animator = ObjectAnimator.ofFloat(
    view, "rotationY", 180);

animator.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animation) {
        view.setLayerType(View.LAYER_TYPE_NONE, null);
    }
});

animator.start();
Tips & tricks
1. Don’t use too many views
    Keep your hierarchy flat
2. Be careful of setAlpha()
Without hardware layers, it costs 2x the fill-rate
3. Reuse rendering objects
Don’t create new Paints, Bitmaps, etc. in draw()
4. Don’t modify Bitmaps often
Every change causes a texture upload
5. Don’t modify Paths often
Every change causes a new rasterization
6. Avoid overdraw
GPUs are fill-rate limited
7. Profile
DDMS and traceview are your friends
Android blog d.android.com
Romain’s blog curious-creature.org
   Chet’s blog graphics-geek.blogspot.com
Feedback http://goo.gl/wI57L
Hashtags #io2011, #Android
Q&A   Feedback http://goo.gl/wI57L
      Hashtags #io2011, #Android
Google I/O 2011, Android Accelerated Rendering

More Related Content

What's hot

Firefox OS Graphics inside
Firefox OS Graphics insideFirefox OS Graphics inside
Firefox OS Graphics insideSotaro Ikeda
 
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)Nanik Tolaram
 
Intro to Flutter
Intro to FlutterIntro to Flutter
Intro to FlutterEason Pai
 
Android Security Internals
Android Security InternalsAndroid Security Internals
Android Security InternalsOpersys inc.
 
Android AIDL Concept
Android AIDL ConceptAndroid AIDL Concept
Android AIDL ConceptCharile Tsai
 
Overview of Android binder IPC implementation
Overview of Android binder IPC implementationOverview of Android binder IPC implementation
Overview of Android binder IPC implementationChethan Pchethan
 
Building beautiful apps using google flutter
Building beautiful apps using google flutterBuilding beautiful apps using google flutter
Building beautiful apps using google flutterAhmed Abu Eldahab
 
Developer Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersDeveloper Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersJiaxuan Lin
 
An Introduction to the Android Framework -- a core architecture view from app...
An Introduction to the Android Framework -- a core architecture view from app...An Introduction to the Android Framework -- a core architecture view from app...
An Introduction to the Android Framework -- a core architecture view from app...William Liang
 
Inside Android's UI
Inside Android's UIInside Android's UI
Inside Android's UIOpersys inc.
 
Android Automotive
Android AutomotiveAndroid Automotive
Android AutomotiveOpersys inc.
 
Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System ServerOpersys inc.
 
A flight with Flutter
A flight with FlutterA flight with Flutter
A flight with FlutterAhmed Tarek
 
BKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack UpdateBKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack UpdateLinaro
 

What's hot (20)

Firefox OS Graphics inside
Firefox OS Graphics insideFirefox OS Graphics inside
Firefox OS Graphics inside
 
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
 
Intro to Flutter
Intro to FlutterIntro to Flutter
Intro to Flutter
 
Android Security Internals
Android Security InternalsAndroid Security Internals
Android Security Internals
 
Duel of Two Libraries: Cairo & Skia
Duel of Two Libraries: Cairo & SkiaDuel of Two Libraries: Cairo & Skia
Duel of Two Libraries: Cairo & Skia
 
Android AIDL Concept
Android AIDL ConceptAndroid AIDL Concept
Android AIDL Concept
 
Overview of Android binder IPC implementation
Overview of Android binder IPC implementationOverview of Android binder IPC implementation
Overview of Android binder IPC implementation
 
Binder: Android IPC
Binder: Android IPCBinder: Android IPC
Binder: Android IPC
 
Flutter
FlutterFlutter
Flutter
 
Building beautiful apps using google flutter
Building beautiful apps using google flutterBuilding beautiful apps using google flutter
Building beautiful apps using google flutter
 
Android ppt
Android pptAndroid ppt
Android ppt
 
Developer Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersDeveloper Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for Beginners
 
An Introduction to the Android Framework -- a core architecture view from app...
An Introduction to the Android Framework -- a core architecture view from app...An Introduction to the Android Framework -- a core architecture view from app...
An Introduction to the Android Framework -- a core architecture view from app...
 
Inside Android's UI
Inside Android's UIInside Android's UI
Inside Android's UI
 
Android Automotive
Android AutomotiveAndroid Automotive
Android Automotive
 
Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System Server
 
Android presentation
Android presentationAndroid presentation
Android presentation
 
Flutter beyond hello world
Flutter beyond hello worldFlutter beyond hello world
Flutter beyond hello world
 
A flight with Flutter
A flight with FlutterA flight with Flutter
A flight with Flutter
 
BKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack UpdateBKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack Update
 

Viewers also liked

Meet Henry
Meet HenryMeet Henry
Meet HenryEthos3
 
Odoo - Create themes for website
Odoo - Create themes for websiteOdoo - Create themes for website
Odoo - Create themes for websiteOdoo
 
faradays law and its applications ppt
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.
Classification of yarn yarn classification. Textile yarn. Yarn count. Vaibhav Mathankar
 
Engaging Learners with Technology
Engaging Learners with TechnologyEngaging Learners with Technology
Engaging Learners with TechnologyDean Shareski
 
Web Trends to Watch in 2014
Web Trends to Watch in 2014Web Trends to Watch in 2014
Web Trends to Watch in 2014David King
 
Thai tech startup ecosystem report 2017
Thai tech startup ecosystem report 2017Thai tech startup ecosystem report 2017
Thai tech startup ecosystem report 2017Techsauce Media
 
Environmental Impact Assessment (EIA) report on Rampal 1320MW coal-based powe...
Environmental Impact Assessment (EIA) report on Rampal 1320MW coal-based powe...Environmental Impact Assessment (EIA) report on Rampal 1320MW coal-based powe...
Environmental Impact Assessment (EIA) report on Rampal 1320MW coal-based powe...Probir Bidhan
 
4. heredity and evolution
4. heredity and evolution4. heredity and evolution
4. heredity and evolutionAbhay Goyal
 
Ion exchange chromatography
Ion exchange chromatographyIon exchange chromatography
Ion exchange chromatographyshishirkawde
 
Fintech and Transformation of the Financial Services Industry
Fintech and Transformation of the Financial Services IndustryFintech and Transformation of the Financial Services Industry
Fintech and Transformation of the Financial Services IndustryRobin Teigland
 
What I Carry: 10 Tools for Success
What I Carry: 10 Tools for SuccessWhat I Carry: 10 Tools for Success
What I Carry: 10 Tools for SuccessJonathon Colman
 
The Ultimate Guide to Creating Visually Appealing Content
The Ultimate Guide to Creating Visually Appealing ContentThe Ultimate Guide to Creating Visually Appealing Content
The Ultimate Guide to Creating Visually Appealing ContentNeil Patel
 
Stanford E245 Lean LaunchPad winter 10 session 01 course overview rev 4
Stanford E245 Lean LaunchPad winter 10 session 01 course overview rev 4Stanford E245 Lean LaunchPad winter 10 session 01 course overview rev 4
Stanford E245 Lean LaunchPad winter 10 session 01 course overview rev 4Stanford University
 
Dear NSA, let me take care of your slides.
Dear NSA, let me take care of your slides.Dear NSA, let me take care of your slides.
Dear NSA, let me take care of your slides.Emiland
 
Fmcg training modules-bfg
Fmcg training modules-bfgFmcg training modules-bfg
Fmcg training modules-bfgRomy Cagampan
 

Viewers also liked (20)

Meet Henry
Meet HenryMeet Henry
Meet Henry
 
Odoo - Create themes for website
Odoo - Create themes for websiteOdoo - Create themes for website
Odoo - Create themes for website
 
Means of transportation
Means of transportationMeans of transportation
Means of transportation
 
faradays law and its applications ppt
faradays law and its applications pptfaradays law and its applications ppt
faradays law and its applications ppt
 
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.
Classification of yarn yarn classification. Textile yarn. Yarn count.
 
Visual Cryptography
Visual CryptographyVisual Cryptography
Visual Cryptography
 
Engaging Learners with Technology
Engaging Learners with TechnologyEngaging Learners with Technology
Engaging Learners with Technology
 
Web Trends to Watch in 2014
Web Trends to Watch in 2014Web Trends to Watch in 2014
Web Trends to Watch in 2014
 
Thai tech startup ecosystem report 2017
Thai tech startup ecosystem report 2017Thai tech startup ecosystem report 2017
Thai tech startup ecosystem report 2017
 
5000 Sat Words With Definitions
5000 Sat Words With Definitions5000 Sat Words With Definitions
5000 Sat Words With Definitions
 
Environmental Impact Assessment (EIA) report on Rampal 1320MW coal-based powe...
Environmental Impact Assessment (EIA) report on Rampal 1320MW coal-based powe...Environmental Impact Assessment (EIA) report on Rampal 1320MW coal-based powe...
Environmental Impact Assessment (EIA) report on Rampal 1320MW coal-based powe...
 
4. heredity and evolution
4. heredity and evolution4. heredity and evolution
4. heredity and evolution
 
Ion exchange chromatography
Ion exchange chromatographyIon exchange chromatography
Ion exchange chromatography
 
Fintech and Transformation of the Financial Services Industry
Fintech and Transformation of the Financial Services IndustryFintech and Transformation of the Financial Services Industry
Fintech and Transformation of the Financial Services Industry
 
What I Carry: 10 Tools for Success
What I Carry: 10 Tools for SuccessWhat I Carry: 10 Tools for Success
What I Carry: 10 Tools for Success
 
Mri brain anatomy Dr Muhammad Bin Zulfiqar
Mri brain anatomy Dr Muhammad Bin ZulfiqarMri brain anatomy Dr Muhammad Bin Zulfiqar
Mri brain anatomy Dr Muhammad Bin Zulfiqar
 
The Ultimate Guide to Creating Visually Appealing Content
The Ultimate Guide to Creating Visually Appealing ContentThe Ultimate Guide to Creating Visually Appealing Content
The Ultimate Guide to Creating Visually Appealing Content
 
Stanford E245 Lean LaunchPad winter 10 session 01 course overview rev 4
Stanford E245 Lean LaunchPad winter 10 session 01 course overview rev 4Stanford E245 Lean LaunchPad winter 10 session 01 course overview rev 4
Stanford E245 Lean LaunchPad winter 10 session 01 course overview rev 4
 
Dear NSA, let me take care of your slides.
Dear NSA, let me take care of your slides.Dear NSA, let me take care of your slides.
Dear NSA, let me take care of your slides.
 
Fmcg training modules-bfg
Fmcg training modules-bfgFmcg training modules-bfg
Fmcg training modules-bfg
 

Recently uploaded

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 

Recently uploaded (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 

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&amp;#x2019;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&amp;#x2019;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&amp;#x2019;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&amp;#x2019;s all you need to do\n
  28. To enable 2D h/w acceleration, put this in AndroidManifest.xml\nThat&amp;#x2019;s all you need to do\n
  29. Hardware acceleration can be enabled/disabled at several levels\nLet&amp;#x2019;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&amp;#x2019;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() &amp;&amp; !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&amp;#x2019;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&amp;#x2019;s examine what happens when enabling WiFi in Settings\nWe&amp;#x2019;re going to tap the Wi-Fi list item and look at what happens in both models\n\n
  89. Let&amp;#x2019;s examine what happens when enabling WiFi in Settings\nWe&amp;#x2019;re going to tap the Wi-Fi list item and look at what happens in both models\n\n
  90. Let&amp;#x2019;s examine what happens when enabling WiFi in Settings\nWe&amp;#x2019;re going to tap the Wi-Fi list item and look at what happens in both models\n\n
  91. Let&amp;#x2019;s examine what happens when enabling WiFi in Settings\nWe&amp;#x2019;re going to tap the Wi-Fi list item and look at what happens in both models\n\n
  92. Let&amp;#x2019;s examine what happens when enabling WiFi in Settings\nWe&amp;#x2019;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&amp;#x2019;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&amp;#x2019;s just a texture\nIt&amp;#x2019;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&amp;#x2019;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&amp;#x2019;s DisplayList is dirtied\nRebuilding the parent&amp;#x2019;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&amp;#x2019;s DisplayList is dirtied\nRebuilding the parent&amp;#x2019;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&amp;#x2019;s DisplayList is dirtied\nRebuilding the parent&amp;#x2019;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&amp;#x2019;s DisplayList is dirtied\nRebuilding the parent&amp;#x2019;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&amp;#x2019;s DisplayList is dirtied\nRebuilding the parent&amp;#x2019;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&amp;#x2019;s DisplayList is dirtied\nRebuilding the parent&amp;#x2019;s display list is usually very cheap, since it refers to DisplayLists/Layers\n
  149. Here is a simplified version of the parent&amp;#x2019;s display list\nDoes NOT execute() viewB.draw()\n
  150. Here is a simplified version of the parent&amp;#x2019;s display list\nDoes NOT execute() viewB.draw()\n
  151. Here is a simplified version of the parent&amp;#x2019;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&amp;#x2019;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&amp;#x2019;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