diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2016-05-31 12:26:04 +0900 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2016-06-08 11:39:22 +0900 |
commit | 18260a0d9a381a105ffb032ee8f1050c77062102 (patch) | |
tree | 8ebdd55593e4d7efe718ee8a8282d37cc0776c4e /vcl/opengl/RenderList.cxx | |
parent | bb157523310eb237dc16818f24df58d110242367 (diff) |
opengl: deferred texture drawing in RenderList, add drawAlphaRect
Drawing accumulated textures (in Accumulatedtextures) is independent
of drawing with render list which causes problems with rendering
order when render list and accumulated textures are flushed. To
solve this we need to combine both so we can check for overlapped
drawing.
Previously drawRect was using RenderList batch drawing but not
drawAlphaRect which is essentially the same as drawRect but
additionally supports alpha value. This adds support to draw
alpha rectangles to RenderList and converts drawAlphaRect.
Change-Id: I82bf0b410e5ebabb13bab7b29a2e53a6fdaa404f
Diffstat (limited to 'vcl/opengl/RenderList.cxx')
-rw-r--r-- | vcl/opengl/RenderList.cxx | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/vcl/opengl/RenderList.cxx b/vcl/opengl/RenderList.cxx index de5a9d6dc02a..818831950aaf 100644 --- a/vcl/opengl/RenderList.cxx +++ b/vcl/opengl/RenderList.cxx @@ -52,10 +52,13 @@ void RenderList::addDrawPixel(long nX, long nY, const SalColor& rColor) vcl::vertex::addQuadEmptyExtrusionVectors<GL_TRIANGLES>(rRenderParameter.maExtrusionVectors); } -void RenderList::addDrawRectangle(long nX, long nY, long nWidth, long nHeight, const SalColor& rLineColor, const SalColor& rFillColor) +void RenderList::addDrawRectangle(long nX, long nY, long nWidth, long nHeight, double fTransparency, + const SalColor& rLineColor, const SalColor& rFillColor) { if (rLineColor == SALCOLOR_NONE && rFillColor == SALCOLOR_NONE) return; + if (fTransparency == 1.0f) + return; GLfloat fX1(nX); GLfloat fY1(nY); @@ -74,10 +77,10 @@ void RenderList::addDrawRectangle(long nX, long nY, long nWidth, long nHeight, c vcl::vertex::addRectangle<GL_TRIANGLES>(rRenderParameter.maVertices, fX2 - 0.5f, fY1 - 0.5f, fX2 + 0.5f, fY2 + 0.5f); vcl::vertex::addRectangle<GL_TRIANGLES>(rRenderParameter.maVertices, fX1 - 0.5f, fY2 - 0.5f, fX2 + 0.5f, fY2 + 0.5f); - vcl::vertex::addQuadColors<GL_TRIANGLES>(rRenderParameter.maColors, rLineColor, 0.0f); - vcl::vertex::addQuadColors<GL_TRIANGLES>(rRenderParameter.maColors, rLineColor, 0.0f); - vcl::vertex::addQuadColors<GL_TRIANGLES>(rRenderParameter.maColors, rLineColor, 0.0f); - vcl::vertex::addQuadColors<GL_TRIANGLES>(rRenderParameter.maColors, rLineColor, 0.0f); + vcl::vertex::addQuadColors<GL_TRIANGLES>(rRenderParameter.maColors, rLineColor, fTransparency); + vcl::vertex::addQuadColors<GL_TRIANGLES>(rRenderParameter.maColors, rLineColor, fTransparency); + vcl::vertex::addQuadColors<GL_TRIANGLES>(rRenderParameter.maColors, rLineColor, fTransparency); + vcl::vertex::addQuadColors<GL_TRIANGLES>(rRenderParameter.maColors, rLineColor, fTransparency); vcl::vertex::addQuadEmptyExtrusionVectors<GL_TRIANGLES>(rRenderParameter.maExtrusionVectors); vcl::vertex::addQuadEmptyExtrusionVectors<GL_TRIANGLES>(rRenderParameter.maExtrusionVectors); @@ -95,10 +98,10 @@ void RenderList::addDrawRectangle(long nX, long nY, long nWidth, long nHeight, c vcl::vertex::addRectangle<GL_TRIANGLES>(rRenderParameter.maVertices, fX2 - 0.5f, fY1 - 0.5f, fX2 + 0.5f, fY2 + 0.5f); vcl::vertex::addRectangle<GL_TRIANGLES>(rRenderParameter.maVertices, fX1 - 0.5f, fY2 - 0.5f, fX2 + 0.5f, fY2 + 0.5f); - vcl::vertex::addQuadColors<GL_TRIANGLES>(rRenderParameter.maColors, rFillColor, 0.0f); - vcl::vertex::addQuadColors<GL_TRIANGLES>(rRenderParameter.maColors, rFillColor, 0.0f); - vcl::vertex::addQuadColors<GL_TRIANGLES>(rRenderParameter.maColors, rFillColor, 0.0f); - vcl::vertex::addQuadColors<GL_TRIANGLES>(rRenderParameter.maColors, rFillColor, 0.0f); + vcl::vertex::addQuadColors<GL_TRIANGLES>(rRenderParameter.maColors, rFillColor, fTransparency); + vcl::vertex::addQuadColors<GL_TRIANGLES>(rRenderParameter.maColors, rFillColor, fTransparency); + vcl::vertex::addQuadColors<GL_TRIANGLES>(rRenderParameter.maColors, rFillColor, fTransparency); + vcl::vertex::addQuadColors<GL_TRIANGLES>(rRenderParameter.maColors, rFillColor, fTransparency); vcl::vertex::addQuadEmptyExtrusionVectors<GL_TRIANGLES>(rRenderParameter.maExtrusionVectors); vcl::vertex::addQuadEmptyExtrusionVectors<GL_TRIANGLES>(rRenderParameter.maExtrusionVectors); @@ -107,7 +110,7 @@ void RenderList::addDrawRectangle(long nX, long nY, long nWidth, long nHeight, c } // Draw rectangle fill with fill color vcl::vertex::addRectangle<GL_TRIANGLES>(rRenderParameter.maVertices, fX1 + 0.5f, fY1 + 0.5f, fX2 - 0.5f, fY2 - 0.5f); - vcl::vertex::addQuadColors<GL_TRIANGLES>(rRenderParameter.maColors, rFillColor, 0.0f); + vcl::vertex::addQuadColors<GL_TRIANGLES>(rRenderParameter.maColors, rFillColor, fTransparency); vcl::vertex::addQuadEmptyExtrusionVectors<GL_TRIANGLES>(rRenderParameter.maExtrusionVectors); } } @@ -213,4 +216,29 @@ void RenderList::addDrawPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPolygon, } } +bool RenderList::addDrawTextureWithMaskColor(OpenGLTexture& rTexture, const SalColor& rColor, const SalTwoRect& r2Rect) +{ + if (!rTexture) + return false; + + GLfloat fX1 = r2Rect.mnDestX; + GLfloat fY1 = r2Rect.mnDestY; + GLfloat fX2 = fX1 + r2Rect.mnDestWidth; + GLfloat fY2 = fY1 + r2Rect.mnDestHeight; + + checkOverlapping(basegfx::B2DRange(fX1, fY1, fX2, fY2)); + + GLuint nTextureId = rTexture.Id(); + + RenderTextureParameters& rTextureParameter = maRenderEntries.back().maTextureParametersMap[nTextureId]; + rTextureParameter.maTexture = rTexture; + + rTexture.FillCoords<GL_TRIANGLES>(rTextureParameter.maTextureCoords, r2Rect, false); + + vcl::vertex::addRectangle<GL_TRIANGLES>(rTextureParameter.maVertices, fX1, fY1, fX2, fY2); + vcl::vertex::addQuadColors<GL_TRIANGLES>(rTextureParameter.maColors, rColor, 0.0f); + + return true; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |