summaryrefslogtreecommitdiff
path: root/vcl/opengl/gdiimpl.cxx
AgeCommit message (Collapse)AuthorFilesLines
2016-12-09tdf#104034 skip polygons with less than 2 points (LO 5-2)Tomaž Vajngerl1-0/+4
We can get polypolgons with polygons that have 0 or 1 point only, so we need to guard agains division-by-zero errors by skipping if we detect such polygons (as we can't draw them anyway). Change-Id: I08c4f4c9bb946fcbaedede4b4ae23c96e431190e Reviewed-on: https://gerrit.libreoffice.org/31790 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2016-11-11tdf#103804 reduced register areaScale shader and detection for intelTomaž Vajngerl1-3/+13
Some intel drivers crash when areaScale shader with "large" array is used. This adds a "reduced register" version of the areaScale shader. We still use the first version of the shader for other drivers and switch between the 2 implementations with a runtime detection. Change-Id: I1860f898c03b40a600eb1b41f7262719382a7171 Reviewed-on: https://gerrit.libreoffice.org/30571 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit d115a235bf3ff5366d992d01fb418a3eacb9d125) Reviewed-on: https://gerrit.libreoffice.org/30764 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
2016-08-08tdf#101008 fix XOR renderingTomaž Vajngerl1-24/+69
Change-Id: Ied73966633e5ffd56faccea7ec1408bd83642b58 Reviewed-on: https://gerrit.libreoffice.org/27862 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/27922 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2016-08-08tdf#100915 draw antialiased line just for polygon outlineTomaž Vajngerl1-13/+24
To get the anti-aliased polygon we draw a anti-aliased line around every trapezoid. This works fine until we draw a transparent polygon where the lines become visible because of blending. A much better and faster way is to just draw the polygon outline with anti-aliased lines. This is done with this commit. Same fix as aeb0c407a620ea8c28903f61d9d53e6d9ae7c53a in master, but the code differs in 5.2 from master so much that it is generally a separate implementation. Change-Id: I95f98cc930caa7138a59048af68d4015046334d4 Reviewed-on: https://gerrit.libreoffice.org/27923 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2016-06-24tdf#100411 start the flush timer when batching (PostBatchDraw)Tomaž Vajngerl1-0/+10
When we batch a draw command we need to start the flush timer (if not already started) as otherwise it could happen that we won't flush the offscreen texture at the correct time or at all. This fixes a problem with drawing of pop-up "help" text. (cherry picked from commit e1296e295e7d4f1104d2c90b1f51d52251358bea) Change-Id: I6afcf173c3ac517ed0612cd413d95e28c19faa81 Reviewed-on: https://gerrit.libreoffice.org/26629 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jan Holesovsky <kendy@collabora.com>
2016-06-09tdf#99795 drawAlphaBitmap should scale the bitmap if necessaryTomaž Vajngerl1-3/+16
drawAlphaBitmap didn't use a high quality scaler for scaling the texture but used the default scaling method in OpenGL (either GL_NEAREST or GL_LINEAR, whichever is defined when texture is created) which are low quality scalers - especially when downscaling textures. Change-Id: I6236b2ee92b9e5044b176a40a444027072b09b58 (cherry picked from commit 19baa61e1d7b140b9e24717f7080617ab3d324d4) Reviewed-on: https://gerrit.libreoffice.org/26096 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tor Lillqvist <tml@collabora.com>
2016-05-30tdf#100080 set unused shader attribs with values, fixes GL on AMDTomaž Vajngerl1-10/+58
AMD drivers don't work well if a shader has a defined but not enabled shader attributes. For this reason we need to make sure that all attributes are set to some value even if the shader doesn't use that attribute. Intel drivers, on the other hand, crash if you enable an attribute and don't set it (set it to null) - so we can't use this workaround. Change-Id: Ic076cf8a5fac8ef048d0054e6e4340b47b4d5188 Reviewed-on: https://gerrit.libreoffice.org/25591 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit fdcd13c1c2b8b9fbc3480c8fa92920d8c8d4e5a7) Reviewed-on: https://gerrit.libreoffice.org/25594 Tested-by: Tomaž Vajngerl <quikee@gmail.com>
2016-05-23opengl: combined shaders to reduce shader switchingTomaž Vajngerl1-25/+44
Combine most common shaders for non-texture drawing and texture drawing into two combined shaders. Inside the shader we switch between the code paths with if statements. Using if statements (or any other branching statements) is discouraged inside shaders but on the other hand we reduce program state changes if we have less shader changes - which is more important for us as we want to push more work to the GPU. Change-Id: I6701b93faa9b0f55dd0af6d983ce4c2de4539c70 Reviewed-on: https://gerrit.libreoffice.org/25357 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com>
2016-05-23opengl: use line shader for all line drawing not just polylinesTomaž Vajngerl1-200/+14
Change-Id: I9c2d5c5ca4761867a0a38cb3bc3c4973454ee992 Reviewed-on: https://gerrit.libreoffice.org/25157 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2016-05-23opengl: use existing code for "legacy" polyline, polygon render.Tomaž Vajngerl1-69/+25
Rendering polylines, polygons, polypolygons which take an array as parameter ("legacy" code) can re-use the other, already existing code paths (same thing as "headless" svp backend does). Change-Id: Ie45812d7fce6bc70484e9f0c05cc81e995800bcb Reviewed-on: https://gerrit.libreoffice.org/25156 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2016-05-19loplugin:defaultparamsTor Lillqvist1-1/+1
Change-Id: Ib3d2367fc5c0e97b269e6a4b18f85c20ca89221e
2016-05-19opengl: track the state of blend, DrawArrays on OpenGLProgramTomaž Vajngerl1-65/+51
This adds tracking of GL_BLEND and glBlendFunc which are usually set when setting up the current draw call on OpenGLProgram with SetBlendFunc method. Until now the final draw call (glDrawArrays) was called outside of OpenGLProgram. This is a problem because we need to know if we did call SetBlendFunc or not between when we used or reused the current program. So we added DrawArrays to OpenGLProgram and refactored all draw calls in OpenGLSalGraphicsImpl to use this. From now on glDrawArrays should not be called directly but always through OpenGLProgram. Change-Id: I530b4b948af8a962669a3751e1a95ff3986ffec9 Reviewed-on: https://gerrit.libreoffice.org/25083 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2016-05-17tdf#99130 use subdivision on B2DPolygon, angle based subdivisionTomaž Vajngerl1-3/+1
Remove the subdivider we used until now as there is a better way to subdivide a polygon with getDefaultAdaptiveSubdivision, which in additiona also caches the result. The subdivider used in getDefaultAdaptiveSubdivision was a limited count based subdivider so this exchanges that with an angle based one which gives much better results. Change-Id: I95c009ccf3d54305df0d8eef177cab0df0a23bea Reviewed-on: https://gerrit.libreoffice.org/25033 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2016-05-13clang-tidy modernize-loop-convert in vclNoel Grandin1-13/+13
Change-Id: I79e97a4826bfe3918de223cccf48646a1404f901 Reviewed-on: https://gerrit.libreoffice.org/24922 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-05-12simplify SalGraphics::copyArea flags argumentNoel Grandin1-3/+2
Change-Id: Iaaef4d90d7fe817a32cd51652d41c2e49c8909a4 Reviewed-on: https://gerrit.libreoffice.org/24832 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-05-11There is nothing called 'flushAndSwap'Tor Lillqvist1-5/+5
Probably what is meant is the name of the function, which is doFlush(). Change-Id: Ia949a2f8ce19950b1cd0b676c5146488ce7182ee
2016-05-10Convert SAL_INVERT to scoped enumNoel Grandin1-3/+3
Change-Id: If9f725c791f9d01efba098caed8387f21862fa04 Reviewed-on: https://gerrit.libreoffice.org/24825 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-05-10Check if we have an OpenGL context before using API that requires itTor Lillqvist1-2/+5
Avoid GL errors when glDisable() is called without a context. Change-Id: Ie9eae498c207a82934228ad2f74b7096308f5530
2016-04-30opengl: track the state of glViewportTomaž Vajngerl1-5/+2
We don't want to set the viewport over and over again. Change-Id: I60b84a009d4058743e30587616604f9b6fc0f601 Reviewed-on: https://gerrit.libreoffice.org/24507 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2016-04-30opengl: sync scissor and stencil state, generic capability stateTomaž Vajngerl1-5/+7
Scissor and stencil test needed to be disabled in flush() (which means every postDraw call) because sometimes the state became out of sync with the current state. This commit adds sync() function which synchronises the actual OpenGL state and adds debugging mechanisms to warn when the state becomes out of sync (so we can inspect the exact moment in apitrace). Added a GenericCapabilityState for GL capabilities like GL_SCISSORS_TEST, GL_STENCIL_TEST, GL_BLEND,... and refactored existing ScissorState and StencilState to inherit from it. Change-Id: Ifc159108a5ce850c78a89b1f5b8d12ecdd84f459 Reviewed-on: https://gerrit.libreoffice.org/24506 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2016-04-30opengl: track the state of stencil testTomaž Vajngerl1-19/+14
Change-Id: Id3e15e91316df740f04a42ed8c95b77d83240b5a Reviewed-on: https://gerrit.libreoffice.org/24505 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com>
2016-04-30opengl: track the state of scissor test and the dimensionsTomaž Vajngerl1-25/+26
For performance reasons we shouldn't set glScissors if it is not necessary so we remember to what dimensions we set the glScissor and don't set it again if this is not necessary. The same goes for enabling/disabling the GL_SCISSOR_TEST. Change-Id: I5e1383081b4e76bdded04525c780d3a724f9db5c Reviewed-on: https://gerrit.libreoffice.org/24504 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com>
2016-04-26tdf#48066 render stroke-miterlimit correctly in SVG importRegina Henschel1-7/+6
The property stroke-miterlimit is transported to the renderers via a new member mfMiterMinimumAngle in class LineAttribute Several drawPolyLine methods are adapted. This patch does not include changes in MetaAction. Presentation mode, printing, and PDF-export is still wrong. Corrected LineJoinMiter to LineJoinBevel in canvas, that s closer to NONE. Removed DrawPolyLine method without MiterMinimumAngle and adapted calls accordingly. Change-Id: I6bcd24add5d85c4d9a39e3788e0682091c5fc9c4 Reviewed-on: https://gerrit.libreoffice.org/23946 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de> Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
2016-04-14use atan2 from std instead of glmTomaž Vajngerl1-2/+1
Some system glm libs don't (yet) have atan2 available and it is not really needed in this case anyway (as we don't use it for glm::vec2 for example) so just replace it with std::atan2. Change-Id: I5d417338ec167489f0252821650c64be454cca8a
2016-04-14tdf#99244 opengl: miter limit for poly linesTomaž Vajngerl1-0/+14
Change-Id: I1c363a8f1d21bbacab0c5785544aa8becfe39363
2016-04-12clang-tidy performance-unnecessary-value-param in vclNoel Grandin1-1/+1
Change-Id: I403f148060891feec56d7d2ef173a9c4934baf9e Reviewed-on: https://gerrit.libreoffice.org/23995 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-04-08opengl: fix wrong clipping when drawing textTomaž Vajngerl1-10/+25
Change-Id: I41a182c5309586337032328dfe82b1c6715f0dc2
2016-04-08opengl: use packed texture atlas for glyph cache in win. backendTomaž Vajngerl1-1/+3
Change-Id: I6a627699d49bad47213788877fa3947ad2ef83f4
2016-04-08opengl: deferred and optimized (text) texture drawingTomaz Vajngerl1-0/+96
Switching between textures is not cheap, so minimizing the amount of switching performs better. So instead of immediate drawing we can accumulate texture draw actions and defer drawing as long as possible. After that switch all accumulated textures and draw everything needed with one GL draw call. This is beneficial for text drawing as we cache many glyphs in per textue. Change-Id: I1b94b9ac6a5f2c1a3dbbd75f4df76436a5d40f31
2016-04-07loplugin:stringconstantStephan Bergmann1-1/+1
Change-Id: I35551656e5d5d65fd94d60b04e7a07cf1f4be003
2016-04-07tdf#98960 - DrawTransformedTexture adapted to the new area scale shaderMarco Cecchetti1-32/+130
Change-Id: I7c911f2aaccbffacfa5673b120b6177b8bea0672 Reviewed-on: https://gerrit.libreoffice.org/23864 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2016-03-16loplugin:constantparams in vcl/Noel Grandin1-4/+4
also some improvements to the plugin Change-Id: I0e3a519d70756e577fcb1bd47dd66864b5b4c871 Reviewed-on: https://gerrit.libreoffice.org/23289 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
2016-03-14tdf#95616 - fix flickering issueMarco Cecchetti1-0/+1
Change-Id: I0d5bfdf44dde2cd06c193f34e81c6ce71291bba1 Reviewed-on: https://gerrit.libreoffice.org/23238 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2016-03-09vcldemo: improved text rendering test.Michael Meeks1-0/+3
Merge in some interesting font / unicode combinations from bugs. Change-Id: I2c89cf505a7850fcc482826328e1cdb8e37508aa Reviewed-on: https://gerrit.libreoffice.org/23056 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2016-03-07opengl: fix inv.scale values are always integer - cid#1352479Tomaž Vajngerl1-2/+2
Force cast to double to avoid integer division - which gives a wrong inverse scale value. Change-Id: I0135e44ef07f3915619f9dfead9aadf50fc03685
2016-02-25opengl: shader based polyline rendering - fixes tdf#97137 for OGLTomaž Vajngerl1-47/+317
Adds native opengl polyline rendering to draw polylines, line joins and line caps as triangle strips. The vertex shader allows for the dynamic line width by calculating the correct vertex posiitons, and the fragment shader is used for anti-aliasing. Change-Id: If7982c828cae1fae59c57194c8ac77e5ad7f1d26
2016-02-11tdf#97763 - avoid divide by zero for scaling images to tiny dimensions.Michael Meeks1-0/+4
Change-Id: I27efebcc1c24d45c17da2ad2959b673153c3eead Reviewed-on: https://gerrit.libreoffice.org/22297 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
2016-02-11tdf#97715 fix inv. scale calculation in DrawTransformedTextureTomaž Vajngerl1-2/+7
When image was rotated towards 90 degree the ixscale and iyscale went towards infinity. That caused problems in fragment shader areaScaleFastFragmentShader. The problem was with calculation of destination width and height which didn't take rotation into account correctly. This commit takes this calculation from WinSalGraphicsImpl::drawTransformedBitmap. Change-Id: I30f14a1ecda21ef167e58eda8e2fcef00bdfa2b7 Reviewed-on: https://gerrit.libreoffice.org/22289 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
2016-01-13Bin unused fieldTor Lillqvist1-3/+2
Change-Id: I664e3815bcdaff82a03309ae387154914471a80b
2016-01-12tdf#96385 - opengl: dynamically adjust priority of swap buffers.Michael Meeks1-1/+3
Initially we start with a very low priority, so that the lame bits of code that do eg. focus, and cursor rendering before the document is visible do not cause a swap, flash. Then after we've processed a REPAINT priority idle (hopefully our first paint) we adjust the swap priority to highest. Essentially a fusion of Tor's approach and mine. Change-Id: Ib9b78a18fb9359ac8c3dee1cfeb30177c08fe162 Reviewed-on: https://gerrit.libreoffice.org/21405 Reviewed-by: Tor Lillqvist <tml@collabora.com> Tested-by: Tor Lillqvist <tml@collabora.com>
2016-01-09tdf#96657 - vcl opengl: implement invert: Track Frame.Michael Meeks1-1/+12
Change-Id: I422ea8cfb8a81cca36203d496b92e15ea5b449d2 Reviewed-on: https://gerrit.libreoffice.org/21291 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2016-01-09tdf#96919 - vcl opengl: implement missing XOR mode.Michael Meeks1-14/+31
Also revert "tdf#96257: Silly work-around to produce same result ..." from commit ec8bc265050d86a749140c353360a78cce4e3fce. XOR rendering (it turns out) behaves oddly, and not for all operations. Change-Id: Ie07d988bbf7fed10fb5625ac547a01a306b05319 Reviewed-on: https://gerrit.libreoffice.org/21282 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2016-01-06loplugin:defaultparamsStephan Bergmann1-1/+1
Change-Id: Ic5bfc72c75745d0a4d9ff165d840ab51c90a8690
2016-01-06vcl: opengl - Kill the last glErrors on common paths.Michael Meeks1-36/+6
Re-work the makeSomeOpenGLContextCurrent logic into a shared function with the existing AcquireContext logic in the SalOpenGLGraphics impl. Use an OpenGLVCLContextZone placeholder to do both context and zone management - to include destructors into the zone. Fix a number of error cases around SalBitmaps where we did not have a GL context associated when allocating, and/or freeing textures.. Don't drag a (potentially) slower context around in the OpenGLSalBitmap when we're going to check / fetch a better VCL context anyway. Change-Id: Ibbb2358c47156cd078ad28b6aad4f03af36aaf23 Reviewed-on: https://gerrit.libreoffice.org/21127 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
2016-01-04tdf#96690 - don't copy tiny non-rendered-to virtual devices.Michael Meeks1-0/+7
Change-Id: Ic9d90bb7f652599b5a6ce303aa026b7e4e255324
2016-01-02vcl: opengl - ensure we have the right GL context for rendering.Michael Meeks1-34/+14
Also significantly simplify, and remove paranoid ramblings from the flushing code. Change-Id: Ie7cc742caac290d77ac931c54cc4fe777a7872de
2016-01-02tdf#96858 - opengl - fix off-by-1 in glScissor clipping.Michael Meeks1-1/+1
Change-Id: I3085e2d2848e2041c2faadbfce099ce75c62b712 Reviewed-on: https://gerrit.libreoffice.org/21043 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2016-01-01Fix drawTransformedBitmap for NULL pAlphaBitmap #2.Michael Meeks1-1/+1
Change-Id: Ie4d03a01c557e93a3ba3b5925896e38ed07f9a27
2016-01-01vcl: improve OpenGL debugging variously.Michael Meeks1-1/+1
Change-Id: I097f1c1fb7fb505b6859289997bff3562fc06ba6 Reviewed-on: https://gerrit.libreoffice.org/21027 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
2015-12-31tdf#95507 - implement opengl / 50% invert method.Michael Meeks1-34/+26
Change-Id: I8488cb8e8074831a6f81e6c8c122462c9819d25d Reviewed-on: https://gerrit.libreoffice.org/21025 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>