Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ONscreen vs. OFFscreen rendering v iOS - For-Mobile 3/2013

ONscreen vs. OFFscreen rendering v iOS - For-Mobile 3/2013

Slidy z mé prezentace na téma "ONscreen vs. OFFscreen rendering v iOS", která proběhla na For-Mobile iOS v březnu 2013 v prostorách Microsoft ČR.

Více o události For-Mobile: http://srazy.info/for-mobile/3293

#forMobileCZ

Tomas Jukin

March 26, 2013
Tweet

More Decks by Tomas Jukin

Other Decks in Programming

Transcript

  1. iOS Stack UIKit UIKit Core Animation Core Animation OpenGL ES

    Core Graphics GPU CPU UIButton UILabel smooth transitions 2D/3D Graphics Quartz
  2. iOS Stack UIKit UIKit Core Animation Core Animation OpenGL ES

    Core Graphics GPU CPU UIButton UILabel smooth transitions 2D/3D Graphics Quartz C language C language
  3. iOS Stack UIKit UIKit Core Animation Core Animation OpenGL ES

    Core Graphics GPU CPU Hardware Acceleration
  4. Kdy se použije OFFscreen rendering? • Core Graphics (když použiju

    cokoliv s CG*) • drawRect() metoda, i prázdná! • CALayer s shouldRasterize == YES. • CALayer s maskami (setMasksToBounds) dynamickými stíny (setShadow*). • drawText včetně Core Text. • použití group opacity (UIViewGroupOpacity).
  5. drawRect drawRect -> Core Graphics touch -> setNeedsDisplay -> redraw

    CPU & memory waste hodně tlačítek v UI naráz = smrt
  6. Závěr? Máme tedy JEN assety? NE! Je tu hybridní přístup:

    Kód -> obrázek -> assetový postup pro všechny instance
  7. GPU OFFscreen rendering! CPU OFFscreen rendering je synchronní s aplikací

    - je to zápis do bitmapy pixel by pixel OFFscreen rendering může dělat i GPU! -> render server - asynchronně Změna kontextu mezi ON a OFF je pro GPU ale strašně drahá!
  8. GPU OFFscreen rendering! důsledek: GPU může kreslit pomaleji než CPU!

    (flush + bariéra) Proto je CoreGraphics přes CPU [CALayer setShouldRasterize:] vs. CG - nutno testovat!