Bug 107099

Summary: Coordinated Graphics: Remove m_pendingSyncBackingStores in LayerTreeRenderer.
Product: WebKit Reporter: Dongseong Hwang <dongseong.hwang>
Component: Layout and RenderingAssignee: Dongseong Hwang <dongseong.hwang>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, laszlo.gombos, noam, ostap73, webkit.review.bot, zeno
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 105787    
Bug Blocks: 103854, 107073    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch for landing none

Description Dongseong Hwang 2013-01-16 23:34:46 PST
LayerTreeRenderer difficultly uses m_pendingSyncBackingStores to set a backing
store to TextureMapperLayer, although LayerTreeRenderer easily sets a direct
composited image to TextureMapperLayer. It is because LayerTreeRenderer directly
set a backing store to TextureMapperLayer, instead of GraphicsLayerTextureMapper.

This patch makes LayerTreeRenderer set a backing store to GraphicsLayerTextureMapper
and then GraphicsLayerTextureMapper will set a backing store to TextureMapperLayer
like other members.
Comment 1 Dongseong Hwang 2013-01-16 23:42:07 PST
Created attachment 183130 [details]
Patch
Comment 2 Dongseong Hwang 2013-01-17 02:17:28 PST
Created attachment 183153 [details]
Patch
Comment 3 Dongseong Hwang 2013-01-17 17:43:40 PST
Created attachment 183330 [details]
Patch
Comment 4 Dongseong Hwang 2013-01-17 18:02:40 PST
Created attachment 183335 [details]
Patch
Comment 5 Noam Rosenthal 2013-01-24 02:36:29 PST
Please put it up for review when it applies :)
Comment 6 Dongseong Hwang 2013-01-24 21:45:17 PST
Created attachment 184659 [details]
Patch
Comment 7 Dongseong Hwang 2013-01-25 02:02:44 PST
Created attachment 184704 [details]
Patch
Comment 8 Dongseong Hwang 2013-01-25 06:02:20 PST
(In reply to comment #5)
> Please put it up for review when it applies :)

Now could you review? :)
Comment 9 Noam Rosenthal 2013-01-25 06:12:34 PST
Comment on attachment 184704 [details]
Patch

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

I'm fine with this, needs a WK2 owner to review; they might want more explanations...

> Source/WebKit2/ChangeLog:15
> +        LayerTreeRenderer difficultly uses m_pendingSyncBackingStores to set a backing
> +        store to TextureMapperLayer, although LayerTreeRenderer easily sets a direct
> +        composited image to TextureMapperLayer. It is because LayerTreeRenderer directly
> +        set a backing store to TextureMapperLayer, instead of GraphicsLayerTextureMapper.
> +
> +        This patch makes LayerTreeRenderer set a backing store to GraphicsLayerTextureMapper
> +        and then GraphicsLayerTextureMapper will set a backing store to TextureMapperLayer
> +        like other members.

Allow me to propose an alternative wording for the explanation :)
Instead of queuing the setting of backing stores in LayerTreeRenderer, and then setting them directly to TextureMapperLayer,
we allow GraphicsLayerTextureMapper's existing queuing mechanism to handle that.
Instead of a m_pendingSyncBackingStores queue, we have a m_backingStores queue which can be applied much more easily to the layer tree.
Comment 10 Dongseong Hwang 2013-01-28 17:38:49 PST
Created attachment 185117 [details]
Patch
Comment 11 Dongseong Hwang 2013-01-28 17:47:19 PST
(In reply to comment #9)
> (From update of attachment 184704 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=184704&action=review
> 
> I'm fine with this, needs a WK2 owner to review; they might want more explanations...

Thank you for your favor as well as review!

I'll ask WK2 owner. Now this bug depends on Bug 105787.
Comment 12 Dongseong Hwang 2013-01-28 22:59:48 PST
Created attachment 185169 [details]
Patch
Comment 13 Benjamin Poulain 2013-01-29 14:58:47 PST
Comment on attachment 185169 [details]
Patch

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

I am okay with this for WebKit2, with comments.

Noam, your call for the r+.

> Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h:159
> -    RefPtr<TextureMapperBackingStore> m_backingStore;
> +    TextureMapperBackingStore* m_backingStore;

Just a comment: For this, you must have a strong guarantee that TextureMapperBackingStore always outlive TextureMapperLayer.

Here the guarantee is m_releasedCoordinatedBackingStores. I think the ownership is too convoluted.

> Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp:414
> +    CoordinatedBackingStore* backingStore = 0;
> +    BackingStoreMap::iterator it = m_backingStores.find(graphicsLayer);
> +    if (it != m_backingStores.end())
>          backingStore = it->value.get();
>      return backingStore;

This is what HashMap::get() is for.
Comment 14 Dongseong Hwang 2013-01-29 21:11:41 PST
(In reply to comment #13)
> (From update of attachment 185169 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=185169&action=review
> 
> I am okay with this for WebKit2, with comments.
> 
> Noam, your call for the r+.

Thank you for review!

> > Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h:159
> > -    RefPtr<TextureMapperBackingStore> m_backingStore;
> > +    TextureMapperBackingStore* m_backingStore;
> 
> Just a comment: For this, you must have a strong guarantee that TextureMapperBackingStore always outlive TextureMapperLayer.
> Here the guarantee is m_releasedCoordinatedBackingStores. I think the ownership is too convoluted.

m_releasedCoordinatedBackingStores is already existing and this bug uses it.
I agree that m_releasedCoordinatedBackingStores is convoluted, so I will remove this twisted lifecycle management after Bug 103854.
It is because Bug 103854 will remove the time gap between setting platform layer and flushing layer scene info.

> > Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp:414
> > +    CoordinatedBackingStore* backingStore = 0;
> > +    BackingStoreMap::iterator it = m_backingStores.find(graphicsLayer);
> > +    if (it != m_backingStores.end())
> >          backingStore = it->value.get();
> >      return backingStore;
> 
> This is what HashMap::get() is for.

Oh, I had put lots of above redundant code. someday I'll get rid of all. Thank you.
Comment 15 Dongseong Hwang 2013-01-29 21:54:57 PST
Created attachment 185396 [details]
Patch
Comment 16 Dongseong Hwang 2013-01-29 21:55:49 PST
(In reply to comment #13)
> (From update of attachment 185169 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=185169&action=review
> 
> I am okay with this for WebKit2, with comments.
> 
> Noam, your call for the r+.

Noam, could you review this bug?
Comment 17 Benjamin Poulain 2013-01-29 22:05:58 PST
Comment on attachment 185396 [details]
Patch

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

> Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp:420
> +    if (m_backingStores.get(graphicsLayer))

To test if a key exists in a HashMap/HashSet, the correct thing to do is HashMap::contains().

> Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp:435
> +    if (!m_backingStores.get(graphicsLayer))
>          return;
> -    }
>  
> -    if (!layer->backingStore())
> -        return; // The layer has no backing store (and no pending addition).
> -
> -    ASSERT(!m_pendingSyncBackingStores.contains(layer));
> -    m_pendingSyncBackingStores.add(layer, 0);
> +    m_releasedCoordinatedBackingStores.append(m_backingStores.take(graphicsLayer));
> +    toGraphicsLayerTextureMapper(graphicsLayer)->setBackingStore(0);

This particular code should be using iterators. Otherwise you are doing get() twice.
Comment 18 Dongseong Hwang 2013-01-29 22:56:14 PST
Created attachment 185400 [details]
Patch
Comment 19 Dongseong Hwang 2013-01-29 22:59:25 PST
(In reply to comment #17)
> (From update of attachment 185396 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=185396&action=review
> To test if a key exists in a HashMap/HashSet, the correct thing to do is HashMap::contains().
> This particular code should be using iterators. Otherwise you are doing get() twice.

Oh, you are right! Done.

(In reply to comment #13)
> (From update of attachment 185169 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=185169&action=review
> Just a comment: For this, you must have a strong guarantee that TextureMapperBackingStore always outlive TextureMapperLayer.
> Here the guarantee is m_releasedCoordinatedBackingStores. I think the ownership is too convoluted.

After rethinking, I understand this patch does not need to use m_releasedCoordinatedBackingStores. TextureMapperLayer still have RefPtr<TextureMapperBackingStore>.
As I mentioned, m_releasedImageBackings is still alive and I'll kill in Bug 108296.
Comment 20 Noam Rosenthal 2013-01-29 23:34:43 PST
Comment on attachment 185400 [details]
Patch

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

Some nitpick in the changelog, otherwise good to go. Also seems that you have addressed all of Benjamin's concerns.

> Source/WebCore/ChangeLog:12
> +        because of dead code now.

because of dead code now -> because they are no longer used.
Comment 21 Dongseong Hwang 2013-01-29 23:38:45 PST
Created attachment 185407 [details]
Patch for landing
Comment 22 WebKit Review Bot 2013-01-30 00:24:30 PST
Comment on attachment 185407 [details]
Patch for landing

Clearing flags on attachment: 185407

Committed r141232: <http://trac.webkit.org/changeset/141232>
Comment 23 WebKit Review Bot 2013-01-30 00:24:36 PST
All reviewed patches have been landed.  Closing bug.