Bug 58833

Summary: [chromium] Move draw implementation for ContentLayerChromium/ImageLayerChromium to the appropriate CCLayerImpl subclass
Product: WebKit Reporter: James Robinson <jamesr>
Component: New BugsAssignee: James Robinson <jamesr>
Status: RESOLVED FIXED    
Severity: Normal CC: alokp, enne, jamesr, nduca, vangelis, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: OS X 10.5   
Bug Depends on: 64401, 64406    
Bug Blocks: 58799    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch none

Description James Robinson 2011-04-18 14:50:23 PDT
As title says.  I'm looking into this now.
Comment 1 James Robinson 2011-06-27 14:26:25 PDT
Created attachment 98785 [details]
Patch
Comment 2 Adrienne Walker 2011-06-27 19:03:48 PDT
Comment on attachment 98785 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=98785&action=review

I'm really excited that you're cleaning this up, because it's been a long time coming.

Did you sort out why changing the tile size was causing rendering issues?

> Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp:178
> +bool ImageLayerChromium::drawsContent() const
>  {
> -    if (!m_textureUpdater)
> -        m_textureUpdater = ImageLayerTextureUpdater::create(layerRendererContext(), layerRenderer()->contextSupportsMapSub());
> +    return m_contents;

I'm curious why you needed an implementation of drawsContent for ImageLayer.  I could see adding a check for m_contents as an early out.  However, I think you might need to call the base class version too to catch cases like GraphicsLayerChromium::drawsContent() returning false or a really huge image layer being used as a mask that can't be drawn.

> Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp:49
> +// When tiling is enabled, use tiles of this dimension squared.
> +static int defaultTileSize = 256;

I suppose that this could wait for a follow-up patch, but I think the TiledLayerChromium-derived classes should manage their own tile sizes, so that image layers and content layers can have different behavior.
Comment 3 James Robinson 2011-06-27 20:23:23 PDT
(In reply to comment #2)
> (From update of attachment 98785 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=98785&action=review
> 
> I'm really excited that you're cleaning this up, because it's been a long time coming.
> 
> Did you sort out why changing the tile size was causing rendering issues?

No, but I'm pretty sure it's orthogonal to this patch.  I'll try to investigate that in parallel.

> 
> > Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp:178
> > +bool ImageLayerChromium::drawsContent() const
> >  {
> > -    if (!m_textureUpdater)
> > -        m_textureUpdater = ImageLayerTextureUpdater::create(layerRendererContext(), layerRenderer()->contextSupportsMapSub());
> > +    return m_contents;
> 
> I'm curious why you needed an implementation of drawsContent for ImageLayer.  I could see adding a check for m_contents as an early out.  However, I think you might need to call the base class version too to catch cases like GraphicsLayerChromium::drawsContent() returning false or a really huge image layer being used as a mask that can't be drawn.

drawsContent() was returning false for simple image layers that should render, I need to do some more digging to figure out why.

> 
> > Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp:49
> > +// When tiling is enabled, use tiles of this dimension squared.
> > +static int defaultTileSize = 256;
> 
> I suppose that this could wait for a follow-up patch, but I think the TiledLayerChromium-derived classes should manage their own tile sizes, so that image layers and content layers can have different behavior.

Agree on both points.
Comment 4 Alok Priyadarshi 2011-06-28 08:56:19 PDT
Comment on attachment 98785 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=98785&action=review

lgtm

> Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp:164
> +LayerTextureUpdater* ImageLayerChromium::textureUpdater() const

nit: move this to the header file

> Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp:382
> +static void paintLayerHelper(LayerChromium* layer, const IntRect& targetRenderSurface)

nit: paintLayerContentsIfDirty may be a better name

> Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp:276
> +    m_textureOrientation = textureUpdater->orientation();

ASSERT if all tiles are not being updated and orientation and texelformat changes.
Comment 5 James Robinson 2011-06-28 13:50:02 PDT
(In reply to comment #3)
> (In reply to comment #2)
> > (From update of attachment 98785 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=98785&action=review
> > 
> > I'm really excited that you're cleaning this up, because it's been a long time coming.
> > 
> > Did you sort out why changing the tile size was causing rendering issues?
> 
> No, but I'm pretty sure it's orthogonal to this patch.  I'll try to investigate that in parallel.
> 

It seems that the tiler can't handle non-square tiles smaller than the layer bounds.  If I make the default tile size 256x306 then I get weird distortion on compositing/color-matching/image-color-matching.html.  Interesting, but not directly related to this patch.
Comment 6 James Robinson 2011-06-28 14:33:27 PDT
Comment on attachment 98785 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=98785&action=review

>> Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp:164
>> +LayerTextureUpdater* ImageLayerChromium::textureUpdater() const
> 
> nit: move this to the header file

no can do, ImageLayerTextureUpdater is declared in the .cpp so in the header there's no way for the compiler to know whether a ImageLayerTextureUpdater* actually is a LayerTextureUpdater* or not.

>> Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp:382
>> +static void paintLayerHelper(LayerChromium* layer, const IntRect& targetRenderSurface)
> 
> nit: paintLayerContentsIfDirty may be a better name

good idea

>> Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp:276
>> +    m_textureOrientation = textureUpdater->orientation();
> 
> ASSERT if all tiles are not being updated and orientation and texelformat changes.

sure
Comment 7 James Robinson 2011-06-28 15:49:13 PDT
(In reply to comment #3)
> > > Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp:178
> > > +bool ImageLayerChromium::drawsContent() const
> > >  {
> > > -    if (!m_textureUpdater)
> > > -        m_textureUpdater = ImageLayerTextureUpdater::create(layerRendererContext(), layerRenderer()->contextSupportsMapSub());
> > > +    return m_contents;
> > 
> > I'm curious why you needed an implementation of drawsContent for ImageLayer.  I could see adding a check for m_contents as an early out.  However, I think you might need to call the base class version too to catch cases like GraphicsLayerChromium::drawsContent() returning false or a really huge image layer being used as a mask that can't be drawn.
> 
> drawsContent() was returning false for simple image layers that should render, I need to do some more digging to figure out why.
> 

Ah, the issue is that GraphicsLayer::drawsContent() returns false for simple composited images, as it should, because only the image layer draws.  It would make sense to return false for the other cases, though.  I'll see how reasonable that is.
Comment 8 James Robinson 2011-06-28 16:05:40 PDT
Created attachment 98989 [details]
Patch
Comment 9 James Robinson 2011-06-28 16:10:18 PDT
Addressed most review feedback:
- renamed the helper fn in LayerRendererChromium to paintLayerContentsIfDirty
- made ImageLayerChromium::drawsContent() check m_contents and the parent class' ::drawsContent() to check for missing owner, bad tiling assumptions, etc. To do this I added a ContentLayerChromium::drawsContent() override to check for m_owner->drawsContent() since that check is only applicable to content layers


There's no good way to ASSERT() that the texel format or texture orientation only change if all of the tiles are updated since there's no simple way to define 'all the tiles'. The code behaves the same way with this patch as it did before, anyhow, since the draw() implementation assumes that all tiles have the texture orientation and texel format as the updater.
Comment 10 Vangelis Kokkevis 2011-06-29 19:03:04 PDT
Comment on attachment 98989 [details]
Patch

Looks really good!  If you don't mind holding off landing it until the memory reduction patches are in, it will make backporting them to M13 a lot simpler.
Comment 11 James Robinson 2011-07-06 15:00:35 PDT
Created attachment 99890 [details]
Patch
Comment 12 James Robinson 2011-07-06 15:01:58 PDT
Merge up to ToT.  I think https://bugs.webkit.org/show_bug.cgi?id=64009 is the last bug that Vangelis wanted to hold off on, and it shouldn't conflict with this patch, so as soon as that lands we should be good to go for this one.
Comment 13 Adrienne Walker 2011-07-11 16:04:17 PDT
Comment on attachment 99890 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=99890&action=review

Unofficially, this looks good to me, other than that one nit.

> Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp:142
>  void CCLayerImpl::draw()
>  {
> -    return m_owner->draw();
> +    ASSERT_NOT_REACHED();
>  }

Nit: If you don't want anyone to call this particular function, consider making it abstract.
Comment 14 Kenneth Russell 2011-07-11 17:30:59 PDT
Comment on attachment 99890 [details]
Patch

Looks good based on cursory review and Adrienne's and Vangelis's unofficial reviews. r=me
Comment 15 James Robinson 2011-07-12 12:57:17 PDT
Committed r90842: <http://trac.webkit.org/changeset/90842>
Comment 16 James Robinson 2011-07-12 12:59:35 PDT
(In reply to comment #13)
> (From update of attachment 99890 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=99890&action=review
> 
> Unofficially, this looks good to me, other than that one nit.
> 
> > Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp:142
> >  void CCLayerImpl::draw()
> >  {
> > -    return m_owner->draw();
> > +    ASSERT_NOT_REACHED();
> >  }
> 
> Nit: If you don't want anyone to call this particular function, consider making it abstract.

Note for posterity:  This can't be abstract since we do instantiate CCLayerImpls (the base class), but the draw() call should be unreached since drawsContent() always returns false for these.
Comment 17 James Robinson 2011-07-12 16:00:32 PDT
Patch was reverted, I was being a little sloppy with drawsContent() handling.  Updating patch on the way...
Comment 18 James Robinson 2011-07-12 16:16:19 PDT
http://trac.webkit.org/changeset/90859
Comment 19 James Robinson 2011-07-12 17:56:31 PDT
Created attachment 100599 [details]
Patch
Comment 20 James Robinson 2011-07-12 17:59:56 PDT
Patch updated.  The change between the previous version that fixes the bug is changing LayerRendererChromium::updateCompositorResources() to check drawsContent() on the LayerChromium* instead of the CCLayerImpl*, since that bit hasn't been synchronized at the time the function is called.  Other changes to make things a bit safer/more reliable are:
- adding invalid values for the LayerTextureUpdater enums and initializing the values on LayerTilerChromium explicitly
- initializing CCLayerImpl::m_drawsContent explicitly (oops).

passes all tests on linux in release _and_ debug so should be good to go.
Comment 21 Adrienne Walker 2011-07-12 18:05:52 PDT
(In reply to comment #20)
> Patch updated.  The change between the previous version that fixes the bug is changing LayerRendererChromium::updateCompositorResources() to check drawsContent() on the LayerChromium* instead of the CCLayerImpl*, since that bit hasn't been synchronized at the time the function is called.  Other changes to make things a bit safer/more reliable are:
> - adding invalid values for the LayerTextureUpdater enums and initializing the values on LayerTilerChromium explicitly
> - initializing CCLayerImpl::m_drawsContent explicitly (oops).
> 
> passes all tests on linux in release _and_ debug so should be good to go.

Those changes unofficially look good to me.
Comment 22 Kenneth Russell 2011-07-13 14:56:38 PDT
Comment on attachment 100599 [details]
Patch

Sounds fine. rs=me
Comment 23 WebKit Review Bot 2011-07-13 16:15:10 PDT
Comment on attachment 100599 [details]
Patch

Clearing flags on attachment: 100599

Committed r90963: <http://trac.webkit.org/changeset/90963>
Comment 24 WebKit Review Bot 2011-07-13 16:15:15 PDT
All reviewed patches have been landed.  Closing bug.