#Fresco
##Outline
- Architecture
- Usage
- Drawee
- ImagePipeline
##Architecture
##Memory
####Regions of Memory
- Java Heap: limited, GC
- Native Heap: as large as the memory size; Program is responsible for freeing memory
- Ashmen: (Anonymous Shared Memory) like native heap; pin or unpin, lazy free purging facility.
####Purgeable bitmaps
|
|
####Fast UI and fast memory
NDK: AndroidBitmap_lockPixels
, and unlockPixels
match.
Solution: call lockPixels
without a matching unlockPixels
####Write code in Java, think in C++
In C++, smart pointer implement reference counting.
In Java:
SharedReference
:addReference()
: increase reference countdeleteReference()
:decrease reference count- when reference count goes to 0, resource disposal(such as Bitmap.recycle)
CloseableReference
:- implemented interfaces :
Closeable
,Cloneable
- constructor and
clone()
method calladdReference()
close()
method callsdeleteReference()
- implemented interfaces :
Java developers need only follow two simple rules:
- On assigning a CloseableReference to a new object, call
.clone()
. - Before going out of scope, call
.close()
, usually in a finally block.
####Pipeline
DataSource
Produce series of continuous results. Future
can get only one result.
DataSource
:
DataSubscriber
Executor
Producer/Consumer framework:
Producer
:produceResults()
Consumer
:onNewResult()
,onFailure()
,onCancellation()
,onProgressUpdate()
##Drawee
MVC-like
- DraweeHierarchy: Model
- DraweeController: connect to the image pipeline or any image loader.
- DraweeView: