bool VideoLayerChromium::reserveTextures(const VideoFrameChromium* frame, GC3Denum textureFormat) { ASSERT(layerTreeHost()); ASSERT(frame); ASSERT(textureFormat != GraphicsContext3D::INVALID_VALUE); int maxTextureSize = layerTreeHost()->layerRendererCapabilities().maxTextureSize; for (unsigned plane = 0; plane < frame->planes(); plane++) { IntSize requiredTextureSize = frame->requiredTextureSize(plane); // If the renderer cannot handle this large of a texture, return false. // FIXME: Remove this test when tiled layers are implemented. if (requiredTextureSize.isZero() || requiredTextureSize.width() > maxTextureSize || requiredTextureSize.height() > maxTextureSize) return false; if (!m_textures[plane].m_texture) return false; if (m_textures[plane].m_texture->size() != requiredTextureSize) m_textures[plane].m_visibleSize = computeVisibleSize(frame, plane); m_textures[plane].m_texture->reserve(requiredTextureSize, textureFormat); } return true; }
bool CCVideoLayerImpl::allocatePlaneData(CCRenderer* layerRenderer) { int maxTextureSize = layerRenderer->capabilities().maxTextureSize; for (unsigned planeIndex = 0; planeIndex < m_frame->planes(); ++planeIndex) { CCVideoLayerImpl::FramePlane& plane = m_framePlanes[planeIndex]; IntSize requiredTextureSize(m_frame->stride(planeIndex), videoFrameDimension(m_frame->height(), planeIndex, m_frame->format())); // FIXME: Remove the test against maxTextureSize when tiled layers are implemented. if (requiredTextureSize.isZero() || requiredTextureSize.width() > maxTextureSize || requiredTextureSize.height() > maxTextureSize) return false; if (plane.size != requiredTextureSize || plane.format != m_format) { plane.freeData(layerRenderer); plane.size = requiredTextureSize; plane.format = m_format; } if (!plane.textureId) { if (!plane.allocateData(layerRenderer)) return false; plane.visibleSize = computeVisibleSize(*m_frame, planeIndex); } } return true; }
bool CCVideoLayerImpl::reserveTextures(const VideoFrameChromium* frame, GC3Denum format, LayerRendererChromium* layerRenderer) { if (frame->planes() > MaxPlanes) return false; int maxTextureSize = layerRenderer->capabilities().maxTextureSize; for (unsigned plane = 0; plane < frame->planes(); ++plane) { IntSize requiredTextureSize = frame->requiredTextureSize(plane); // If the renderer cannot handle this large of a texture, return false. // FIXME: Remove this test when tiled layers are implemented. if (requiredTextureSize.isZero() || requiredTextureSize.width() > maxTextureSize || requiredTextureSize.height() > maxTextureSize) return false; if (!m_textures[plane].m_texture) { m_textures[plane].m_texture = ManagedTexture::create(layerRenderer->renderSurfaceTextureManager()); if (!m_textures[plane].m_texture) return false; m_textures[plane].m_visibleSize = IntSize(); } else { // The renderSurfaceTextureManager may have been destroyed and recreated since the last frame, so pass the new one. // This is a no-op if the TextureManager is still around. m_textures[plane].m_texture->setTextureManager(layerRenderer->renderSurfaceTextureManager()); } if (m_textures[plane].m_texture->size() != requiredTextureSize) m_textures[plane].m_visibleSize = computeVisibleSize(frame, plane); if (!m_textures[plane].m_texture->reserve(requiredTextureSize, format)) return false; } return true; }