SlideShare une entreprise Scribd logo
1  sur  67
Télécharger pour lire hors ligne
Understanding Hardware Acceleration
                                      Ariya Hidayat
                on Mobile Browsers
whoami
Challenges
Game vs Web
Game


                                     Text




                                            Textured
                                             objects
   Animation




          Transformation   Physics
Large Area, but Still Bounded
Web Page




             Images

      Text
From Wave to Pixels



                       Network stack




                                   Layout engine



                      JavaScript engine            Graphics




                                          User interface
WebKit Components



          DOM               CSS


                WebCore              SVG


   HTML
                      rendering

                                           JavaScriptCore



                    WebKit Library
Platform Abstraction



       Network          Unicode      Clipboard


       Graphics          Theme        Events


        Thread         Geolocation    Timer
Graphics Abstraction



GraphicsContext       Mac        Chromium       Qt


                                   Skia
                  CoreGraphics
                                            QPainter


                                      graphics stack
Mobile Device



                         Radio




       Touch interface


                                 CPU

              Power


                          GPU
Graphics Processor



                     Divide and conquer




                     Very specific purpose
Relationship




           CPU   GPU
SoC = System-on-a-Chip
Fundamental Physical Limitations



               1.Available memory
               2.Bus bandwith
               3.Speed difference
Optimized for Games




                      Fixed geometry

                      Transformation

                      Textured triangles



                              Parallelism
Challenges




Predictable contents (assets)   ✔
Mostly text                           ✔
Mostly images                   ✔
Initial response                    immediate
http://www.trollquotes.org/619-super-spider-bat-troll-quote/
Primitive Drawing
Path is Everything




                     Triangle   Rectangle




      Path
                     Ellipse         Polygon
Stroke = Outline




       Solid       Dashed   Dotted   Textured
Brush = Fill




   None        Solid   Gradient   Textured
Smooth via Antialiasing


                          Multiple levels of transparency




                                       Perfect for parallelism
Path Approximation


   Curves




                     Polygon
Gradient: Expensive


      CPU: sequential, tedious




      GPU: parallel, still a lot of work
Blur Shadow: Really Posh


             Involved pixel “blending”




            GPU: parallel, still tedious
Transformation




   Scaling
                            Perspective
                 Rotation
Text Rasterization
Font Atlas


             Buffer




                      Bye
Simple to Complex



                                      ello!
                                    H


 Simple shape                       Curves
  Solid color                   Gradient brush
                                Textured stroke
                                 Blur shadow
                Make it as an      Serif text
                  image            Rotated
Backing Store
Maps




       Tile
Pinch to Zoom




when you pinch...
Responsive Interface



                                 decoupled
     Rendering

                Processor

                        User interaction
Rendering vs Interaction



                                          Screen
                  Backing Store
      Rendering




Web Page                          User interaction
Checkerboard Pattern
Progressive Rendering


    Fast but blurry




                        Crisp but slow
Tiling System




                       Texture upload


                ....                ....



    CPU                                    GPU
Tile Transformation




 Panning = Translation   Zooming = Scaling
Backing Store Support




Vector-based




Texture-based
                        Honeycomb and later
Y U NO
position:fixed
Layer & Compositing
Mechanics of Animation

                  “Hey, this is good stuff. Keep it around as texture #42.”




 Initialization



                           “Apply [operation] to texture #42.”



 Animation step
Elements = Layer
Typical Animation




       opacity, movement, scaling, rotation, ...
Immediate Mode




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


                            every animation tick
Scene Graph




  box.drawInto(layer);
  setInterval(function() {
      layer.translate(10, 0);   Change transformation
                                       matrix
  }, 20);
Logical 3-D
Keep the Textures
Compositing Support




               Honeycomb and later
Well-known Trick




                                       forcing 3-D transform



             -webkit-transform: translateZ(0)




              Not needed for CSS animation!
Magical Advice

       Use translate3d for hardware   Misleading (at best)
               acceleration
Debugging in Safari



 defaults write com.apple.Safari IncludeInternalDebugMenu 1
Compositing Indicators



                         Texture (number = upload)


                                      Composited layer




                         No texture

                                       Container layer


                                          Overflow
Avoid Texture Reupload



         No reupload                           Upload




         Opacity                        Everything else!
         Position
          Size
        Animation


                  “Hardware accelerated CSS”
Examples
Avoid Overcapacity




              GPU = Limited silicon space
            Large layer ➔ broken into “tiles”
Prepare & Reuse




                        Hide the layer offscreen




             Viewport
Alpha Blending




                 Color change
Alpha Blending: The Trick




                  Blended with
Wrap-up
Hardware Acceleration




   Drawing          Backing     Layer &
   primitives        stores   compositing
What Can We Learn?




  Traditional graphics programming has been
               always full of tricks.

              It will always be.
There is No Silver Bullet
Thank You



            ariya.hidayat@gmail.com



            ariya.ofilabs.com



            @AriyaHidayat

Contenu connexe

Tendances (6)

JavaOne TS-5098 Groovy SwingBuilder
JavaOne TS-5098 Groovy SwingBuilderJavaOne TS-5098 Groovy SwingBuilder
JavaOne TS-5098 Groovy SwingBuilder
 
Minimalism in Web Development
Minimalism in Web DevelopmentMinimalism in Web Development
Minimalism in Web Development
 
Wakanda: NoSQL for Model-Driven Web applications - NoSQL matters 2012
Wakanda: NoSQL for Model-Driven Web applications - NoSQL matters 2012Wakanda: NoSQL for Model-Driven Web applications - NoSQL matters 2012
Wakanda: NoSQL for Model-Driven Web applications - NoSQL matters 2012
 
I Can't Believe It's Not Flash
I Can't Believe It's Not FlashI Can't Believe It's Not Flash
I Can't Believe It's Not Flash
 
Groovy & Grails for Spring/Java developers
Groovy & Grails for Spring/Java developersGroovy & Grails for Spring/Java developers
Groovy & Grails for Spring/Java developers
 
Introduction to WebGL and WebVR
Introduction to WebGL and WebVRIntroduction to WebGL and WebVR
Introduction to WebGL and WebVR
 

Similaire à Understanding Hardware Acceleration on Mobile Browsers

Advanced Silverlight
Advanced SilverlightAdvanced Silverlight
Advanced Silverlight
rsnarayanan
 
Gentek Introduce(en)
Gentek Introduce(en)Gentek Introduce(en)
Gentek Introduce(en)
cloudmmog
 
LCA2013 : Implementing threaded accelerated compositing in WebKitGtk+
LCA2013 :  Implementing threaded accelerated compositing in WebKitGtk+LCA2013 :  Implementing threaded accelerated compositing in WebKitGtk+
LCA2013 : Implementing threaded accelerated compositing in WebKitGtk+
Gwang Yoon Hwang
 
Building Windows 8 Metro Style casual games using HTML5 and JavaScript
Building Windows 8 Metro Style casual games using HTML5 and JavaScriptBuilding Windows 8 Metro Style casual games using HTML5 and JavaScript
Building Windows 8 Metro Style casual games using HTML5 and JavaScript
David Isbitski
 
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Johan Andersson
 
Adobe AIR - Mobile Performance – Tips & Tricks
Adobe AIR - Mobile Performance – Tips & TricksAdobe AIR - Mobile Performance – Tips & Tricks
Adobe AIR - Mobile Performance – Tips & Tricks
Mihai Corlan
 
Magento Imagine 2013: Fabrizio Branca - Learning To Fly: How Angry Birds Reac...
Magento Imagine 2013: Fabrizio Branca - Learning To Fly: How Angry Birds Reac...Magento Imagine 2013: Fabrizio Branca - Learning To Fly: How Angry Birds Reac...
Magento Imagine 2013: Fabrizio Branca - Learning To Fly: How Angry Birds Reac...
AOE
 

Similaire à Understanding Hardware Acceleration on Mobile Browsers (20)

Understanding hardware acceleration on mobile browsers presentation
Understanding hardware acceleration on mobile browsers presentationUnderstanding hardware acceleration on mobile browsers presentation
Understanding hardware acceleration on mobile browsers presentation
 
GTC 2012: GPU-Accelerated Path Rendering
GTC 2012: GPU-Accelerated Path RenderingGTC 2012: GPU-Accelerated Path Rendering
GTC 2012: GPU-Accelerated Path Rendering
 
Advanced Silverlight
Advanced SilverlightAdvanced Silverlight
Advanced Silverlight
 
NV_path_rendering
NV_path_renderingNV_path_rendering
NV_path_rendering
 
Gentek Introduce(en)
Gentek Introduce(en)Gentek Introduce(en)
Gentek Introduce(en)
 
SIGGRAPH Asia 2012: GPU-accelerated Path Rendering
SIGGRAPH Asia 2012: GPU-accelerated Path RenderingSIGGRAPH Asia 2012: GPU-accelerated Path Rendering
SIGGRAPH Asia 2012: GPU-accelerated Path Rendering
 
LCA2013 : Implementing threaded accelerated compositing in WebKitGtk+
LCA2013 :  Implementing threaded accelerated compositing in WebKitGtk+LCA2013 :  Implementing threaded accelerated compositing in WebKitGtk+
LCA2013 : Implementing threaded accelerated compositing in WebKitGtk+
 
Building Windows 8 Metro Style casual games using HTML5 and JavaScript
Building Windows 8 Metro Style casual games using HTML5 and JavaScriptBuilding Windows 8 Metro Style casual games using HTML5 and JavaScript
Building Windows 8 Metro Style casual games using HTML5 and JavaScript
 
GDSC KIIT Huddle Session 4 - "Graphics Pipelining"
GDSC KIIT Huddle Session 4 - "Graphics Pipelining"GDSC KIIT Huddle Session 4 - "Graphics Pipelining"
GDSC KIIT Huddle Session 4 - "Graphics Pipelining"
 
Building a game engine with jQuery
Building a game engine with jQueryBuilding a game engine with jQuery
Building a game engine with jQuery
 
Actors, a Unifying Pattern for Scalable Concurrency | C4 2006
Actors, a Unifying Pattern for Scalable Concurrency | C4 2006 Actors, a Unifying Pattern for Scalable Concurrency | C4 2006
Actors, a Unifying Pattern for Scalable Concurrency | C4 2006
 
Catan world and Churchill
Catan world and ChurchillCatan world and Churchill
Catan world and Churchill
 
Going Mobile - A Pragmatic Look At Mobile Design
Going Mobile - A Pragmatic Look At Mobile DesignGoing Mobile - A Pragmatic Look At Mobile Design
Going Mobile - A Pragmatic Look At Mobile Design
 
Advanced Web Graphics with Canvas
Advanced Web Graphics with CanvasAdvanced Web Graphics with Canvas
Advanced Web Graphics with Canvas
 
High Performance Cloud Computing
High Performance Cloud ComputingHigh Performance Cloud Computing
High Performance Cloud Computing
 
SIGGRAPH 2012: GPU-Accelerated 2D and Web Rendering
SIGGRAPH 2012: GPU-Accelerated 2D and Web RenderingSIGGRAPH 2012: GPU-Accelerated 2D and Web Rendering
SIGGRAPH 2012: GPU-Accelerated 2D and Web Rendering
 
The Rendering Pipeline - Challenges & Next Steps
The Rendering Pipeline - Challenges & Next StepsThe Rendering Pipeline - Challenges & Next Steps
The Rendering Pipeline - Challenges & Next Steps
 
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
 
Adobe AIR - Mobile Performance – Tips & Tricks
Adobe AIR - Mobile Performance – Tips & TricksAdobe AIR - Mobile Performance – Tips & Tricks
Adobe AIR - Mobile Performance – Tips & Tricks
 
Magento Imagine 2013: Fabrizio Branca - Learning To Fly: How Angry Birds Reac...
Magento Imagine 2013: Fabrizio Branca - Learning To Fly: How Angry Birds Reac...Magento Imagine 2013: Fabrizio Branca - Learning To Fly: How Angry Birds Reac...
Magento Imagine 2013: Fabrizio Branca - Learning To Fly: How Angry Birds Reac...
 

Plus de Ariya Hidayat

Understanding Webkit Rendering
Understanding Webkit RenderingUnderstanding Webkit Rendering
Understanding Webkit Rendering
Ariya Hidayat
 
JavaScript Parser Infrastructure for Code Quality Analysis
JavaScript Parser Infrastructure for Code Quality AnalysisJavaScript Parser Infrastructure for Code Quality Analysis
JavaScript Parser Infrastructure for Code Quality Analysis
Ariya Hidayat
 
Hybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKitHybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKit
Ariya Hidayat
 
Efficient Graphics with Qt
Efficient Graphics with QtEfficient Graphics with Qt
Efficient Graphics with Qt
Ariya Hidayat
 
Introduction to QtWebKit
Introduction to QtWebKitIntroduction to QtWebKit
Introduction to QtWebKit
Ariya Hidayat
 

Plus de Ariya Hidayat (7)

Understanding Webkit Rendering
Understanding Webkit RenderingUnderstanding Webkit Rendering
Understanding Webkit Rendering
 
JavaScript Parser Infrastructure for Code Quality Analysis
JavaScript Parser Infrastructure for Code Quality AnalysisJavaScript Parser Infrastructure for Code Quality Analysis
JavaScript Parser Infrastructure for Code Quality Analysis
 
Hybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKitHybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKit
 
Hybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitHybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKit
 
Hybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitHybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKit
 
Efficient Graphics with Qt
Efficient Graphics with QtEfficient Graphics with Qt
Efficient Graphics with Qt
 
Introduction to QtWebKit
Introduction to QtWebKitIntroduction to QtWebKit
Introduction to QtWebKit
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
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)
 
[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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
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
 

Understanding Hardware Acceleration on Mobile Browsers