chart2/source/view/charttypes/GL3DBarChart.cxx | 3 ++- chart2/source/view/inc/3DChartObjects.hxx | 19 +++++++++++++++---- chart2/source/view/inc/GL3DRenderer.hxx | 13 +++++++++++-- chart2/source/view/main/3DChartObjects.cxx | 24 +++++++++++++++--------- chart2/source/view/main/GL3DRenderer.cxx | 21 +++++++++++++-------- chart2/source/view/main/OpenGLRender.cxx | 21 ++++++++++++++++----- chart2/source/view/main/OpenGLRender.hxx | 11 +++++++++-- 7 files changed, 81 insertions(+), 31 deletions(-)
New commits: commit ed24ae433bc280100c18b00d6083b6730ac35ecc Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Tue May 27 16:32:25 2014 +0200 prevent that early return prevents further user interaction Change-Id: I24f814a402d2b8af3ddf888719b78d3158c2a38f diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx index 455b9e4..8f70d05 100644 --- a/chart2/source/view/charttypes/GL3DBarChart.cxx +++ b/chart2/source/view/charttypes/GL3DBarChart.cxx @@ -293,7 +293,6 @@ void GL3DBarChart::clickedAt(const Point& /*rPos*/, sal_uInt16 nButtons) if(nButtons != MOUSE_LEFT) return; - mbBlockUserInput = true; sal_uInt32 nId = 5; /* { @@ -309,6 +308,8 @@ void GL3DBarChart::clickedAt(const Point& /*rPos*/, sal_uInt16 nButtons) if(itr == maBarMap.end()) return; + mbBlockUserInput = true; + const BarInformation& rBarInfo = itr->second; mnStepsTotal = 100; mnStep = 0; commit 8c9b3cdccef118cbb0115a84c62e90633fc0d8e3 Author: Michael Meeks <michael.me...@collabora.com> Date: Mon May 26 20:34:44 2014 +0100 cache the bitmap converted to flat RGBA pixels. Conflicts: chart2/source/view/inc/3DChartObjects.hxx chart2/source/view/main/3DChartObjects.cxx Change-Id: Ied38d4457fbc04ded42fe4fb55a8ec654cefa259 diff --git a/chart2/source/view/inc/3DChartObjects.hxx b/chart2/source/view/inc/3DChartObjects.hxx index 31e64f2..fb7147c 100644 --- a/chart2/source/view/inc/3DChartObjects.hxx +++ b/chart2/source/view/inc/3DChartObjects.hxx @@ -15,17 +15,28 @@ #include "GL3DRenderer.hxx" #include <boost/ptr_container/ptr_map.hpp> +#include <boost/shared_array.hpp> namespace chart { namespace opengl3D { +struct TextCacheItem +{ + TextCacheItem(sal_uInt8 *pPixels, ::Size aSize) + : maSize(aSize), maPixels(pPixels) + { + } + ::Size maSize; + boost::shared_array<sal_uInt8> maPixels; +}; + class TextCache { public: - const BitmapEx& getText(OUString const & rText); + const TextCacheItem &getText(OUString const & rText); private: - typedef boost::ptr_map<OUString const, BitmapEx> TextCacheType; + typedef boost::ptr_map<OUString const, TextCacheItem> TextCacheType; TextCacheType maTextCache; }; @@ -85,7 +96,7 @@ public: void setPosition(const glm::vec3& rTopLeft, const glm::vec3& rTopRight, const glm::vec3& rBottomRight); private: - const BitmapEx& mrText; + TextCacheItem maText; glm::vec3 maTopLeft; glm::vec3 maTopRight; glm::vec3 maBottomRight; @@ -100,7 +111,7 @@ public: void setPosition(const glm::vec2& rTopLeft, const glm::vec2& rBottomRight); private: - const BitmapEx& mrText; + TextCacheItem maText; glm::vec2 maTopLeft; glm::vec2 maBottomRight; }; diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx index 8b2b9a5..4cba423 100644 --- a/chart2/source/view/inc/GL3DRenderer.hxx +++ b/chart2/source/view/inc/GL3DRenderer.hxx @@ -16,6 +16,7 @@ #include "glm/gtx/quaternion.hpp" #include <com/sun/star/awt/Point.hpp> +#include <boost/shared_array.hpp> #include <tools/gen.hxx> #include <vcl/bitmapex.hxx> @@ -161,8 +162,16 @@ public: void EndAddShape3DExtrudeObject(); void SetSize(const Size& rSize); void SetCameraInfo(glm::vec3 pos, glm::vec3 direction, glm::vec3 up); - void CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vTopLeft,glm::vec3 vTopRight, glm::vec3 vBottomRight, glm::vec3 vBottomLeft, sal_uInt32 nUniqueId); - void CreateScreenTextTexture(const BitmapEx& rBitmapEx, glm::vec2 vTopLeft, glm::vec2 vBottomRight, sal_uInt32 nUniqueId); + void CreateTextTexture(const boost::shared_array<sal_uInt8> &bitmapBuf, + ::Size maSizePixels, + glm::vec3 vTopLeft,glm::vec3 vTopRight, + glm::vec3 vBottomRight, glm::vec3 vBottomLeft, + sal_uInt32 nUniqueId); + void CreateScreenTextTexture(const boost::shared_array<sal_uInt8> &bitmapBuf, + ::Size maSizePixels, + + glm::vec2 vTopLeft, glm::vec2 vBottomRight, + sal_uInt32 nUniqueId); void ProcessUnrenderedShape(); void SetPickingMode(bool bPickingMode); diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx index e510235..2573191 100644 --- a/chart2/source/view/main/3DChartObjects.cxx +++ b/chart2/source/view/main/3DChartObjects.cxx @@ -68,7 +68,7 @@ void Line::setLineColor(const Color& rColor) maLineColor = rColor; } -const BitmapEx& TextCache::getText(OUString const & rText) +const TextCacheItem& TextCache::getText(OUString const & rText) { TextCacheType::const_iterator itr = maTextCache.find(rText); if(itr != maTextCache.end()) @@ -85,14 +85,16 @@ const BitmapEx& TextCache::getText(OUString const & rText) aDevice.SetBackground(Wallpaper(COL_TRANSPARENT)); aDevice.DrawText(Point(0,0), rText); - BitmapEx* pText = new BitmapEx(aDevice.GetBitmapEx(Point(0,0), aDevice.GetOutputSize())); - maTextCache.insert(rText, pText); - return *pText; + BitmapEx aText(aDevice.GetBitmapEx(Point(0,0), aDevice.GetOutputSize())); + TextCacheItem *pItem = new TextCacheItem(OpenGLHelper::ConvertBitmapExToRGBABuffer(aText), aText.GetSizePixel()); + maTextCache.insert(rText, pItem); + + return *maTextCache.find(rText)->second; } Text::Text(OpenGL3DRenderer* pRenderer, TextCache& rTextCache, const OUString& rStr, sal_uInt32 nId): Renderable3DObject(pRenderer, nId), - mrText(rTextCache.getText(rStr)) + maText(rTextCache.getText(rStr)) { } @@ -100,12 +102,14 @@ void Text::render() { glm::vec3 dir2 = maTopRight - maTopLeft; glm::vec3 bottomLeft = maBottomRight - dir2; - mpRenderer->CreateTextTexture(mrText, maTopLeft, maTopRight, maBottomRight, bottomLeft, mnUniqueId); + mpRenderer->CreateTextTexture(maText.maPixels, maText.maSize, + maTopLeft, maTopRight, maBottomRight, bottomLeft, + mnUniqueId); } Size Text::getSize() const { - return mrText.GetSizePixel(); + return maText.maSize; } void Text::setPosition(const glm::vec3& rTopLeft, const glm::vec3& rTopRight, const glm::vec3& rBottomRight) @@ -117,7 +121,7 @@ void Text::setPosition(const glm::vec3& rTopLeft, const glm::vec3& rTopRight, co ScreenText::ScreenText(OpenGL3DRenderer* pRenderer, TextCache& rTextCache, const OUString& rStr, sal_uInt32 nId): Renderable3DObject(pRenderer, nId), - mrText(rTextCache.getText(rStr)) + maText(rTextCache.getText(rStr)) { } @@ -129,7 +133,9 @@ void ScreenText::setPosition(const glm::vec2& rTopLeft, const glm::vec2& rBottom void ScreenText::render() { - mpRenderer->CreateScreenTextTexture(mrText, maTopLeft, maBottomRight, mnUniqueId); + mpRenderer->CreateScreenTextTexture(maText.maPixels, maText.maSize, + maTopLeft, maBottomRight, + mnUniqueId); } Rectangle::Rectangle(OpenGL3DRenderer* pRenderer, sal_uInt32 nId): diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx index 061db79..d1d4331 100644 --- a/chart2/source/view/main/GL3DRenderer.cxx +++ b/chart2/source/view/main/GL3DRenderer.cxx @@ -1378,11 +1378,13 @@ void OpenGL3DRenderer::RenderExtrude3DObject() glDisable(GL_CULL_FACE); } -void OpenGL3DRenderer::CreateScreenTextTexture(const BitmapEx& rBitmapEx, glm::vec2 vTopLeft, glm::vec2 vBottomRight, sal_uInt32 nUniqueId) +void OpenGL3DRenderer::CreateScreenTextTexture( + const boost::shared_array<sal_uInt8> &bitmapBuf, + ::Size maSizePixels, + glm::vec2 vTopLeft, glm::vec2 vBottomRight, sal_uInt32 nUniqueId) { - long bmpWidth = rBitmapEx.GetSizePixel().Width(); - long bmpHeight = rBitmapEx.GetSizePixel().Height(); - boost::scoped_array<sal_uInt8> bitmapBuf(OpenGLHelper::ConvertBitmapExToRGBABuffer(rBitmapEx)); + long bmpWidth = maSizePixels.Width(); + long bmpHeight = maSizePixels.Height(); TextInfo aTextInfo; aTextInfo.id = getColorAsVector(nUniqueId); @@ -1422,11 +1424,14 @@ void OpenGL3DRenderer::CreateScreenTextTexture(const BitmapEx& rBitmapEx, glm::v m_ScreenTextInfoList.push_back(aTextInfo); } -void OpenGL3DRenderer::CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vTopLeft,glm::vec3 vTopRight, glm::vec3 vBottomRight, glm::vec3 vBottomLeft, sal_uInt32 nUniqueId) +void OpenGL3DRenderer::CreateTextTexture(const boost::shared_array<sal_uInt8> &bitmapBuf, + ::Size maSizePixels, + glm::vec3 vTopLeft,glm::vec3 vTopRight, + glm::vec3 vBottomRight, glm::vec3 vBottomLeft, + sal_uInt32 nUniqueId) { - long bmpWidth = rBitmapEx.GetSizePixel().Width(); - long bmpHeight = rBitmapEx.GetSizePixel().Height(); - boost::scoped_array<sal_uInt8> bitmapBuf(OpenGLHelper::ConvertBitmapExToRGBABuffer(rBitmapEx)); + long bmpWidth = maSizePixels.Width(); + long bmpHeight = maSizePixels.Height(); TextInfo aTextInfo; aTextInfo.id = getColorAsVector(nUniqueId); diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx index 12dfb79..02f770f 100644 --- a/chart2/source/view/main/OpenGLRender.cxx +++ b/chart2/source/view/main/OpenGLRender.cxx @@ -38,7 +38,6 @@ #include <vcl/opengl/OpenGLHelper.hxx> -#include <boost/scoped_array.hpp> #include "CommonConverters.hxx" using namespace com::sun::star; @@ -946,9 +945,21 @@ int OpenGLRender::CreateTextTexture(const BitmapEx& rBitmapEx, const awt::Point& } #endif - long bmpWidth = rBitmapEx.GetSizePixel().Width(); - long bmpHeight = rBitmapEx.GetSizePixel().Height(); - boost::scoped_array<sal_uInt8> bitmapBuf(OpenGLHelper::ConvertBitmapExToRGBABuffer(rBitmapEx)); + boost::shared_array<sal_uInt8> bitmapBuf(OpenGLHelper::ConvertBitmapExToRGBABuffer(rBitmapEx)); + + return CreateTextTexture(bitmapBuf, rBitmapEx.GetSizePixel(), + awt::Point(), aSize, rotation, rTrans); +} + +int OpenGLRender::CreateTextTexture(const boost::shared_array<sal_uInt8> &rPixels, + const ::Size &aPixelSize, + const awt::Point&, + const awt::Size& aSize, + long rotation, + const drawing::HomogenMatrix3& rTrans) +{ + long bmpWidth = aPixelSize.Width(); + long bmpHeight = aPixelSize.Height(); TextInfo aTextInfo; aTextInfo.rotation = -(double)rotation / 360.0 * 2* GL_PI; @@ -983,7 +994,7 @@ int OpenGLRender::CreateTextTexture(const BitmapEx& rBitmapEx, const awt::Point& CHECK_GL_ERROR(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); CHECK_GL_ERROR(); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bmpWidth, bmpHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, bitmapBuf.get()); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bmpWidth, bmpHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, rPixels.get()); CHECK_GL_ERROR(); glBindTexture(GL_TEXTURE_2D, 0); CHECK_GL_ERROR(); diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx index e88fffa..fdb93b8 100644 --- a/chart2/source/view/main/OpenGLRender.hxx +++ b/chart2/source/view/main/OpenGLRender.hxx @@ -12,6 +12,7 @@ #include <com/sun/star/drawing/XDrawPage.hpp> #include <vcl/font.hxx> #include <vcl/opengl/OpenGLContext.hxx> +#include <boost/shared_array.hpp> // Include GLM #include <list> @@ -96,9 +97,15 @@ public: int RenderRectangleShape(bool bBorder, bool bFill); int RectangleShapePoint(float x, float y, float directionX, float directionY); + int CreateTextTexture(const boost::shared_array<sal_uInt8> &rPixels, + const ::Size &aPixelSize, + const ::css::awt::Point&, + const ::css::awt::Size& aSize, + long rotation, + const ::css::drawing::HomogenMatrix3& rTrans); int CreateTextTexture(const BitmapEx& rBitmapEx, - const com::sun::star::awt::Point& aPos, const com::sun::star::awt::Size& aSize, - long rotation, const com::sun::star::drawing::HomogenMatrix3& rTrans); + const ::css::awt::Point& aPos, const css::awt::Size& aSize, + long rotation, const ::css::drawing::HomogenMatrix3& rTrans); int CreateTextTexture(::rtl::OUString const &textValue, Font aFont, long fontColor, awt::Point aPos, awt::Size aSize, long rotation); int RenderTextShape(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits