void VideoLayerChromium::updateCompositorResources(GraphicsContext3D* context) { if (!m_contentsDirty || !m_delegate) return; ASSERT(drawsContent()); m_skipsDraw = false; VideoFrameChromium* frame = m_provider->getCurrentFrame(); if (!frame) { m_skipsDraw = true; m_provider->putCurrentFrame(frame); return; } m_frameFormat = frame->format(); GC3Denum textureFormat = determineTextureFormat(frame); if (textureFormat == GraphicsContext3D::INVALID_VALUE) { // FIXME: Implement other paths. notImplemented(); m_skipsDraw = true; m_provider->putCurrentFrame(frame); return; } // Allocate textures for planes if they are not allocated already, or // reallocate textures that are the wrong size for the frame. bool texturesReserved = reserveTextures(frame, textureFormat); if (!texturesReserved) { m_skipsDraw = true; m_provider->putCurrentFrame(frame); return; } // Update texture planes. for (unsigned plane = 0; plane < frame->planes(); plane++) { Texture& texture = m_textures[plane]; ASSERT(texture.m_texture); ASSERT(frame->requiredTextureSize(plane) == texture.m_texture->size()); updateTexture(context, texture, frame->data(plane)); } m_dirtyRect.setSize(FloatSize()); m_contentsDirty = false; m_provider->putCurrentFrame(frame); }
void VideoLayerChromium::updateContentsIfDirty() { if (!m_contentsDirty) return; RenderLayerBacking* backing = static_cast<RenderLayerBacking*>(m_owner->client()); if (!backing || backing->paintingGoesToWindow()) return; ASSERT(drawsContent()); m_skipsDraw = false; VideoFrameChromium* frame = m_provider->getCurrentFrame(); if (!frame) { m_skipsDraw = true; m_provider->putCurrentFrame(frame); return; } m_frameFormat = frame->format(); unsigned textureFormat = determineTextureFormat(frame); if (textureFormat == GraphicsContext3D::INVALID_VALUE) { // FIXME: Implement other paths. notImplemented(); m_skipsDraw = true; m_provider->putCurrentFrame(frame); return; } if (frame->surfaceType() == VideoFrameChromium::TypeTexture) { releaseCurrentFrame(); saveCurrentFrame(frame); m_dirtyRect.setSize(FloatSize()); m_contentsDirty = false; return; } // Allocate textures for planes if they are not allocated already, or // reallocate textures that are the wrong size for the frame. GraphicsContext3D* context = layerRendererContext(); bool texturesAllocated = allocateTexturesIfNeeded(context, frame, textureFormat); if (!texturesAllocated) { m_skipsDraw = true; m_provider->putCurrentFrame(frame); return; } // Update texture planes. for (unsigned plane = 0; plane < frame->planes(); plane++) { ASSERT(frame->requiredTextureSize(plane) == m_textureSizes[plane]); updateTexture(context, m_textures[plane], frame->requiredTextureSize(plane), textureFormat, frame->data(plane)); } m_dirtyRect.setSize(FloatSize()); m_contentsDirty = false; m_provider->putCurrentFrame(frame); }