Open Bug 280531 Opened 20 years ago Updated 2 years ago

image handling: merging onstart/stopdecode with onstart/stopcontainer

Categories

(Core :: Graphics: ImageLib, defect)

defect

Tracking

()

People

(Reporter: alfredkayser, Assigned: jrmuizel)

Details

The 'events' onstartdecode and onstartcontainer are always called from the same
location, and all users have one of them as a NOP (mostly onstartdecode is NOP).
Same is true of onstopdecode and onstopcontainer, but then the onstopcontainer
in NOP).

Can we not combine these into onstartdecode and onstopdecode, saving code and
overhead?
Here is some analysis of these 'callbacks/events' of the image handling:

List of the 'callbacks': 
    OnStartDecode, OnStartContainer, OnStartFrame, OnDataAvailable, OnStopFrame,
OnStopContainer, OnStopDecode

Implementers of these 'callbacks':
nsImageDocument:        onStartContainer (check size, and set title)
nsImageLoader:          onStartContainer(set and start animation),
OnStopFrame(RedrawDirtyFrame...)
nsBulletFrame:          frame->onStartContainer, frame->OnDataAvailable
nsImageFrame:           frame->onStartContainer, frame->OnDataAvailable,
frame->onStopDecode
nsSVGImageFrame:        onStopDecode(UpdateGraphic)
nsImageBoxFrame:        frame->onStartContainer, frame->OnStopContainer,
frame->onStopDecode
nsTreeImageListener:    onStartContainer(start animation)
nsImageLoadingContent:  LOOP_OVER_OBSERVERS(for all...), OnStopDecode: fire
events...

Note: OnStartDecode(request): argument request is never used?

imgRequest: 
    OnStartDecode:      set state, LOOP_OVER_PROXY_OBSERVERS, and
mCacheEntry->SetDataSize(0);
    OnStartContainer:   set state, LOOP_OVER_PROXY_OBSERVERS,
    OnStartFrame:       LOOP_OVER_PROXY_OBSERVERS
    OnDataAvailable:    LOOP_OVER_PROXY_OBSERVERS
    OnStopFrame:        set ImageState, increase cache size with frame size,
LOOP_OVER_PROXY_OBSERVERS
    OnStopContainer:    set state, LOOP_OVER_PROXY_OBSERVERS,
    OnStopDecode:       set state, set ImageState, LOOP_OVER_PROXY_OBSERVERS
    (state is only used to replay these events to any new proxies...)
    onStopDecode,onStartDecode,onStartContainer,onStopContainer
    onStopRequest,

imgRequestProxy:
    All: mListener->On**(this); (just pass through)

Usage pattern:
    OnStartDecode is nowhere really used..., except by imgRequest (but this
could be moved to OnStartContainer)
    OnStartFrame is nowhere really used...
    OnDataAvailable is nowhere really used... (passed through in some cases)
    OnStopContainer is nowhere really used... (passed through in some cases)

    OnStartContainer is used by nsImageDocument, nsImageLoader, nsTreeImageListener
    OnStopFrame is used by nsImageLoader, and imgRequest
    OnStopDecode used by nsSVGImageFrame, nsImageLoadingContent, imgRequest

So we could bring 7 callbacks back to 3, reducing code in:
* layout (7 locations where these callbacks are implemented), 
* content (nsImageLoadingContent), 
* libpr0n (imgRequest/proxy and all of the decoders (removing the callers...)

This would have a positive effect on codesize, performance (pageloading!), and
reducing complexity.
Assignee: pavlov → nobody
QA Contact: imagelib
Jeff really wants to reduce the number of callbacks Imagelib uses.
Assignee: nobody → jmuizelaar
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.