From 3f08d8a506241bf9b9cdfb2be37f8a3868869adf Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Wed, 15 Oct 2014 14:41:45 +0200 Subject: Don't rely on quads to set the texture size What really matters with texture coordinates is the normalized 0-1 coordinate that will end up on vertex attributes. By default QSGSimpleTextureNode will use the full texture size to calculate those coordinates. In that case any texture size will end up with the same (0,0)-(1,1) coordinates, so we don't really need to set the actual texel size of the texture. So instead of relying on dependent quads to come back and set the size on the texture, do like the Chromium compositor does and just make sure that the full normalized texture rect is set on vertices if no texture size was provided on the resource. Since the scene graph doesn't achieve this behavior by default with an empty texture size, set a 1x1 size to get it to do what we want. Change-Id: I48751d2c2f6ea82dcb4bec9e984b64f7e77316f6 Reviewed-by: Zeno Albisser --- src/core/delegated_frame_node.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp index 375a10713..d1e01cac0 100644 --- a/src/core/delegated_frame_node.cpp +++ b/src/core/delegated_frame_node.cpp @@ -348,6 +348,12 @@ MailboxTexture::MailboxTexture(const cc::TransferableResource &resource) , m_importCount(1) { initializeOpenGLFunctions(); + + // Assume that resources without a size will be used with a full source rect. + // Setting a size of 1x1 will let any texture node compute a normalized source + // rect of (0, 0) to (1, 1) while an empty texture size would set (0, 0) on all corners. + if (m_textureSize.isEmpty()) + m_textureSize = QSize(1, 1); } void MailboxTexture::bind() @@ -570,9 +576,6 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData, const cc::TextureDrawQuad *tquad = cc::TextureDrawQuad::MaterialCast(quad); QSharedPointer &texture = findMailboxTexture(tquad->resource_id, m_chromiumCompositorData->mailboxTextures, mailboxTextureCandidates); - // FIXME: TransferableResource::size isn't always set properly for TextureDrawQuads, use the size of its DrawQuad::rect instead. - texture->setTextureSize(toQt(quad->rect.size())); - // TransferableResource::format seems to always be GL_BGRA even though it might not // contain any pixel with alpha < 1.0. The information about if they need blending // for the contents itself is actually stored in quads. -- cgit v1.2.3