[Libreoffice-commits] core.git: 3 commits - include/vcl vcl/Library_vcl.mk vcl/source

2018-04-21 Thread Chris Sherlock
 include/vcl/BitmapPopArtFilter.hxx |   33 
 include/vcl/BitmapSepiaFilter.hxx  |   34 
 include/vcl/BitmapSolarizeFilter.hxx   |   34 
 include/vcl/bitmap.hxx |3 
 vcl/Library_vcl.mk |3 
 vcl/source/bitmap/BitmapPopArtFilter.cxx   |  118 ++
 vcl/source/bitmap/BitmapSepiaFilter.cxx|  106 
 vcl/source/bitmap/BitmapSolarizeFilter.cxx |   68 
 vcl/source/gdi/bitmap4.cxx |  239 ++---
 9 files changed, 414 insertions(+), 224 deletions(-)

New commits:
commit 1ab12471f3a69c4d502e6271e84ddf8a981f507f
Author: Chris Sherlock 
Date:   Fri Apr 20 20:32:23 2018 +1000

vcl: ImplSepia -> BitmapSepiaFilter

Change-Id: I96a4072bf919bd37b30c01ab16d98779c76717ab
Reviewed-on: https://gerrit.libreoffice.org/53202
Tested-by: Jenkins 
Reviewed-by: Tomaž Vajngerl 

diff --git a/include/vcl/BitmapSepiaFilter.hxx 
b/include/vcl/BitmapSepiaFilter.hxx
new file mode 100644
index ..717f10d1466b
--- /dev/null
+++ b/include/vcl/BitmapSepiaFilter.hxx
@@ -0,0 +1,34 @@
+/* -*- 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/.
+ *
+ */
+
+#ifndef INCLUDED_VCL_BITMAPSEPIAFILTER_HXX
+#define INCLUDED_VCL_BITMAPSEPIAFILTER_HXX
+
+#include 
+
+class BitmapEx;
+
+class VCL_DLLPUBLIC BitmapSepiaFilter : public BitmapFilter
+{
+public:
+BitmapSepiaFilter(double nSepiaPercent)
+: mnSepiaPercent(nSepiaPercent)
+{
+}
+
+virtual BitmapEx execute(BitmapEx const& rBitmapEx) override;
+
+private:
+sal_uInt16 mnSepiaPercent;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx
index bffeca808ea2..b71f8a4224ba 100644
--- a/include/vcl/bitmap.hxx
+++ b/include/vcl/bitmap.hxx
@@ -659,7 +659,6 @@ public:
 SAL_DLLPRIVATE bool ImplDitherFloyd16();
 
 SAL_DLLPRIVATE bool ImplEmbossGrey( const BmpFilterParam* pFilterParam 
);
-SAL_DLLPRIVATE bool ImplSepia( const BmpFilterParam* pFilterParam );
 SAL_DLLPRIVATE bool ImplMosaic( const BmpFilterParam* pFilterParam );
 SAL_DLLPRIVATE bool ImplDuotoneFilter( const sal_uLong nColorOne,  
sal_uLong nColorTwo );
 
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 940bd8b35974..82f67dd845b9 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -314,6 +314,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
 vcl/source/bitmap/bitmapfilter \
 vcl/source/bitmap/BitmapSobelGreyFilter \
 vcl/source/bitmap/BitmapSolarizeFilter \
+vcl/source/bitmap/BitmapSepiaFilter \
 vcl/source/bitmap/BitmapPopArtFilter \
 vcl/source/bitmap/BitmapConvolutionMatrixFilter \
 vcl/source/bitmap/BitmapMedianFilter \
diff --git a/vcl/source/bitmap/BitmapSepiaFilter.cxx 
b/vcl/source/bitmap/BitmapSepiaFilter.cxx
new file mode 100644
index ..a953fcbee2a8
--- /dev/null
+++ b/vcl/source/bitmap/BitmapSepiaFilter.cxx
@@ -0,0 +1,106 @@
+/* -*- 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 
+#include 
+#include 
+#include 
+
+#include 
+
+BitmapEx BitmapSepiaFilter::execute(BitmapEx const& rBitmapEx)
+{
+Bitmap aBitmap(rBitmapEx.GetBitmap());
+Bitmap::ScopedReadAccess pReadAcc(aBitmap);
+bool bRet = false;
+
+if (pReadAcc)
+{
+const long nSepia = 1 - 100 * SAL_BOUND(mnSepiaPercent, 0, 100);
+BitmapPalette aSepiaPal(256);
+
+for (sal_uInt16 i = 0; i < 256; i++)
+{
+BitmapColor& rCol = aSepiaPal[i];
+const sal_uInt8 cSepiaValue = static_cast(nSepia * i / 
1);
+
+rCol.SetRed(static_cast(i));
+rCol.SetGreen(cSepiaValue);
+rCol.SetBlue(cSepiaValue);
+}
+
+Bitmap aNewBmp(aBitmap.GetSizePixel(), 8, );
+BitmapScopedWriteAccess pWriteAcc(aNewBmp);
+
+if (pWriteAcc)
+{
+BitmapColor aCol(sal_uInt8(0));
+const long nWidth = pWriteAcc->Width();
+const long nHeight = pWriteAcc->Height();
+
+if (pReadAcc->HasPalette())
+{
+const sal_uInt16 nPalCount = pReadAcc->GetPaletteEntryCount();
+std::unique_ptr pIndexMap(new 
sal_uInt8[nPalCount]);
+for 

[Libreoffice-commits] core.git: 3 commits - include/vcl vcl/Library_vcl.mk vcl/source

2014-05-22 Thread Michael Meeks
 include/vcl/debugevent.hxx   |   36 
 include/vcl/window.hxx   |3 
 vcl/Library_vcl.mk   |1 
 vcl/source/app/svmain.cxx|5 
 vcl/source/window/debugevent.cxx |  281 +++
 vcl/source/window/window.cxx |   12 +
 6 files changed, 338 insertions(+)

New commits:
commit 344dc7fd0684acc31f4c18e99e65bfa6700c9c64
Author: Michael Meeks michael.me...@collabora.com
Date:   Thu May 8 21:59:45 2014 +0100

Make the inserted text more European and sensible for now.

Change-Id: I8b2ecef11362c0fc1dc2b76780140881e769bb89

diff --git a/include/vcl/debugevent.hxx b/include/vcl/debugevent.hxx
index ce31570..2700324 100644
--- a/include/vcl/debugevent.hxx
+++ b/include/vcl/debugevent.hxx
@@ -20,7 +20,7 @@ class VCL_DLLPUBLIC DebugEventInjector : Timer {
   DebugEventInjector( sal_uInt32 nMaxEvents );
 
   Window *ChooseWindow();
-  void InjectKeyEvent();
+  void InjectTextEvent();
   void InjectMenuEvent();
   void InjectMouseEvent();
   void InjectEvent();
diff --git a/vcl/source/window/debugevent.cxx b/vcl/source/window/debugevent.cxx
index 37ca716..e83909e 100644
--- a/vcl/source/window/debugevent.cxx
+++ b/vcl/source/window/debugevent.cxx
@@ -7,7 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include stdio.h
+// #include stdio.h
 #include rtl/math.hxx
 #include rtl/string.hxx
 #include tools/time.hxx
@@ -110,11 +110,11 @@ void DebugEventInjector::InjectMenuEvent()
 SalMenuEvent aEvent = aIds[ getRandom() * aIds.size() ];
 bool bHandled = ImplWindowFrameProc( pSysWin, NULL, nEvent, aEvent);
 
-fprintf( stderr, Injected menu event %p (%d) '%s' - %d\n,
+/*fprintf( stderr, Injected menu event %p (%d) '%s' - %d\n,
  aEvent.mpMenu, aEvent.mnId,
  OUStringToOString( ((Menu *)aEvent.mpMenu)-GetItemText( 
aEvent.mnId ),
 RTL_TEXTENCODING_UTF8 ).getStr(),
- (int)bHandled);
+ (int)bHandled); */
 }
 
 static void InitKeyEvent( SalKeyEvent rKeyEvent )
@@ -131,22 +131,43 @@ static void InitKeyEvent( SalKeyEvent rKeyEvent )
 rKeyEvent.mnRepeat = 0;
 }
 
-void DebugEventInjector::InjectKeyEvent()
+void DebugEventInjector::InjectTextEvent()
 {
 SalKeyEvent aKeyEvent;
 Window *pWindow = ChooseWindow();
 
 InitKeyEvent( aKeyEvent );
-sal_uInt16 nCode = getRandom() * KEY_CODE;
-if( getRandom()  0.05 ) // modifier
-nCode |= (sal_uInt16)( getRandom() * KEY_MODTYPE )  KEY_MODTYPE;
 
-aKeyEvent.mnCode = nCode;
-aKeyEvent.mnCharCode = getRandom() * 0x;
+if (getRandom()  0.10) // Occasionally a truly random event
+{
+aKeyEvent.mnCode = getRandom() * KEY_CODE;
+aKeyEvent.mnCharCode = getRandom() * 0x;
+}
+else
+{
+struct {
+sal_uInt16 nCodeStart, nCodeEnd;
+char   aCharStart;
+} nTextCodes[] = {
+{ KEY_0, KEY_9, '0' },
+{ KEY_A, KEY_Z, 'a' }
+};
+
+size_t i = getRandom() * SAL_N_ELEMENTS( nTextCodes );
+int offset = trunc( getRandom() * ( nTextCodes[i].nCodeEnd - 
nTextCodes[i].nCodeStart ) );
+aKeyEvent.mnCode = nTextCodes[i].nCodeStart + offset;
+aKeyEvent.mnCharCode = nTextCodes[i].aCharStart + offset;
+//fprintf( stderr, Char '%c' offset %d into record %d base '%c'\n,
+// aKeyEvent.mnCharCode, offset, (int)i, 
nTextCodes[i].aCharStart );
+}
+
+if( getRandom()  0.05 ) // modifier
+aKeyEvent.mnCode |= (sal_uInt16)( getRandom() * KEY_MODTYPE )  
KEY_MODTYPE;
 
 bool bHandled = ImplWindowFrameProc( pWindow, NULL, SALEVENT_KEYINPUT, 
aKeyEvent);
-fprintf (stderr, Injected key 0x%x - %d win %p\n,
- (int) aKeyEvent.mnCode, (int)bHandled, pWindow);
+//fprintf( stderr, Injected key 0x%x - %d win %p\n,
+// (int) aKeyEvent.mnCode, (int)bHandled, pWindow );
+ImplWindowFrameProc( pWindow, NULL, SALEVENT_KEYUP, aKeyEvent );
 }
 
 /*
@@ -155,12 +176,14 @@ void DebugEventInjector::InjectKeyEvent()
  */
 void DebugEventInjector::InjectEvent()
 {
+//fprintf( stderr, %6d - , (int)mnEventsLeft );
+
 double nRand = getRandom();
-if (nRand  0.50)
+if (nRand  0.30)
 {
 int nEvents = getRandom() * 10;
 for (int i = 0; i  nEvents; i++)
-InjectKeyEvent();
+InjectTextEvent();
 }
 else if (nRand  0.60)
 InjectKeyNavEdit();
@@ -222,8 +245,8 @@ void DebugEventInjector::InjectKeyNavEdit()
 aKeyEvent.mnCharCode = 0x0; // hopefully unused.
 
 bool bHandled = ImplWindowFrameProc( pWindow, NULL, SALEVENT_KEYINPUT, 
aKeyEvent );
-fprintf( stderr, Injected edit / move key 0x%x - %d win %p\n,
- (int) aKeyEvent.mnCode, (int)bHandled, pWindow );
+//fprintf( stderr, Injected edit / move key 0x%x - %d win %p\n,
+// (int) aKeyEvent.mnCode, (int)bHandled, pWindow );
 

[Libreoffice-commits] core.git: 3 commits - include/vcl vcl/Library_vcl.mk vcl/source

2014-04-25 Thread Chris Sherlock
 include/vcl/outdev.hxx|   49 ---
 include/vcl/outdevmap.hxx |   44 +++
 include/vcl/outdevstate.hxx   |   78 ++
 vcl/Library_vcl.mk|1 
 vcl/source/app/settings.cxx   |   14 -
 vcl/source/outdev/outdev.cxx  |  475 +++---
 vcl/source/outdev/outdevstate.cxx |   82 ++
 7 files changed, 415 insertions(+), 328 deletions(-)

New commits:
commit 5e57796c80d5f6e1888ff40bed5b4c1a081db93a
Author: Chris Sherlock chris.sherloc...@gmail.com
Date:   Fri Apr 25 22:55:47 2014 +1000

VCL: Move OutputDevice map structures to own VCL header file

Change-Id: Ifbaa51018d47fde72be80d5d1870fdda214db320

diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index c0a2306..40f3345 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -33,8 +33,8 @@
 #include vcl/wall.hxx
 #include vcl/metaact.hxx
 #include vcl/salnativewidgets.hxx
-
 #include vcl/outdevstate.hxx
+#include vcl/outdevmap.hxx
 
 #include basegfx/vector/b2enums.hxx
 #include basegfx/polygon/b2dpolypolygon.hxx
@@ -122,26 +122,6 @@ namespace vcl
 struct FontCapabilities;
 }
 
-// OutputDevice-Data
-
-struct ImplMapRes
-{
-longmnMapOfsX;  // Offset in X direction
-longmnMapOfsY;  // Offset in Y direction
-longmnMapScNumX;// Scaling factor - numerator in X 
direction
-longmnMapScNumY;// Scaling factor - numerator in Y 
direction
-longmnMapScDenomX;  // Scaling factor - denominator in 
X direction
-longmnMapScDenomY;  // Scaling factor - denominator in 
Y direction
-};
-
-struct ImplThresholdRes
-{
-longmnThresLogToPixX;   // Thresholds for calculation
-longmnThresLogToPixY;   // with BigInts
-longmnThresPixToLogX;   // 
-longmnThresPixToLogY;   // 
-};
-
 // OutputDevice-Types
 
 // Flags for DrawText()
diff --git a/include/vcl/outdevmap.hxx b/include/vcl/outdevmap.hxx
new file mode 100644
index 000..cda9e62
--- /dev/null
+++ b/include/vcl/outdevmap.hxx
@@ -0,0 +1,44 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the License); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VCL_INC_OUTDEVMAP_HXX
+#define INCLUDED_VCL_INC_OUTDEVMAP_HXX
+
+
+struct ImplMapRes
+{
+longmnMapOfsX;  // Offset in X direction
+longmnMapOfsY;  // Offset in Y direction
+longmnMapScNumX;// Scaling factor - numerator in X 
direction
+longmnMapScNumY;// Scaling factor - numerator in Y 
direction
+longmnMapScDenomX;  // Scaling factor - denominator in 
X direction
+longmnMapScDenomY;  // Scaling factor - denominator in 
Y direction
+};
+
+struct ImplThresholdRes
+{
+longmnThresLogToPixX;   // Thresholds for calculation
+longmnThresLogToPixY;   // with BigInts
+longmnThresPixToLogX;   // 
+longmnThresPixToLogY;   // 
+};
+
+#endif // INCLUDED_VCL_INC_OUTDEVMAP_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit cf3c6cb40f99fa1761a6af3d7447a899b9447868
Author: Chris Sherlock chris.sherloc...@gmail.com
Date:   Fri Apr 25 20:56:35 2014 +1000

VCL: ImpObjStack replaced with std::stack

ImpObjStack uses it's own home-grown stack and stack functions. There
is a function that unwinds the stack, but really it would be better if
we used std::set. In fact, this is better, because the name ImpObjStack
is really not terribly descriptive. I've replaced it with a stack of
OutDevState objects.

Change-Id: I87bdd4340ad77b7ffd9ff176fa5a9ffeac8b8666

diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index da3b4b3..c0a2306 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -34,6 +34,8 @@
 #include vcl/metaact.hxx
 #include vcl/salnativewidgets.hxx
 
+#include vcl/outdevstate.hxx
+
 #include basegfx/vector/b2enums.hxx
 #include