diff --git a/es-app/src/components/RatingComponent.cpp b/es-app/src/components/RatingComponent.cpp index 73e18edb06..4a06cf142f 100644 --- a/es-app/src/components/RatingComponent.cpp +++ b/es-app/src/components/RatingComponent.cpp @@ -76,9 +76,9 @@ void RatingComponent::onSizeChanged() void RatingComponent::updateVertices() { const float numStars = NUM_RATING_STARS; - const float h = Math::round(getSize().y()); // is the same as a single star's width - const float w = Math::round(h * mValue * numStars); - const float fw = Math::round(h * numStars); + const float h = getSize().y(); // is the same as a single star's width + const float w = getSize().y() * mValue * numStars; + const float fw = getSize().y() * numStars; const unsigned int color = Renderer::convertColor(mColorShift); mVertices[0] = { { 0.0f, 0.0f }, { 0.0f, 1.0f }, color }; @@ -90,6 +90,10 @@ void RatingComponent::updateVertices() mVertices[5] = { { 0.0f, h }, { 0.0f, 0.0f }, color }; mVertices[6] = { { fw, 0.0f }, { numStars, 1.0f }, color }; mVertices[7] = { { fw, h }, { numStars, 0.0f }, color }; + + // round vertices + for(int i = 0; i < 8; ++i) + mVertices[i].pos.round(); } void RatingComponent::updateColors() diff --git a/es-core/src/components/ImageComponent.cpp b/es-core/src/components/ImageComponent.cpp index 8f78aaac54..6ad41d18e8 100644 --- a/es-core/src/components/ImageComponent.cpp +++ b/es-core/src/components/ImageComponent.cpp @@ -282,9 +282,8 @@ void ImageComponent::updateVertices() // we go through this mess to make sure everything is properly rounded // if we just round vertices at the end, edge cases occur near sizes of 0.5 - const Vector2f size = { Math::round(mSize.x()), Math::round(mSize.y()) }; - const Vector2f topLeft = { size * mTopLeftCrop }; - const Vector2f bottomRight = { size * mBottomRightCrop }; + const Vector2f topLeft = { mSize * mTopLeftCrop }; + const Vector2f bottomRight = { mSize * mBottomRightCrop }; const float px = mTexture->isTiled() ? mSize.x() / getTextureSize().x() : 1.0f; const float py = mTexture->isTiled() ? mSize.y() / getTextureSize().y() : 1.0f; const unsigned int color = Renderer::convertColor(mColorShift); @@ -295,14 +294,19 @@ void ImageComponent::updateVertices() mVertices[2] = { { bottomRight.x(), topLeft.y() }, { mBottomRightCrop.x() * px, py - mTopLeftCrop.y() }, mColorGradientHorizontal ? color : colorEnd }; mVertices[3] = { { bottomRight.x(), bottomRight.y() }, { mBottomRightCrop.x() * px, 1.0f - mBottomRightCrop.y() }, color }; + // round vertices + for(int i = 0; i < 4; ++i) + mVertices[i].pos.round(); + if(mFlipX) { - for(int i = 0; i < 4; i++) + for(int i = 0; i < 4; ++i) mVertices[i].tex[0] = px - mVertices[i].tex[0]; } + if(mFlipY) { - for(int i = 0; i < 4; i++) + for(int i = 0; i < 4; ++i) mVertices[i].tex[1] = py - mVertices[i].tex[1]; } } diff --git a/es-core/src/components/NinePatchComponent.cpp b/es-core/src/components/NinePatchComponent.cpp index 96301de107..6ab1c89a04 100644 --- a/es-core/src/components/NinePatchComponent.cpp +++ b/es-core/src/components/NinePatchComponent.cpp @@ -56,10 +56,10 @@ void NinePatchComponent::buildVertices() const float imgPosY[3] = { 0, imgSizeY[0], imgSizeY[0] + imgSizeY[1]}; //the "1 +" in posY and "-" in sizeY is to deal with texture coordinates having a bottom left corner origin vs. verticies having a top left origin - const float texSizeX[3] = { mCornerSize.x() / texSize.x(), (texSize.x() - mCornerSize.x() * 2) / texSize.x(), mCornerSize.x() / texSize.x() }; - const float texSizeY[3] = { -mCornerSize.y() / texSize.y(), -(texSize.y() - mCornerSize.y() * 2) / texSize.y(), -mCornerSize.y() / texSize.y() }; - const float texPosX[3] = { 0, texSizeX[0], texSizeX[0] + texSizeX[1] }; - const float texPosY[3] = { 1, 1 + texSizeY[0], 1 + texSizeY[0] + texSizeY[1] }; + const float texSizeX[3] = { mCornerSize.x() / texSize.x(), (texSize.x() - mCornerSize.x() * 2) / texSize.x(), mCornerSize.x() / texSize.x() }; + const float texSizeY[3] = { -mCornerSize.y() / texSize.y(), -(texSize.y() - mCornerSize.y() * 2) / texSize.y(), -mCornerSize.y() / texSize.y() }; + const float texPosX[3] = { 0, texSizeX[0], texSizeX[0] + texSizeX[1] }; + const float texPosY[3] = { 1, 1 + texSizeY[0], 1 + texSizeY[0] + texSizeY[1] }; int v = 0; for(int slice = 0; slice < 9; slice++) @@ -76,6 +76,10 @@ void NinePatchComponent::buildVertices() mVertices[v + 3] = { { imgPos.x() + imgSize.x(), imgPos.y() }, { texPos.x() + texSize.x(), texPos.y() }, 0 }; mVertices[v + 4] = { { imgPos.x() + imgSize.x(), imgPos.y() + imgSize.y() }, { texPos.x() + texSize.x(), texPos.y() + texSize.y() }, 0 }; + // round vertices + for(int i = 1; i < 5; ++i) + mVertices[v + i].pos.round(); + // make duplicates of first and last vertex so this can be rendered as a triangle strip mVertices[v + 0] = mVertices[v + 1]; mVertices[v + 5] = mVertices[v + 4]; @@ -83,12 +87,6 @@ void NinePatchComponent::buildVertices() v += 6; } - // round vertices - for(int i = 0; i < 6*9; i++) - { - mVertices[i].pos.round(); - } - updateColors(); } diff --git a/es-core/src/components/VideoVlcComponent.cpp b/es-core/src/components/VideoVlcComponent.cpp index ac163d28c7..a4aeaf111a 100644 --- a/es-core/src/components/VideoVlcComponent.cpp +++ b/es-core/src/components/VideoVlcComponent.cpp @@ -137,7 +137,6 @@ void VideoVlcComponent::render(const Transform4x4f& parentTrans) VideoComponent::render(parentTrans); Transform4x4f trans = parentTrans * getTransform(); GuiComponent::renderChildren(trans); - Renderer::setMatrix(trans); if (mIsPlaying && mContext.valid) @@ -151,6 +150,10 @@ void VideoVlcComponent::render(const Transform4x4f& parentTrans) vertices[2] = { { mSize.x(), 0.0f }, { 1.0f, 0.0f }, color }; vertices[3] = { { mSize.x(), mSize.y() }, { 1.0f, 1.0f }, color }; + // round vertices + for(int i = 0; i < 4; ++i) + vertices[i].pos.round(); + // Build a texture for the video frame mTexture->initFromPixels((unsigned char*)mContext.surface->pixels, mContext.surface->w, mContext.surface->h); mTexture->bind(); diff --git a/es-core/src/renderers/Renderer.cpp b/es-core/src/renderers/Renderer.cpp index e0c841891d..003e4ac489 100644 --- a/es-core/src/renderers/Renderer.cpp +++ b/es-core/src/renderers/Renderer.cpp @@ -238,10 +238,6 @@ namespace Renderer void drawRect(const float _x, const float _y, const float _w, const float _h, const unsigned int _color, const unsigned int _colorEnd, bool horizontalGradient, const Blend::Factor _srcBlendFactor, const Blend::Factor _dstBlendFactor) { - const float x = Math::round(_x); - const float y = Math::round(_y); - const float w = Math::round(_w); - const float h = Math::round(_h); const unsigned int color = convertColor(_color); const unsigned int colorEnd = convertColor(_colorEnd); Vertex vertices[4]; @@ -251,6 +247,10 @@ namespace Renderer vertices[2] = { { _x + _w,_y }, { 0.0f, 0.0f }, horizontalGradient ? color : colorEnd }; vertices[3] = { { _x + _w,_y + _h }, { 0.0f, 0.0f }, colorEnd }; + // round vertices + for(int i = 0; i < 4; ++i) + vertices[i].pos.round(); + bindTexture(0); drawTriangleStrips(vertices, 4, _srcBlendFactor, _dstBlendFactor); diff --git a/es-core/src/resources/Font.cpp b/es-core/src/resources/Font.cpp index ad8e671d4f..440540cf28 100644 --- a/es-core/src/resources/Font.cpp +++ b/es-core/src/resources/Font.cpp @@ -604,10 +604,14 @@ TextCache* Font::buildTextCache(const std::string& text, Vector2f offset, unsign const Vector2i& textureSize = glyph->texture->textureSize; const unsigned int convertedColor = Renderer::convertColor(color); - vertices[1] = { { Math::round(glyphStartX ), Math::round(y - glyph->bearing.y() ) }, { glyph->texPos.x(), glyph->texPos.y() }, convertedColor }; - vertices[2] = { { Math::round(glyphStartX ), Math::round(y - glyph->bearing.y() + (glyph->texSize.y() * textureSize.y())) }, { glyph->texPos.x(), glyph->texPos.y() + glyph->texSize.y() }, convertedColor }; - vertices[3] = { { Math::round(glyphStartX + glyph->texSize.x() * textureSize.x()), Math::round(y - glyph->bearing.y() ) }, { glyph->texPos.x() + glyph->texSize.x(), glyph->texPos.y() }, convertedColor }; - vertices[4] = { { Math::round(glyphStartX + glyph->texSize.x() * textureSize.x()), Math::round(y - glyph->bearing.y() + (glyph->texSize.y() * textureSize.y())) }, { glyph->texPos.x() + glyph->texSize.x(), glyph->texPos.y() + glyph->texSize.y() }, convertedColor }; + vertices[1] = { { glyphStartX , y - glyph->bearing.y() }, { glyph->texPos.x(), glyph->texPos.y() }, convertedColor }; + vertices[2] = { { glyphStartX , y - glyph->bearing.y() + (glyph->texSize.y() * textureSize.y()) }, { glyph->texPos.x(), glyph->texPos.y() + glyph->texSize.y() }, convertedColor }; + vertices[3] = { { glyphStartX + glyph->texSize.x() * textureSize.x(), y - glyph->bearing.y() }, { glyph->texPos.x() + glyph->texSize.x(), glyph->texPos.y() }, convertedColor }; + vertices[4] = { { glyphStartX + glyph->texSize.x() * textureSize.x(), y - glyph->bearing.y() + (glyph->texSize.y() * textureSize.y()) }, { glyph->texPos.x() + glyph->texSize.x(), glyph->texPos.y() + glyph->texSize.y() }, convertedColor }; + + // round vertices + for(int i = 1; i < 5; ++i) + vertices[i].pos.round(); // make duplicates of first and last vertex so this can be rendered as a triangle strip vertices[0] = vertices[1];