diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-10-15 14:41:45 +0200 |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-11-25 16:27:13 +0100 |
commit | 3f08d8a506241bf9b9cdfb2be37f8a3868869adf (patch) | |
tree | 481555f802ae812bc5933867b3449f89ff69948f /src/core/delegated_frame_node.cpp | |
parent | db3d2a61ec427254323809970b4c5880e7727d61 (diff) |
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 <zeno.albisser@digia.com>
Diffstat (limited to 'src/core/delegated_frame_node.cpp')
-rw-r--r-- | src/core/delegated_frame_node.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
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<MailboxTexture> &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. |