Rebased ref, commits from common ancestor: commit b49bea154047efeb9e487dde6c9742cf31c11400 Author: Louis-Francis Ratté-Boulianne <l...@collabora.com> Date: Tue Nov 11 16:16:57 2014 -0500
vcl: Use offscreen rendering for native GTK widgets with OpenGL backend Change-Id: I142e1b34e54a3cbe149e5af9adeba1250a4ca9a9 diff --git a/vcl/Library_vclplug_gtk.mk b/vcl/Library_vclplug_gtk.mk index db2dd21..ec7f2f8 100644 --- a/vcl/Library_vclplug_gtk.mk +++ b/vcl/Library_vclplug_gtk.mk @@ -65,6 +65,7 @@ $(eval $(call gb_Library_use_externals,vclplug_gtk,\ cairo \ dbus \ gio \ + glew \ gtk \ gthread \ icuuc \ diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx index 0cf68fd..2473297 100644 --- a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx @@ -41,6 +41,8 @@ #include "fontmanager.hxx" #include <vcl/decoview.hxx> +#include <vcl/opengl/OpenGLHelper.hxx> + typedef struct _cairo_font_options cairo_font_options_t; const char* const tabPrelitDataName="libreoffice-tab-is-prelit"; @@ -533,6 +535,10 @@ void GtkData::initNWF( void ) if( pEnv && *pEnv ) GtkSalGraphics::bNeedPixmapPaint = true; + // use offscreen rendering when using OpenGL backend + if( OpenGLHelper::isVCLOpenGLEnabled() ) + GtkSalGraphics::bNeedPixmapPaint = true; + #if OSL_DEBUG_LEVEL > 1 std::fprintf( stderr, "GtkPlugin: using %s NWF\n", GtkSalGraphics::bNeedPixmapPaint ? "offscreen" : "direct" ); commit e1e787d5e418a328f8023d3b777384b98441a9de Author: Louis-Francis Ratté-Boulianne <l...@collabora.com> Date: Tue Nov 11 15:54:03 2014 -0500 vcl: Add support for radial gradients in OpenGL backend Change-Id: Ie47fb18ae7d5286fe7559c7dffbc54b0856d4d8e diff --git a/vcl/Package_opengl.mk b/vcl/Package_opengl.mk index da40d71..18c56fc 100644 --- a/vcl/Package_opengl.mk +++ b/vcl/Package_opengl.mk @@ -16,6 +16,7 @@ $(eval $(call gb_Package_add_files,vcl_opengl_shader,$(LIBO_ETC_FOLDER)/opengl,\ maskVertexShader.glsl \ maskedTextureFragmentShader.glsl \ maskedTextureVertexShader.glsl \ + radialGradientFragmentShader.glsl \ solidFragmentShader.glsl \ solidVertexShader.glsl \ textureFragmentShader.glsl \ diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx index 535bc72..f80c969 100644 --- a/vcl/inc/openglgdiimpl.hxx +++ b/vcl/inc/openglgdiimpl.hxx @@ -63,13 +63,18 @@ protected: GLuint mnLinearGradientProgram; GLuint mnLinearGradientStartColorUniform; GLuint mnLinearGradientEndColorUniform; - GLuint mnLinearGradientTransformUniform; + + GLuint mnRadialGradientProgram; + GLuint mnRadialGradientStartColorUniform; + GLuint mnRadialGradientEndColorUniform; + GLuint mnRadialGradientCenterUniform; bool CreateSolidProgram( void ); bool CreateTextureProgram( void ); bool CreateMaskedTextureProgram( void ); bool CreateMaskProgram( void ); bool CreateLinearGradientProgram( void ); + bool CreateRadialGradientProgram( void ); void BeginSolid( SalColor nColor, sal_uInt8 nTransparency ); void BeginSolid( SalColor nColor, double fTransparency ); @@ -84,6 +89,7 @@ protected: void DrawConvexPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ); void DrawConvexPolygon( const Polygon& rPolygon ); void DrawRect( long nX, long nY, long nWidth, long nHeight ); + void DrawRect( const Rectangle& rRect ); void DrawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ); void DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon ); void DrawTextureRect( const Size& rSize, const SalTwoRect& rPosAry, bool bInverted = false ); @@ -91,6 +97,7 @@ protected: void DrawTextureWithMask( GLuint nTexture, GLuint nMask, const Size& rSize, const SalTwoRect& rPosAry ); void DrawMask( GLuint nMask, SalColor nMaskColor, const SalTwoRect& rPosAry ); void DrawLinearGradient( const Gradient& rGradient, const Rectangle& rRect ); + void DrawRadialGradient( const Gradient& rGradient, const Rectangle& rRect ); protected: // get the width of the device diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 65c4f30..744aa7f 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -75,6 +75,13 @@ OpenGLSalGraphicsImpl::OpenGLSalGraphicsImpl() , mnMaskProgram(0) , mnMaskUniform(0) , mnMaskColorUniform(0) + , mnLinearGradientProgram(0) + , mnLinearGradientStartColorUniform(0) + , mnLinearGradientEndColorUniform(0) + , mnRadialGradientProgram(0) + , mnRadialGradientStartColorUniform(0) + , mnRadialGradientEndColorUniform(0) + , mnRadialGradientCenterUniform(0) { } @@ -295,7 +302,20 @@ bool OpenGLSalGraphicsImpl::CreateLinearGradientProgram( void ) glBindAttribLocation( mnTextureProgram, GL_ATTRIB_TEX, "tex_coord_in" ); mnLinearGradientStartColorUniform = glGetUniformLocation( mnLinearGradientProgram, "start_color" ); mnLinearGradientEndColorUniform = glGetUniformLocation( mnLinearGradientProgram, "end_color" ); - mnLinearGradientTransformUniform = glGetUniformLocation( mnLinearGradientProgram, "transform" ); + return true; +} + +bool OpenGLSalGraphicsImpl::CreateRadialGradientProgram( void ) +{ + mnRadialGradientProgram = OpenGLHelper::LoadShaders( "textureVertexShader", "radialGradientFragmentShader" ); + if( mnRadialGradientProgram == 0 ) + return false; + + glBindAttribLocation( mnTextureProgram, GL_ATTRIB_POS, "position" ); + glBindAttribLocation( mnTextureProgram, GL_ATTRIB_TEX, "tex_coord_in" ); + mnRadialGradientStartColorUniform = glGetUniformLocation( mnRadialGradientProgram, "start_color" ); + mnRadialGradientEndColorUniform = glGetUniformLocation( mnRadialGradientProgram, "end_color" ); + mnRadialGradientCenterUniform = glGetUniformLocation( mnRadialGradientProgram, "center" ); return true; } @@ -455,6 +475,18 @@ void OpenGLSalGraphicsImpl::DrawRect( long nX, long nY, long nWidth, long nHeigh DrawConvexPolygon( 4, aPoints ); } +void OpenGLSalGraphicsImpl::DrawRect( const Rectangle& rRect ) +{ + long nX1( rRect.Left() ); + long nY1( GetHeight() - rRect.Top() ); + long nX2( rRect.Right() ); + long nY2( GetHeight() - rRect.Bottom() ); + const SalPoint aPoints[] = { { nX1, nY2 }, { nX1, nY1 }, + { nX2, nY1 }, { nX2, nY2 }}; + + DrawConvexPolygon( 4, aPoints ); +} + void OpenGLSalGraphicsImpl::DrawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ) { ::basegfx::B2DPolygon aPolygon; @@ -601,18 +633,6 @@ void OpenGLSalGraphicsImpl::DrawMask( GLuint nMask, SalColor nMaskColor, const S void OpenGLSalGraphicsImpl::DrawLinearGradient( const Gradient& rGradient, const Rectangle& rRect ) { - if( rGradient.GetBorder() >= 100.0 ) - { - // border >= 100%, draw solid rectangle - Color aCol = rGradient.GetStartColor(); - long nF = rGradient.GetStartIntensity(); - BeginSolid( MAKE_SALCOLOR( aCol.GetRed() * nF / 100, - aCol.GetGreen() * nF / 100, - aCol.GetBlue() * nF / 100 ) ); - DrawRect( rRect.Left(), rRect.Top(), rRect.GetWidth(), rRect.GetHeight() ); - EndSolid(); - return; - } if( mnLinearGradientProgram == 0 ) { @@ -632,10 +652,6 @@ void OpenGLSalGraphicsImpl::DrawLinearGradient( const Gradient& rGradient, const Rectangle aBoundRect; Point aCenter; rGradient.GetBoundRect( rRect, aBoundRect, aCenter ); - aBoundRect.Left()--; - aBoundRect.Top()--; - aBoundRect.Right()++; - aBoundRect.Bottom()++; Polygon aPoly( aBoundRect ); aPoly.Rotate( aCenter, rGradient.GetAngle() % 3600 ); @@ -653,6 +669,43 @@ void OpenGLSalGraphicsImpl::DrawLinearGradient( const Gradient& rGradient, const glUseProgram( 0 ); } +void OpenGLSalGraphicsImpl::DrawRadialGradient( const Gradient& rGradient, const Rectangle& rRect ) +{ + if( mnRadialGradientProgram == 0 ) + { + if( !CreateRadialGradientProgram() ) + return; + } + + glUseProgram( mnRadialGradientProgram ); + + Color aStartCol = rGradient.GetStartColor(); + Color aEndCol = rGradient.GetEndColor(); + long nFactor = rGradient.GetStartIntensity(); + glUniformColorIntensity( mnRadialGradientStartColorUniform, aStartCol, nFactor ); + nFactor = rGradient.GetEndIntensity(); + glUniformColorIntensity( mnRadialGradientEndColorUniform, aEndCol, nFactor ); + + Rectangle aRect; + Point aCenter; + rGradient.GetBoundRect( rRect, aRect, aCenter ); + + // adjust coordinates so that radius has distance equals to 1.0 + double fRadius = aRect.GetWidth() / 2.0f; + GLfloat fWidth = rRect.GetWidth() / fRadius; + GLfloat fHeight = rRect.GetHeight() / fRadius; + glUniform2f( mnRadialGradientCenterUniform, (aCenter.X() -rRect.Left()) / fRadius, (aCenter.Y() - rRect.Top()) / fRadius ); + + GLfloat aTexCoord[8] = { 0, 0, 0, fHeight, fWidth, fHeight, fWidth, 0 }; + glEnableVertexAttribArray( GL_ATTRIB_TEX ); + glVertexAttribPointer( GL_ATTRIB_TEX, 2, GL_FLOAT, GL_FALSE, 0, aTexCoord ); + + DrawRect( rRect ); + + glDisableVertexAttribArray( GL_ATTRIB_TEX ); + glUseProgram( 0 ); +} + // draw --> LineColor and FillColor and RasterOp and ClipRegion void OpenGLSalGraphicsImpl::drawPixel( long nX, long nY ) @@ -1189,11 +1242,33 @@ bool OpenGLSalGraphicsImpl::drawAlphaRect( bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly, const Gradient& rGradient) { - const Rectangle aBoundRect( rPolyPoly.GetBoundRect() ); + Rectangle aBoundRect( rPolyPoly.GetBoundRect() ); + + SAL_INFO( "vcl.opengl", "::drawGradient" ); if( aBoundRect.IsEmpty() ) return true; + aBoundRect.Left()--; + aBoundRect.Top()--; + aBoundRect.Right()++; + aBoundRect.Bottom()++; + + // if border >= 100%, draw solid rectangle with start color + if( rGradient.GetBorder() >= 100.0 ) + { + Color aCol = rGradient.GetStartColor(); + long nF = rGradient.GetStartIntensity(); + PreDraw(); + BeginSolid( MAKE_SALCOLOR( aCol.GetRed() * nF / 100, + aCol.GetGreen() * nF / 100, + aCol.GetBlue() * nF / 100 ) ); + DrawRect( aBoundRect ); + EndSolid(); + PostDraw(); + return true; + } + //TODO: lfrb: some missing transformation with the polygon in outdev if( rGradient.GetStyle() == GradientStyle_LINEAR ) { @@ -1202,6 +1277,13 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly, PostDraw(); return true; } + else if( rGradient.GetStyle() == GradientStyle_RADIAL ) + { + PreDraw(); + DrawRadialGradient( rGradient, aBoundRect ); + PostDraw(); + return true; + } return false; } diff --git a/vcl/opengl/radialGradientFragmentShader.glsl b/vcl/opengl/radialGradientFragmentShader.glsl new file mode 100644 index 0000000..94a86eb --- /dev/null +++ b/vcl/opengl/radialGradientFragmentShader.glsl @@ -0,0 +1,23 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#version 120 + +uniform vec4 start_color; +uniform vec4 end_color; +uniform vec2 center; +varying vec2 tex_coord; + +void main(void) +{ + gl_FragColor = mix(end_color, start_color, + clamp(distance(tex_coord, center), 0.0, 1.0)); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 74c3dbe87e7256f8f8b3eac3a34415780035f465 Author: Louis-Francis Ratté-Boulianne <l...@collabora.com> Date: Tue Nov 11 13:43:56 2014 -0500 vcl: Read back OpenGL FBO to create offscreen X11 pixmap Change-Id: I330e7d62bf31b4a90b5866d9531f073f7c69c92a diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx index c9e8b68..535bc72 100644 --- a/vcl/inc/openglgdiimpl.hxx +++ b/vcl/inc/openglgdiimpl.hxx @@ -86,8 +86,8 @@ protected: void DrawRect( long nX, long nY, long nWidth, long nHeight ); void DrawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ); void DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon ); - void DrawTextureRect( const Size& rSize, const SalTwoRect& rPosAry ); - void DrawTexture( GLuint nTexture, const Size& rSize, const SalTwoRect& rPosAry ); + void DrawTextureRect( const Size& rSize, const SalTwoRect& rPosAry, bool bInverted = false ); + void DrawTexture( GLuint nTexture, const Size& rSize, const SalTwoRect& rPosAry, bool bInverted = false ); void DrawTextureWithMask( GLuint nTexture, GLuint nMask, const Size& rSize, const SalTwoRect& rPosAry ); void DrawMask( GLuint nMask, SalColor nMaskColor, const SalTwoRect& rPosAry ); void DrawLinearGradient( const Gradient& rGradient, const Rectangle& rRect ); diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 72387e2..65c4f30 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -503,14 +503,23 @@ void OpenGLSalGraphicsImpl::DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPol glDisableVertexAttribArray( GL_ATTRIB_POS ); } -void OpenGLSalGraphicsImpl::DrawTextureRect( const Size& rSize, const SalTwoRect& rPosAry ) +void OpenGLSalGraphicsImpl::DrawTextureRect( const Size& rSize, const SalTwoRect& rPosAry, bool bInverted ) { GLfloat aTexCoord[8]; aTexCoord[0] = aTexCoord[2] = rPosAry.mnSrcX / (double) rSize.Width(); aTexCoord[4] = aTexCoord[6] = (rPosAry.mnSrcX + rPosAry.mnSrcWidth) / (double) rSize.Width(); - aTexCoord[3] = aTexCoord[5] = (rSize.Height() - rPosAry.mnSrcY) / (double) rSize.Height(); - aTexCoord[1] = aTexCoord[7] = (rSize.Height() - rPosAry.mnSrcY - rPosAry.mnSrcHeight) / (double) rSize.Height(); + + if( !bInverted ) + { + aTexCoord[3] = aTexCoord[5] = (rSize.Height() - rPosAry.mnSrcY) / (double) rSize.Height(); + aTexCoord[1] = aTexCoord[7] = (rSize.Height() - rPosAry.mnSrcY - rPosAry.mnSrcHeight) / (double) rSize.Height(); + } + else + { + aTexCoord[1] = aTexCoord[7] = (rSize.Height() - rPosAry.mnSrcY) / (double) rSize.Height(); + aTexCoord[3] = aTexCoord[5] = (rSize.Height() - rPosAry.mnSrcY - rPosAry.mnSrcHeight) / (double) rSize.Height(); + } glEnableVertexAttribArray( GL_ATTRIB_TEX ); glVertexAttribPointer( GL_ATTRIB_TEX, 2, GL_FLOAT, GL_FALSE, 0, aTexCoord ); @@ -520,7 +529,7 @@ void OpenGLSalGraphicsImpl::DrawTextureRect( const Size& rSize, const SalTwoRect glDisableVertexAttribArray( GL_ATTRIB_TEX ); } -void OpenGLSalGraphicsImpl::DrawTexture( GLuint nTexture, const Size& rSize, const SalTwoRect& pPosAry ) +void OpenGLSalGraphicsImpl::DrawTexture( GLuint nTexture, const Size& rSize, const SalTwoRect& pPosAry, bool bInverted ) { if( mnTextureProgram == 0 ) { @@ -534,7 +543,7 @@ void OpenGLSalGraphicsImpl::DrawTexture( GLuint nTexture, const Size& rSize, con CHECK_GL_ERROR(); glBindTexture( GL_TEXTURE_2D, nTexture ); - DrawTextureRect( rSize, pPosAry ); + DrawTextureRect( rSize, pPosAry, bInverted ); CHECK_GL_ERROR(); glBindTexture( GL_TEXTURE_2D, 0 ); diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx index 6e803bd..13b7049 100644 --- a/vcl/opengl/x11/gdiimpl.cxx +++ b/vcl/opengl/x11/gdiimpl.cxx @@ -83,9 +83,38 @@ X11Pixmap* X11OpenGLSalGraphicsImpl::GetPixmapFromScreen( const Rectangle& rRect { Display* pDisplay = mrParent.GetXDisplay(); SalX11Screen nScreen = mrParent.GetScreenNumber(); + XVisualInfo aVisualInfo; + X11Pixmap* pPixmap; + XImage* pImage; + sal_uInt8* pData; SAL_INFO( "vcl.opengl", "GetPixmapFromScreen" ); - return new X11Pixmap( pDisplay, nScreen, rRect.GetWidth(), rRect.GetHeight(), 24 ); + // TODO: lfrb: Use context depth + pPixmap = new X11Pixmap( pDisplay, nScreen, rRect.GetWidth(), rRect.GetHeight(), 24 ); + + if( !OpenGLHelper::GetVisualInfo( pDisplay, nScreen.getXScreen(), aVisualInfo ) ) + return pPixmap; + + // make sure everything is synced up before reading back + maContext.makeCurrent(); + glXWaitX(); + + // TODO: lfrb: What if offscreen? + pData = new sal_uInt8[rRect.GetWidth() * rRect.GetHeight() * 4]; + glPixelStorei( GL_PACK_ALIGNMENT, 1 ); + glReadPixels( rRect.Left(), GetHeight() - rRect.Top(), rRect.GetWidth(), rRect.GetHeight(), + GL_RGBA, GL_UNSIGNED_BYTE, pData ); + + pImage = XCreateImage( pDisplay, aVisualInfo.visual, 24, ZPixmap, 0, (char*) pData, + rRect.GetWidth(), rRect.GetHeight(), 8, 0 ); + XInitImage( pImage ); + GC aGC = XCreateGC( pDisplay, pPixmap->GetPixmap(), 0, NULL ); + XPutImage( pDisplay, pPixmap->GetDrawable(), aGC, pImage, + 0, 0, 0, 0, rRect.GetWidth(), rRect.GetHeight() ); + XFreeGC( pDisplay, aGC ); + XDestroyImage( pImage ); + + return pPixmap; } bool X11OpenGLSalGraphicsImpl::RenderPixmapToScreen( X11Pixmap* pPixmap, int nX, int nY ) @@ -128,7 +157,7 @@ bool X11OpenGLSalGraphicsImpl::RenderPixmapToScreen( X11Pixmap* pPixmap, int nX, glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - DrawTexture( nTexture, pPixmap->GetSize(), aPosAry ); + DrawTexture( nTexture, pPixmap->GetSize(), aPosAry, !bInverted ); glXReleaseTexImageEXT( pDisplay, pGlxPixmap, GLX_FRONT_LEFT_EXT ); glDeleteTextures( 1, &nTexture ); commit c7a5ce27e6d27af4d868dedcde1f650fa129e6f8 Author: Louis-Francis Ratté-Boulianne <l...@collabora.com> Date: Tue Nov 11 05:13:40 2014 -0500 vcl: Add initial support for linear gradient with OpenGL Change-Id: Iccc12c94bfd68387dfc0161a5fde4f595edda0e1 diff --git a/vcl/Package_opengl.mk b/vcl/Package_opengl.mk index 79dabb7..da40d71 100644 --- a/vcl/Package_opengl.mk +++ b/vcl/Package_opengl.mk @@ -11,6 +11,7 @@ $(eval $(call gb_Package_Package,vcl_opengl_shader,$(SRCDIR)/vcl/opengl)) $(eval $(call gb_Package_add_files,vcl_opengl_shader,$(LIBO_ETC_FOLDER)/opengl,\ convolutionFragmentShader.glsl \ + linearGradientFragmentShader.glsl \ maskFragmentShader.glsl \ maskVertexShader.glsl \ maskedTextureFragmentShader.glsl \ diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx index 6f920e5..c9e8b68 100644 --- a/vcl/inc/openglgdiimpl.hxx +++ b/vcl/inc/openglgdiimpl.hxx @@ -25,6 +25,7 @@ #include "opengl/texture.hxx" +#include <tools/poly.hxx> #include <vcl/opengl/OpenGLContext.hxx> class SalFrame; @@ -59,10 +60,16 @@ protected: GLuint mnMaskUniform; GLuint mnMaskColorUniform; + GLuint mnLinearGradientProgram; + GLuint mnLinearGradientStartColorUniform; + GLuint mnLinearGradientEndColorUniform; + GLuint mnLinearGradientTransformUniform; + bool CreateSolidProgram( void ); bool CreateTextureProgram( void ); bool CreateMaskedTextureProgram( void ); bool CreateMaskProgram( void ); + bool CreateLinearGradientProgram( void ); void BeginSolid( SalColor nColor, sal_uInt8 nTransparency ); void BeginSolid( SalColor nColor, double fTransparency ); @@ -75,6 +82,7 @@ protected: void DrawLine( long nX1, long nY1, long nX2, long nY2 ); void DrawLines( sal_uInt32 nPoints, const SalPoint* pPtAry, bool bClose ); void DrawConvexPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ); + void DrawConvexPolygon( const Polygon& rPolygon ); void DrawRect( long nX, long nY, long nWidth, long nHeight ); void DrawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ); void DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon ); @@ -82,6 +90,7 @@ protected: void DrawTexture( GLuint nTexture, const Size& rSize, const SalTwoRect& rPosAry ); void DrawTextureWithMask( GLuint nTexture, GLuint nMask, const Size& rSize, const SalTwoRect& rPosAry ); void DrawMask( GLuint nMask, SalColor nMaskColor, const SalTwoRect& rPosAry ); + void DrawLinearGradient( const Gradient& rGradient, const Rectangle& rRect ); protected: // get the width of the device diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 2cf9806..72387e2 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -51,6 +51,13 @@ ((float) SALCOLOR_BLUE( nColor )) / 255, \ (1.0f - fTransparency) ) +#define glUniformColorIntensity(nUniform, aColor, nFactor) \ + glUniform4f( nUniform, \ + ((float) aColor.GetRed()) * nFactor / 25500.0, \ + ((float) aColor.GetGreen()) * nFactor / 25500.0, \ + ((float) aColor.GetBlue()) * nFactor / 25500.0, \ + 1.0f ) + OpenGLSalGraphicsImpl::OpenGLSalGraphicsImpl() : mpFrame(NULL) , mbOffscreen(false) @@ -278,6 +285,20 @@ bool OpenGLSalGraphicsImpl::CreateMaskProgram( void ) return true; } +bool OpenGLSalGraphicsImpl::CreateLinearGradientProgram( void ) +{ + mnLinearGradientProgram = OpenGLHelper::LoadShaders( "textureVertexShader", "linearGradientFragmentShader" ); + if( mnLinearGradientProgram == 0 ) + return false; + + glBindAttribLocation( mnTextureProgram, GL_ATTRIB_POS, "position" ); + glBindAttribLocation( mnTextureProgram, GL_ATTRIB_TEX, "tex_coord_in" ); + mnLinearGradientStartColorUniform = glGetUniformLocation( mnLinearGradientProgram, "start_color" ); + mnLinearGradientEndColorUniform = glGetUniformLocation( mnLinearGradientProgram, "end_color" ); + mnLinearGradientTransformUniform = glGetUniformLocation( mnLinearGradientProgram, "transform" ); + return true; +} + void OpenGLSalGraphicsImpl::BeginSolid( SalColor nColor, sal_uInt8 nTransparency ) { if( mnSolidProgram == 0 ) @@ -403,6 +424,25 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( sal_uInt32 nPoints, const SalPoin glDisableVertexAttribArray( GL_ATTRIB_POS ); } +void OpenGLSalGraphicsImpl::DrawConvexPolygon( const Polygon& rPolygon ) +{ + sal_uInt16 nPoints = rPolygon.GetSize() - 1; + std::vector<GLfloat> aVertices(nPoints * 2); + sal_uInt32 i, j; + + for( i = 0, j = 0; i < nPoints; i++, j += 2 ) + { + const Point& rPt = rPolygon.GetPoint( i ); + aVertices[j] = (2 * rPt.X()) / GetWidth() - 1.0; + aVertices[j+1] = (2 * (GetHeight() - rPt.Y())) / GetHeight() - 1.0; + } + + glEnableVertexAttribArray( GL_ATTRIB_POS ); + glVertexAttribPointer( GL_ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, &aVertices[0] ); + glDrawArrays( GL_TRIANGLE_FAN, 0, nPoints ); + glDisableVertexAttribArray( GL_ATTRIB_POS ); +} + void OpenGLSalGraphicsImpl::DrawRect( long nX, long nY, long nWidth, long nHeight ) { long nX1( nX ); @@ -550,6 +590,60 @@ void OpenGLSalGraphicsImpl::DrawMask( GLuint nMask, SalColor nMaskColor, const S glUseProgram( 0 ); } +void OpenGLSalGraphicsImpl::DrawLinearGradient( const Gradient& rGradient, const Rectangle& rRect ) +{ + if( rGradient.GetBorder() >= 100.0 ) + { + // border >= 100%, draw solid rectangle + Color aCol = rGradient.GetStartColor(); + long nF = rGradient.GetStartIntensity(); + BeginSolid( MAKE_SALCOLOR( aCol.GetRed() * nF / 100, + aCol.GetGreen() * nF / 100, + aCol.GetBlue() * nF / 100 ) ); + DrawRect( rRect.Left(), rRect.Top(), rRect.GetWidth(), rRect.GetHeight() ); + EndSolid(); + return; + } + + if( mnLinearGradientProgram == 0 ) + { + if( !CreateLinearGradientProgram() ) + return; + } + + glUseProgram( mnLinearGradientProgram ); + + Color aStartCol = rGradient.GetStartColor(); + Color aEndCol = rGradient.GetEndColor(); + long nFactor = rGradient.GetStartIntensity(); + glUniformColorIntensity( mnLinearGradientStartColorUniform, aStartCol, nFactor ); + nFactor = rGradient.GetEndIntensity(); + glUniformColorIntensity( mnLinearGradientEndColorUniform, aEndCol, nFactor ); + + Rectangle aBoundRect; + Point aCenter; + rGradient.GetBoundRect( rRect, aBoundRect, aCenter ); + aBoundRect.Left()--; + aBoundRect.Top()--; + aBoundRect.Right()++; + aBoundRect.Bottom()++; + Polygon aPoly( aBoundRect ); + aPoly.Rotate( aCenter, rGradient.GetAngle() % 3600 ); + + GLfloat aTexCoord[8] = { 0, 1, 1, 1, 1, 0, 0, 0 }; + GLfloat fMin = 1.0 - 100.0 / (100.0 - rGradient.GetBorder()); + aTexCoord[5] = aTexCoord[7] = fMin; + glEnableVertexAttribArray( GL_ATTRIB_TEX ); + glVertexAttribPointer( GL_ATTRIB_TEX, 2, GL_FLOAT, GL_FALSE, 0, aTexCoord ); + + DrawConvexPolygon( aPoly ); + + glDisableVertexAttribArray( GL_ATTRIB_TEX ); + CHECK_GL_ERROR(); + + glUseProgram( 0 ); +} + // draw --> LineColor and FillColor and RasterOp and ClipRegion void OpenGLSalGraphicsImpl::drawPixel( long nX, long nY ) @@ -1083,9 +1177,22 @@ bool OpenGLSalGraphicsImpl::drawAlphaRect( return true; } -bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& /*rPolygon*/, - const Gradient& /*rGradient*/) +bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly, + const Gradient& rGradient) { + const Rectangle aBoundRect( rPolyPoly.GetBoundRect() ); + + if( aBoundRect.IsEmpty() ) + return true; + + //TODO: lfrb: some missing transformation with the polygon in outdev + if( rGradient.GetStyle() == GradientStyle_LINEAR ) + { + PreDraw(); + DrawLinearGradient( rGradient, aBoundRect ); + PostDraw(); + return true; + } return false; } diff --git a/vcl/opengl/linearGradientFragmentShader.glsl b/vcl/opengl/linearGradientFragmentShader.glsl new file mode 100644 index 0000000..7b84c06 --- /dev/null +++ b/vcl/opengl/linearGradientFragmentShader.glsl @@ -0,0 +1,23 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#version 120 + +uniform vec4 start_color; +uniform vec4 end_color; +uniform mat3x3 transform; +varying vec2 tex_coord; + +void main(void) +{ + gl_FragColor = mix(start_color, end_color, + clamp(tex_coord.t, 0.0, 1.0)); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit b021b5983c62e266b82d9f0c5c6d8d8900553827 Author: Michael Meeks <michael.me...@collabora.com> Date: Wed Nov 12 00:21:28 2014 +0000 WaE: calm clang tinderbox. Change-Id: Id07741c3d7780da72a351c33fc001f7d2a73bc64 diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx index e4f9205..c5e4d61 100644 --- a/vcl/opengl/salbmp.cxx +++ b/vcl/opengl/salbmp.cxx @@ -34,7 +34,7 @@ static bool isValidBitCount( sal_uInt16 nBitCount ) OpenGLSalBitmap::OpenGLSalBitmap() : mpContext(NULL) -, mpTexture(NULL) +, mpTexture() , mbDirtyTexture(true) , mnBits(0) , mnBytesPerRow(0) commit 98f9baa5253f7bb8034f148519f31f548b1452fa Author: Michael Meeks <michael.me...@collabora.com> Date: Wed Nov 12 00:02:03 2014 +0000 vcldemo: add some clipping tests under the checkerboard tile. Change-Id: I801931055aeba38e9173fb04dcc44b220cd3f17e diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index 4bf7993a..0aae845 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -195,9 +195,60 @@ public: struct DrawCheckered : public RegionRenderer { virtual void RenderRegion(OutputDevice &rDev, Rectangle r, - const RenderContext &) SAL_OVERRIDE + const RenderContext &rCtx) SAL_OVERRIDE { - rDev.DrawCheckered(r.TopLeft(), r.GetSize()); + if (rCtx.meStyle == RENDER_EXPANDED) + { + std::vector<Rectangle> aRegions(DemoWin::partition(rDev, 2, 2)); + for (size_t i = 0; i < aRegions.size(); i++) + { + vcl::Region aRegion; + Rectangle aSub(aRegions[i]); + Rectangle aSmaller(aSub); + aSmaller.Move(10,10); + aSmaller.setWidth(aSmaller.getWidth()-20); + aSmaller.setHeight(aSmaller.getHeight()-24); + switch (i) { + case 0: + aRegion = vcl::Region(aSub); + break; + case 1: + aRegion = vcl::Region(aSmaller); + aRegion.XOr(aSub); + break; + case 2: + { + Polygon aPoly(aSub); + aPoly.Rotate(aSub.Center(), 450); + aPoly.Clip(aSmaller); + aRegion = vcl::Region(aPoly); + break; + } + case 3: + { + tools::PolyPolygon aPolyPoly; + sal_Int32 nTW = aSub.GetWidth()/6; + sal_Int32 nTH = aSub.GetHeight()/6; + Rectangle aTiny(Point(4, 4), Size(nTW*2, nTH*2)); + aPolyPoly.Insert(Polygon(aTiny)); + aTiny.Move(nTW*3, nTH*3); + aPolyPoly.Insert(Polygon(aTiny)); + aTiny.Move(nTW, nTH); + aPolyPoly.Insert(Polygon(aTiny)); + + aRegion = vcl::Region(aPolyPoly); + break; + } + } // switch + rDev.SetClipRegion(aRegion); + rDev.DrawCheckered(aSub.TopLeft(), aSub.GetSize()); + rDev.SetClipRegion(); + } + } + else + { + rDev.DrawCheckered(r.TopLeft(), r.GetSize()); + } } }; commit a05fe51feb29301968299d6167fa1acb0d5850e0 Author: Michael Meeks <michael.me...@collabora.com> Date: Tue Nov 11 23:32:35 2014 +0000 vcldemo: render a selection of odd gradients. Change-Id: Ic3d2f795d453b9c48316d78d0d50486624cdc2b1 diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index b5c2ddf..4bf7993a 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -103,8 +103,46 @@ public: drawToDevice(getOutDev(), false); } - std::vector<Rectangle> partitionAndClear(OutputDevice &rDev, - int nX, int nY); + static std::vector<Rectangle> partition(OutputDevice &rDev, int nX, int nY) + { + Rectangle r; + std::vector<Rectangle> aRegions; + + // Make small cleared area for these guys + Size aSize(rDev.GetOutputSizePixel()); + long nBorderSize = aSize.Width() / 32; + long nBoxWidth = (aSize.Width() - nBorderSize*(nX+1)) / nX; + long nBoxHeight = (aSize.Height() - nBorderSize*(nY+1)) / nY; + for (int y = 0; y < nY; y++ ) + { + for (int x = 0; x < nX; x++ ) + { + r.SetPos(Point(nBorderSize + (nBorderSize + nBoxWidth) * x, + nBorderSize + (nBorderSize + nBoxHeight) * y)); + r.SetSize(Size(nBoxWidth, nBoxHeight)); + aRegions.push_back(r); + } + } + + return aRegions; + } + + static void clearRects(OutputDevice &rDev, std::vector<Rectangle> &rRects) + { + for (size_t i = 0; i < rRects.size(); i++) + { + // knock up a nice little border + rDev.SetLineColor(COL_GRAY); + rDev.SetFillColor(COL_LIGHTGRAY); + if (i % 2) + { + int nBorderSize = rRects[i].GetWidth() / 5; + rDev.DrawRect(rRects[i], nBorderSize, nBorderSize); + } + else + rDev.DrawRect(rRects[i]); + } + } void drawBackground(OutputDevice &rDev, Rectangle r) { @@ -150,7 +188,7 @@ public: rDev.SetTextColor( Color( COL_BLACK ) ); vcl::Font aFont( OUString( "Times" ), Size( 0, 25 ) ); rDev.SetFont( aFont ); - rDev.DrawText( r, OUString( "Just a simple text" ) ); + rDev.DrawText( r, OUString( "Click any rect to zoom" ) ); } }; @@ -200,15 +238,70 @@ public: struct DrawGradient : public RegionRenderer { virtual void RenderRegion(OutputDevice &rDev, Rectangle r, - const RenderContext &) SAL_OVERRIDE + const RenderContext &rCtx) SAL_OVERRIDE { - Gradient aGradient; - aGradient.SetStartColor(COL_YELLOW); - aGradient.SetEndColor(COL_RED); -// aGradient.SetAngle(45); - aGradient.SetStyle(GradientStyle_RECT); - aGradient.SetBorder(r.GetSize().Width()/20); - rDev.DrawGradient(r, aGradient); + if (rCtx.meStyle == RENDER_EXPANDED) + { + std::vector<Rectangle> aRegions(DemoWin::partition(rDev, 5, 4)); + sal_uInt32 nStartCols[] = { + COL_RED, COL_RED, COL_RED, COL_GREEN, COL_GREEN, + COL_BLUE, COL_BLUE, COL_BLUE, COL_CYAN, COL_CYAN, + COL_GRAY, COL_GRAY, COL_LIGHTGRAY, COL_LIGHTBLUE, COL_LIGHTCYAN, + COL_WHITE, COL_WHITE, COL_BLACK, COL_BLACK + }; + sal_uInt32 nEndCols[] = { + COL_WHITE, COL_WHITE, COL_BLACK, COL_BLACK, + COL_RED, COL_RED, COL_RED, COL_GREEN, COL_GREEN, + COL_GRAY, COL_GRAY, COL_LIGHTGRAY, COL_LIGHTBLUE, COL_LIGHTCYAN, + COL_BLUE, COL_BLUE, COL_BLUE, COL_CYAN, COL_CYAN + }; + GradientStyle eStyles[] = { + GradientStyle_LINEAR, GradientStyle_AXIAL, GradientStyle_RADIAL, GradientStyle_ELLIPTICAL, GradientStyle_SQUARE, + GradientStyle_RECT, GradientStyle_FORCE_EQUAL_SIZE, GradientStyle_LINEAR, GradientStyle_RADIAL, + GradientStyle_LINEAR, GradientStyle_AXIAL, GradientStyle_RADIAL, GradientStyle_ELLIPTICAL, GradientStyle_SQUARE, + GradientStyle_RECT, GradientStyle_FORCE_EQUAL_SIZE, GradientStyle_LINEAR, GradientStyle_RADIAL + }; + sal_uInt16 nAngles[] = { + 0, 0, 0, 0, 0, + 15, 30, 45, 60, 75, + 90, 120, 135, 160, 180, + 0, 0, 0, 0, 0 + }; + sal_uInt16 nBorders[] = { + 0, 0, 0, 0, 0, + 1, 10, 100, 10, 1, + 0, 0, 0, 0, 0, + 1, 10, 20, 10, 1, + 0, 0, 0, 0, 0 + }; + DemoWin::clearRects(rDev, aRegions); + assert(aRegions.size() <= SAL_N_ELEMENTS(nStartCols)); + assert(aRegions.size() <= SAL_N_ELEMENTS(nEndCols)); + assert(aRegions.size() <= SAL_N_ELEMENTS(eStyles)); + assert(aRegions.size() <= SAL_N_ELEMENTS(nAngles)); + assert(aRegions.size() <= SAL_N_ELEMENTS(nBorders)); + for (size_t i = 0; i < aRegions.size(); i++) + { + Rectangle aSub = aRegions[i]; + Gradient aGradient; + aGradient.SetStartColor(Color(nStartCols[i])); + aGradient.SetEndColor(Color(nEndCols[i])); + aGradient.SetStyle(eStyles[i]); + aGradient.SetAngle(nAngles[i]); + aGradient.SetBorder(nBorders[i]); + rDev.DrawGradient(aSub, aGradient); + } + } + else + { + Gradient aGradient; + aGradient.SetStartColor(COL_YELLOW); + aGradient.SetEndColor(COL_RED); + // aGradient.SetAngle(45); + aGradient.SetStyle(GradientStyle_RECT); + aGradient.SetBorder(r.GetSize().Width()/20); + rDev.DrawGradient(r, aGradient); + } } }; @@ -378,7 +471,8 @@ public: else { aCtx.meStyle = RENDER_THUMB; - std::vector<Rectangle> aRegions(partitionAndClear(rDev, mnSegmentsX, mnSegmentsY)); + std::vector<Rectangle> aRegions(DemoWin::partition(rDev, mnSegmentsX, mnSegmentsY)); + DemoWin::clearRects(rDev, aRegions); for (size_t i = 0; i < maRenderers.size(); i++) maRenderers[i]->RenderRegion(rDev, aRegions[i], aCtx); } @@ -417,7 +511,7 @@ void DemoWin::MouseButtonDown( const MouseEvent& rMEvt ) } // click on a region to zoom into it - std::vector<Rectangle> aRegions(partitionAndClear(*this, mnSegmentsX, mnSegmentsY)); + std::vector<Rectangle> aRegions(partition(*this, mnSegmentsX, mnSegmentsY)); for (size_t i = 0; i < aRegions.size(); i++) { if (aRegions[i].IsInside(rMEvt.GetPosPixel())) @@ -453,39 +547,6 @@ void DemoWin::MouseButtonDown( const MouseEvent& rMEvt ) } } -std::vector<Rectangle> DemoWin::partitionAndClear(OutputDevice &rDev, int nX, int nY) -{ - Rectangle r; - std::vector<Rectangle> aRegions; - - // Make small cleared area for these guys - Size aSize(rDev.GetOutputSizePixel()); - long nBorderSize = aSize.Width() / 32; - long nBoxWidth = (aSize.Width() - nBorderSize*(nX+1)) / nX; - long nBoxHeight = (aSize.Height() - nBorderSize*(nY+1)) / nY; - for (int y = 0; y < nY; y++ ) - { - for (int x = 0; x < nX; x++ ) - { - r.SetPos(Point(nBorderSize + (nBorderSize + nBoxWidth) * x, - nBorderSize + (nBorderSize + nBoxHeight) * y)); - r.SetSize(Size(nBoxWidth, nBoxHeight)); - - // knock up a nice little border - rDev.SetLineColor(COL_GRAY); - rDev.SetFillColor(COL_LIGHTGRAY); - if ((x + y) % 2) - rDev.DrawRect(r, nBorderSize, nBorderSize); - else - rDev.DrawRect(r); - - aRegions.push_back(r); - } - } - - return aRegions; -} - void DemoWin::InitRenderers() { maRenderers.push_back(new DrawRadialLines()); commit c3eab4a893a4cde7c23ad06e4090283775b1e49b Author: Michael Meeks <michael.me...@collabora.com> Date: Tue Nov 11 22:55:38 2014 +0000 vcldemo: render an enlarged view on mouse click. Change-Id: I9021ab4744b16f967eaa5006128d30621b421d7a diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index 57eecfa..b5c2ddf 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -52,6 +52,9 @@ class DemoWin : public DemoBase Bitmap maIntroBW; BitmapEx maIntro; + int mnSegmentsX; + int mnSegmentsY; + struct RenderContext { RenderStyle meStyle; bool mbVDev; @@ -65,11 +68,15 @@ class DemoWin : public DemoBase }; std::vector< RegionRenderer * > maRenderers; + sal_Int32 mnSelectedRenderer; void InitRenderers(); public: DemoWin() : DemoBase() + , mnSegmentsX(4) + , mnSegmentsY(3) + , mnSelectedRenderer(-1) , mpButton(NULL) , mpButtonWin(NULL) { @@ -99,14 +106,12 @@ public: std::vector<Rectangle> partitionAndClear(OutputDevice &rDev, int nX, int nY); - void drawBackground(OutputDevice &rDev) + void drawBackground(OutputDevice &rDev, Rectangle r) { - Rectangle r(Point(0,0), rDev.GetOutputSizePixel()); Gradient aGradient; aGradient.SetStartColor(COL_BLUE); aGradient.SetEndColor(COL_GREEN); aGradient.SetStyle(GradientStyle_LINEAR); -// aGradient.SetBorder(r.GetSize().Width()/20); rDev.DrawGradient(r, aGradient); } @@ -358,15 +363,25 @@ public: void drawToDevice(OutputDevice &rDev, bool bVdev) { RenderContext aCtx; - aCtx.meStyle = RENDER_THUMB; aCtx.mbVDev = bVdev; aCtx.mpDemoWin = this; - drawBackground(rDev); + Rectangle aWholeWin(Point(0,0), rDev.GetOutputSizePixel()); + + drawBackground(rDev, aWholeWin); - std::vector<Rectangle> aRegions(partitionAndClear(rDev, 4, 3)); - for (size_t i = 0; i < maRenderers.size(); i++) - maRenderers[i]->RenderRegion(rDev, aRegions[i], aCtx); + if (mnSelectedRenderer >= 0) + { + aCtx.meStyle = RENDER_EXPANDED; + maRenderers[mnSelectedRenderer]->RenderRegion(rDev, aWholeWin, aCtx); + } + else + { + aCtx.meStyle = RENDER_THUMB; + std::vector<Rectangle> aRegions(partitionAndClear(rDev, mnSegmentsX, mnSegmentsY)); + for (size_t i = 0; i < maRenderers.size(); i++) + maRenderers[i]->RenderRegion(rDev, aRegions[i], aCtx); + } } }; @@ -393,7 +408,27 @@ IMPL_LINK_NOARG(DemoWin,BounceTimerCb) void DemoWin::MouseButtonDown( const MouseEvent& rMEvt ) { - (void) rMEvt; + // click to zoom out + if (mnSelectedRenderer >= 0) + { + mnSelectedRenderer = -1; + Invalidate(); + return; + } + + // click on a region to zoom into it + std::vector<Rectangle> aRegions(partitionAndClear(*this, mnSegmentsX, mnSegmentsY)); + for (size_t i = 0; i < aRegions.size(); i++) + { + if (aRegions[i].IsInside(rMEvt.GetPosPixel())) + { + mnSelectedRenderer = i; + Invalidate(); + return; + } + } + + // otherwise bounce floating windows if (!mpButton) { mpButtonWin = new FloatingWindow(this); commit 1c526c9ddda5d52f7a4db5655a4ec60b8c62835c Author: Michael Meeks <michael.me...@collabora.com> Date: Tue Nov 11 22:24:39 2014 +0000 vcldemo: re-factor rendering panes, to enable zooming. Change-Id: Ib50fcba992293ec661912444a051a02d856c7189 diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index 00bab53..57eecfa 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -42,11 +42,32 @@ public: OutputDevice &getOutDev() { return *this; } }; +enum RenderStyle { + RENDER_THUMB, // small view <n> to a page + RENDER_EXPANDED, // expanded view of this renderer +}; + class DemoWin : public DemoBase { Bitmap maIntroBW; BitmapEx maIntro; + struct RenderContext { + RenderStyle meStyle; + bool mbVDev; + DemoWin *mpDemoWin; + }; + struct RegionRenderer { + public: + virtual ~RegionRenderer() {} + virtual void RenderRegion(OutputDevice &rDev, Rectangle r, + const RenderContext &rCtx) = 0; + }; + + std::vector< RegionRenderer * > maRenderers; + + void InitRenderers(); + public: DemoWin() : DemoBase() , mpButton(NULL) @@ -56,6 +77,8 @@ public: Application::Abort("Failed to load intro image"); maIntroBW = maIntro.GetBitmap(); maIntroBW.Filter( BMP_FILTER_EMBOSS_GREY ); + + InitRenderers(); } // Bouncing windows on click ... @@ -67,8 +90,6 @@ public: virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE; - void drawToDevice(OutputDevice &r, bool bVdev); - virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE { fprintf(stderr, "DemoWin::Paint(%ld,%ld,%ld,%ld)\n", rRect.getX(), rRect.getY(), rRect.getWidth(), rRect.getHeight()); @@ -89,199 +110,263 @@ public: rDev.DrawGradient(r, aGradient); } - void drawRadialLines(OutputDevice &rDev, Rectangle r) + struct DrawRadialLines : public RegionRenderer { - rDev.SetFillColor(Color(COL_LIGHTRED)); - rDev.SetLineColor(Color(COL_BLACK)); - rDev.DrawRect( r ); - - for(int i=0; i<r.GetHeight(); i+=15) - rDev.DrawLine( Point(r.Left(), r.Top()+i), Point(r.Right(), r.Bottom()-i) ); - for(int i=0; i<r.GetWidth(); i+=15) - rDev.DrawLine( Point(r.Left()+i, r.Bottom()), Point(r.Right()-i, r.Top()) ); - - // Should draw a white-line across the middle - Color aLastPixel( COL_WHITE ); - Point aCenter((r.Left() + r.Right())/2 - 4, - (r.Top() + r.Bottom())/2 - 4); - for(int i=0; i<8; i++) + virtual void RenderRegion(OutputDevice &rDev, Rectangle r, + const RenderContext &) SAL_OVERRIDE { - rDev.DrawPixel(aCenter, aLastPixel); - aLastPixel = rDev.GetPixel(aCenter); - aCenter.Move(1,1); + rDev.SetFillColor(Color(COL_LIGHTRED)); + rDev.SetLineColor(Color(COL_BLACK)); + rDev.DrawRect( r ); + + for(int i=0; i<r.GetHeight(); i+=15) + rDev.DrawLine( Point(r.Left(), r.Top()+i), Point(r.Right(), r.Bottom()-i) ); + for(int i=0; i<r.GetWidth(); i+=15) + rDev.DrawLine( Point(r.Left()+i, r.Bottom()), Point(r.Right()-i, r.Top()) ); + + // Should draw a white-line across the middle + Color aLastPixel( COL_WHITE ); + Point aCenter((r.Left() + r.Right())/2 - 4, + (r.Top() + r.Bottom())/2 - 4); + for(int i=0; i<8; i++) + { + rDev.DrawPixel(aCenter, aLastPixel); + aLastPixel = rDev.GetPixel(aCenter); + aCenter.Move(1,1); + } } - } - - void drawText(OutputDevice &rDev, Rectangle r) + }; + struct DrawText : public RegionRenderer { - rDev.SetTextColor( Color( COL_BLACK ) ); - vcl::Font aFont( OUString( "Times" ), Size( 0, 25 ) ); - rDev.SetFont( aFont ); - rDev.DrawText( r, OUString( "Just a simple text" ) ); - } + virtual void RenderRegion(OutputDevice &rDev, Rectangle r, + const RenderContext &) SAL_OVERRIDE + { + rDev.SetTextColor( Color( COL_BLACK ) ); + vcl::Font aFont( OUString( "Times" ), Size( 0, 25 ) ); + rDev.SetFont( aFont ); + rDev.DrawText( r, OUString( "Just a simple text" ) ); + } + }; - void drawPoly(OutputDevice &rDev, Rectangle r) // pretty + struct DrawCheckered : public RegionRenderer { - drawCheckered(rDev, r); - - long nDx = r.GetWidth()/20; - long nDy = r.GetHeight()/20; - Rectangle aShrunk(r); - aShrunk.Move(nDx, nDy); - aShrunk.SetSize(Size(r.GetWidth()-nDx*2, - r.GetHeight()-nDy*2)); - Polygon aPoly(aShrunk); - tools::PolyPolygon aPPoly(aPoly); - rDev.SetLineColor(Color(COL_RED)); - rDev.SetFillColor(Color(COL_RED)); - // This hits the optional 'drawPolyPolygon' code-path - rDev.DrawTransparent(aPPoly, 64); - } - void drawEllipse(OutputDevice &rDev, Rectangle r) + virtual void RenderRegion(OutputDevice &rDev, Rectangle r, + const RenderContext &) SAL_OVERRIDE + { + rDev.DrawCheckered(r.TopLeft(), r.GetSize()); + } + }; + struct DrawPoly : public RegionRenderer { - rDev.SetLineColor(Color(COL_RED)); - rDev.SetFillColor(Color(COL_GREEN)); - rDev.DrawEllipse(r); - } - void drawCheckered(OutputDevice &rDev, Rectangle r) + DrawCheckered maCheckered; + virtual void RenderRegion(OutputDevice &rDev, Rectangle r, + const RenderContext &rCtx) SAL_OVERRIDE + { + maCheckered.RenderRegion(rDev, r, rCtx); + + long nDx = r.GetWidth()/20; + long nDy = r.GetHeight()/20; + Rectangle aShrunk(r); + aShrunk.Move(nDx, nDy); + aShrunk.SetSize(Size(r.GetWidth()-nDx*2, + r.GetHeight()-nDy*2)); + Polygon aPoly(aShrunk); + tools::PolyPolygon aPPoly(aPoly); + rDev.SetLineColor(Color(COL_RED)); + rDev.SetFillColor(Color(COL_RED)); + // This hits the optional 'drawPolyPolygon' code-path + rDev.DrawTransparent(aPPoly, 64); + } + }; + struct DrawEllipse : public RegionRenderer { - rDev.DrawCheckered(r.TopLeft(), r.GetSize()); - } - void drawGradient(OutputDevice &rDev, Rectangle r) + virtual void RenderRegion(OutputDevice &rDev, Rectangle r, + const RenderContext &) SAL_OVERRIDE + { + rDev.SetLineColor(Color(COL_RED)); + rDev.SetFillColor(Color(COL_GREEN)); + rDev.DrawEllipse(r); + } + }; + struct DrawGradient : public RegionRenderer { - Gradient aGradient; - aGradient.SetStartColor(COL_YELLOW); - aGradient.SetEndColor(COL_RED); -// aGradient.SetAngle(45); - aGradient.SetStyle(GradientStyle_RECT); - aGradient.SetBorder(r.GetSize().Width()/20); - rDev.DrawGradient(r, aGradient); - } - void drawBitmap(OutputDevice &rDev, Rectangle r) + virtual void RenderRegion(OutputDevice &rDev, Rectangle r, + const RenderContext &) SAL_OVERRIDE + { + Gradient aGradient; + aGradient.SetStartColor(COL_YELLOW); + aGradient.SetEndColor(COL_RED); +// aGradient.SetAngle(45); + aGradient.SetStyle(GradientStyle_RECT); + aGradient.SetBorder(r.GetSize().Width()/20); + rDev.DrawGradient(r, aGradient); + } + }; + struct DrawBitmap : public RegionRenderer { - Bitmap aBitmap(maIntroBW); - aBitmap.Scale(r.GetSize(), BMP_SCALE_BESTQUALITY); - rDev.DrawBitmap(r.TopLeft(), aBitmap); - } - void drawBitmapEx(OutputDevice &rDev, Rectangle r) + virtual void RenderRegion(OutputDevice &rDev, Rectangle r, + const RenderContext &rCtx) SAL_OVERRIDE + { + Bitmap aBitmap(rCtx.mpDemoWin->maIntroBW); + aBitmap.Scale(r.GetSize(), BMP_SCALE_BESTQUALITY); + rDev.DrawBitmap(r.TopLeft(), aBitmap); + } + }; + struct DrawBitmapEx : public RegionRenderer { - drawCheckered(rDev, r); - - BitmapEx aBitmap(maIntro); - aBitmap.Scale(r.GetSize(), BMP_SCALE_BESTQUALITY); - AlphaMask aSemiTransp(aBitmap.GetSizePixel()); - aSemiTransp.Erase(64); - rDev.DrawBitmapEx(r.TopLeft(), BitmapEx(aBitmap.GetBitmap(), - aSemiTransp)); - } - void drawPolyPolgons(OutputDevice &rDev, Rectangle r) + DrawCheckered maCheckered; + virtual void RenderRegion(OutputDevice &rDev, Rectangle r, + const RenderContext &rCtx) SAL_OVERRIDE + { + maCheckered.RenderRegion(rDev, r, rCtx); + + BitmapEx aBitmap(rCtx.mpDemoWin->maIntro); + aBitmap.Scale(r.GetSize(), BMP_SCALE_BESTQUALITY); + AlphaMask aSemiTransp(aBitmap.GetSizePixel()); + aSemiTransp.Erase(64); + rDev.DrawBitmapEx(r.TopLeft(), BitmapEx(aBitmap.GetBitmap(), + aSemiTransp)); + } + }; + struct DrawPolyPolygons : public RegionRenderer { - struct { - double nX, nY; - } aPoints[] = { { 0.1, 0.1 }, { 0.9, 0.9 }, + virtual void RenderRegion(OutputDevice &rDev, Rectangle r, + const RenderContext &) SAL_OVERRIDE + { + struct { + double nX, nY; + } aPoints[] = { { 0.1, 0.1 }, { 0.9, 0.9 }, #ifdef FIXME_SELF_INTERSECTING_WORKING - { 0.9, 0.1 }, { 0.1, 0.9 }, - { 0.1, 0.1 } }; + { 0.9, 0.1 }, { 0.1, 0.9 }, + { 0.1, 0.1 } #else - { 0.1, 0.9 }, { 0.5, 0.5 }, - { 0.9, 0.1 }, { 0.1, 0.1 } }; + { 0.1, 0.9 }, { 0.5, 0.5 }, + { 0.9, 0.1 }, { 0.1, 0.1 } #endif + }; - tools::PolyPolygon aPolyPoly; - // Render 4x polygons & aggregate into another PolyPolygon - for (int x = 0; x < 2; x++) - { - for (int y = 0; y < 2; y++) + tools::PolyPolygon aPolyPoly; + // Render 4x polygons & aggregate into another PolyPolygon + for (int x = 0; x < 2; x++) { - Rectangle aSubRect(r); - aSubRect.Move(x * r.GetWidth()/3, y * r.GetHeight()/3); - aSubRect.SetSize(Size(r.GetWidth()/2, r.GetHeight()/4)); - Polygon aPoly(SAL_N_ELEMENTS(aPoints)); - for (size_t v = 0; v < SAL_N_ELEMENTS(aPoints); v++) + for (int y = 0; y < 2; y++) { - aPoly.SetPoint(Point(aSubRect.Left() + - aSubRect.GetWidth() * aPoints[v].nX, - aSubRect.Top() + - aSubRect.GetHeight() * aPoints[v].nY), - v); + Rectangle aSubRect(r); + aSubRect.Move(x * r.GetWidth()/3, y * r.GetHeight()/3); + aSubRect.SetSize(Size(r.GetWidth()/2, r.GetHeight()/4)); + Polygon aPoly(SAL_N_ELEMENTS(aPoints)); + for (size_t v = 0; v < SAL_N_ELEMENTS(aPoints); v++) + { + aPoly.SetPoint(Point(aSubRect.Left() + + aSubRect.GetWidth() * aPoints[v].nX, + aSubRect.Top() + + aSubRect.GetHeight() * aPoints[v].nY), + v); + } + rDev.SetLineColor(Color(COL_YELLOW)); + rDev.SetFillColor(Color(COL_BLACK)); + rDev.DrawPolygon(aPoly); + + // now move and add to the polypolygon + aPoly.Move(0, r.GetHeight()/2); + aPolyPoly.Insert(aPoly); } - rDev.SetLineColor(Color(COL_YELLOW)); - rDev.SetFillColor(Color(COL_BLACK)); - rDev.DrawPolygon(aPoly); - - // now move and add to the polypolygon - aPoly.Move(0, r.GetHeight()/2); - aPolyPoly.Insert(aPoly); } + rDev.SetLineColor(Color(COL_LIGHTRED)); + rDev.SetFillColor(Color(COL_GREEN)); + rDev.DrawTransparent(aPolyPoly, 50); } - rDev.SetLineColor(Color(COL_LIGHTRED)); - rDev.SetFillColor(Color(COL_GREEN)); - rDev.DrawTransparent(aPolyPoly, 50); - } - void drawToVirtualDevice(OutputDevice &rDev, Rectangle r) - { - VirtualDevice aNested(rDev); - aNested.SetOutputSizePixel(r.GetSize()); - Rectangle aWhole(Point(0,0), r.GetSize()); - // mini me - drawToDevice(aNested, true); - - Bitmap aBitmap(aNested.GetBitmap(Point(0,0),aWhole.GetSize())); - rDev.DrawBitmap(r.TopLeft(), aBitmap); - } + }; - std::vector<BitmapEx> maIcons; - void initIcons() + struct DrawToVirtualDevice : public RegionRenderer { - if (maIcons.size()) - return; - - const char *pNames[] = { - "cmd/lc_openurl.png", - "cmd/lc_newdoc.png", - "cmd/lc_save.png", - "cmd/lc_saveas.png", - "cmd/lc_sendmail.png", - "cmd/lc_editdoc.png", - "cmd/lc_print.png", - "cmd/lc_printpreview.png", - "cmd/lc_cut.png", - "cmd/lc_copy.png", - "cmd/lc_paste.png", - "cmd/lc_formatpaintbrush.png", - "cmd/lc_undo.png", - "cmd/lc_redo.png", - }; - for (size_t i = 0; i < SAL_N_ELEMENTS(pNames); i++) - maIcons.push_back(BitmapEx(OUString::createFromAscii(pNames[i]))); - } - void drawIcons(OutputDevice &rDev, Rectangle r) + virtual void RenderRegion(OutputDevice &rDev, Rectangle r, + const RenderContext &rCtx) SAL_OVERRIDE + { + // avoid infinite recursion + if (rCtx.mbVDev) + return; + VirtualDevice aNested(rDev); + aNested.SetOutputSizePixel(r.GetSize()); + Rectangle aWhole(Point(0,0), r.GetSize()); + // mini me + rCtx.mpDemoWin->drawToDevice(aNested, true); + + Bitmap aBitmap(aNested.GetBitmap(Point(0,0),aWhole.GetSize())); + rDev.DrawBitmap(r.TopLeft(), aBitmap); + } + }; + + struct DrawIcons : public RegionRenderer { - initIcons(); + std::vector<BitmapEx> maIcons; + DrawIcons() + { + const char *pNames[] = { + "cmd/lc_openurl.png", + "cmd/lc_newdoc.png", + "cmd/lc_save.png", + "cmd/lc_saveas.png", + "cmd/lc_sendmail.png", + "cmd/lc_editdoc.png", + "cmd/lc_print.png", + "cmd/lc_printpreview.png", + "cmd/lc_cut.png", + "cmd/lc_copy.png", + "cmd/lc_paste.png", + "cmd/lc_formatpaintbrush.png", + "cmd/lc_undo.png", + "cmd/lc_redo.png", + }; + for (size_t i = 0; i < SAL_N_ELEMENTS(pNames); i++) + maIcons.push_back(BitmapEx(OUString::createFromAscii(pNames[i]))); + } - Rectangle p(r); - for (size_t i = 0; i < maIcons.size(); i++) + virtual void RenderRegion(OutputDevice &rDev, Rectangle r, + const RenderContext &) SAL_OVERRIDE { - Size aSize(maIcons[i].GetSizePixel()); - rDev.DrawBitmapEx(p.TopLeft(), maIcons[i]); - p.Move(aSize.Width(), 0); - if (p.Left() >= r.Right()) - break; + Rectangle p(r); + for (size_t i = 0; i < maIcons.size(); i++) + { + Size aSize(maIcons[i].GetSizePixel()); + rDev.DrawBitmapEx(p.TopLeft(), maIcons[i]); + p.Move(aSize.Width(), 0); + if (p.Left() >= r.Right()) + break; + } } - } + }; - void fetchDrawBitmap(OutputDevice &rDev, Rectangle r) + struct FetchDrawBitmap : public RegionRenderer { - Bitmap aBitmap(rDev.GetBitmap(Point(0,0),rDev.GetOutputSizePixel())); - aBitmap.Scale(r.GetSize(), BMP_SCALE_BESTQUALITY); - rDev.DrawBitmap(r.TopLeft(), aBitmap); + virtual void RenderRegion(OutputDevice &rDev, Rectangle r, + const RenderContext &) SAL_OVERRIDE + { + Bitmap aBitmap(rDev.GetBitmap(Point(0,0),rDev.GetOutputSizePixel())); + aBitmap.Scale(r.GetSize(), BMP_SCALE_BESTQUALITY); + rDev.DrawBitmap(r.TopLeft(), aBitmap); + } + }; + + void drawToDevice(OutputDevice &rDev, bool bVdev) + { + RenderContext aCtx; + aCtx.meStyle = RENDER_THUMB; + aCtx.mbVDev = bVdev; + aCtx.mpDemoWin = this; + + drawBackground(rDev); + + std::vector<Rectangle> aRegions(partitionAndClear(rDev, 4, 3)); + for (size_t i = 0; i < maRenderers.size(); i++) + maRenderers[i]->RenderRegion(rDev, aRegions[i], aCtx); } }; @@ -366,26 +451,20 @@ std::vector<Rectangle> DemoWin::partitionAndClear(OutputDevice &rDev, int nX, in return aRegions; } -void DemoWin::drawToDevice(OutputDevice &rDev, bool bVdev) +void DemoWin::InitRenderers() { - drawBackground(rDev); - - std::vector<Rectangle> aRegions(partitionAndClear(rDev, 4, 3)); - - drawRadialLines(rDev, aRegions[0]); - drawText(rDev, aRegions[1]); - drawPoly(rDev, aRegions[2]); - drawEllipse(rDev, aRegions[3]); - drawCheckered(rDev, aRegions[4]); - drawBitmapEx(rDev, aRegions[5]); - drawBitmap(rDev, aRegions[6]); - drawGradient(rDev, aRegions[7]); - drawPolyPolgons(rDev, aRegions[8]); - if (!bVdev) - drawToVirtualDevice(rDev, aRegions[9]); - drawIcons(rDev, aRegions[10]); - // last - thumbnail all the above - fetchDrawBitmap(rDev, aRegions[11]); + maRenderers.push_back(new DrawRadialLines()); + maRenderers.push_back(new DrawText()); + maRenderers.push_back(new DrawPoly()); + maRenderers.push_back(new DrawEllipse()); + maRenderers.push_back(new DrawCheckered()); + maRenderers.push_back(new DrawBitmapEx()); + maRenderers.push_back(new DrawBitmap()); + maRenderers.push_back(new DrawGradient()); + maRenderers.push_back(new DrawPolyPolygons()); + maRenderers.push_back(new DrawToVirtualDevice()); + maRenderers.push_back(new DrawIcons()); + maRenderers.push_back(new DrawBitmap()); } class DemoApp : public Application commit 880310280901f7fc2966724265b7ba331244c07e Author: Michael Meeks <michael.me...@collabora.com> Date: Tue Nov 11 21:51:58 2014 +0000 vcldemo: click to invalidate bits and bounce a floatwin around. Change-Id: I0c417842393eb32132fd430b8bf31e93e7ec3b27 diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index 354c4b3..00bab53 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -23,6 +23,8 @@ #include <vcl/wrkwin.hxx> #include <vcl/virdev.hxx> #include <vcl/graphicfilter.hxx> +#include <vcl/button.hxx> +#include <vcl/floatwin.hxx> #if 0 # define FIXME_SELF_INTERSECTING_WORKING @@ -47,6 +49,8 @@ class DemoWin : public DemoBase public: DemoWin() : DemoBase() + , mpButton(NULL) + , mpButtonWin(NULL) { if (!Application::LoadBrandBitmap("intro", maIntro)) Application::Abort("Failed to load intro image"); @@ -54,6 +58,15 @@ public: maIntroBW.Filter( BMP_FILTER_EMBOSS_GREY ); } + // Bouncing windows on click ... + PushButton *mpButton; + FloatingWindow *mpButtonWin; + AutoTimer maBounce; + int mnBounceX, mnBounceY; + DECL_LINK(BounceTimerCb, void *); + + virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE; + void drawToDevice(OutputDevice &r, bool bVdev); virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE @@ -272,6 +285,54 @@ public: } }; +IMPL_LINK_NOARG(DemoWin,BounceTimerCb) +{ + mpButton->Check(mnBounceX>0); + mpButton->SetPressed(mnBounceY>0); + + Point aCur = mpButtonWin->GetPosPixel(); + static const int nMovePix = 10; + aCur.Move(mnBounceX * nMovePix, mnBounceX * nMovePix); + Size aWinSize = GetSizePixel(); + if (aCur.X() <= 0 || aCur.X() >= aWinSize.Width()) + mnBounceX *= -1; + if (aCur.Y() <= 0 || aCur.Y() >= aWinSize.Height()) + mnBounceX *= -1; + mpButtonWin->SetPosPixel(aCur); + + // All smoke and mirrors to test sub-region invalidation underneath + Rectangle aRect(aCur, mpButtonWin->GetSizePixel()); + Invalidate(aRect); + return 0; +} + +void DemoWin::MouseButtonDown( const MouseEvent& rMEvt ) +{ + (void) rMEvt; + if (!mpButton) + { + mpButtonWin = new FloatingWindow(this); + mpButton = new PushButton(mpButtonWin); + mpButton->SetSymbol(SymbolType::HELP); + mpButton->SetText("PushButton demo"); + mpButton->SetPosSizePixel(Point(0,0), mpButton->GetOptimalSize()); + mpButton->Show(); + mpButtonWin->SetPosSizePixel(Point(0,0), mpButton->GetOptimalSize()); + mpButtonWin->Show(); + mnBounceX = 1; mnBounceX = 1; + maBounce.SetTimeoutHdl(LINK(this,DemoWin,BounceTimerCb)); + maBounce.SetTimeout(55); + maBounce.Start(); + } + else + { + maBounce.Stop(); + delete mpButtonWin; + mpButtonWin = NULL; + mpButton = NULL; + } +} + std::vector<Rectangle> DemoWin::partitionAndClear(OutputDevice &rDev, int nX, int nY) { Rectangle r; commit 355770eff40acc07e9cd46fa4dcfb39e6a86166e Author: Samuel Mehrbrodt <s.mehrbr...@gmail.com> Date: Tue Nov 11 21:47:01 2014 +0100 fdo82708 Add missing tooltips to Writer Statusbar Change-Id: Ie44b8de69b98ebfa789cc8f9a1d8a60b698fc154 Reviewed-on: https://gerrit.libreoffice.org/12368 Reviewed-by: Samuel Mehrbrodt <s.mehrbr...@gmail.com> Tested-by: Samuel Mehrbrodt <s.mehrbr...@gmail.com> diff --git a/framework/inc/classes/resource.hrc b/framework/inc/classes/resource.hrc index 9c02511..a74b314 100644 --- a/framework/inc/classes/resource.hrc +++ b/framework/inc/classes/resource.hrc @@ -50,6 +50,7 @@ #define STR_RESET_TO_DEFAULT_LANGUAGE (RID_STR_START+22) #define STR_CLEAR_RECENT_FILES (RID_STR_START+23) #define STR_CLEAR_RECENT_FILES_HELP (RID_STR_START+24) +#define STR_LANGSTATUS_HINT (RID_STR_START+25) #define POPUPMENU_TOOLBAR_QUICKCUSTOMIZATION (RID_MENU_START+0) diff --git a/framework/source/classes/resource.src b/framework/source/classes/resource.src index 1f4f5df..8411220 100644 --- a/framework/source/classes/resource.src +++ b/framework/source/classes/resource.src @@ -190,4 +190,9 @@ String STR_SET_LANGUAGE_FOR_ALL_TEXT Text [ en-US ] = "Set Language for all Text" ; }; +String STR_LANGSTATUS_HINT +{ + Text [ en-US ] = "Text Language. Right-click to set selection or paragraph language" ; +}; + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/source/uielement/langselectionstatusbarcontroller.cxx b/framework/source/uielement/langselectionstatusbarcontroller.cxx index f043c1d..004e43c 100644 --- a/framework/source/uielement/langselectionstatusbarcontroller.cxx +++ b/framework/source/uielement/langselectionstatusbarcontroller.cxx @@ -146,6 +146,7 @@ throw (css::uno::Exception, css::uno::RuntimeException, std::exception) if ( m_xStatusbarItem.is() ) { m_xStatusbarItem->setText( FWK_RESSTR(STR_LANGSTATUS_MULTIPLE_LANGUAGES) ); + m_xStatusbarItem->setQuickHelpText(FWK_RESSTR(STR_LANGSTATUS_HINT)); } } diff --git a/include/svx/dialogs.hrc b/include/svx/dialogs.hrc index 067298f..495cae8 100644 --- a/include/svx/dialogs.hrc +++ b/include/svx/dialogs.hrc @@ -1045,9 +1045,13 @@ #define RID_SVXSTR_RECOVERY_INPROGRESS (RID_SVX_START + 1288) #define RID_SVXSTR_RECOVERYONLY_FINISH_DESCR (RID_SVX_START + 1289) #define RID_SVXSTR_RECOVERYONLY_FINISH (RID_SVX_START + 1290) +#define RID_SVXSTR_ZOOMTOOL_HINT (RID_SVX_START + 1291) +#define RID_SVXSTR_ZOOM (RID_SVX_START + 1292) +#define RID_SVXSTR_ZOOM_IN (RID_SVX_START + 1293) +#define RID_SVXSTR_ZOOM_OUT (RID_SVX_START + 1294) // !!! IMPORTANT: consider and update RID_SVXSTR_NEXTFREE when introducing new RIDs for Strings !!! -#define RID_SVXSTR_NEXTFREE (RID_SVX_START + 1291) +#define RID_SVXSTR_NEXTFREE (RID_SVX_START + 1295) // if we have _a_lot_ time, we should group the resource ids by type, instead // of grouping them by semantics. The reason is that resource ids have to be diff --git a/svx/source/stbctrls/stbctrls.src b/svx/source/stbctrls/stbctrls.src index a9e98a7..3a997bc 100644 --- a/svx/source/stbctrls/stbctrls.src +++ b/svx/source/stbctrls/stbctrls.src @@ -121,6 +121,26 @@ String RID_SVXSTR_FIT_SLIDE Text [ en-US ] = "Fit slide to current window."; }; +String RID_SVXSTR_ZOOMTOOL_HINT +{ + Text [ en-US ] = "Zoom level. Click for dialog box and right-click for zoom list"; +}; + +String RID_SVXSTR_ZOOM +{ + Text [ en-US ] = "Adjust zoom level"; +}; + +String RID_SVXSTR_ZOOM_IN +{ + Text [ en-US ] = "Zoom in"; +}; + +String RID_SVXSTR_ZOOM_OUT +{ + Text [ en-US ] = "Zoom out"; +}; + // PopupMenu ------------------------------------------------------------- Menu RID_SVXMNU_ZOOM { diff --git a/svx/source/stbctrls/zoomctrl.cxx b/svx/source/stbctrls/zoomctrl.cxx index 01a6924..63210fe 100644 --- a/svx/source/stbctrls/zoomctrl.cxx +++ b/svx/source/stbctrls/zoomctrl.cxx @@ -103,6 +103,7 @@ SvxZoomStatusBarControl::SvxZoomStatusBarControl( sal_uInt16 _nSlotId, nZoom( 100 ), nValueSet( SVX_ZOOM_ENABLE_ALL ) { + GetStatusBar().SetQuickHelpText(GetId(), SVX_RESSTR(RID_SVXSTR_ZOOMTOOL_HINT)); } void SvxZoomStatusBarControl::StateChanged( sal_uInt16, SfxItemState eState, diff --git a/svx/source/stbctrls/zoomsliderctrl.cxx b/svx/source/stbctrls/zoomsliderctrl.cxx index 6f5b400..8ea241b 100644 --- a/svx/source/stbctrls/zoomsliderctrl.cxx +++ b/svx/source/stbctrls/zoomsliderctrl.cxx @@ -351,14 +351,13 @@ bool SvxZoomSliderControl::MouseMove( const MouseEvent & rEvt ) return true; const short nButtons = rEvt.GetButtons(); + const Rectangle aControlRect = getControlRect(); + const Point aPoint = rEvt.GetPosPixel(); + const sal_Int32 nXDiff = aPoint.X() - aControlRect.Left(); // check mouse move with button pressed if ( 1 == nButtons ) { - const Rectangle aControlRect = getControlRect(); - const Point aPoint = rEvt.GetPosPixel(); - const sal_Int32 nXDiff = aPoint.X() - aControlRect.Left(); - if ( nXDiff >= nSliderXOffset && nXDiff <= aControlRect.GetWidth() - nSliderXOffset ) { mpImpl->mnCurrentZoom = Offset2Zoom( nXDiff ); @@ -367,6 +366,23 @@ bool SvxZoomSliderControl::MouseMove( const MouseEvent & rEvt ) } } + // Tooltips + + long nIncDecWidth = mpImpl->maIncreaseButton.GetSizePixel().Width(); + + const long nButtonLeftOffset = (nSliderXOffset - nIncDecWidth)/2; + const long nButtonRightOffset = (nSliderXOffset + nIncDecWidth)/2; + + // click to - button + if ( nXDiff >= nButtonLeftOffset && nXDiff <= nButtonRightOffset ) + GetStatusBar().SetQuickHelpText(GetId(), SVX_RESSTR(RID_SVXSTR_ZOOM_OUT)); + // click to + button + else if ( nXDiff >= aControlRect.GetWidth() - nSliderXOffset + nButtonLeftOffset && + nXDiff <= aControlRect.GetWidth() - nSliderXOffset + nButtonRightOffset ) + GetStatusBar().SetQuickHelpText(GetId(), SVX_RESSTR(RID_SVXSTR_ZOOM_IN)); + else + GetStatusBar().SetQuickHelpText(GetId(), SVX_RESSTR(RID_SVXSTR_ZOOM)); + return true; } diff --git a/sw/AllLangResTarget_sw.mk b/sw/AllLangResTarget_sw.mk index c4c7780..c95c16a 100644 --- a/sw/AllLangResTarget_sw.mk +++ b/sw/AllLangResTarget_sw.mk @@ -80,6 +80,7 @@ $(eval $(call gb_SrsTarget_add_files,sw/res,\ sw/source/uibase/utlui/attrdesc.src \ sw/source/uibase/utlui/navipi.src \ sw/source/uibase/utlui/initui.src \ + sw/source/uibase/utlui/statusbar.src \ sw/source/uibase/wrtsh/wrtsh.src \ sw/source/uibase/utlui/unotools.src \ sw/source/uibase/dbui/mailmergechildwindow.src \ diff --git a/sw/inc/rcid.hrc b/sw/inc/rcid.hrc index 4e8428a..0af4762 100644 --- a/sw/inc/rcid.hrc +++ b/sw/inc/rcid.hrc @@ -40,7 +40,6 @@ #define RC_FRMDLG (RC_BASE + 1000) #define RC_FLDDLG (RC_BASE + 1100) #define RC_UTLUI (RC_BASE + 1250) -#define RC_ATTR (RC_BASE + 1350) #define RC_TABLE (RC_BASE + 1450) #define RC_CONFIG (RC_BASE + 1550) #define RC_MISC (RC_BASE + 1650) @@ -71,6 +70,7 @@ #define RC_PAGEFRM (RC_BASE + 4250) #define RC_IDXTXT (RC_BASE + 4350) #define RC_SIDEBAR (RC_BASE + 4450) +#define RC_ATTR (RC_BASE + 4550) /*-------------------------------------------------------------------- Description: areas unharness @@ -149,11 +149,7 @@ // Utilities UI #define RC_UTLUI_BEGIN RC_UTLUI -#define RC_UTLUI_END (RC_UTLUI + 99) - -// Utilities UI-Attributes -#define RC_ATTR_BEGIN RC_ATTR -#define RC_ATTR_END (RC_ATTR + 99) +#define RC_UTLUI_END (RC_UTLUI + 199) // Tables #define RC_TABLE_BEGIN RC_TABLE @@ -258,6 +254,11 @@ // sidebar (mostly the Page one) #define RC_SIDEBAR_BEGIN RC_SIDEBAR +#define RC_SIDEBAR_END (RC_SIDEBAR + 99) + +// Utilities UI-Attributes +#define RC_ATTR_BEGIN RC_ATTR +#define RC_ATTR_END (RC_ATTR + 99) #endif diff --git a/sw/source/uibase/inc/utlui.hrc b/sw/source/uibase/inc/utlui.hrc index 9007b88..4caa3b3 100644 --- a/sw/source/uibase/inc/utlui.hrc +++ b/sw/source/uibase/inc/utlui.hrc @@ -45,7 +45,15 @@ #define STR_CONTENT_TYPE_INDEX (RC_UTLUI_BEGIN + 17) #define STR_CONTENT_TYPE_POSTIT (RC_UTLUI_BEGIN + 18) #define STR_CONTENT_TYPE_DRAWOBJECT (RC_UTLUI_BEGIN + 19) -#define STR_CONTENT_END (RC_UTLUI_BEGIN + 19) +// Statusbar: Word count/Viewlayout/Page count +#define STR_WORDCOUNT_HINT (RC_UTLUI_BEGIN + 20) +#define STR_VIEWLAYOUT_ONE (RC_UTLUI_BEGIN + 21) +#define STR_VIEWLAYOUT_TWO (RC_UTLUI_BEGIN + 22) +#define STR_VIEWLAYOUT_BOOK (RC_UTLUI_BEGIN + 23) +#define STR_BOOKCTRL_HINT (RC_UTLUI_BEGIN + 24) +#define STR_BOOKCTRL_HINT_EXTENDED (RC_UTLUI_BEGIN + 25) +#define STR_TMPLCTRL_HINT (RC_UTLUI_BEGIN + 26) +#define STR_CONTENT_END (RC_UTLUI_BEGIN + 26) #define STR_CONTENT_TYPE_SINGLE_FIRST (STR_CONTENT_END + 1) #define STR_CONTENT_TYPE_SINGLE_OUTLINE (STR_CONTENT_TYPE_SINGLE_FIRST + 0) @@ -142,13 +150,13 @@ #define IMG_NAVI_ENTRYBMP (RC_UTLUI_BEGIN + 4) #define ILIST_DB_DLG (RC_UTLUI_BEGIN + 6) -#define IMG_VIEWLAYOUT_AUTOMATIC (RC_UTLUI_BEGIN + 12) -#define IMG_VIEWLAYOUT_AUTOMATIC_ACTIVE (RC_UTLUI_BEGIN + 13) -#define IMG_VIEWLAYOUT_BOOKMODE (RC_UTLUI_BEGIN + 14) -#define IMG_VIEWLAYOUT_BOOKMODE_ACTIVE (RC_UTLUI_BEGIN + 15) -#define IMG_VIEWLAYOUT_SINGLECOLUMN (RC_UTLUI_BEGIN + 16) -#define IMG_VIEWLAYOUT_SINGLECOLUMN_ACTIVE (RC_UTLUI_BEGIN + 17) -#define IMG_PAGE_BREAK (RC_UTLUI_BEGIN + 18) +#define IMG_VIEWLAYOUT_AUTOMATIC (RC_UTLUI_BEGIN + 12) +#define IMG_VIEWLAYOUT_AUTOMATIC_ACTIVE (RC_UTLUI_BEGIN + 13) +#define IMG_VIEWLAYOUT_BOOKMODE (RC_UTLUI_BEGIN + 14) +#define IMG_VIEWLAYOUT_BOOKMODE_ACTIVE (RC_UTLUI_BEGIN + 15) +#define IMG_VIEWLAYOUT_SINGLECOLUMN (RC_UTLUI_BEGIN + 16) +#define IMG_VIEWLAYOUT_SINGLECOLUMN_ACTIVE (RC_UTLUI_BEGIN + 17) +#define IMG_PAGE_BREAK (RC_UTLUI_BEGIN + 18) //local ids of the Database ImageLists #define IMG_COLLAPSE 18002 /*RID_SVXIMG_COLLAPSEDNODE*/ diff --git a/sw/source/uibase/inc/viewlayoutctrl.hxx b/sw/source/uibase/inc/viewlayoutctrl.hxx index 0816b001..fb47e04 100644 --- a/sw/source/uibase/inc/viewlayoutctrl.hxx +++ b/sw/source/uibase/inc/viewlayoutctrl.hxx @@ -38,6 +38,7 @@ public: virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) SAL_OVERRIDE; virtual void Paint( const UserDrawEvent& rEvt ) SAL_OVERRIDE; virtual bool MouseButtonDown( const MouseEvent & ) SAL_OVERRIDE; + virtual bool MouseMove( const MouseEvent & ) SAL_OVERRIDE; }; #endif diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx index 159941f..1625a88 100644 --- a/sw/source/uibase/uiview/view2.cxx +++ b/sw/source/uibase/uiview/view2.cxx @@ -1278,9 +1278,16 @@ void SwView::UpdatePageNums(sal_uInt16 nPhyNum, sal_uInt16 nVirtNum, const OUStr { OUString sTemp(GetPageStr( nPhyNum, nVirtNum, rPgStr )); const SfxStringItem aTmp( FN_STAT_PAGE, sTemp ); + // Used to distinguish which tooltip to show + const SfxBoolItem bExtendedTooltip( FN_STAT_PAGE, + !rPgStr.isEmpty() && OUString::number(nPhyNum) != rPgStr + && nPhyNum != nVirtNum ); + SfxBindings &rBnd = GetViewFrame()->GetBindings(); rBnd.SetState( aTmp ); rBnd.Update( FN_STAT_PAGE ); + rBnd.SetState( bExtendedTooltip ); + rBnd.Update( FN_STAT_PAGE ); } void SwView::UpdateDocStats() diff --git a/sw/source/uibase/utlui/bookctrl.cxx b/sw/source/uibase/utlui/bookctrl.cxx index e4e5c90..70a913f 100644 --- a/sw/source/uibase/utlui/bookctrl.cxx +++ b/sw/source/uibase/utlui/bookctrl.cxx @@ -18,6 +18,8 @@ */ #include "hintids.hxx" +#include <swtypes.hxx> +#include <utlui.hrc> #include <svl/intitem.hxx> #include <svl/stritem.hxx> @@ -79,6 +81,14 @@ void SwBookmarkControl::StateChanged( sPageNumber = ((SfxStringItem*)pState)->GetValue(); GetStatusBar().SetItemText( GetId(), sPageNumber ); } + else if ( pState->ISA( SfxBoolItem ) ) + { + if (((SfxBoolItem*)pState)->GetValue()) // Indicates whether to show extended tooltip + GetStatusBar().SetQuickHelpText(GetId(), SW_RESSTR(STR_BOOKCTRL_HINT_EXTENDED)); + else + GetStatusBar().SetQuickHelpText(GetId(), SW_RESSTR(STR_BOOKCTRL_HINT)); + } + } void SwBookmarkControl::Paint( const UserDrawEvent& ) diff --git a/sw/source/uibase/utlui/statusbar.src b/sw/source/uibase/utlui/statusbar.src new file mode 100644 index 0000000..dcb5bba --- /dev/null +++ b/sw/source/uibase/utlui/statusbar.src @@ -0,0 +1,43 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <utlui.hrc> + +String STR_WORDCOUNT_HINT +{ + Text [ en-US ] = "Word and character count. Click for more extensive stats"; +}; +String STR_VIEWLAYOUT_ONE +{ + Text [ en-US ] = "Single page view"; +}; + +String STR_VIEWLAYOUT_TWO +{ + Text [ en-US ] = "Two page view"; +}; + +String STR_VIEWLAYOUT_BOOK +{ + Text [ en-US ] = "Book view"; +}; +String STR_BOOKCTRL_HINT +{ + Text [ en-US ] = "Page number/Total pages. Click to show Navigator"; +}; +String STR_BOOKCTRL_HINT_EXTENDED +{ + Text [ en-US ] = "Document page number/Total pages (Print page number). Click to show Navigator"; +}; +String STR_TMPLCTRL_HINT +{ + Text [ en-US ] = "Page Style. Right-click to change style and click to modify style"; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/tmplctrl.cxx b/sw/source/uibase/utlui/tmplctrl.cxx index a22c112..1046b05 100644 --- a/sw/source/uibase/utlui/tmplctrl.cxx +++ b/sw/source/uibase/utlui/tmplctrl.cxx @@ -23,6 +23,9 @@ #include <sfx2/dispatch.hxx> #include <vcl/status.hxx> +#include <swtypes.hxx> +#include <utlui.hrc> + #include "wrtsh.hxx" #include "view.hxx" #include "swmodule.hxx" @@ -56,13 +59,12 @@ void SwTemplatePopup_Impl::Select() nCurId = GetCurItemId(); } -// class SvxZoomStatusBarControl - SwTemplateControl::SwTemplateControl( sal_uInt16 _nSlotId, sal_uInt16 _nId, StatusBar& rStb ) : SfxStatusBarControl( _nSlotId, _nId, rStb ) { + GetStatusBar().SetQuickHelpText(GetId(), SW_RESSTR(STR_TMPLCTRL_HINT)); } SwTemplateControl::~SwTemplateControl() diff --git a/sw/source/uibase/utlui/viewlayoutctrl.cxx b/sw/source/uibase/utlui/viewlayoutctrl.cxx index bc58ff8..b3204ee 100644 --- a/sw/source/uibase/utlui/viewlayoutctrl.cxx +++ b/sw/source/uibase/utlui/viewlayoutctrl.cxx @@ -191,4 +191,32 @@ bool SwViewLayoutControl::MouseButtonDown( const MouseEvent & rEvt ) return true; } +bool SwViewLayoutControl::MouseMove( const MouseEvent & rEvt ) +{ + const Rectangle aRect = getControlRect(); + const Point aPoint = rEvt.GetPosPixel(); + const long nXDiff = aPoint.X() - aRect.Left(); + + const long nImageWidthSingle = mpImpl->maImageSingleColumn.GetSizePixel().Width(); + const long nImageWidthAuto = mpImpl->maImageAutomatic.GetSizePixel().Width(); + const long nImageWidthBook = mpImpl->maImageBookMode.GetSizePixel().Width(); + const long nImageWidthSum = nImageWidthSingle + nImageWidthAuto + nImageWidthBook; + + const long nXOffset = (aRect.GetWidth() - nImageWidthSum)/2; + + if ( nXDiff < nXOffset + nImageWidthSingle ) + { + GetStatusBar().SetQuickHelpText(GetId(), SW_RESSTR(STR_VIEWLAYOUT_ONE)); + } + else if ( nXDiff < nXOffset + nImageWidthSingle + nImageWidthAuto ) + { + GetStatusBar().SetQuickHelpText(GetId(), SW_RESSTR(STR_VIEWLAYOUT_TWO)); + } + else + { + GetStatusBar().SetQuickHelpText(GetId(), SW_RESSTR(STR_VIEWLAYOUT_BOOK)); + } + return true; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/wordcountctrl.cxx b/sw/source/uibase/utlui/wordcountctrl.cxx index 3d3ac34..58fe4b4 100644 --- a/sw/source/uibase/utlui/wordcountctrl.cxx +++ b/sw/source/uibase/utlui/wordcountctrl.cxx @@ -7,6 +7,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <swtypes.hxx> +#include <utlui.hrc> #include "wordcountctrl.hxx" #include <svl/stritem.hxx> @@ -29,6 +31,8 @@ void SwWordCountStatusBarControl::StateChanged( { if (eState == SfxItemState::DEFAULT) // Can access pState GetStatusBar().SetItemText( GetId(), ((SfxStringItem*)pState)->GetValue() ); + + GetStatusBar().SetQuickHelpText(GetId(), SW_RESSTR(STR_WORDCOUNT_HINT)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 93b34d091756de6fc3e5424aa45e00397146cc51 Author: Jan Holesovsky <ke...@collabora.com> Date: Tue Nov 11 21:33:53 2014 +0100 vcl: Use the fast path for rendering. There was a discrepancy between the comment and the code; and I believe the comment was right, and the code wrong - so adapted the code accordingly. [I guess we will want to kill this condition for good when rendering via OpenGL at some stage; the assert() will tell us ;-)] Change-Id: I651261373068e975004c898b2a930c602c158b64 diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx index 4955b4b..9a2e56d 100644 --- a/vcl/source/outdev/bitmap.cxx +++ b/vcl/source/outdev/bitmap.cxx @@ -527,7 +527,7 @@ void OutputDevice::DrawDeviceBitmap( const Point& rDestPt, const Size& rDestSize // only paint direct when no scaling and no MapMode, else the // more expensive conversions may be done for short-time Bitmap/BitmapEx // used for buffering only - if(!IsMapMode() && aPosAry.mnSrcWidth == aPosAry.mnDestWidth && aPosAry.mnSrcHeight == aPosAry.mnDestHeight) + if (IsMapMode() || aPosAry.mnSrcWidth != aPosAry.mnDestWidth || aPosAry.mnSrcHeight != aPosAry.mnDestHeight) { bTryDirectPaint = false; } @@ -661,18 +661,16 @@ void OutputDevice::DrawDeviceAlphaBitmap( const Bitmap& rBmp, const AlphaMask& r // separate alpha VDev bool bTryDirectPaint(!mpAlphaVDev && !pDisableNative && !bHMirr && !bVMirr); -#ifdef WNT - if(bTryDirectPaint) + if (bTryDirectPaint) { // only paint direct when no scaling and no MapMode, else the // more expensive conversions may be done for short-time Bitmap/BitmapEx // used for buffering only - if(!IsMapMode() && rSrcSizePixel.Width() == aOutSz.Width() && rSrcSizePixel.Height() == aOutSz.Height()) + if (IsMapMode() || rSrcSizePixel.Width() != aOutSz.Width() || rSrcSizePixel.Height() != aOutSz.Height()) { bTryDirectPaint = false; } } -#endif if(bTryDirectPaint) { commit d87b163f8dc787d3bbb17d4a0008ef60c61fe6b0 Author: Jan Holesovsky <ke...@collabora.com> Date: Tue Nov 11 21:25:07 2014 +0100 windows opengl: Make sure we don't reach the slow parts of the code. Change-Id: I2a4d1bd294d1d88651c8556091f5453ef0aa5293 diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx index 20e6367..4955b4b 100644 --- a/vcl/source/outdev/bitmap.cxx +++ b/vcl/source/outdev/bitmap.cxx @@ -20,6 +20,7 @@ #include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> #include <vcl/bmpacc.hxx> +#include <vcl/opengl/OpenGLHelper.hxx> #include <vcl/outdev.hxx> #include <vcl/virdev.hxx> #include <vcl/image.hxx> @@ -32,7 +33,6 @@ #include <basegfx/matrix/b2dhommatrixtools.hxx> #include <boost/scoped_array.hpp> - void OutputDevice::DrawBitmap( const Point& rDestPt, const Bitmap& rBitmap ) { const Size aSizePix( rBitmap.GetSizePixel() ); @@ -656,7 +656,6 @@ void OutputDevice::DrawDeviceAlphaBitmap( const Bitmap& rBmp, const AlphaMask& r if( !aDstRect.Intersection( Rectangle( aOutPt, aOutSz ) ).IsEmpty() ) { - bool bNativeAlpha = false; static const char* pDisableNative = getenv( "SAL_DISABLE_NATIVE_ALPHA"); // #i83087# Naturally, system alpha blending cannot work with // separate alpha VDev @@ -686,14 +685,18 @@ void OutputDevice::DrawDeviceAlphaBitmap( const Bitmap& rBmp, const AlphaMask& r }; SalBitmap* pSalSrcBmp = rBmp.ImplGetImpBitmap()->ImplGetSalBitmap(); SalBitmap* pSalAlphaBmp = rAlpha.ImplGetImpBitmap()->ImplGetSalBitmap(); - bNativeAlpha = mpGraphics->DrawAlphaBitmap( aTR, *pSalSrcBmp, *pSalAlphaBmp, this ); + + if (mpGraphics->DrawAlphaBitmap( aTR, *pSalSrcBmp, *pSalAlphaBmp, this )) + return; } + // we need to make sure OpenGL never reaches this slow code path + assert(!OpenGLHelper::isVCLOpenGLEnabled()); + VirtualDevice* pOldVDev = mpAlphaVDev; Rectangle aBmpRect( Point(), rBmp.GetSizePixel() ); - if( !bNativeAlpha - && !aBmpRect.Intersection( Rectangle( rSrcPtPixel, rSrcSizePixel ) ).IsEmpty() ) + if (!aBmpRect.Intersection(Rectangle(rSrcPtPixel, rSrcSizePixel)).IsEmpty()) { // The scaling in this code path produces really ugly results - it // does the most trivial scaling with no smoothing. commit d9fbaf248ea907428c3a5d0422d0c9a9ce50b907 Author: Jan Holesovsky <ke...@collabora.com> Date: Tue Nov 11 21:19:02 2014 +0100 windows opengl: Instantiate OpenGLSalBitmap even on Windows. Change-Id: I2229141cc12ad7bc9fccfd6e2c7fec44ac4f6284 diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 8a2f89b..2cf9806 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -865,6 +865,9 @@ void OpenGLSalGraphicsImpl::copyBits( const SalTwoRect& rPosAry, SalGraphics* /* void OpenGLSalGraphicsImpl::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap ) { + // check that carefully only in the debug mode + assert(dynamic_cast<const OpenGLSalBitmap*>(&rSalBitmap)); + const OpenGLSalBitmap& rBitmap = static_cast<const OpenGLSalBitmap&>(rSalBitmap); GLuint nTexture = rBitmap.GetTexture( maContext ); const Size aSize = rSalBitmap.GetSize(); diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx index 5a93aaa..e4f9205 100644 --- a/vcl/opengl/salbmp.cxx +++ b/vcl/opengl/salbmp.cxx @@ -34,6 +34,7 @@ static bool isValidBitCount( sal_uInt16 nBitCount ) OpenGLSalBitmap::OpenGLSalBitmap() : mpContext(NULL) +, mpTexture(NULL) , mbDirtyTexture(true) , mnBits(0) , mnBytesPerRow(0) @@ -57,7 +58,7 @@ bool OpenGLSalBitmap::Create( OpenGLContext& rContext, OpenGLTextureSharedPtr pT static const BitmapPalette aEmptyPalette; Destroy(); - SAL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create from FBO" ); + SAL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create from FBO: [" << nX << ", " << nY << "] " << nWidth << "x" << nHeight ); mpContext = &rContext; mnWidth = nWidth; @@ -83,7 +84,7 @@ bool OpenGLSalBitmap::Create( OpenGLContext& rContext, OpenGLTextureSharedPtr pT bool OpenGLSalBitmap::Create( const Size& rSize, sal_uInt16 nBits, const BitmapPalette& rBitmapPalette ) { Destroy(); - SAL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create with size" ); + SAL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create with size: " << rSize ); if( !isValidBitCount( nBits ) ) return false; @@ -106,9 +107,12 @@ bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, SalGraphics* pGraphics ) bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount ) { + // check that carefully only in the debug mode + assert(dynamic_cast<const OpenGLSalBitmap*>(&rSalBmp)); + const OpenGLSalBitmap& rSourceBitmap = static_cast<const OpenGLSalBitmap&>(rSalBmp); - SAL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create from BMP " << rSourceBitmap.mnHeight ); + SAL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create from BMP: " << rSourceBitmap.mnWidth << "x" << rSourceBitmap.mnHeight ); if( isValidBitCount( nNewBitCount ) ) { @@ -328,6 +332,7 @@ Size OpenGLSalBitmap::GetSize() const GLuint OpenGLSalBitmap::CreateTexture() { + SAL_INFO( "vcl.opengl", "::CreateTexture" ); GLenum nFormat = GL_RGBA; GLenum nType = GL_UNSIGNED_BYTE; sal_uInt8* pData( NULL ); diff --git a/vcl/win/source/app/salinst.cxx b/vcl/win/source/app/salinst.cxx index b1d33e4..a601ff5 100644 --- a/vcl/win/source/app/salinst.cxx +++ b/vcl/win/source/app/salinst.cxx @@ -26,9 +26,11 @@ #include <tools/solarmutex.hxx> -#include <vcl/timer.hxx> #include <vcl/apptypes.hxx> +#include <vcl/opengl/OpenGLHelper.hxx> +#include <vcl/timer.hxx> +#include <opengl/salbmp.hxx> #include <win/wincomp.hxx> #include <win/salids.hrc> #include <win/saldata.hxx> @@ -1007,7 +1009,10 @@ SalTimer* WinSalInstance::CreateSalTimer() SalBitmap* WinSalInstance::CreateSalBitmap() { - return new WinSalBitmap(); + if (OpenGLHelper::isVCLOpenGLEnabled()) + return new OpenGLSalBitmap(); + else + return new WinSalBitmap(); } class WinImeStatus : public SalI18NImeStatus commit a237e0838196774cceeffe984d614198dbabd21e Author: Stephan Bergmann <sberg...@redhat.com> Date: Tue Nov 11 19:37:53 2014 +0100 Copy the original prop/prop unit ...instead of scaling the translated nNewHeight once more by the original prop Change-Id: Iadb53361a79f0b37b3c7c50066e4cfb7d24ed5e8 diff --git a/editeng/source/editeng/eertfpar.cxx b/editeng/source/editeng/eertfpar.cxx index 641b5b9..4eb6a03 100644 --- a/editeng/source/editeng/eertfpar.cxx +++ b/editeng/source/editeng/eertfpar.cxx @@ -315,7 +315,10 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet ) long nNewHeight; nNewHeight = OutputDevice::LogicToLogic( (long)nHeight, eSrcUnit, eDestUnit ); - SvxFontHeightItem aFntHeightItem( nNewHeight, static_cast<const SvxFontHeightItem*>(pItem)->GetProp(), aFntHeightIems[i] ); + SvxFontHeightItem aFntHeightItem( nNewHeight, 100, aFntHeightIems[i] ); + aFntHeightItem.SetProp( + static_cast<const SvxFontHeightItem*>(pItem)->GetProp(), + static_cast<const SvxFontHeightItem*>(pItem)->GetPropUnit()); rSet.GetAttrSet().Put( aFntHeightItem ); } } commit 63c48a7e0e3debec16dfc7cd04e7eca4c6fbe0ea Author: Stephan Bergmann <sberg...@redhat.com> Date: Tue Nov 11 19:36:27 2014 +0100 Fix SvxFontHeightItem::operator= ...and remove thus unused SetHeightValue Change-Id: I9c8c18614233df6086ff23533e7e7129848f42ef diff --git a/include/editeng/fhgtitem.hxx b/include/editeng/fhgtitem.hxx index 3ff3e64..2ea466f 100644 --- a/include/editeng/fhgtitem.hxx +++ b/include/editeng/fhgtitem.hxx @@ -66,8 +66,10 @@ public: inline SvxFontHeightItem& operator=(const SvxFontHeightItem& rSize) { - SetHeightValue( rSize.GetHeight() ); - SetProp( rSize.GetProp(), ePropUnit ); + DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" ); + nHeight = rSize.nHeight; + nProp = rSize.nProp; + ePropUnit = rSize.ePropUnit; return *this; } @@ -79,12 +81,6 @@ public: sal_uInt32 GetHeight() const { return nHeight; } - void SetHeightValue( sal_uInt32 nNewHeight ) - { - DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" ); - nHeight = nNewHeight; - } - void SetProp( const sal_uInt16 nNewProp, SfxMapUnit eUnit = SFX_MAPUNIT_RELATIVE ) { commit 2a68ed19e8f35909e5dba691f9552099eae3162f Author: Stephan Bergmann <sberg...@redhat.com> Date: Tue Nov 11 19:18:12 2014 +0100 Revert "Some SvxFontHeightItem clean-up" This reverts commit d5f93eb47ec4c27e93ad908b0199790c702491a0, SvxFontHeightItem::SetProp was used to override "dummy" 100% nProp/ePropUnit values that did not match the computed nHeight value with nProp/ePropUnit values that are supposed to match the computed nHeight value. Yuck. Change-Id: Ic12e824054b3c5da7aca766b9b3eb076d1837d9a diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx index 56be239..4a2bbd8 100644 --- a/editeng/source/items/textitem.cxx +++ b/editeng/source/items/textitem.cxx @@ -723,12 +723,7 @@ SvxFontHeightItem::SvxFontHeightItem( const sal_uLong nSz, SetHeight( nSz,nPrp ); // calculate in percentage } -SvxFontHeightItem::SvxFontHeightItem( - sal_uInt16 wid, sal_uInt32 height, sal_uInt16 prop, SfxMapUnit propUnit): - SfxPoolItem(wid) -{ - SetHeight(height, prop, propUnit); -} + SfxPoolItem* SvxFontHeightItem::Clone( SfxItemPool * ) const { @@ -776,8 +771,8 @@ SfxPoolItem* SvxFontHeightItem::Create( SvStream& rStrm, if( FONTHEIGHT_UNIT_VERSION <= nVersion ) rStrm.ReadUInt16( nPropUnit ); - SvxFontHeightItem* pItem = new SvxFontHeightItem( - Which(), nsize, nprop, (SfxMapUnit)nPropUnit ); + SvxFontHeightItem* pItem = new SvxFontHeightItem( nsize, 100, Which() ); + pItem->SetProp( nprop, (SfxMapUnit)nPropUnit ); return pItem; } diff --git a/forms/source/richtext/rtattributehandler.cxx b/forms/source/richtext/rtattributehandler.cxx index 688068c..c9b90c0 100644 --- a/forms/source/richtext/rtattributehandler.cxx +++ b/forms/source/richtext/rtattributehandler.cxx @@ -336,9 +336,8 @@ namespace frm ).Height(); } - SvxFontHeightItem* pNewItem = new SvxFontHeightItem( - getWhich(), nHeight, pFontHeightItem->GetProp(), - pFontHeightItem->GetPropUnit() ); + SvxFontHeightItem* pNewItem = new SvxFontHeightItem( nHeight, 100, getWhich() ); + pNewItem->SetProp( pFontHeightItem->GetProp(), pFontHeightItem->GetPropUnit() ); aState.setItem( pNewItem ); } @@ -365,9 +364,8 @@ namespace frm ).Height(); } - SvxFontHeightItem aNewItem( - getWhich(), nHeight, pFontHeightItem->GetProp(), - pFontHeightItem->GetPropUnit() ); + SvxFontHeightItem aNewItem( nHeight, 100, getWhich() ); + aNewItem.SetProp( pFontHeightItem->GetProp(), pFontHeightItem->GetPropUnit() ); if ( ( getAttributeId() == SID_ATTR_CHAR_FONTHEIGHT ) && _nForScriptType ) putItemForScript( _rNewAttribs, aNewItem, _nForScriptType ); diff --git a/include/editeng/fhgtitem.hxx b/include/editeng/fhgtitem.hxx index a52da18..3ff3e64 100644 --- a/include/editeng/fhgtitem.hxx +++ b/include/editeng/fhgtitem.hxx @@ -47,10 +47,6 @@ public: SvxFontHeightItem( const sal_uLong nSz /*= 240*/, const sal_uInt16 nPropHeight /*= 100*/, const sal_uInt16 nId ); - SvxFontHeightItem( - sal_uInt16 wid, sal_uInt32 height, sal_uInt16 prop, - SfxMapUnit propUnit); - // "pure virtual Methods" from SfxPoolItem virtual bool operator==( const SfxPoolItem& ) const SAL_OVERRIDE; virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const SAL_OVERRIDE; @@ -70,10 +66,8 @@ public: inline SvxFontHeightItem& operator=(const SvxFontHeightItem& rSize) { - DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" ); - nHeight = rSize.nHeight; - nProp = rSize.nProp; - ePropUnit = rSize.ePropUnit; + SetHeightValue( rSize.GetHeight() ); + SetProp( rSize.GetProp(), ePropUnit ); return *this; } @@ -85,6 +79,20 @@ public: sal_uInt32 GetHeight() const { return nHeight; } + void SetHeightValue( sal_uInt32 nNewHeight ) + { + DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" ); + nHeight = nNewHeight; + } + + void SetProp( const sal_uInt16 nNewProp, + SfxMapUnit eUnit = SFX_MAPUNIT_RELATIVE ) + { + DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" ); + nProp = nNewProp; + ePropUnit = eUnit; + } + sal_uInt16 GetProp() const { return nProp; } SfxMapUnit GetPropUnit() const { return ePropUnit; } // Percent, Twip, ... commit 88a40e70fe921680ed303b8ab69ca866ae67078e Author: Richard PALO <rich...@netbsd.org> Date: Sun Nov 9 18:15:45 2014 +0100 O_RDWR and O_CREAT are defined in fcntl.h Change-Id: I568ee2c3f103777720f6c39340a5915b10aeebb4 Signed-off-by: Michael Stahl <mst...@redhat.com> diff --git a/shell/source/unix/sysshell/recently_used_file.cxx b/shell/source/unix/sysshell/recently_used_file.cxx index 2189d0b..08f96a3 100644 --- a/shell/source/unix/sysshell/recently_used_file.cxx +++ b/shell/source/unix/sysshell/recently_used_file.cxx @@ -27,7 +27,7 @@ #include <sys/file.h> #include <sys/types.h> #include <sys/stat.h> - +#include <fcntl.h> #include <unistd.h> const OUString RECENTLY_USED_FILE_NAME(".recently-used"); commit 457105c7d9ede7a4d73d69d1c87306e88d57c0ac Author: Richard PALO <rich...@netbsd.org> Date: Mon Nov 10 17:45:39 2014 +0100 update solaris directories being referenced also borrowed from Gabriele Bulfon <gabriele.bulfon at sonicle.com> Change-Id: I17787fbbf12f1bc8b3e78b8dd2e8b33679bab5b1 Signed-off-by: Michael Stahl <mst...@redhat.com> diff --git a/sysui/CustomTarget_solaris.mk b/sysui/CustomTarget_solaris.mk index 9f671a8..ed264fe 100644 --- a/sysui/CustomTarget_solaris.mk +++ b/sysui/CustomTarget_solaris.mk ... etc. - the rest is truncated
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits