SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Downloaden Sie, um offline zu lesen
ONscreen vs.
OFFscreen rendering

Tomáš Jukin
@Inza
Březen 2013 - iOS
Březen 2013 - iOS


www.srazy.info/for-mobile
@forMobileCZ #forMobileCZ

   www.for-mobile.cz
www.juicymo.cz
www.iknow.eu/cvut/
ONscreen vs.
OFFscreen rendering

Tomáš Jukin
@Inza
iOS Stack
               UIKit

           Core Animation

   OpenGL ES           Core Graphics

     GPU                    CPU
iOS Stack                          UIButton
                                                     UILabel


                             UIKit

                         Core Animation              smooth transitions


2D/3D Graphics                                                 Quartz
                 OpenGL ES           Core Graphics

                   GPU                    CPU
iOS Stack                             UIButton
                                                        UILabel


                                 UIKit

                         Core Animation                 smooth transitions


2D/3D Graphics                                                    Quartz
                 OpenGL ES                Core Graphics

                   GPU                        CPU

                             C language
iOS Stack
                          UIKit

                Core Animation

   OpenGL ES                      Core Graphics

       GPU                            CPU

  Hardware Acceleration
ONscreen rendering

data    GPU    obrazovka
OFFscreen rendering

    data    CPU

                  bitmapa

obrazovka   GPU
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).
Proč a kdy to vadí?

“Offscreen drawing affects
performance when animation is
involved”
Jak to testovat?




Nebo to umí i Instruments...
Case Study: UIButton
Jak udělat grafiku pro UIButton?

                Předrenderované assety

                CALayer

                drawRect
Předrenderované
assety
GPU + předrenderované malé
resizeable/tileable obrázky

ZENové, náročné na údržbu a
realizaci
CALayer
nutné OFFscreen průběhy pro
maskování rohů

v Core Animation je defaultně
zapnutá animace

Overkill
drawRect
drawRect -> Core Graphics

touch -> setNeedsDisplay -> redraw

CPU & memory waste

hodně tlačítek v UI naráz = smrt
Závěr? Máme tedy JEN
assety?
NE!

Je tu hybridní přístup:

Kód -> obrázek -> assetový postup
pro všechny instance
One more thing...
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á!
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!
Next
Next ?

KVC, KVO a Cocoa Bindings

Document Oriented Programing v Cocoa

Advanced Cora Data

Weitere ähnliche Inhalte

Mehr von Tomáš Jukin

CoreData - there is an ORM you can like!
CoreData - there is an ORM you can like!CoreData - there is an ORM you can like!
CoreData - there is an ORM you can like!Tomáš Jukin
 
Few tips for great presentations
Few tips for great presentationsFew tips for great presentations
Few tips for great presentationsTomáš Jukin
 
Bezpečnost platformy iOS
Bezpečnost platformy iOSBezpečnost platformy iOS
Bezpečnost platformy iOSTomáš Jukin
 
MVC na iOS - For-Mobile 2/2013
MVC na iOS - For-Mobile 2/2013MVC na iOS - For-Mobile 2/2013
MVC na iOS - For-Mobile 2/2013Tomáš Jukin
 
iOS6 & CocoaPods - For-Mobile 9/2012
iOS6 & CocoaPods - For-Mobile 9/2012iOS6 & CocoaPods - For-Mobile 9/2012
iOS6 & CocoaPods - For-Mobile 9/2012Tomáš Jukin
 
Make the code work for you with #git
Make the code work for you with #gitMake the code work for you with #git
Make the code work for you with #gitTomáš Jukin
 
Tools beyond ruby on rails
Tools beyond ruby on railsTools beyond ruby on rails
Tools beyond ruby on railsTomáš Jukin
 

Mehr von Tomáš Jukin (7)

CoreData - there is an ORM you can like!
CoreData - there is an ORM you can like!CoreData - there is an ORM you can like!
CoreData - there is an ORM you can like!
 
Few tips for great presentations
Few tips for great presentationsFew tips for great presentations
Few tips for great presentations
 
Bezpečnost platformy iOS
Bezpečnost platformy iOSBezpečnost platformy iOS
Bezpečnost platformy iOS
 
MVC na iOS - For-Mobile 2/2013
MVC na iOS - For-Mobile 2/2013MVC na iOS - For-Mobile 2/2013
MVC na iOS - For-Mobile 2/2013
 
iOS6 & CocoaPods - For-Mobile 9/2012
iOS6 & CocoaPods - For-Mobile 9/2012iOS6 & CocoaPods - For-Mobile 9/2012
iOS6 & CocoaPods - For-Mobile 9/2012
 
Make the code work for you with #git
Make the code work for you with #gitMake the code work for you with #git
Make the code work for you with #git
 
Tools beyond ruby on rails
Tools beyond ruby on railsTools beyond ruby on rails
Tools beyond ruby on rails
 

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