RESOLVED FIXED 24864
Tidy up some accelerated compositing code related to direct image compositing
https://bugs.webkit.org/show_bug.cgi?id=24864
Summary Tidy up some accelerated compositing code related to direct image compositing
Simon Fraser (smfr)
Reported 2009-03-26 17:44:13 PDT
We have some cleanup of code related to "direct compositing" of images.
Attachments
Patch, changelog (9.96 KB, patch)
2009-03-26 17:46 PDT, Simon Fraser (smfr)
darin: review+
Simon Fraser (smfr)
Comment 1 2009-03-26 17:46:44 PDT
Created attachment 28995 [details] Patch, changelog
Darin Adler
Comment 2 2009-03-26 18:03:31 PDT
Comment on attachment 28995 [details] Patch, changelog > -// A layer can use an inner content layer if the render layer's object is a replaced object and has no children. > +// A layer can use direct composoting if the render layer's object is a replaced object and has no children. Typo here. > +void RenderLayerBacking::updateImageContents() > +{ > + ASSERT(renderer()->isImage()); > + RenderImage* imageRenderer = static_cast<RenderImage*>(renderer()); > + if (imageRenderer->cachedImage() && > + imageRenderer->cachedImage()->image() && > + imageRenderer->cachedImage()->isLoaded()) { > + // We have to wait until the image is fully loaded before setting it on the layer. > + > + // This is a no-op if the layer doesn't have an inner layer for the image. > + m_graphicsLayer->setContentsToImage(imageRenderer->cachedImage()->image()); > + > + // Image animation is "lazy", in that it automatically stops unless someone is drawing > + // the image. So we have to kick the animation each time; this has the downside that the > + // image will keep animating, even if its layer is not visible. > + imageRenderer->cachedImage()->image()->startAnimation(); > } > } Now that this is in its own function, you can use early returns to get rid of that cascaded &&, make space to comment about each return if you like, and even put things into local variables instead of repeating imageRenderer->cachedImage()->image(). Look how attractive it is! CachedImage* cachedImage = imageRenderer->cachedImage(); if (!cachedImage) return; Image* image = cachedImage->image(); if (!image) return; // We have to wait until the image is fully loaded before setting it on the layer. if (!cachedImage->isLoaded()) return; // This is a no-op if the layer doesn't have an inner layer for the image. m_graphicsLayer->setContentsToImage(image); // Image animation is "lazy", in that it automatically stops unless someone is drawing // the image. So we have to kick the animation each time; this has the downside that the // image will keep animating, even if its layer is not visible. image)->startAnimation(); r=me
Simon Fraser (smfr)
Comment 3 2009-03-26 18:12:32 PDT
Note You need to log in before you can comment on or make changes to this bug.