[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3-0' - 2 commits - kit/Kit.cpp loleaflet/src loleaflet/unocommands.js
Jan Holesovsky
kendy at collabora.com
Fri Dec 15 12:45:33 UTC 2017
kit/Kit.cpp | 42 +++++++++------------------
loleaflet/src/control/Control.ContextMenu.js | 2 -
loleaflet/src/control/Control.Menubar.js | 6 +++
loleaflet/unocommands.js | 4 ++
4 files changed, 25 insertions(+), 29 deletions(-)
New commits:
commit 784e7a16453b7d7f4d86c79a4a8f470cc863dc7a
Author: Jan Holesovsky <kendy at collabora.com>
Date: Fri Dec 15 11:51:46 2017 +0100
Avoid an unnecessary buffer in the watermark code.
Change-Id: I29b162fd9d8f43d0a2cb75853f0a3c0dc8ee92df
Reviewed-on: https://gerrit.libreoffice.org/46527
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 5cb82801..193b8ccb 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -525,7 +525,7 @@ public:
}
private:
- /// Alpha blend 'pixel_count' pixels from 'from' over the 'to'.
+ /// Alpha blend pixels from 'from' over the 'to'.
void alphaBlend(const unsigned char* from, int from_width, int from_height, int from_offset_x, int from_offset_y,
unsigned char* to, int to_width, int to_height)
{
@@ -556,6 +556,7 @@ private:
}
}
+ /// Create bitmap that we later use as the watermark for every tile.
const unsigned char* getPixmap(int width, int height)
{
if (_pixmap && width == _width && height == _height)
@@ -585,38 +586,24 @@ private:
}
const unsigned int pixel_count = width * height * 4;
-
- // Create the blurred background; first a white text
_pixmap = static_cast<unsigned char*>(malloc(pixel_count));
- unsigned char* from = text;
- unsigned char* to = _pixmap;
- for (; to < _pixmap + pixel_count; from += 4, to += 4)
- {
- // Pre-multiplied alpha!
- const double alpha = from[3] / 255.0;
- to[0] = 0xff * alpha;
- to[1] = 0xff * alpha;
- to[2] = 0xff * alpha;
- to[3] = from[3];
- }
- // Use box blur, which is fast, though crude.
- unsigned char* buffer = static_cast<unsigned char*>(malloc(pixel_count));
- memcpy(buffer, _pixmap, pixel_count);
-
- // Repeat an even number of times to smooth out.
+ // Create the white blurred background
+ // Use box blur, it's enough for our purposes
const int r = 2;
const double weight = (r+1) * (r+1);
- for (int y = r; y < height - r; ++y)
+ for (int y = 0; y < height; ++y)
{
- for (int x = r; x < width - r; ++x)
+ for (int x = 0; x < width; ++x)
{
double t = 0;
- for (int ky = y - r; ky <= y + r; ++ky)
+ for (int ky = std::max(y - r, 0); ky <= std::min(y + r, height - 1); ++ky)
{
- for (int kx = x - r; kx <= x + r; ++kx)
+ for (int kx = std::max(x - r, 0); kx <= std::min(x + r, width - 1); ++kx)
{
- t += buffer[4 * (ky * width + kx) + 3];
+ // Pre-multiplied alpha; the text is black, so all the
+ // information is only in the alpha channel
+ t += text[4 * (ky * width + kx) + 3];
}
}
@@ -624,19 +611,20 @@ private:
double avg = t / weight;
if (avg > 255.0)
avg = 255.0;
+
+ // Pre-multiplied alpha, but use white for the resulting color
const double alpha = avg / 255.0;
_pixmap[4 * (y * width + x) + 0] = 0xff * alpha;
_pixmap[4 * (y * width + x) + 1] = 0xff * alpha;
_pixmap[4 * (y * width + x) + 2] = 0xff * alpha;
- _pixmap[4 * (y * width + x) + 3] = static_cast<unsigned char>(avg < 255.0 ? avg : 255);
+ _pixmap[4 * (y * width + x) + 3] = avg;
}
}
- // Now copy text over the blur
+ // Now copy the (black) text over the (white) blur
alphaBlend(text, _width, _height, 0, 0, _pixmap, _width, _height);
// No longer needed.
- std::free(buffer);
std::free(text);
// Make the resulting pixmap semi-transparent
commit ff0c7fb6445003c562179ca5b13f207ad21e68e5
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Thu Dec 14 20:48:03 2017 +0530
lokdialog: Dialogs related to object and shapes in presentation
Change-Id: If9a2e3d8bdbeab00397d2970f472602201991445
Reviewed-on: https://gerrit.libreoffice.org/46463
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/loleaflet/src/control/Control.ContextMenu.js b/loleaflet/src/control/Control.ContextMenu.js
index e9006719..f49e924e 100644
--- a/loleaflet/src/control/Control.ContextMenu.js
+++ b/loleaflet/src/control/Control.ContextMenu.js
@@ -39,7 +39,7 @@ L.Control.ContextMenu = L.Control.extend({
spreadsheet: ['MergeCells', 'SplitCell', 'RecalcPivotTable', 'FormatCellDialog'],
- presentation: ['EditStyle'],
+ presentation: ['TransformDialog', 'FormatLine', 'FormatArea'],
drawing: []
}
// UNOCOMMANDS_EXTRACT_END <- don't remove this line, it's used by unocommands.py
diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js
index c15a286c..3af4925e 100644
--- a/loleaflet/src/control/Control.Menubar.js
+++ b/loleaflet/src/control/Control.Menubar.js
@@ -244,7 +244,11 @@ L.Control.Menubar = L.Control.extend({
{name: _UNO('.uno:InsertSymbol', 'presentation'), id: 'specialcharacter', type: 'action'}]
},
{name: _UNO('.uno:FormatMenu', 'presentation'), type: 'menu', menu: [
- {uno: '.uno:EditStyle'}
+ {name: _UNO('.uno:FormatObjectMenu', 'presentation'), type: 'menu', menu: [
+ {uno: '.uno:TransformDialog'},
+ {uno: '.uno:FormatLine'},
+ {uno: '.uno:FormatArea'}
+ ]},
]},
{name: _UNO('.uno:TableMenu', 'text'/*HACK should be 'presentation', but not in xcu*/), type: 'menu', menu: [
{name: _UNO('.uno:TableInsertMenu', 'text'/*HACK should be 'presentation', but not in xcu*/), type: 'menu', menu: [
diff --git a/loleaflet/unocommands.js b/loleaflet/unocommands.js
index e610559f..e0442f97 100644
--- a/loleaflet/unocommands.js
+++ b/loleaflet/unocommands.js
@@ -59,9 +59,12 @@ var unoCommandsArray = {
FilterMenu:{spreadsheet:{menu:_('More ~Filters'),},},
FontColor:{global:{menu:_('Font Color'),},text:{menu:_('Font Color'),},},
FontDialog:{global:{menu:_('Character...'),},},
+ FormatArea:{global:{menu:_('A~rea...'),},},
FormatBulletsMenu:{global:{menu:_('Lis~ts'),},},
FormatCellDialog:{spreadsheet:{context:_('~Format Cells...'),menu:_('Ce~lls...'),},},
+ FormatLine:{global:{menu:_('L~ine...'),},},
FormatMenu:{global:{menu:_('F~ormat'),},},
+ FormatObjectMenu:{global:{menu:_('~Object and Shape'),},text:{menu:_('Text Box and Shap~e'),},},
FormatSpacingMenu:{global:{menu:_('~Spacing'),},},
FormatTextMenu:{global:{menu:_('Te~xt'),},},
FormattingMarkMenu:{global:{menu:_('Formatting Mark'),},},
@@ -196,6 +199,7 @@ var unoCommandsArray = {
ToggleMergeCells:{spreadsheet:{menu:_('M~erge and Center Cells'),},},
ToolsMenu:{global:{menu:_('~Tools'),},},
TrackChanges:{text:{menu:_('~Record'),},},
+ TransformDialog:{global:{menu:_('Position and Si~ze...'),},},
Underline:{global:{menu:_('Underline'),},},
UnderlineDouble:{presentation:{menu:_('Double Underline '),},spreadsheet:{menu:_('Underline: Double'),},text:{menu:_('Double Underline '),},},
Undo:{global:{menu:_('Undo'),},},
More information about the Libreoffice-commits
mailing list