summaryrefslogtreecommitdiff
path: root/canvas
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@Sun.COM>2009-10-22 17:29:01 +0200
committerArmin Le Grand <Armin.Le.Grand@Sun.COM>2009-10-22 17:29:01 +0200
commit1e7cd1ecd7a6b730daf90bae9ec9bd9b1b19c9e6 (patch)
tree53a78aaa7367b718070df14bec3290c120faa745 /canvas
parent5de3269dcd48cd653837de3d576d7be3df679927 (diff)
parentcf144cb77169bfc84604434f4b7923fe5dac3d1e (diff)
commit after rebase to DEV300m62
Diffstat (limited to 'canvas')
-rw-r--r--canvas/source/cairo/cairo_textlayout.cxx6
-rw-r--r--canvas/source/cairo/makefile.mk7
-rwxr-xr-xcanvas/source/directx/dx_9rm.cxx42
-rwxr-xr-xcanvas/source/directx/dx_surfacegraphics.cxx5
-rwxr-xr-xcanvas/source/directx/dx_winstuff.hxx25
-rw-r--r--canvas/source/factory/makefile.mk4
-rw-r--r--canvas/source/null/makefile.mk4
-rw-r--r--canvas/source/simplecanvas/makefile.mk3
-rw-r--r--canvas/source/tools/makefile.mk4
-rw-r--r--canvas/source/vcl/canvasfont.cxx15
-rw-r--r--canvas/source/vcl/textlayout.cxx100
11 files changed, 175 insertions, 40 deletions
diff --git a/canvas/source/cairo/cairo_textlayout.cxx b/canvas/source/cairo/cairo_textlayout.cxx
index f822749cab20..08a4e7a70fa1 100644
--- a/canvas/source/cairo/cairo_textlayout.cxx
+++ b/canvas/source/cairo/cairo_textlayout.cxx
@@ -44,6 +44,12 @@
#include <tools/prewin.h>
#include <windows.h>
#include <tools/postwin.h>
+#ifdef max
+#undef max
+#endif
+#ifdef min
+#undef min
+#endif
#endif
#include <vcl/sysdata.hxx>
diff --git a/canvas/source/cairo/makefile.mk b/canvas/source/cairo/makefile.mk
index 2ab726da3464..27a1aeb6dcd7 100644
--- a/canvas/source/cairo/makefile.mk
+++ b/canvas/source/cairo/makefile.mk
@@ -49,7 +49,7 @@ DLLPRE =
# --- X11 Mac build currently doesn't work with cairo -----------
.IF "$(OS)" == "MACOSX" && "$(GUIBASE)" == "unx"
@all:
- @echo "Cannot build cairocanvas with X11..."
+ @echo "Cannot build cairocanvas with X11..."
.ENDIF
.ENDIF
@@ -65,7 +65,7 @@ CFLAGS+=-I$(SOLARINCDIR)/cairo
.IF "$(verbose)"!="" || "$(VERBOSE)"!=""
CDEFS+= -DVERBOSE
.ENDIF
-
+.IF "$(L10N_framework)"==""
SLOFILES = $(SLO)$/cairo_cachedbitmap.obj \
$(SLO)$/cairo_cairo.obj \
$(SLO)$/cairo_canvas.obj \
@@ -97,7 +97,6 @@ SHL1STDLIBS+= -lcairo
.IF "$(GUIBASE)"=="aqua"
# native Mac OS X (Quartz)
SLOFILES+= $(SLO)$/cairo_quartz_cairo.obj
-OBJCXXFLAGS=-x objective-c++ -fobjc-exceptions
CFLAGSCXX+=$(OBJCXXFLAGS)
.ELSE # "$(GUIBASE)"=="aqua"
@@ -131,7 +130,7 @@ SHL1VERSIONMAP=exports.map
DEF1NAME=$(SHL1TARGET)
DEF1EXPORTFILE=exports.dxp
-
+.ENDIF
# ==========================================================================
.INCLUDE : target.mk
diff --git a/canvas/source/directx/dx_9rm.cxx b/canvas/source/directx/dx_9rm.cxx
index 932a15e1f5c1..acef323ddc1b 100755
--- a/canvas/source/directx/dx_9rm.cxx
+++ b/canvas/source/directx/dx_9rm.cxx
@@ -956,11 +956,43 @@ namespace dxcanvas
{
if(hr != D3DERR_DEVICELOST)
return false;
- hr = mpDevice->Reset(&mad3dpp);
- if(SUCCEEDED(hr))
- return true;
- if(hr == D3DERR_DEVICELOST)
- return true;
+
+ // interestingly enough, sometimes the Reset() below
+ // *still* causes DeviceLost errors. So, cycle until
+ // DX was kind enough to really reset the device...
+ do
+ {
+ mpVertexBuffer.reset();
+ hr = mpDevice->Reset(&mad3dpp);
+ if(SUCCEEDED(hr))
+ {
+ IDirect3DVertexBuffer9 *pVB(NULL);
+ DWORD aFVF(D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1);
+ if( FAILED(mpDevice->CreateVertexBuffer(sizeof(dxvertex)*maNumVertices,
+ D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY,
+ aFVF,
+ D3DPOOL_DEFAULT,
+ &pVB,
+ NULL)) )
+ {
+ throw lang::NoSupportException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "Could not create DirectX device - out of memory!")),NULL);
+ }
+ mpVertexBuffer=COMReference<IDirect3DVertexBuffer9>(pVB);
+
+ // retry after the restore
+ if(SUCCEEDED(mpSwapChain->Present(&aRect,&aRect,NULL,NULL,0)))
+ return true;
+ }
+
+ TimeValue aTimeout;
+ aTimeout.Seconds=1;
+ aTimeout.Nanosec=0;
+ osl_waitThread(&aTimeout);
+ }
+ while(hr == D3DERR_DEVICELOST);
+
return false;
}
diff --git a/canvas/source/directx/dx_surfacegraphics.cxx b/canvas/source/directx/dx_surfacegraphics.cxx
index 128095c1315d..8b9af6be6827 100755
--- a/canvas/source/directx/dx_surfacegraphics.cxx
+++ b/canvas/source/directx/dx_surfacegraphics.cxx
@@ -34,6 +34,8 @@
#include "dx_surfacegraphics.hxx"
#include "dx_impltools.hxx"
+using namespace ::com::sun::star;
+
namespace dxcanvas
{
namespace
@@ -75,11 +77,12 @@ namespace dxcanvas
tools::setupGraphics( *pGraphics );
pRet.reset(pGraphics,
GraphicsDeleter(rSurface, aHDC));
+ return pRet;
}
else
rSurface->ReleaseDC( aHDC );
}
- return pRet;
+ throw uno::RuntimeException();
}
}
diff --git a/canvas/source/directx/dx_winstuff.hxx b/canvas/source/directx/dx_winstuff.hxx
index e5e7e4ffb4ae..1c64506c0f21 100755
--- a/canvas/source/directx/dx_winstuff.hxx
+++ b/canvas/source/directx/dx_winstuff.hxx
@@ -97,25 +97,18 @@
#undef DrawText
-// Needed for #?$&/@ gdiplus header
-#ifndef max
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-#define __WORKAROUND_MAX_DEFINED__
-#endif
-
-#ifndef min
-#define min(a,b) (((a) < (b)) ? (a) : (b))
-#define __WORKAROUND_MIN_DEFINED__
-#endif
-
+#ifdef __MINGW32__
+using ::std::max;
+using ::std::min;
+#endif
+
#include <gdiplus.h>
-#ifdef __WORKAROUND_MAX_DEFINED__
-#undef max
+#ifdef min
+# undef min
#endif
-
-#ifdef __WORKAROUND_MIN_DEFINED__
-#undef min
+#ifdef max
+# undef max
#endif
namespace dxcanvas
diff --git a/canvas/source/factory/makefile.mk b/canvas/source/factory/makefile.mk
index 3e9611412463..1051b953ae81 100644
--- a/canvas/source/factory/makefile.mk
+++ b/canvas/source/factory/makefile.mk
@@ -37,7 +37,7 @@ ENABLE_EXCEPTIONS = TRUE
.INCLUDE : settings.mk
DLLPRE =
-
+.IF "$(L10N_framework)"==""
SLOFILES = \
$(SLO)$/cf_service.obj
@@ -55,6 +55,6 @@ SHL1LIBS = $(SLB)$/$(TARGET).lib
SHL1DEF = $(MISC)$/$(SHL1TARGET).def
DEF1NAME = $(SHL1TARGET)
-
+.ENDIF
.INCLUDE : target.mk
diff --git a/canvas/source/null/makefile.mk b/canvas/source/null/makefile.mk
index 76e372c56fd7..99a6bbab93a4 100644
--- a/canvas/source/null/makefile.mk
+++ b/canvas/source/null/makefile.mk
@@ -45,7 +45,7 @@ DLLPRE =
.IF "$(verbose)"!="" || "$(VERBOSE)"!=""
CDEFS+= -DVERBOSE
.ENDIF
-
+.IF "$(L10N_framework)"==""
SLOFILES = $(SLO)$/null_canvasbitmap.obj \
$(SLO)$/null_canvascustomsprite.obj \
$(SLO)$/null_canvasfont.obj \
@@ -68,7 +68,7 @@ SHL1VERSIONMAP=exports.map
DEF1NAME=$(SHL1TARGET)
DEF1EXPORTFILE=exports.dxp
-
+.ENDIF
# ==========================================================================
.INCLUDE : target.mk
diff --git a/canvas/source/simplecanvas/makefile.mk b/canvas/source/simplecanvas/makefile.mk
index 6417ddb0c650..c0a60250ab85 100644
--- a/canvas/source/simplecanvas/makefile.mk
+++ b/canvas/source/simplecanvas/makefile.mk
@@ -45,7 +45,7 @@ DLLPRE =
.IF "$(verbose)"!="" || "$(VERBOSE)"!=""
CDEFS+= -DVERBOSE
.ENDIF
-
+.IF "$(L10N_framework)"==""
SLOFILES = $(SLO)$/simplecanvasimpl.obj
SHL1TARGET=$(TARGET).uno
@@ -60,6 +60,7 @@ SHL1VERSIONMAP=exports.map
DEF1NAME=$(SHL1TARGET)
DEF1EXPORTFILE=exports.dxp
+.ENDIF
# ==========================================================================
diff --git a/canvas/source/tools/makefile.mk b/canvas/source/tools/makefile.mk
index bf99a00febfc..9dc9967fac82 100644
--- a/canvas/source/tools/makefile.mk
+++ b/canvas/source/tools/makefile.mk
@@ -51,7 +51,7 @@ CDEFS+= -DPROFILER
#CFLAGS +:= /Ox /Ot # THIS IS IMPORTANT
-
+.IF "$(L10N_framework)"==""
SLOFILES = \
$(SLO)$/cachedprimitivebase.obj \
$(SLO)$/canvascustomspritehelper.obj \
@@ -95,7 +95,7 @@ DEFLIB1NAME =$(TARGET)
.IF "$(GUI)" == "WNT"
SHL1STDLIBS += $(WINMMLIB) $(KERNEL32LIB)
.ENDIF
-
+.ENDIF
# ==========================================================================
diff --git a/canvas/source/vcl/canvasfont.cxx b/canvas/source/vcl/canvasfont.cxx
index b049e1e4f317..d5b276901594 100644
--- a/canvas/source/vcl/canvasfont.cxx
+++ b/canvas/source/vcl/canvasfont.cxx
@@ -127,8 +127,19 @@ namespace vclcanvas
{
tools::LocalGuard aGuard;
- // TODO(F1)
- return rendering::FontMetrics();
+ OutputDevice& rOutDev = mpOutDevProvider->getOutDev();
+ VirtualDevice aVDev( rOutDev );
+ aVDev.SetFont(getVCLFont());
+ const ::FontMetric& aMetric( aVDev.GetFontMetric() );
+
+ return rendering::FontMetrics(
+ aMetric.GetAscent(),
+ aMetric.GetDescent(),
+ aMetric.GetIntLeading(),
+ aMetric.GetExtLeading(),
+ 0,
+ aMetric.GetDescent() / 2.0,
+ aMetric.GetAscent() / 2.0);
}
uno::Sequence< double > SAL_CALL CanvasFont::getAvailableSizes( ) throw (uno::RuntimeException)
diff --git a/canvas/source/vcl/textlayout.cxx b/canvas/source/vcl/textlayout.cxx
index f9fa6f6dc4d2..5787f32cf4bf 100644
--- a/canvas/source/vcl/textlayout.cxx
+++ b/canvas/source/vcl/textlayout.cxx
@@ -35,6 +35,7 @@
#include <tools/diagnose_ex.h>
#include <canvas/canvastools.hxx>
+#include <com/sun/star/rendering/CompositeOperation.hpp>
#include <com/sun/star/rendering/TextDirection.hpp>
#include <vcl/metric.hxx>
@@ -42,6 +43,7 @@
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/numeric/ftools.hxx>
+#include <basegfx/tools/canvastools.hxx>
#include "impltools.hxx"
#include "textlayout.hxx"
@@ -116,16 +118,104 @@ namespace vclcanvas
{
tools::LocalGuard aGuard;
- // TODO(F1)
- return uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > >();
+ OutputDevice& rOutDev = mpOutDevProvider->getOutDev();
+ VirtualDevice aVDev( rOutDev );
+ aVDev.SetFont( mpFont->getVCLFont() );
+
+ setupLayoutMode( aVDev, mnTextDirection );
+
+ const rendering::ViewState aViewState(
+ geometry::AffineMatrix2D(1,0,0, 0,1,0),
+ NULL);
+
+ rendering::RenderState aRenderState (
+ geometry::AffineMatrix2D(1,0,0,0,1,0),
+ NULL,
+ uno::Sequence<double>(4),
+ rendering::CompositeOperation::SOURCE);
+
+ ::boost::scoped_array< sal_Int32 > aOffsets(new sal_Int32[maLogicalAdvancements.getLength()]);
+ setupTextOffsets(aOffsets.get(), maLogicalAdvancements, aViewState, aRenderState);
+
+ uno::Sequence< uno::Reference< rendering::XPolyPolygon2D> > aOutlineSequence;
+ ::basegfx::B2DPolyPolygonVector aOutlines;
+ if (aVDev.GetTextOutlines(
+ aOutlines,
+ maText.Text,
+ ::canvas::tools::numeric_cast<USHORT>(maText.StartPosition),
+ ::canvas::tools::numeric_cast<USHORT>(maText.StartPosition),
+ ::canvas::tools::numeric_cast<USHORT>(maText.Length),
+ FALSE,
+ 0,
+ aOffsets.get()))
+ {
+ aOutlineSequence.realloc(aOutlines.size());
+ sal_Int32 nIndex (0);
+ for (::basegfx::B2DPolyPolygonVector::const_iterator
+ iOutline(aOutlines.begin()),
+ iEnd(aOutlines.end());
+ iOutline!=iEnd;
+ ++iOutline)
+ {
+ aOutlineSequence[nIndex++] = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
+ mxDevice,
+ *iOutline);
+ }
+ }
+
+ return aOutlineSequence;
}
uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryInkMeasures( ) throw (uno::RuntimeException)
{
tools::LocalGuard aGuard;
- // TODO(F1)
- return uno::Sequence< geometry::RealRectangle2D >();
+
+ OutputDevice& rOutDev = mpOutDevProvider->getOutDev();
+ VirtualDevice aVDev( rOutDev );
+ aVDev.SetFont( mpFont->getVCLFont() );
+
+ setupLayoutMode( aVDev, mnTextDirection );
+
+ const rendering::ViewState aViewState(
+ geometry::AffineMatrix2D(1,0,0, 0,1,0),
+ NULL);
+
+ rendering::RenderState aRenderState (
+ geometry::AffineMatrix2D(1,0,0,0,1,0),
+ NULL,
+ uno::Sequence<double>(4),
+ rendering::CompositeOperation::SOURCE);
+
+ ::boost::scoped_array< sal_Int32 > aOffsets(new sal_Int32[maLogicalAdvancements.getLength()]);
+ setupTextOffsets(aOffsets.get(), maLogicalAdvancements, aViewState, aRenderState);
+
+ MetricVector aMetricVector;
+ uno::Sequence<geometry::RealRectangle2D> aBoundingBoxes;
+ if (aVDev.GetGlyphBoundRects(
+ Point(0,0),
+ maText.Text,
+ ::canvas::tools::numeric_cast<USHORT>(maText.StartPosition),
+ ::canvas::tools::numeric_cast<USHORT>(maText.Length),
+ ::canvas::tools::numeric_cast<USHORT>(maText.StartPosition),
+ aMetricVector))
+ {
+ aBoundingBoxes.realloc(aMetricVector.size());
+ sal_Int32 nIndex (0);
+ for (MetricVector::const_iterator
+ iMetric(aMetricVector.begin()),
+ iEnd(aMetricVector.end());
+ iMetric!=iEnd;
+ ++iMetric)
+ {
+ aBoundingBoxes[nIndex++] = geometry::RealRectangle2D(
+ iMetric->getX(),
+ iMetric->getY(),
+ iMetric->getX() + iMetric->getWidth(),
+ iMetric->getY() + iMetric->getHeight());
+ }
+ }
+ return aBoundingBoxes;
}
uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryMeasures( ) throw (uno::RuntimeException)
@@ -171,7 +261,7 @@ namespace vclcanvas
setupLayoutMode( aVDev, mnTextDirection );
- const sal_Int32 nAboveBaseline( -aMetric.GetIntLeading() - aMetric.GetAscent() );
+ const sal_Int32 nAboveBaseline( /*-aMetric.GetIntLeading()*/ - aMetric.GetAscent() );
const sal_Int32 nBelowBaseline( aMetric.GetDescent() );
if( maLogicalAdvancements.getLength() )