An image can directly compositing if it's the sole content of the layer, and have no box decorations//that require P Ainting. Direct compositing saves backing Store.bool compositedlayermapping::isdirectlycompositedimage () const{ renderobject* RenderObject = renderer (); if (!renderobject->isimage () | | m_owninglayer->hasboxdecorationsorbackground () | | renderobject->hasclip ()) return false; renderimage* imagerenderer = Torenderimage (renderobject); if (imageresource* cachedimage = Imagerenderer->cachedimage ()) { if (!cachedimage->hasimage ()) return false; image* image = Cachedimage->imageforrenderer (imagerenderer); return Image->isbitmapimage (); } return false;}
void compositedlayermapping::contentchanged (Contentchangetype changetype) { if (changetype = = ImageChanged) && Isdirectlycompositedimage ()) { updateimagecontents (); return; } if ((changetype = = maskimagechanged) && m_masklayer) { //The composited layer bounds relies on BOX->MASKCL Iprect (), which changes //When the mask image becomes available. Updateafterlayout (Compositingchildrenonly | isupdateroot); } if (changetype = = Canvaschanged | | changetype = canvaspixelschanged) && Isacceleratedcanvas (Renderer ())) {
m_graphicslayer->setcontentsneedsdisplay (); return;} }
void Compositedlayermapping::updateimagecontents () { ASSERT (renderer ()->isimage ()); renderimage* imagerenderer = Torenderimage (renderer ()); imageresource* cachedimage = Imagerenderer->cachedimage (); if (!cachedimage) return; image* image = Cachedimage->imageforrenderer (imagerenderer); if (!image) return; We have a to wait until the image was fully loaded before setting it on the layer. if (!cachedimage->isloaded ()) return; This is a no-op if the layer doesn ' t has a inner layer for the image. M_graphicslayer->setcontentstoimage (image); BOOL Issimplecontainer = false; Updatedrawscontent (Issimplecontainer);
void Graphicslayer::setcontentstoimage (image* image) { refptr<nativeimageskia> nativeimage = image? image- >nativeimageforcurrentframe (): 0; if (nativeimage) { if (!m_imagelayer) { M_imagelayer = adoptptr (Platform::current ()->compositorsupport ()- >createimagelayer ()); Registercontentslayer (M_imagelayer->layer ()); } M_imagelayer->setbitmap (Nativeimage->bitmap ()); M_imagelayer->layer ()->setopaque (Image->currentframeknowntobeopaque ()); Updatecontentsrect (); } else { if (m_imagelayer) { unregistercontentslayer (M_imagelayer->layer ()); M_imagelayer.clear (); } } Setcontentsto (M_imagelayer m_imagelayer->layer (): 0);}
M39 on the contrary is not this behavior, will go Nativeimageskia::d Raw. Of course, M39 on Slimmingpaint and Ganesh (GPU rasterization) are still in continuous refactoring.
Chromium M34 (img element) direct synthesis, do not go Nativeimageskia::d The raw path of the relevant code