Changeset 95957 in webkit


Ignore:
Timestamp:
Sep 26, 2011 9:44:18 AM (13 years ago)
Author:
enne@google.com
Message:

[chromium] Update VideoLayerChromium textures after texture resources are reclaimed
https://bugs.webkit.org/show_bug.cgi?id=68742

Reviewed by James Robinson.

Source/WebCore:

If video textures are reclaimed (such as during a visibility change on
a tab), the dirty rect for the layer is empty and it skips out of
updating compositor resources, leaving the video textures invalid.
Instead, check the textures here to make sure they're still valid
first before early out so that they can get reupdated if necessary.

Additionally, fix a small bug in pushPropertiesTo where 1 plane RGB
videos would not get drawn because all 3 planes didn't have valid
textures.

Test: compositing/video-page-visibility.html

  • platform/graphics/chromium/VideoLayerChromium.cpp:

(WebCore::VideoLayerChromium::VideoLayerChromium):
(WebCore::VideoLayerChromium::cleanupResources):
(WebCore::VideoLayerChromium::updateCompositorResources):
(WebCore::VideoLayerChromium::pushPropertiesTo):
(WebCore::VideoLayerChromium::setLayerTreeHost):
(WebCore::VideoLayerChromium::texturesValid):

  • platform/graphics/chromium/VideoLayerChromium.h:

LayoutTests:

Without this patch, this video texture is invalid.

  • compositing/video-page-visibility-expected.png: Added.
  • compositing/video-page-visibility-expected.txt: Added.
  • compositing/video-page-visibility.html: Added.
Location:
trunk
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r95956 r95957  
     12011-09-23  Adrienne Walker  <enne@google.com>
     2
     3        [chromium] Update VideoLayerChromium textures after texture resources are reclaimed
     4        https://bugs.webkit.org/show_bug.cgi?id=68742
     5
     6        Reviewed by James Robinson.
     7
     8        Without this patch, this video texture is invalid.
     9
     10        * compositing/video-page-visibility-expected.png: Added.
     11        * compositing/video-page-visibility-expected.txt: Added.
     12        * compositing/video-page-visibility.html: Added.
     13
    1142011-09-26  Ilya Tikhonovsky  <loislo@chromium.org>
    215
  • trunk/Source/WebCore/ChangeLog

    r95953 r95957  
     12011-09-23  Adrienne Walker  <enne@google.com>
     2
     3        [chromium] Update VideoLayerChromium textures after texture resources are reclaimed
     4        https://bugs.webkit.org/show_bug.cgi?id=68742
     5
     6        Reviewed by James Robinson.
     7
     8        If video textures are reclaimed (such as during a visibility change on
     9        a tab), the dirty rect for the layer is empty and it skips out of
     10        updating compositor resources, leaving the video textures invalid.
     11        Instead, check the textures here to make sure they're still valid
     12        first before early out so that they can get reupdated if necessary.
     13
     14        Additionally, fix a small bug in pushPropertiesTo where 1 plane RGB
     15        videos would not get drawn because all 3 planes didn't have valid
     16        textures.
     17
     18        Test: compositing/video-page-visibility.html
     19
     20        * platform/graphics/chromium/VideoLayerChromium.cpp:
     21        (WebCore::VideoLayerChromium::VideoLayerChromium):
     22        (WebCore::VideoLayerChromium::cleanupResources):
     23        (WebCore::VideoLayerChromium::updateCompositorResources):
     24        (WebCore::VideoLayerChromium::pushPropertiesTo):
     25        (WebCore::VideoLayerChromium::setLayerTreeHost):
     26        (WebCore::VideoLayerChromium::texturesValid):
     27        * platform/graphics/chromium/VideoLayerChromium.h:
     28
    1292011-09-26  Pavel Feldman  <pfeldman@google.com>
    230
  • trunk/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp

    r95901 r95957  
    5656    , m_frameFormat(VideoFrameChromium::Invalid)
    5757    , m_provider(provider)
     58    , m_planes(0)
    5859    , m_currentFrame(0)
    5960{
     
    7374{
    7475    LayerChromium::cleanupResources();
    75     for (size_t i = 0; i < 3; ++i)
     76    for (unsigned i = 0; i < MaxPlanes; ++i)
    7677        m_textures[i].m_texture.clear();
    7778    releaseCurrentFrame();
     
    8081void VideoLayerChromium::updateCompositorResources(GraphicsContext3D* context)
    8182{
    82     if (m_dirtyRect.isEmpty() || !m_delegate)
    83         return;
     83    if (!m_delegate)
     84        return;
     85
     86    if (m_dirtyRect.isEmpty() && texturesValid()) {
     87        for (unsigned plane = 0; plane < m_planes; plane++) {
     88            ManagedTexture* tex = m_textures[plane].m_texture.get();
     89            if (!tex->reserve(tex->size(), tex->format())) {
     90                m_skipsDraw = true;
     91                break;
     92            }
     93        }
     94        return;
     95    }
    8496
    8597    ASSERT(drawsContent());
    8698
     99    m_planes = 0;
    87100    m_skipsDraw = false;
     101
    88102    VideoFrameChromium* frame = m_provider->getCurrentFrame();
    89103    if (!frame) {
     
    120134    }
    121135
     136    m_planes = frame->planes();
     137    ASSERT(m_planes <= MaxPlanes);
     138
    122139    resetNeedsDisplay();
    123140
     
    132149    videoLayer->setSkipsDraw(m_skipsDraw);
    133150    videoLayer->setFrameFormat(m_frameFormat);
    134     for (size_t i = 0; i < 3; ++i) {
     151    for (unsigned i = 0; i < m_planes; ++i) {
    135152        if (!m_textures[i].m_texture) {
    136153            videoLayer->setSkipsDraw(true);
     
    139156        videoLayer->setTexture(i, m_textures[i].m_texture->textureId(), m_textures[i].m_texture->size(), m_textures[i].m_visibleSize);
    140157    }
     158    for (unsigned i = m_planes; i < MaxPlanes; ++i)
     159        videoLayer->setTexture(i, 0, IntSize(), IntSize());
    141160}
    142161
     
    144163{
    145164    if (host && layerTreeHost() != host) {
    146         for (size_t i = 0; i < 3; ++i) {
     165        for (unsigned i = 0; i < MaxPlanes; ++i) {
    147166            m_textures[i].m_visibleSize = IntSize();
    148167            m_textures[i].m_texture = ManagedTexture::create(host->contentsTextureManager());
     
    165184    }
    166185    return GraphicsContext3D::INVALID_VALUE;
     186}
     187
     188bool VideoLayerChromium::texturesValid()
     189{
     190    for (unsigned plane = 0; plane < m_planes; plane++) {
     191        ManagedTexture* tex = m_textures[plane].m_texture.get();
     192        if (!tex->isValid(tex->size(), tex->format()))
     193            return false;
     194    }
     195    return true;
    167196}
    168197
  • trunk/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.h

    r95901 r95957  
    7575    static GC3Denum determineTextureFormat(const VideoFrameChromium*);
    7676    static IntSize computeVisibleSize(const VideoFrameChromium*, unsigned plane);
     77    bool texturesValid();
    7778    bool reserveTextures(const VideoFrameChromium*, GC3Denum textureFormat);
    7879    void updateTexture(GraphicsContext3D*, Texture&, const void*) const;
     
    8485    VideoFrameProvider* m_provider;
    8586
    86     Texture m_textures[3];
     87    enum { MaxPlanes = 3 };
     88    Texture m_textures[MaxPlanes];
     89    unsigned m_planes;
    8790
    8891    // This will be null for the entire duration of video playback if hardware
Note: See TracChangeset for help on using the changeset viewer.