vcl/inc/impimagetree.hxx | 7 ++- vcl/opengl/salbmp.cxx | 12 +++++- vcl/source/gdi/impimage.cxx | 9 ++-- vcl/source/gdi/impimagetree.cxx | 69 +++++++++++++++++++++++-------------- vcl/win/source/gdi/winlayout.cxx | 72 +++++++++++++++++++++++++++++++-------- vcl/workben/vcldemo.cxx | 70 +++++++++++++++++++++++++++++++++---- 6 files changed, 183 insertions(+), 56 deletions(-)
New commits: commit f1e5ea6801085b9594263cf41d7421b618189973 Author: Michael Meeks <michael.me...@collabora.com> Date: Fri Nov 14 11:58:28 2014 +0000 vcldemo: dump and render all icons from images.zip when zoomed in. Change-Id: I89f37b8a1ed70334a3485bc3ca06d04cfe6d0827 diff --git a/vcl/inc/impimagetree.hxx b/vcl/inc/impimagetree.hxx index 712ec80..9e4f579 100644 --- a/vcl/inc/impimagetree.hxx +++ b/vcl/inc/impimagetree.hxx @@ -55,6 +55,8 @@ public: * be too late for the destructors of the bitmaps in m_iconCache)*/ void shutDown(); + css::uno::Reference< css::container::XNameAccess > getNameAccess(); + private: bool doLoadImage( OUString const & name, OUString const & style, @@ -62,8 +64,7 @@ private: typedef std::pair< OUString, - com::sun::star::uno::Reference< - com::sun::star::container::XNameAccess > > Path; + css::uno::Reference< css::container::XNameAccess > > Path; typedef boost::unordered_map< OUString, bool, OUStringHash > CheckStyleCache; @@ -78,6 +79,8 @@ private: bool m_cacheIcons; IconLinkHash m_linkHash; + bool checkPathAccess(); + void setStyle(OUString const & style ); void resetPaths(); @@ -89,7 +92,6 @@ private: void loadImageLinks(); void parseLinkFile(boost::shared_ptr< SvStream > stream); OUString const & getRealImageName(OUString const & name); - std::vector<OUString> getAllPaths(); }; typedef salhelper::SingletonRef< ImplImageTree > ImplImageTreeSingletonRef; diff --git a/vcl/source/gdi/impimagetree.cxx b/vcl/source/gdi/impimagetree.cxx index b5fc822..0778bec 100644 --- a/vcl/source/gdi/impimagetree.cxx +++ b/vcl/source/gdi/impimagetree.cxx @@ -248,17 +248,9 @@ bool ImplImageTree::find( } } - if (!m_path.second.is()) { - try { - m_path.second = css::packages::zip::ZipFileAccess::createWithURL(comphelper::getProcessComponentContext(), m_path.first + ".zip"); - } catch (const css::uno::RuntimeException &) { - throw; - } catch (const css::uno::Exception & e) { - SAL_INFO("vcl", "ImplImageTree::find exception " - << e.Message << " for " << m_path.first); - return false; - } - } + if (!checkPathAccess()) + return false; + for (std::vector< OUString >::const_reverse_iterator j(paths.rbegin()); j != paths.rend(); ++j) { @@ -288,21 +280,9 @@ void ImplImageTree::loadImageLinks() } } - if ( !m_path.second.is() ) - { - try - { - m_path.second = css::packages::zip::ZipFileAccess::createWithURL(comphelper::getProcessComponentContext(), m_path.first + ".zip"); - } catch (const css::uno::RuntimeException &) { - throw; - } - catch (const css::uno::Exception & e) - { - SAL_INFO("vcl", "ImplImageTree::find exception " - << e.Message << " for " << m_path.first); - return; - } - } + if (!checkPathAccess()) + return; + if ( m_path.second->hasByName(aLinkFilename) ) { css::uno::Reference< css::io::XInputStream > s; @@ -349,21 +329,41 @@ OUString const & ImplImageTree::getRealImageName(OUString const & name) return it->second; } -std::vector<OUString> ImplImageTree::getAllPaths() +bool ImplImageTree::checkPathAccess() { - std::vector<OUString> aNames; + if (m_path.second.is()) + return true; + + try { + m_path.second = css::packages::zip::ZipFileAccess::createWithURL(comphelper::getProcessComponentContext(), m_path.first + ".zip"); + } catch (const css::uno::RuntimeException &) { + throw; + } catch (const css::uno::Exception & e) { + SAL_INFO("vcl", "ImplImageTree::zip file location exception " + << e.Message << " for " << m_path.first); + return false; + } + return m_path.second.is(); +} - return aNames; +css::uno::Reference< css::container::XNameAccess > ImplImageTree::getNameAccess() +{ + checkPathAccess(); + return m_path.second; } // For vcldemo / debugging -SAL_DLLPUBLIC std::vector<OUString> ImageTree_getAllImageNames(); +SAL_DLLPUBLIC css::uno::Sequence< OUString > ImageTree_getAllImageNames(); /// Recursively dump all names ... -std::vector<OUString> ImageTree_getAllImageNames() +css::uno::Sequence< OUString > ImageTree_getAllImageNames() { static ImplImageTreeSingletonRef aImageTree; - return aImageTree.getAllPaths(); + + css::uno::Reference< css::container::XNameAccess > xRef( + aImageTree->getNameAccess() ); + + return xRef->getElementNames(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index 58dd92c..01c05c0 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -32,7 +32,7 @@ #endif // debugging hook just for us -SAL_DLLPUBLIC std::vector<OUString> ImageTree_getAllImageNames(); +SAL_DLLPUBLIC css::uno::Sequence< OUString > ImageTree_getAllImageNames(); using namespace css; @@ -579,6 +579,7 @@ public: struct DrawIcons : public RegionRenderer { + std::vector<OUString> maIconNames; std::vector<BitmapEx> maIcons; bool bHasLoadedAll; DrawIcons() : bHasLoadedAll(false) @@ -609,18 +610,24 @@ public: "cmd/lc_hyperlinkdialog.png", }; for (size_t i = 0; i < SAL_N_ELEMENTS(pNames); i++) - maIcons.push_back(BitmapEx(OUString::createFromAscii(pNames[i]))); + { + maIconNames.push_back(OUString::createFromAscii(pNames[i])); + maIcons.push_back(BitmapEx(maIconNames[i])); + } } - void LoadAllIcons() + void LoadAllImages() { if (bHasLoadedAll) return; bHasLoadedAll = true; - std::vector<OUString> aAllIcons = ImageTree_getAllImageNames(); - for (size_t i = 0; i < aAllIcons.size(); i++) + css::uno::Sequence< OUString > aAllIcons = ImageTree_getAllImageNames(); + for (sal_Int32 i = 0; i < aAllIcons.getLength() && i < 1024; i++) + { + maIconNames.push_back(aAllIcons[i]); maIcons.push_back(BitmapEx(aAllIcons[i])); + } } void doDrawIcons(OutputDevice &rDev, Rectangle r) @@ -630,6 +637,7 @@ public: for (size_t i = 0; i < maIcons.size(); i++) { Size aSize(maIcons[i].GetSizePixel()); +// sAL_DEBUG("Draw icon '" << maIconNames[i] << "'"); rDev.DrawBitmapEx(p, maIcons[i]); p.Move(aSize.Width(), 0); if (aSize.Height() > nMaxH) @@ -648,6 +656,7 @@ public: { if (rCtx.meStyle == RENDER_EXPANDED) { + LoadAllImages(); doDrawIcons(rDev, r); } else commit fe72da5fa36206a4bd9bd6f1fc4aff1b8115a3b9 Author: Michael Meeks <michael.me...@collabora.com> Date: Fri Nov 14 11:56:46 2014 +0000 vcl: Fix palette modification during BitmapWriteAccess lifetime. Change-Id: I8bdedd63895ff0b3245d996cf35ac92d9ab0ff9d diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx index ab27ade..c2ebb68 100644 --- a/vcl/opengl/salbmp.cxx +++ b/vcl/opengl/salbmp.cxx @@ -234,9 +234,12 @@ public: ImplPixelFormat8( const BitmapPalette& rPalette ) : mrPalette( rPalette ) { + if ( mrPalette.GetEntryCount() < 256 ) + SAL_WARN( "vcl.opengl", "Bad sign, if we get an OOB pixel we die" ); } virtual const BitmapColor& ReadPixel() SAL_OVERRIDE { + assert( mrPalette.GetEntryCount() > *mpData ); return mrPalette[ *mpData++ ]; } }; @@ -252,6 +255,8 @@ public: ImplPixelFormat4( const BitmapPalette& rPalette ) : mrPalette( rPalette ) { + if ( mrPalette.GetEntryCount() < 16 ) + SAL_WARN( "vcl.opengl", "Bad sign, if we get an OOB pixel we die" ); } virtual void StartLine( sal_uInt8* pLine ) SAL_OVERRIDE { @@ -261,7 +266,9 @@ public: } virtual const BitmapColor& ReadPixel() SAL_OVERRIDE { - const BitmapColor& rColor = mrPalette[( mpData[mnX >> 1] >> mnShift) & 0x0f]; + sal_uInt32 nIdx = ( mpData[mnX >> 1] >> mnShift) & 0x0f; + assert( mrPalette.GetEntryCount() > nIdx ); + const BitmapColor& rColor = mrPalette[nIdx]; mnX++; mnShift ^= 4; return rColor; @@ -508,6 +515,9 @@ void OpenGLSalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly ) maTexture = OpenGLTexture(); mbDirtyTexture = true; } + // The palette is modified on read during the BitmapWriteAccess, + // but of course, often it is not modified; interesting. + maPalette = pBuffer->maPalette; delete pBuffer; } commit 1c0e30c2f37c6b620c1e1601c3089189cef06d5b Author: Michael Meeks <michael.me...@collabora.com> Date: Fri Nov 14 09:47:09 2014 +0000 vcldemo: much improved icon rendering tests. Change-Id: I853bc0a0957cf0db629a0a5f1ced67bc069d8403 diff --git a/vcl/inc/impimagetree.hxx b/vcl/inc/impimagetree.hxx index 85e3640..712ec80 100644 --- a/vcl/inc/impimagetree.hxx +++ b/vcl/inc/impimagetree.hxx @@ -89,6 +89,7 @@ private: void loadImageLinks(); void parseLinkFile(boost::shared_ptr< SvStream > stream); OUString const & getRealImageName(OUString const & name); + std::vector<OUString> getAllPaths(); }; typedef salhelper::SingletonRef< ImplImageTree > ImplImageTreeSingletonRef; diff --git a/vcl/source/gdi/impimagetree.cxx b/vcl/source/gdi/impimagetree.cxx index e81bafe..b5fc822 100644 --- a/vcl/source/gdi/impimagetree.cxx +++ b/vcl/source/gdi/impimagetree.cxx @@ -349,4 +349,21 @@ OUString const & ImplImageTree::getRealImageName(OUString const & name) return it->second; } +std::vector<OUString> ImplImageTree::getAllPaths() +{ + std::vector<OUString> aNames; + + return aNames; +} + +// For vcldemo / debugging +SAL_DLLPUBLIC std::vector<OUString> ImageTree_getAllImageNames(); + +/// Recursively dump all names ... +std::vector<OUString> ImageTree_getAllImageNames() +{ + static ImplImageTreeSingletonRef aImageTree; + return aImageTree.getAllPaths(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index 06a6d86..58dd92c 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -31,6 +31,9 @@ # define FIXME_SELF_INTERSECTING_WORKING #endif +// debugging hook just for us +SAL_DLLPUBLIC std::vector<OUString> ImageTree_getAllImageNames(); + using namespace css; class DemoBase : @@ -577,39 +580,79 @@ public: struct DrawIcons : public RegionRenderer { std::vector<BitmapEx> maIcons; - DrawIcons() + bool bHasLoadedAll; + DrawIcons() : bHasLoadedAll(false) { + // a few icons to start with const char *pNames[] = { "cmd/lc_openurl.png", "cmd/lc_newdoc.png", + "cmd/lc_choosemacro.png", "cmd/lc_save.png", "cmd/lc_saveas.png", + "cmd/lc_importdialog.png", "cmd/lc_sendmail.png", "cmd/lc_editdoc.png", "cmd/lc_print.png", + "cmd/lc_combobox.png", + "cmd/lc_insertformcombo.png", "cmd/lc_printpreview.png", "cmd/lc_cut.png", "cmd/lc_copy.png", "cmd/lc_paste.png", + "cmd/sc_autopilotmenu.png", "cmd/lc_formatpaintbrush.png", "cmd/lc_undo.png", "cmd/lc_redo.png", - }; + "cmd/lc_marks.png", + "cmd/lc_fieldnames.png", + "cmd/lc_hyperlinkdialog.png", + }; for (size_t i = 0; i < SAL_N_ELEMENTS(pNames); i++) maIcons.push_back(BitmapEx(OUString::createFromAscii(pNames[i]))); } - virtual void RenderRegion(OutputDevice &rDev, Rectangle r, - const RenderContext &) SAL_OVERRIDE + void LoadAllIcons() { - Rectangle p(r); + if (bHasLoadedAll) + return; + bHasLoadedAll = true; + + std::vector<OUString> aAllIcons = ImageTree_getAllImageNames(); + for (size_t i = 0; i < aAllIcons.size(); i++) + maIcons.push_back(BitmapEx(aAllIcons[i])); + } + + void doDrawIcons(OutputDevice &rDev, Rectangle r) + { + long nMaxH = 0, nVPos = 0; + Point p(r.TopLeft()); for (size_t i = 0; i < maIcons.size(); i++) { Size aSize(maIcons[i].GetSizePixel()); - rDev.DrawBitmapEx(p.TopLeft(), maIcons[i]); + rDev.DrawBitmapEx(p, maIcons[i]); p.Move(aSize.Width(), 0); - if (p.Left() >= r.Right()) - break; + if (aSize.Height() > nMaxH) + nMaxH = aSize.Height(); + if (p.X() >= r.Right()) + { + nVPos += nMaxH; + nMaxH = 0; + p = Point(r.Left(), r.Top() + nVPos); + } + } + } + + virtual void RenderRegion(OutputDevice &rDev, Rectangle r, + const RenderContext &rCtx) SAL_OVERRIDE + { + if (rCtx.meStyle == RENDER_EXPANDED) + { + doDrawIcons(rDev, r); + } + else + { + doDrawIcons(rDev, r); } } }; commit 657e9b7d97f485f3f80d92fed36761c7dea5334e Author: Michael Meeks <michael.me...@collabora.com> Date: Fri Nov 14 08:40:45 2014 +0000 vcl: re-factor image rendering control-flow. Change-Id: I923f92e5e84d35dafd1c0d1b4d63916ce690cb90 diff --git a/vcl/source/gdi/impimage.cxx b/vcl/source/gdi/impimage.cxx index c8f4a72..0072087 100644 --- a/vcl/source/gdi/impimage.cxx +++ b/vcl/source/gdi/impimage.cxx @@ -331,10 +331,9 @@ pOutDev if( !mpDisplayBmp && !maBmpEx.IsEmpty() ) { #if defined WNT - if( maBmpEx.IsAlpha() ) - mpDisplayBmp = new BitmapEx( maBmpEx ); - else + if( !maBmpEx.IsAlpha() ) { + // FIXME: this looks like rather an obsolete code-path to me. const Bitmap aBmp( maBmpEx.GetBitmap().CreateDisplayBitmap( pOutDev ) ); if( maBmpEx.IsTransparent() ) @@ -342,9 +341,9 @@ pOutDev else mpDisplayBmp = new BitmapEx( aBmp ); } -#else - mpDisplayBmp = new BitmapEx( maBmpEx ); + else #endif + mpDisplayBmp = new BitmapEx( maBmpEx ); } } commit daf776a553c6783c93128bfec9bcab8b4472fc0d Author: Jan Holesovsky <ke...@collabora.com> Date: Fri Nov 14 13:58:09 2014 +0100 windows opengl: Finally got the text working. It still does not have a transparent background, but that is pending support in OpenGLSalGraphicsImpl. Change-Id: I477a483e6ac940f54f6ffd6816d753d87206bf23 diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx index ae4ea3a..04672ce 100644 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -192,27 +192,38 @@ void WinLayout::DrawText(SalGraphics& rGraphics) const // TODO: check the performance of this 2nd approach at some stage and // switch to that if it performs well. - // FIXME so that we don't have to use enormous bitmap, move the text - // to 0,0, size the width / height accordingly, and move it back via - // SalTwoRects later - const int width = 1024; - const int height = 1024; + Rectangle aRect; + GetBoundRect(rGraphics, aRect); + + const int origin_x = aRect.Left(); + const int origin_y = aRect.Top(); + const int width = aRect.GetWidth(); + const int height = aRect.GetHeight(); const int bpp = 32; HDC compatibleDC = CreateCompatibleDC(hDC); + // move the origin so that we always paint at 0,0 - to keep the bitmap + // small + OffsetViewportOrgEx(compatibleDC, -origin_x, -origin_y, NULL); + sal_uInt8 *data; HBITMAP hBitmap = WinSalVirtualDevice::ImplCreateVirDevBitmap(compatibleDC, width, height, bpp, reinterpret_cast<void **>(&data)); - // FIXME fill transparent instead of 128, this is for testing - memset(data, 128, width*height*4); - // draw the text to the hidden DC with black color and white - // background, we will use the result later as a mask only + // setup the hidden DC with black color and white background, we will + // use the result of the text drawing later as a mask only HGDIOBJ hBitmapOld = SelectObject(compatibleDC, hBitmap); SelectFont(compatibleDC, mhFont); + SetTextColor(compatibleDC, RGB(0, 0, 0)); SetBkColor(compatibleDC, RGB(255, 255, 255)); + + UINT nTextAlign = GetTextAlign(hDC); + SetTextAlign(compatibleDC, nTextAlign); + + // the actual drawing DrawTextImpl(compatibleDC); + SelectObject(compatibleDC, hBitmapOld); // and turn it into a texture @@ -227,8 +238,8 @@ void WinLayout::DrawText(SalGraphics& rGraphics) const aRects.mnSrcY = 0; aRects.mnSrcWidth = width; aRects.mnSrcHeight = height; - aRects.mnDestX = 0; - aRects.mnDestY = 0; + aRects.mnDestX = origin_x; + aRects.mnDestY = origin_y; aRects.mnDestWidth = width; aRects.mnDestHeight = height; commit 69baf1300689632faff35465f952ca58429f19c9 Author: Jan Holesovsky <ke...@collabora.com> Date: Fri Nov 14 11:15:17 2014 +0100 windows opengl: Explain the concept of the text drawing + minor fixes. Change-Id: I4651e7e9b8163844be548d4ed975a881d4f83fff diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx index 3d3c625..ae4ea3a 100644 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -163,7 +163,34 @@ void WinLayout::DrawText(SalGraphics& rGraphics) const } else { - // we have to render the text to a hidden texture, and draw it + // We have to render the text to a hidden texture, and draw it. + // + // Note that Windows GDI does not really support the alpha correctly + // when drawing - ie. it draws nothing to the alpha channel when + // rendering the text, even the antialiasing is done as 'real' pixels, + // not alpha... + // + // Luckily, this does not really limit us: + // + // To blend properly, we draw the texture, but then use it as an alpha + // channel for solid color (that will define the text color). This + // destroys the subpixel antialiasing - turns it into 'classic' + // antialiasing - but that is the best we can do, because the subpixel + // antialiasing needs to know what is in the background: When the + // background is white, or white-ish, it does the subpixel, but when + // there is a color, it just darkens the color (and does this even + // when part of the character is on a colored background, and part on + // white). It has to work this way, the results would look strange + // otherwise. + // + // For the GL rendering to work even with the subpixel antialiasing, + // we would need to get the current texture from the screen, let GDI + // draw the text to it (so that it can decide well where to use the + // subpixel and where not), and draw the result - but in that case we + // don't need alpha anyway. + // + // TODO: check the performance of this 2nd approach at some stage and + // switch to that if it performs well. // FIXME so that we don't have to use enormous bitmap, move the text // to 0,0, size the width / height accordingly, and move it back via @@ -176,12 +203,15 @@ void WinLayout::DrawText(SalGraphics& rGraphics) const sal_uInt8 *data; HBITMAP hBitmap = WinSalVirtualDevice::ImplCreateVirDevBitmap(compatibleDC, width, height, bpp, reinterpret_cast<void **>(&data)); - // FIXME fill transparent instead of 128 + // FIXME fill transparent instead of 128, this is for testing memset(data, 128, width*height*4); - // draw the text to the hidden DC + // draw the text to the hidden DC with black color and white + // background, we will use the result later as a mask only HGDIOBJ hBitmapOld = SelectObject(compatibleDC, hBitmap); SelectFont(compatibleDC, mhFont); + SetTextColor(compatibleDC, RGB(0, 0, 0)); + SetBkColor(compatibleDC, RGB(255, 255, 255)); DrawTextImpl(compatibleDC); SelectObject(compatibleDC, hBitmapOld); @@ -203,7 +233,12 @@ void WinLayout::DrawText(SalGraphics& rGraphics) const aRects.mnDestHeight = height; pImpl->PreDraw(); - pImpl->DrawAlphaTexture(aTexture, aRects); + COLORREF color = GetTextColor(hDC); + SalColor salColor = MAKE_SALCOLOR(GetRValue(color), GetGValue(color), GetBValue(color)); + // TODO when we have it: + // pImpl->DrawSolidColorWithMask(salColor, aTexture, aRects); + // and kill the following interim thing: + pImpl->DrawTexture(aTexture, aRects); pImpl->PostDraw(); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits