SlideShare una empresa de Scribd logo
1 de 64
Descargar para leer sin conexión
Wednesday, November 2, 11
Wednesday, November 2, 11
Hardware Acceleration
                on Mobile
                              Ariya Hidayat & Jarred Nicholls
                                         Sencha




                            Twitter: @ariyahidayat   @jarrednicholls

Wednesday, November 2, 11
Challenges




Wednesday, November 2, 11
Game vs Web




Wednesday, November 2, 11
Game
                                                         Text




                                                                Textured
                                                                 objects
                       Animation




                              Transformation   Physics




Wednesday, November 2, 11
Web Pages


                                   Images

                            Text




Wednesday, November 2, 11
How Browser Works

                             Network stack




                                         Layout engine



                            JavaScript engine            Graphics




                                                User interface




Wednesday, November 2, 11
WebKit Components

                            DOM               CSS


                                  WebCore              SVG


                    HTML
                                        rendering

                                                             JavaScriptCore



                                      WebKit Library




Wednesday, November 2, 11
Platform Abstraction

                            Network     Unicode      Clipboard


                            Graphics     Theme        Events


                            Thread     Geolocation    Timer




Wednesday, November 2, 11
Graphics Abstraction

       GraphicsContext          Mac        Chromium       Qt     Gtk


                                             Skia
                            CoreGraphics
                                                      QPainter


                                                graphics stack




Wednesday, November 2, 11
Components of Mobile

                                              Radio




                            Touch interface


                                                      CPU

                                  Power


                                               GPU



Wednesday, November 2, 11
Graphics Processor

                            Divide and conquer




                            Very specific purpose




Wednesday, November 2, 11
Optimized for Games


                            Fixed geometry

                            Transformation

                            Textured triangles



                                    Parallelism

Wednesday, November 2, 11
Challenges



         Predictable contents (assets)   ✔
         Mostly text                           ✔
         Mostly images                   ✔
          Expected run-time response         immediate



Wednesday, November 2, 11
Primitive Drawing




Wednesday, November 2, 11
Path is Everything



                               Triangle   Rectangle




                        Path
                               Ellipse         Polygon


Wednesday, November 2, 11
Stroke = Outline




                  Solid     Dashed   Dotted   Textured


Wednesday, November 2, 11
Brush = Fill




            None            Solid   Gradient   Textured




Wednesday, November 2, 11
Smooth via Antialiasing
                            Multiple levels of transparency




                                         Perfect for parallelism


Wednesday, November 2, 11
Path Approximation
                  Curves




                            Polygon




Wednesday, November 2, 11
Gradient: Expensive
                            CPU: sequential, tedious




                            GPU: parallel, still a lot of work

Wednesday, November 2, 11
Blur Shadow: Really Posh
                            Involved pixel “blending”




                            GPU: parallel, still tedious

Wednesday, November 2, 11
Transformation




                 Scaling
                                       Perspective
                            Rotation




Wednesday, November 2, 11
Text Rasterization




Wednesday, November 2, 11
Font Atlas
                            Buffer




                                     Bye




Wednesday, November 2, 11
Simple to Complex

                                                  ello!
                                                H


           Simple shape                         Curves
            Solid color                     Gradient brush
                                            Textured stroke
                                             Blur shadow
                            Make it as an      Serif text
                              image            Rotated
Wednesday, November 2, 11
HOW FAST?




Wednesday, November 2, 11
Android Drawing

                                                   Log file
                   WebCore
                   graphics


                              GraphicsContext



                                            Skia




Wednesday, November 2, 11
Example: Bing
    platformInit
    savePlatformState
    translate 0,0
    translate 0,0
    clip 1,0 0x6.95322e-310
    fillRect 0,0 800x556 color   ff ff ff ff
    restorePlatformState
    platformDestroy
    platformInit
    savePlatformState
    translate 0,0
    translate 0,0
    clip 1,0 0x6.95322e-310
    fillRect 0,0 800x556 color   ff ff ff ff
    restorePlatformState
    platformDestroy
    platformInit
    savePlatformState
    translate 0,0
    translate 0,0
    clip 1,0 0x6.95322e-310
    fillRect 0,0 800x556 color   ff ff ff ff
    fillRect 0,0 800x556 color   ff ff ff ff

Wednesday, November 2, 11
How Fast?

              #include "TimeCounter.h"


              bool WebViewCore::drawContent(SkCanvas* canvas, SkColor)
              {
                  uint32_t timestamp = getThreadMsec();

                       .... painting code ....

                       DBG_SET_LOGD("% ms", getThreadMsec() - timestamp);
              }




                            external/webkit/WebKit/android/jni/WebViewCore.cpp

Wednesday, November 2, 11
Example: Google News

         adb logcat -v time | grep drawContent
        16:24:04.070 D/webcoreglue(  273): drawContent   11   ms
        16:24:04.110 D/webcoreglue(  273): drawContent   13   ms
        16:24:04.150 D/webcoreglue(  273): drawContent   13   ms
        16:24:04.190 D/webcoreglue(  273): drawContent   10   ms
        16:24:04.240 D/webcoreglue(  273): drawContent   10   ms
        16:24:04.280 D/webcoreglue(  273): drawContent   13   ms
        16:24:04.320 D/webcoreglue(  273): drawContent   13   ms
        16:24:04.360 D/webcoreglue(  273): drawContent   13   ms
        16:24:06.080 D/webcoreglue(  273): drawContent   12   ms
        16:24:06.140 D/webcoreglue(  273): drawContent   10   ms
        16:24:06.180 D/webcoreglue(  273): drawContent   13   ms
        16:24:06.230 D/webcoreglue(  273): drawContent   14   ms
        16:24:06.600 D/webcoreglue(  273): drawContent   26   ms
        16:24:06.640 D/webcoreglue(  273): drawContent   13   ms
        16:24:06.860 D/webcoreglue(  273): drawContent   33   ms
        16:24:06.890 D/webcoreglue(  273): drawContent   12   ms
        16:24:06.930 D/webcoreglue(  273): drawContent   13   ms
        16:24:06.960 D/webcoreglue(  273): drawContent   13   ms
        16:24:07.000 D/webcoreglue(  273): drawContent   13   ms


Wednesday, November 2, 11
Backing Store




Wednesday, November 2, 11
Maps

                            Tile




Wednesday, November 2, 11
Pinch to Zoom




         when you pinch...




Wednesday, November 2, 11
Responsive UI

                                           decoupled
                     Rendering

                             Processor

                                    User interaction


Wednesday, November 2, 11
Rendering vs Interaction

                                                      Screen
                              Backing Store
                  Rendering




    Web Page                                  User interaction




Wednesday, November 2, 11
Checkerboard Pattern




Wednesday, November 2, 11
Progressive Rendering
                    Fast but blurry




                                      Crisp but slow


Wednesday, November 2, 11
Tiling System



                                   Texture upload


                            ....               ....



                   CPU                                GPU


Wednesday, November 2, 11
Tile Transformation




           Panning = Translation   Zooming = Scaling

Wednesday, November 2, 11
Backing Store Support


       Vector-based




       Texture-based
                            Honeycomb and later

Wednesday, November 2, 11
Y U NO
                            position:fixed




Wednesday, November 2, 11
Demo




Wednesday, November 2, 11
Layer & Compositing




Wednesday, November 2, 11
Elements = Layers




Wednesday, November 2, 11
Typical Animation




                            opacity, movement, scaling, rotation, ...

Wednesday, November 2, 11
Immediate Mode


                            setInterval(function() {
                                box.draw(x, y);
                                x += 10;
                            }, 20);


                                              every animation tick




Wednesday, November 2, 11
Scene Graph


             box.drawInto(layer);
             setInterval(function() {
                 layer.translate(10, 0);   Change transformation
                                                  matrix
             }, 20);




Wednesday, November 2, 11
Logical 3-D




Wednesday, November 2, 11
Keep the Textures




Wednesday, November 2, 11
Demo




Wednesday, November 2, 11
Compositing Support




                            Honeycomb and later




Wednesday, November 2, 11
Well-known Trick

                                                      forcing 3-D transform



                            -webkit-transform: translateZ(0)




                                Not needed for CSS animation!



Wednesday, November 2, 11
Debugging in Safari

             defaults write com.apple.Safari IncludeInternalDebugMenu




Wednesday, November 2, 11
Compositing Indicators

                            Texture (number = upload)


                                         Composited layer




                            No texture

                                          Container layer


                                             Overflow




Wednesday, November 2, 11
Debugging in Chrome

                  about:flags




Wednesday, November 2, 11
Avoid Texture Reupload

                            No reupload                          Upload




                             Opacity                     Everything else!
                             Position
                              Size
                            Animation


                                    “Hardware accelerated CSS”

Wednesday, November 2, 11
Avoid Overcapacity




                              GPU = Limited silicon space
                            Large layer ➔ broken into “tiles”
Wednesday, November 2, 11
Prepare & Reuse




                                       Hide the layer offscreen




                            Viewport
Wednesday, November 2, 11
Wrap Up




Wednesday, November 2, 11
Hardware Acceleration




                Drawing     Backing     Layer &
               primitives    stores   compositing


Wednesday, November 2, 11
THANK YOU!




Wednesday, November 2, 11
QUESTIONS?


            ariya @ sencha.com             jarred @ sencha.com



                 ariya.ofilabs.com


                            ariyahidayat   jarrednicholls



Wednesday, November 2, 11

Más contenido relacionado

Similar a Hardware Acceleration on Mobile, Ariya Hidayat & Jarred Nicholls

Java Tech & Tools | Big Blobs: Moving Big Data In and Out of the Cloud | Adri...
Java Tech & Tools | Big Blobs: Moving Big Data In and Out of the Cloud | Adri...Java Tech & Tools | Big Blobs: Moving Big Data In and Out of the Cloud | Adri...
Java Tech & Tools | Big Blobs: Moving Big Data In and Out of the Cloud | Adri...
JAX London
 
Devon 2011-f-4-improve your-javascript
Devon 2011-f-4-improve your-javascriptDevon 2011-f-4-improve your-javascript
Devon 2011-f-4-improve your-javascript
Daum DNA
 

Similar a Hardware Acceleration on Mobile, Ariya Hidayat & Jarred Nicholls (20)

Fast & Furious: Speed in the Opera browser
Fast & Furious: Speed in the Opera browserFast & Furious: Speed in the Opera browser
Fast & Furious: Speed in the Opera browser
 
Mapnik2 Performance, September 2011
Mapnik2 Performance, September 2011Mapnik2 Performance, September 2011
Mapnik2 Performance, September 2011
 
Building Sencha Themes
Building Sencha ThemesBuilding Sencha Themes
Building Sencha Themes
 
Java Tech & Tools | Big Blobs: Moving Big Data In and Out of the Cloud | Adri...
Java Tech & Tools | Big Blobs: Moving Big Data In and Out of the Cloud | Adri...Java Tech & Tools | Big Blobs: Moving Big Data In and Out of the Cloud | Adri...
Java Tech & Tools | Big Blobs: Moving Big Data In and Out of the Cloud | Adri...
 
Accessing Native APIs from Touch
Accessing Native APIs from TouchAccessing Native APIs from Touch
Accessing Native APIs from Touch
 
Community Code: Xero
Community Code: XeroCommunity Code: Xero
Community Code: Xero
 
Cloud9 IDE Talk at meet.js Poznań
Cloud9 IDE Talk at meet.js PoznańCloud9 IDE Talk at meet.js Poznań
Cloud9 IDE Talk at meet.js Poznań
 
Sencha Animator
Sencha AnimatorSencha Animator
Sencha Animator
 
Mume2012
Mume2012Mume2012
Mume2012
 
soft-shake.ch - Data grids and Data Grids
soft-shake.ch - Data grids and Data Gridssoft-shake.ch - Data grids and Data Grids
soft-shake.ch - Data grids and Data Grids
 
Municipal Government Meets NoSQL
Municipal Government Meets NoSQLMunicipal Government Meets NoSQL
Municipal Government Meets NoSQL
 
Btree Nosql Oak
Btree Nosql OakBtree Nosql Oak
Btree Nosql Oak
 
WebGL Fundamentals
WebGL FundamentalsWebGL Fundamentals
WebGL Fundamentals
 
HTML5 and Sencha Touch
HTML5 and Sencha TouchHTML5 and Sencha Touch
HTML5 and Sencha Touch
 
Ext GWT 3.0 Theming and Appearances
Ext GWT 3.0 Theming and AppearancesExt GWT 3.0 Theming and Appearances
Ext GWT 3.0 Theming and Appearances
 
What's new in HTML5, CSS3 and JavaScript, James Pearce
What's new in HTML5, CSS3 and JavaScript, James PearceWhat's new in HTML5, CSS3 and JavaScript, James Pearce
What's new in HTML5, CSS3 and JavaScript, James Pearce
 
ネットゲームつくろうぜ on Unity
ネットゲームつくろうぜ on Unityネットゲームつくろうぜ on Unity
ネットゲームつくろうぜ on Unity
 
PHP Server-side Breakout
PHP Server-side BreakoutPHP Server-side Breakout
PHP Server-side Breakout
 
Community Code: The TouchForums App
Community Code: The TouchForums AppCommunity Code: The TouchForums App
Community Code: The TouchForums App
 
Devon 2011-f-4-improve your-javascript
Devon 2011-f-4-improve your-javascriptDevon 2011-f-4-improve your-javascript
Devon 2011-f-4-improve your-javascript
 

Más de Sencha

Más de Sencha (20)

Breathe New Life into Your Existing JavaScript Applications with Web Components
Breathe New Life into Your Existing JavaScript Applications with Web ComponentsBreathe New Life into Your Existing JavaScript Applications with Web Components
Breathe New Life into Your Existing JavaScript Applications with Web Components
 
Ext JS 6.6 Highlights
Ext JS 6.6 HighlightsExt JS 6.6 Highlights
Ext JS 6.6 Highlights
 
Sencha Roadshow 2017: BufferedStore Internals featuring eyeworkers interactiv...
Sencha Roadshow 2017: BufferedStore Internals featuring eyeworkers interactiv...Sencha Roadshow 2017: BufferedStore Internals featuring eyeworkers interactiv...
Sencha Roadshow 2017: BufferedStore Internals featuring eyeworkers interactiv...
 
Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd
Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd
Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd
 
Sencha Roadshow 2017: Best Practices for Implementing Continuous Web App Testing
Sencha Roadshow 2017: Best Practices for Implementing Continuous Web App TestingSencha Roadshow 2017: Best Practices for Implementing Continuous Web App Testing
Sencha Roadshow 2017: Best Practices for Implementing Continuous Web App Testing
 
Sencha Roadshow 2017: What's New in Sencha Test
Sencha Roadshow 2017: What's New in Sencha TestSencha Roadshow 2017: What's New in Sencha Test
Sencha Roadshow 2017: What's New in Sencha Test
 
Sencha Roadshow 2017: Sencha Upgrades - The Good. The Bad. The Ugly - Eva Luc...
Sencha Roadshow 2017: Sencha Upgrades - The Good. The Bad. The Ugly - Eva Luc...Sencha Roadshow 2017: Sencha Upgrades - The Good. The Bad. The Ugly - Eva Luc...
Sencha Roadshow 2017: Sencha Upgrades - The Good. The Bad. The Ugly - Eva Luc...
 
Sencha Roadshow 2017: Modernizing the Ext JS Class System and Tooling
Sencha Roadshow 2017: Modernizing the Ext JS Class System and ToolingSencha Roadshow 2017: Modernizing the Ext JS Class System and Tooling
Sencha Roadshow 2017: Modernizing the Ext JS Class System and Tooling
 
Sencha Roadshow 2017: Sencha Best Practices: Coworkee App
Sencha Roadshow 2017: Sencha Best Practices: Coworkee App Sencha Roadshow 2017: Sencha Best Practices: Coworkee App
Sencha Roadshow 2017: Sencha Best Practices: Coworkee App
 
Sencha Roadshow 2017: Mobile First or Desktop First
Sencha Roadshow 2017: Mobile First or Desktop FirstSencha Roadshow 2017: Mobile First or Desktop First
Sencha Roadshow 2017: Mobile First or Desktop First
 
Sencha Roadshow 2017: Innovations in Ext JS 6.5 and Beyond
Sencha Roadshow 2017: Innovations in Ext JS 6.5 and BeyondSencha Roadshow 2017: Innovations in Ext JS 6.5 and Beyond
Sencha Roadshow 2017: Innovations in Ext JS 6.5 and Beyond
 
Leveraging React and GraphQL to Create a Performant, Scalable Data Grid
Leveraging React and GraphQL to Create a Performant, Scalable Data GridLeveraging React and GraphQL to Create a Performant, Scalable Data Grid
Leveraging React and GraphQL to Create a Performant, Scalable Data Grid
 
Learn Key Insights from The State of Web Application Testing Research Report
Learn Key Insights from The State of Web Application Testing Research ReportLearn Key Insights from The State of Web Application Testing Research Report
Learn Key Insights from The State of Web Application Testing Research Report
 
Introducing ExtReact: Adding Powerful Sencha Components to React Apps
Introducing ExtReact: Adding Powerful Sencha Components to React AppsIntroducing ExtReact: Adding Powerful Sencha Components to React Apps
Introducing ExtReact: Adding Powerful Sencha Components to React Apps
 
SenchaCon 2016: Keynote Presentation - Art Landro, Gautam Agrawal, Mark Brocato
SenchaCon 2016: Keynote Presentation - Art Landro, Gautam Agrawal, Mark BrocatoSenchaCon 2016: Keynote Presentation - Art Landro, Gautam Agrawal, Mark Brocato
SenchaCon 2016: Keynote Presentation - Art Landro, Gautam Agrawal, Mark Brocato
 
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...
 
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
 
SenchaCon 2016: Expect the Unexpected - Dealing with Errors in Web Apps
SenchaCon 2016: Expect the Unexpected - Dealing with Errors in Web AppsSenchaCon 2016: Expect the Unexpected - Dealing with Errors in Web Apps
SenchaCon 2016: Expect the Unexpected - Dealing with Errors in Web Apps
 
Ext JS Architecture Best Practices - Mitchell Simeons
Ext JS Architecture Best Practices - Mitchell SimeonsExt JS Architecture Best Practices - Mitchell Simeons
Ext JS Architecture Best Practices - Mitchell Simeons
 
SenchaCon 2016: Mobile First? Desktop First? Or Should you Think Universal Ap...
SenchaCon 2016: Mobile First? Desktop First? Or Should you Think Universal Ap...SenchaCon 2016: Mobile First? Desktop First? Or Should you Think Universal Ap...
SenchaCon 2016: Mobile First? Desktop First? Or Should you Think Universal Ap...
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

Hardware Acceleration on Mobile, Ariya Hidayat & Jarred Nicholls

  • 3. Hardware Acceleration on Mobile Ariya Hidayat & Jarred Nicholls Sencha Twitter: @ariyahidayat @jarrednicholls Wednesday, November 2, 11
  • 5. Game vs Web Wednesday, November 2, 11
  • 6. Game Text Textured objects Animation Transformation Physics Wednesday, November 2, 11
  • 7. Web Pages Images Text Wednesday, November 2, 11
  • 8. How Browser Works Network stack Layout engine JavaScript engine Graphics User interface Wednesday, November 2, 11
  • 9. WebKit Components DOM CSS WebCore SVG HTML rendering JavaScriptCore WebKit Library Wednesday, November 2, 11
  • 10. Platform Abstraction Network Unicode Clipboard Graphics Theme Events Thread Geolocation Timer Wednesday, November 2, 11
  • 11. Graphics Abstraction GraphicsContext Mac Chromium Qt Gtk Skia CoreGraphics QPainter graphics stack Wednesday, November 2, 11
  • 12. Components of Mobile Radio Touch interface CPU Power GPU Wednesday, November 2, 11
  • 13. Graphics Processor Divide and conquer Very specific purpose Wednesday, November 2, 11
  • 14. Optimized for Games Fixed geometry Transformation Textured triangles Parallelism Wednesday, November 2, 11
  • 15. Challenges Predictable contents (assets) ✔ Mostly text ✔ Mostly images ✔ Expected run-time response immediate Wednesday, November 2, 11
  • 17. Path is Everything Triangle Rectangle Path Ellipse Polygon Wednesday, November 2, 11
  • 18. Stroke = Outline Solid Dashed Dotted Textured Wednesday, November 2, 11
  • 19. Brush = Fill None Solid Gradient Textured Wednesday, November 2, 11
  • 20. Smooth via Antialiasing Multiple levels of transparency Perfect for parallelism Wednesday, November 2, 11
  • 21. Path Approximation Curves Polygon Wednesday, November 2, 11
  • 22. Gradient: Expensive CPU: sequential, tedious GPU: parallel, still a lot of work Wednesday, November 2, 11
  • 23. Blur Shadow: Really Posh Involved pixel “blending” GPU: parallel, still tedious Wednesday, November 2, 11
  • 24. Transformation Scaling Perspective Rotation Wednesday, November 2, 11
  • 26. Font Atlas Buffer Bye Wednesday, November 2, 11
  • 27. Simple to Complex ello! H Simple shape Curves Solid color Gradient brush Textured stroke Blur shadow Make it as an Serif text image Rotated Wednesday, November 2, 11
  • 29. Android Drawing Log file WebCore graphics GraphicsContext Skia Wednesday, November 2, 11
  • 30. Example: Bing platformInit savePlatformState translate 0,0 translate 0,0 clip 1,0 0x6.95322e-310 fillRect 0,0 800x556 color ff ff ff ff restorePlatformState platformDestroy platformInit savePlatformState translate 0,0 translate 0,0 clip 1,0 0x6.95322e-310 fillRect 0,0 800x556 color ff ff ff ff restorePlatformState platformDestroy platformInit savePlatformState translate 0,0 translate 0,0 clip 1,0 0x6.95322e-310 fillRect 0,0 800x556 color ff ff ff ff fillRect 0,0 800x556 color ff ff ff ff Wednesday, November 2, 11
  • 31. How Fast? #include "TimeCounter.h" bool WebViewCore::drawContent(SkCanvas* canvas, SkColor) { uint32_t timestamp = getThreadMsec(); .... painting code .... DBG_SET_LOGD("% ms", getThreadMsec() - timestamp); } external/webkit/WebKit/android/jni/WebViewCore.cpp Wednesday, November 2, 11
  • 32. Example: Google News adb logcat -v time | grep drawContent 16:24:04.070 D/webcoreglue(  273): drawContent 11 ms 16:24:04.110 D/webcoreglue(  273): drawContent 13 ms 16:24:04.150 D/webcoreglue(  273): drawContent 13 ms 16:24:04.190 D/webcoreglue(  273): drawContent 10 ms 16:24:04.240 D/webcoreglue(  273): drawContent 10 ms 16:24:04.280 D/webcoreglue(  273): drawContent 13 ms 16:24:04.320 D/webcoreglue(  273): drawContent 13 ms 16:24:04.360 D/webcoreglue(  273): drawContent 13 ms 16:24:06.080 D/webcoreglue(  273): drawContent 12 ms 16:24:06.140 D/webcoreglue(  273): drawContent 10 ms 16:24:06.180 D/webcoreglue(  273): drawContent 13 ms 16:24:06.230 D/webcoreglue(  273): drawContent 14 ms 16:24:06.600 D/webcoreglue(  273): drawContent 26 ms 16:24:06.640 D/webcoreglue(  273): drawContent 13 ms 16:24:06.860 D/webcoreglue(  273): drawContent 33 ms 16:24:06.890 D/webcoreglue(  273): drawContent 12 ms 16:24:06.930 D/webcoreglue(  273): drawContent 13 ms 16:24:06.960 D/webcoreglue(  273): drawContent 13 ms 16:24:07.000 D/webcoreglue(  273): drawContent 13 ms Wednesday, November 2, 11
  • 34. Maps Tile Wednesday, November 2, 11
  • 35. Pinch to Zoom when you pinch... Wednesday, November 2, 11
  • 36. Responsive UI decoupled Rendering Processor User interaction Wednesday, November 2, 11
  • 37. Rendering vs Interaction Screen Backing Store Rendering Web Page User interaction Wednesday, November 2, 11
  • 39. Progressive Rendering Fast but blurry Crisp but slow Wednesday, November 2, 11
  • 40. Tiling System Texture upload .... .... CPU GPU Wednesday, November 2, 11
  • 41. Tile Transformation Panning = Translation Zooming = Scaling Wednesday, November 2, 11
  • 42. Backing Store Support Vector-based Texture-based Honeycomb and later Wednesday, November 2, 11
  • 43. Y U NO position:fixed Wednesday, November 2, 11
  • 47. Typical Animation opacity, movement, scaling, rotation, ... Wednesday, November 2, 11
  • 48. Immediate Mode setInterval(function() {     box.draw(x, y);     x += 10; }, 20); every animation tick Wednesday, November 2, 11
  • 49. Scene Graph box.drawInto(layer); setInterval(function() {     layer.translate(10, 0); Change transformation matrix }, 20); Wednesday, November 2, 11
  • 53. Compositing Support Honeycomb and later Wednesday, November 2, 11
  • 54. Well-known Trick forcing 3-D transform -webkit-transform: translateZ(0) Not needed for CSS animation! Wednesday, November 2, 11
  • 55. Debugging in Safari defaults write com.apple.Safari IncludeInternalDebugMenu Wednesday, November 2, 11
  • 56. Compositing Indicators Texture (number = upload) Composited layer No texture Container layer Overflow Wednesday, November 2, 11
  • 57. Debugging in Chrome about:flags Wednesday, November 2, 11
  • 58. Avoid Texture Reupload No reupload Upload Opacity Everything else! Position Size Animation “Hardware accelerated CSS” Wednesday, November 2, 11
  • 59. Avoid Overcapacity GPU = Limited silicon space Large layer ➔ broken into “tiles” Wednesday, November 2, 11
  • 60. Prepare & Reuse Hide the layer offscreen Viewport Wednesday, November 2, 11
  • 62. Hardware Acceleration Drawing Backing Layer & primitives stores compositing Wednesday, November 2, 11
  • 64. QUESTIONS? ariya @ sencha.com jarred @ sencha.com ariya.ofilabs.com ariyahidayat jarrednicholls Wednesday, November 2, 11