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 +++++++++-- 6 files changed, 79 insertions(+), 30 deletions(-)
New commits: commit 24e9b8fda0e0ca6ae8b5fbe26f13948da7d7b6f4 Author: Michael Meeks <michael.me...@collabora.com> Date: Mon May 26 20:34:44 2014 +0100 cache the bitmap converted to flat RGBA pixels. Change-Id: Ied38d4457fbc04ded42fe4fb55a8ec654cefa259 diff --git a/chart2/source/view/inc/3DChartObjects.hxx b/chart2/source/view/inc/3DChartObjects.hxx index 39d2411..4674646 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 rText); + const TextCacheItem &getText(OUString rText); private: - typedef boost::ptr_map<OUString, BitmapEx> TextCacheType; + typedef boost::ptr_map<OUString, 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 c2d6b4b..b16453c 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> @@ -162,8 +163,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 b838d31..09ed6aa 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 rText) +const TextCacheItem& TextCache::getText(OUString rText) { TextCacheType::const_iterator itr = maTextCache.find(rText); if(itr != maTextCache.end()) @@ -85,14 +85,16 @@ const BitmapEx& TextCache::getText(OUString 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 7b03dab..74f8ec1 100644 --- a/chart2/source/view/main/GL3DRenderer.cxx +++ b/chart2/source/view/main/GL3DRenderer.cxx @@ -1359,11 +1359,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); @@ -1403,11 +1405,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