summaryrefslogtreecommitdiff
path: root/canvas
diff options
context:
space:
mode:
Diffstat (limited to 'canvas')
-rw-r--r--canvas/inc/canvas/base/graphicdevicebase.hxx82
-rwxr-xr-x[-rw-r--r--]canvas/inc/canvas/canvastools.hxx35
-rw-r--r--canvas/inc/canvas/parametricpolypolygon.hxx40
-rw-r--r--canvas/prj/build.lst1
-rw-r--r--canvas/source/cairo/cairo_canvas.hxx3
-rw-r--r--canvas/source/cairo/cairo_canvashelper.cxx309
-rw-r--r--canvas/source/cairo/cairo_spritecanvas.hxx3
-rw-r--r--canvas/source/cairo/makefile.mk4
-rw-r--r--canvas/source/directx/dx_canvas.hxx5
-rwxr-xr-xcanvas/source/directx/dx_canvashelper_texturefill.cxx446
-rwxr-xr-xcanvas/source/directx/dx_impltools.cxx2
-rwxr-xr-xcanvas/source/directx/dx_spritecanvas.hxx17
-rw-r--r--canvas/source/java/BackBuffer.java112
-rw-r--r--canvas/source/java/BezierPolyPolygon.java151
-rw-r--r--canvas/source/java/BitmapCanvas.java136
-rw-r--r--canvas/source/java/BufferedGraphics2D.java600
-rw-r--r--canvas/source/java/CanvasBase.java341
-rw-r--r--canvas/source/java/CanvasBitmap.java252
-rw-r--r--canvas/source/java/CanvasClonedSprite.java185
-rw-r--r--canvas/source/java/CanvasCustomSprite.java204
-rw-r--r--canvas/source/java/CanvasFont.java116
-rw-r--r--canvas/source/java/CanvasGraphicDevice.java222
-rw-r--r--canvas/source/java/CanvasSprite.java308
-rw-r--r--canvas/source/java/CanvasTest_perftest.java676
-rw-r--r--canvas/source/java/CanvasUtils.java627
-rw-r--r--canvas/source/java/JavaCanvas.java675
-rw-r--r--canvas/source/java/LinePolyPolygon.java192
-rw-r--r--canvas/source/java/SpriteBase.java34
-rw-r--r--canvas/source/java/SpriteRep.java175
-rw-r--r--canvas/source/java/SpriteRunner.java200
-rw-r--r--canvas/source/java/TextLayout.java205
-rw-r--r--canvas/source/java/aqua/WindowAdapter.java202
-rw-r--r--canvas/source/java/java_Service.java118
-rw-r--r--canvas/source/java/makefile.mk93
-rw-r--r--canvas/source/java/manifest1
-rw-r--r--canvas/source/java/perftest/PerfTest.java314
-rw-r--r--canvas/source/java/perftest/WindowAdapter.java197
-rw-r--r--canvas/source/java/perftest/makefile.mk55
-rw-r--r--canvas/source/java/perftest/manifest1
-rw-r--r--canvas/source/java/win/WindowAdapter.java199
-rw-r--r--canvas/source/java/x11/WindowAdapter.java197
-rw-r--r--canvas/source/null/null_spritecanvas.hxx4
-rwxr-xr-x[-rw-r--r--]canvas/source/tools/canvastools.cxx48
-rw-r--r--canvas/source/tools/image.cxx2
-rw-r--r--canvas/source/tools/parametricpolypolygon.cxx114
-rw-r--r--canvas/source/tools/verifyinput.cxx4
-rw-r--r--canvas/source/vcl/canvas.hxx3
-rwxr-xr-x[-rw-r--r--]canvas/source/vcl/canvashelper_texturefill.cxx476
-rw-r--r--canvas/source/vcl/spritecanvas.hxx3
49 files changed, 731 insertions, 7658 deletions
diff --git a/canvas/inc/canvas/base/graphicdevicebase.hxx b/canvas/inc/canvas/base/graphicdevicebase.hxx
index 20de68094028..6750c28e22c8 100644
--- a/canvas/inc/canvas/base/graphicdevicebase.hxx
+++ b/canvas/inc/canvas/base/graphicdevicebase.hxx
@@ -30,11 +30,11 @@
#include <rtl/ref.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/util/XUpdatable.hpp>
#include <com/sun/star/rendering/XGraphicDevice.hpp>
#include <com/sun/star/rendering/XColorSpace.hpp>
-#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp>
#include <canvas/parametricpolypolygon.hxx>
#include <canvas/propertysethelper.hxx>
@@ -47,8 +47,7 @@ namespace canvas
/** Helper template base class for XGraphicDevice implementations.
This base class provides partial implementations of the
- XGraphicDevice-related interface, such as
- XParametricPolyPolygon2DFactory and XColorSpace.
+ XGraphicDevice-related interface, such as XColorSpace.
This template basically interposes itself between the full
interface you implement (i.e. not restricted to XGraphicDevice
@@ -246,7 +245,7 @@ namespace canvas
return maDeviceHelper.createVolatileAlphaBitmap( this, size );
}
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2DFactory > SAL_CALL getParametricPolyPolygonFactory( ) throw (::com::sun::star::uno::RuntimeException)
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > SAL_CALL getParametricPolyPolygonFactory( ) throw (::com::sun::star::uno::RuntimeException)
{
return this;
}
@@ -265,79 +264,26 @@ namespace canvas
return maDeviceHelper.enterFullScreenMode( bEnter );
}
- // XParametricPolyPolygon2DFactory
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createLinearHorizontalGradient( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors, const ::com::sun::star::uno::Sequence< double >& stops ) throw (::com::sun::star::lang::IllegalArgumentException,
- ::com::sun::star::uno::RuntimeException)
+ // XMultiServiceFactory
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( const ::rtl::OUString& aServiceSpecifier ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
{
return ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D >(
- ParametricPolyPolygon::createLinearHorizontalGradient( this,
- colors,
- stops ) );
+ ParametricPolyPolygon::create(this,
+ aServiceSpecifier,
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >()));
}
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createAxialHorizontalGradient( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors, const ::com::sun::star::uno::Sequence< double >& stops ) throw (::com::sun::star::lang::IllegalArgumentException,
- ::com::sun::star::uno::RuntimeException)
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::rtl::OUString& aServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
{
return ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D >(
- ParametricPolyPolygon::createAxialHorizontalGradient( this,
- colors,
- stops ) );
+ ParametricPolyPolygon::create(this,
+ aServiceSpecifier,
+ Arguments));
}
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createEllipticalGradient( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors, const ::com::sun::star::uno::Sequence< double >& stops, const ::com::sun::star::geometry::RealRectangle2D& boundRect ) throw (::com::sun::star::lang::IllegalArgumentException,
- ::com::sun::star::uno::RuntimeException)
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServiceNames( ) throw (::com::sun::star::uno::RuntimeException)
{
- return ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D >(
- ParametricPolyPolygon::createEllipticalGradient( this,
- colors,
- stops,
- boundRect ) );
- }
-
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createRectangularGradient( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors, const ::com::sun::star::uno::Sequence< double >& stops, const ::com::sun::star::geometry::RealRectangle2D& boundRect ) throw (::com::sun::star::lang::IllegalArgumentException,
- ::com::sun::star::uno::RuntimeException)
- {
- return ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D >(
- ParametricPolyPolygon::createRectangularGradient( this,
- colors,
- stops,
- boundRect ) );
- }
-
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createVerticalLinesHatch( const ::com::sun::star::uno::Sequence< double >& /*leftColor*/,
- const ::com::sun::star::uno::Sequence< double >& /*rightColor*/ ) throw (::com::sun::star::lang::IllegalArgumentException,
- ::com::sun::star::uno::RuntimeException)
- {
- // TODO(F1): hatch factory NYI
- return ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XParametricPolyPolygon2D >();
- }
-
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createOrthogonalLinesHatch( const ::com::sun::star::uno::Sequence< double >& /*leftTopColor*/,
- const ::com::sun::star::uno::Sequence< double >& /*rightBottomColor*/ ) throw (::com::sun::star::lang::IllegalArgumentException,
- ::com::sun::star::uno::RuntimeException)
- {
- // TODO(F1): hatch factory NYI
- return ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XParametricPolyPolygon2D >();
- }
-
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createThreeCrossingLinesHatch( const ::com::sun::star::uno::Sequence< double >& /*startColor*/,
- const ::com::sun::star::uno::Sequence< double >& /*endColor*/ ) throw (::com::sun::star::lang::IllegalArgumentException,
- ::com::sun::star::uno::RuntimeException)
- {
- // TODO(F1): hatch factory NYI
- return ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XParametricPolyPolygon2D >();
- }
-
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createFourCrossingLinesHatch( const ::com::sun::star::uno::Sequence< double >& /*startColor*/,
- const ::com::sun::star::uno::Sequence< double >& /*endColor*/ ) throw (::com::sun::star::lang::IllegalArgumentException,
- ::com::sun::star::uno::RuntimeException)
- {
- // TODO(F1): hatch factory NYI
- return ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XParametricPolyPolygon2D >();
+ return ParametricPolyPolygon::getAvailableServiceNames();
}
diff --git a/canvas/inc/canvas/canvastools.hxx b/canvas/inc/canvas/canvastools.hxx
index de4785346909..6c9fdfee484a 100644..100755
--- a/canvas/inc/canvas/canvastools.hxx
+++ b/canvas/inc/canvas/canvastools.hxx
@@ -66,6 +66,7 @@ namespace com { namespace sun { namespace star { namespace rendering
struct ViewState;
struct IntegerBitmapLayout;
class XCanvas;
+ struct Texture;
class XIntegerBitmapColorSpace;
class XPolyPolygon2D;
@@ -414,28 +415,6 @@ namespace canvas
*/
::basegfx::B2IRange spritePixelAreaFromB2DRange( const ::basegfx::B2DRange& rRange );
- /** This method clamps the given value to the specified range
-
- @param val
- The value to clamp
-
- @param minVal
- The minimal value val is allowed to attain
-
- @param maxVal
- The maximal value val is allowed to attain
-
- @return the clamped value
- */
- template< typename T > T clamp( T val,
- T minVal,
- T maxVal )
- {
- return ::std::max( minVal,
- ::std::min( maxVal,
- val ) );
- }
-
/** Retrieve various internal properties of the actual canvas implementation.
This method retrieves a bunch of internal, implementation-
@@ -518,6 +497,18 @@ namespace canvas
*/
::basegfx::B2DPolyPolygon getBoundMarksPolyPolygon( const ::basegfx::B2DRange& rRange );
+ /** Calculate number of gradient "strips" to generate (takes
+ into account device resolution)
+
+ @param nColorSteps
+ Maximal integer difference between all color stops, needed
+ for smooth gradient color differences
+ */
+ int calcGradientStepCount( ::basegfx::B2DHomMatrix& rTotalTransform,
+ const ::com::sun::star::rendering::ViewState& viewState,
+ const ::com::sun::star::rendering::RenderState& renderState,
+ const ::com::sun::star::rendering::Texture& texture,
+ int nColorSteps );
/** A very simplistic map for ASCII strings and arbitrary value
types.
diff --git a/canvas/inc/canvas/parametricpolypolygon.hxx b/canvas/inc/canvas/parametricpolypolygon.hxx
index 4bd7e14b0229..aac98a67a713 100644
--- a/canvas/inc/canvas/parametricpolypolygon.hxx
+++ b/canvas/inc/canvas/parametricpolypolygon.hxx
@@ -30,7 +30,7 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/rendering/XGraphicDevice.hpp>
-#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp>
+#include <com/sun/star/rendering/XParametricPolyPolygon2D.hpp>
#include <cppuhelper/compbase2.hxx>
#include <comphelper/broadcasthelper.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
@@ -59,7 +59,6 @@ namespace canvas
enum GradientType
{
GRADIENT_LINEAR,
- GRADIENT_AXIAL,
GRADIENT_ELLIPTICAL,
GRADIENT_RECTANGULAR
};
@@ -100,24 +99,11 @@ namespace canvas
const GradientType meType;
};
- static ParametricPolyPolygon* createLinearHorizontalGradient( const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XGraphicDevice >& rDevice,
- const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors,
- const ::com::sun::star::uno::Sequence< double >& stops );
- static ParametricPolyPolygon* createAxialHorizontalGradient( const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XGraphicDevice >& rDevice,
- const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors,
- const ::com::sun::star::uno::Sequence< double >& stops );
- static ParametricPolyPolygon* createEllipticalGradient( const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XGraphicDevice >& rDevice,
- const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors,
- const ::com::sun::star::uno::Sequence< double >& stops,
- const ::com::sun::star::geometry::RealRectangle2D& boundRect );
- static ParametricPolyPolygon* createRectangularGradient( const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XGraphicDevice >& rDevice,
- const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors,
- const ::com::sun::star::uno::Sequence< double >& stops,
- const ::com::sun::star::geometry::RealRectangle2D& boundRect );
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getAvailableServiceNames();
+ static ParametricPolyPolygon* create(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice,
+ const ::rtl::OUString& rServiceName,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rArgs );
/// Dispose all internal references
virtual void SAL_CALL disposing();
@@ -140,6 +126,20 @@ namespace canvas
~ParametricPolyPolygon(); // we're a ref-counted UNO class. _We_ destroy ourselves.
private:
+ static ParametricPolyPolygon* createLinearHorizontalGradient( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::rendering::XGraphicDevice >& rDevice,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors,
+ const ::com::sun::star::uno::Sequence< double >& stops );
+ static ParametricPolyPolygon* createEllipticalGradient( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::rendering::XGraphicDevice >& rDevice,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors,
+ const ::com::sun::star::uno::Sequence< double >& stops,
+ double fAspect );
+ static ParametricPolyPolygon* createRectangularGradient( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::rendering::XGraphicDevice >& rDevice,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors,
+ const ::com::sun::star::uno::Sequence< double >& stops,
+ double fAspect );
/// Private, because objects can only be created from the static factories
ParametricPolyPolygon( const ::com::sun::star::uno::Reference<
diff --git a/canvas/prj/build.lst b/canvas/prj/build.lst
index 28e8524a9b38..cacbdb5bb894 100644
--- a/canvas/prj/build.lst
+++ b/canvas/prj/build.lst
@@ -7,5 +7,4 @@ cv canvas\source\simplecanvas nmake - all cv_simplecanvas cv_tools cv_inc
cv canvas\source\cairo nmake - all cv_cairo cv_tools cv_inc NULL
cv canvas\source\directx nmake - w cv_directx cv_tools cv_inc NULL
cv canvas\source\null nmake - all cv_null cv_tools cv_inc NULL
-cv canvas\source\java nmake - all cv_java cv_inc NULL
cv canvas\source\factory nmake - all cv_factory cv_inc NULL
diff --git a/canvas/source/cairo/cairo_canvas.hxx b/canvas/source/cairo/cairo_canvas.hxx
index 26e2904cf71f..bbcb89c54c7d 100644
--- a/canvas/source/cairo/cairo_canvas.hxx
+++ b/canvas/source/cairo/cairo_canvas.hxx
@@ -41,7 +41,6 @@
#include <com/sun/star/rendering/XIntegerBitmap.hpp>
#include <com/sun/star/rendering/XGraphicDevice.hpp>
#include <com/sun/star/rendering/XBufferController.hpp>
-#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp>
#include <cppuhelper/compbase7.hxx>
#include <comphelper/uno3.hxx>
@@ -65,7 +64,7 @@ namespace cairocanvas
typedef ::cppu::WeakComponentImplHelper7< ::com::sun::star::rendering::XBitmapCanvas,
::com::sun::star::rendering::XIntegerBitmap,
::com::sun::star::rendering::XGraphicDevice,
- ::com::sun::star::rendering::XParametricPolyPolygon2DFactory,
+ ::com::sun::star::lang::XMultiServiceFactory,
::com::sun::star::util::XUpdatable,
::com::sun::star::beans::XPropertySet,
::com::sun::star::lang::XServiceName > GraphicDeviceBase_Base;
diff --git a/canvas/source/cairo/cairo_canvashelper.cxx b/canvas/source/cairo/cairo_canvashelper.cxx
index 17d187d46b27..eec6a09fb215 100644
--- a/canvas/source/cairo/cairo_canvashelper.cxx
+++ b/canvas/source/cairo/cairo_canvashelper.cxx
@@ -53,6 +53,8 @@
#include <basegfx/polygon/b2dpolypolygon.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx>
#include <basegfx/tools/canvastools.hxx>
+#include <basegfx/tools/keystoplerp.hxx>
+#include <basegfx/tools/lerp.hxx>
#include <comphelper/sequence.hxx>
#include <cppuhelper/compbase1.hxx>
@@ -70,6 +72,7 @@
#include "cairo_canvashelper.hxx"
#include "cairo_canvasbitmap.hxx"
+#include <boost/tuple/tuple.hpp>
#include <algorithm>
using namespace ::cairo;
@@ -119,9 +122,29 @@ namespace cairocanvas
mpCairo = pSurface->getCairo();
}
+ static void setColor( Cairo* pCairo,
+ const uno::Sequence<double>& rColor )
+ {
+ if( rColor.getLength() > 3 )
+ {
+ const double alpha = rColor[3];
+
+ cairo_set_source_rgba( pCairo,
+ alpha*rColor[0],
+ alpha*rColor[1],
+ alpha*rColor[2],
+ alpha );
+ }
+ else if( rColor.getLength() == 3 )
+ cairo_set_source_rgb( pCairo,
+ rColor[0],
+ rColor[1],
+ rColor[2] );
+ }
+
void CanvasHelper::useStates( const rendering::ViewState& viewState,
const rendering::RenderState& renderState,
- bool setColor )
+ bool bSetColor )
{
Matrix aViewMatrix;
Matrix aRenderMatrix;
@@ -155,19 +178,8 @@ namespace cairocanvas
OSL_TRACE ("render clip END");
}
- if( setColor ) {
- if( renderState.DeviceColor.getLength() > 3 )
- cairo_set_source_rgba( mpCairo.get(),
- renderState.DeviceColor [0],
- renderState.DeviceColor [1],
- renderState.DeviceColor [2],
- renderState.DeviceColor [3] );
- else if (renderState.DeviceColor.getLength() == 3)
- cairo_set_source_rgb( mpCairo.get(),
- renderState.DeviceColor [0],
- renderState.DeviceColor [1],
- renderState.DeviceColor [2] );
- }
+ if( bSetColor )
+ setColor(mpCairo.get(),renderState.DeviceColor);
cairo_operator_t compositingMode( CAIRO_OPERATOR_OVER );
switch( renderState.CompositeOperation )
@@ -662,11 +674,33 @@ namespace cairocanvas
double alpha = rColor[3];
// cairo expects premultiplied alpha
cairo_pattern_add_color_stop_rgba( pPattern, stop, rColor[0]*alpha, rColor[1]*alpha, rColor[2]*alpha, alpha );
- //cairo_pattern_add_color_stop_rgba( pPattern, stop, rColor[0], rColor[1], rColor[2], alpha );
}
}
}
+ static uno::Sequence<double> lerp(const uno::Sequence<double>& rLeft, const uno::Sequence<double>& rRight, double fAlpha)
+ {
+ if( rLeft.getLength() == 3 )
+ {
+ uno::Sequence<double> aRes(3);
+ aRes[0] = basegfx::tools::lerp(rLeft[0],rRight[0],fAlpha);
+ aRes[1] = basegfx::tools::lerp(rLeft[1],rRight[1],fAlpha);
+ aRes[2] = basegfx::tools::lerp(rLeft[2],rRight[2],fAlpha);
+ return aRes;
+ }
+ else if( rLeft.getLength() == 4 )
+ {
+ uno::Sequence<double> aRes(4);
+ aRes[0] = basegfx::tools::lerp(rLeft[0],rRight[0],fAlpha);
+ aRes[1] = basegfx::tools::lerp(rLeft[1],rRight[1],fAlpha);
+ aRes[2] = basegfx::tools::lerp(rLeft[2],rRight[2],fAlpha);
+ aRes[3] = basegfx::tools::lerp(rLeft[3],rRight[3],fAlpha);
+ return aRes;
+ }
+
+ return uno::Sequence<double>();
+ }
+
static Pattern* patternFromParametricPolyPolygon( ::canvas::ParametricPolyPolygon& rPolygon )
{
Pattern* pPattern = NULL;
@@ -675,7 +709,6 @@ namespace cairocanvas
// undef macros from vclenum.hxx which conflicts with GradientType enum values
#undef GRADIENT_LINEAR
-#undef GRADIENT_AXIAL
#undef GRADIENT_ELLIPTICAL
switch( aValues.meType ) {
@@ -688,26 +721,17 @@ namespace cairocanvas
addColorStops( pPattern, aValues.maColors, aValues.maStops );
break;
- // FIXME: NYI
- case ::canvas::ParametricPolyPolygon::GRADIENT_RECTANGULAR:
- case ::canvas::ParametricPolyPolygon::GRADIENT_AXIAL:
- x0 = 0;
- y0 = 0;
- x1 = 1;
- y1 = 0;
- pPattern = cairo_pattern_create_linear( x0, y0, x1, y1 );
- addColorStops( pPattern, aValues.maColors, aValues.maStops );
- break;
-
case ::canvas::ParametricPolyPolygon::GRADIENT_ELLIPTICAL:
- cx = 0.5;
- cy = 0.5;
+ cx = 0;
+ cy = 0;
r0 = 0;
- r1 = 0.5;
+ r1 = 1;
- pPattern = cairo_pattern_create_radial( cx, cy, r0, cx, cy, r1 );
+ pPattern = cairo_pattern_create_radial( cx, cy, r0, cy, cy, r1 );
addColorStops( pPattern, aValues.maColors, aValues.maStops, true );
break;
+ default:
+ break;
}
return pPattern;
@@ -716,7 +740,8 @@ namespace cairocanvas
static void doOperation( Operation aOperation,
Cairo* pCairo,
const uno::Sequence< rendering::Texture >* pTextures,
- const SurfaceProviderRef& pDevice )
+ const SurfaceProviderRef& pDevice,
+ const basegfx::B2DRange& rBounds )
{
switch( aOperation ) {
case Fill:
@@ -751,7 +776,20 @@ namespace cairocanvas
if( aTexture.RepeatModeX == rendering::TexturingMode::REPEAT &&
aTexture.RepeatModeY == rendering::TexturingMode::REPEAT )
+ {
cairo_pattern_set_extend( pPattern, CAIRO_EXTEND_REPEAT );
+ }
+ else if ( aTexture.RepeatModeX == rendering::TexturingMode::NONE &&
+ aTexture.RepeatModeY == rendering::TexturingMode::NONE )
+ {
+ cairo_pattern_set_extend( pPattern, CAIRO_EXTEND_NONE );
+ }
+ else if ( aTexture.RepeatModeX == rendering::TexturingMode::CLAMP &&
+ aTexture.RepeatModeY == rendering::TexturingMode::CLAMP )
+ {
+ cairo_pattern_set_extend( pPattern, CAIRO_EXTEND_PAD );
+ }
+
aScaledTextureMatrix.x0 = basegfx::fround( aScaledTextureMatrix.x0 );
aScaledTextureMatrix.y0 = basegfx::fround( aScaledTextureMatrix.y0 );
cairo_pattern_set_matrix( pPattern, &aScaledTextureMatrix );
@@ -787,19 +825,70 @@ namespace cairocanvas
cairo_matrix_init( &aTextureMatrix,
aTransform.m00, aTransform.m10, aTransform.m01,
aTransform.m11, aTransform.m02, aTransform.m12);
- Pattern* pPattern = patternFromParametricPolyPolygon( *pPolyImpl );
+ if( pPolyImpl->getValues().meType == canvas::ParametricPolyPolygon::GRADIENT_RECTANGULAR )
+ {
+ // no general path gradient yet in cairo; emulate then
+ cairo_save( pCairo );
+ cairo_clip( pCairo );
+
+ // fill bound rect with start color
+ cairo_rectangle( pCairo, rBounds.getMinX(), rBounds.getMinY(),
+ rBounds.getWidth(), rBounds.getHeight() );
+ setColor(pCairo,pPolyImpl->getValues().maColors[0]);
+ cairo_fill(pCairo);
+
+ cairo_transform( pCairo, &aTextureMatrix );
+
+ // longest line in gradient bound rect
+ const unsigned int nGradientSize(
+ static_cast<unsigned int>(
+ ::basegfx::B2DVector(rBounds.getMinimum() - rBounds.getMaximum()).getLength() + 1.0 ) );
+
+ // typical number for pixel of the same color (strip size)
+ const unsigned int nStripSize( nGradientSize < 50 ? 2 : 4 );
+
+ // use at least three steps, and at utmost the number of color
+ // steps
+ const unsigned int nStepCount(
+ ::std::max(
+ 3U,
+ ::std::min(
+ nGradientSize / nStripSize,
+ 128U )) + 1 );
+
+ const uno::Sequence<double>* pColors=&pPolyImpl->getValues().maColors[0];
+ basegfx::tools::KeyStopLerp aLerper(pPolyImpl->getValues().maStops);
+ for( unsigned int i=1; i<nStepCount; ++i )
+ {
+ const double fT( i/double(nStepCount) );
- if( pPattern ) {
- OSL_TRACE( "filling with pattern" );
+ std::ptrdiff_t nIndex;
+ double fAlpha;
+ boost::tuples::tie(nIndex,fAlpha)=aLerper.lerp(fT);
- cairo_save( pCairo );
+ setColor(pCairo, lerp(pColors[nIndex], pColors[nIndex+1], fAlpha));
+ cairo_rectangle( pCairo, -1+fT, -1+fT, 2-2*fT, 2-2*fT );
+ cairo_fill(pCairo);
+ }
- cairo_transform( pCairo, &aTextureMatrix );
- cairo_set_source( pCairo, pPattern );
- cairo_fill( pCairo );
cairo_restore( pCairo );
+ }
+ else
+ {
+ Pattern* pPattern = patternFromParametricPolyPolygon( *pPolyImpl );
+
+ if( pPattern ) {
+ OSL_TRACE( "filling with pattern" );
- cairo_pattern_destroy( pPattern );
+ cairo_save( pCairo );
+
+ cairo_transform( pCairo, &aTextureMatrix );
+ cairo_set_source( pCairo, pPattern );
+ cairo_fill( pCairo );
+ cairo_restore( pCairo );
+
+ cairo_pattern_destroy( pPattern );
+ }
}
}
}
@@ -932,7 +1021,7 @@ namespace cairocanvas
if( aOperation == Fill && pTextures ) {
cairo_set_matrix( pCairo, &aOrigMatrix );
- doOperation( aOperation, pCairo, pTextures, pDevice );
+ doOperation( aOperation, pCairo, pTextures, pDevice, aPolyPolygon.getB2DRange() );
cairo_set_matrix( pCairo, &aIdentityMatrix );
}
} else {
@@ -945,7 +1034,7 @@ namespace cairocanvas
}
}
if( bOpToDo && ( aOperation != Fill || !pTextures ) )
- doOperation( aOperation, pCairo, pTextures, pDevice );
+ doOperation( aOperation, pCairo, pTextures, pDevice, aPolyPolygon.getB2DRange() );
cairo_set_matrix( pCairo, &aOrigMatrix );
@@ -980,11 +1069,11 @@ namespace cairocanvas
aEdge.append(aCandidate.getB2DPoint(0));
aEdge.append(basegfx::B2DPoint(0.0, 0.0));
- for(sal_uInt32 a(0); a < nEdgeCount; a++)
+ for(sal_uInt32 b(0); b < nEdgeCount; b++)
{
- const sal_uInt32 nNextIndex((a + 1) % nPointCount);
+ const sal_uInt32 nNextIndex((b + 1) % nPointCount);
aEdge.setB2DPoint(1, aCandidate.getB2DPoint(nNextIndex));
- aEdge.setNextControlPoint(0, aCandidate.getNextControlPoint(a));
+ aEdge.setNextControlPoint(0, aCandidate.getNextControlPoint(b));
aEdge.setPrevControlPoint(1, aCandidate.getPrevControlPoint(nNextIndex));
doPolyPolygonImplementation( basegfx::B2DPolyPolygon(aEdge),
@@ -1209,12 +1298,12 @@ namespace cairocanvas
const rendering::ViewState& viewState,
const rendering::RenderState& renderState,
const geometry::IntegerSize2D& rSize,
- bool /*bModulateColors*/,
+ bool bModulateColors,
bool bHasAlpha )
{
SurfaceSharedPtr pSurface=pInputSurface;
uno::Reference< rendering::XCachedPrimitive > rv = uno::Reference< rendering::XCachedPrimitive >(NULL);
- geometry::IntegerSize2D aBitmapSize = rSize;
+ geometry::IntegerSize2D aBitmapSize = rSize;
if( mpCairo ) {
cairo_save( mpCairo.get() );
@@ -1236,38 +1325,38 @@ namespace cairocanvas
::rtl::math::approxEqual( aMatrix.y0, 0 ) &&
basegfx::fround( rSize.Width * aMatrix.xx ) > 8 &&
basegfx::fround( rSize.Height* aMatrix.yy ) > 8 )
- {
- double dWidth, dHeight;
-
- dWidth = basegfx::fround( rSize.Width * aMatrix.xx );
- dHeight = basegfx::fround( rSize.Height* aMatrix.yy );
- aBitmapSize.Width = static_cast<sal_Int32>( dWidth );
- aBitmapSize.Height = static_cast<sal_Int32>( dHeight );
-
- SurfaceSharedPtr pScaledSurface = mpSurfaceProvider->createSurface(
- ::basegfx::B2ISize( aBitmapSize.Width, aBitmapSize.Height ),
- bHasAlpha ? CAIRO_CONTENT_COLOR_ALPHA : CAIRO_CONTENT_COLOR );
- CairoSharedPtr pCairo = pScaledSurface->getCairo();
-
- cairo_set_operator( pCairo.get(), CAIRO_OPERATOR_SOURCE );
- // add 0.5px to size to avoid rounding errors in cairo, leading sometimes to random data on the image right/bottom borders
- cairo_scale( pCairo.get(), (dWidth+0.5)/rSize.Width, (dHeight+0.5)/rSize.Height );
- cairo_set_source_surface( pCairo.get(), pSurface->getCairoSurface().get(), 0, 0 );
- cairo_paint( pCairo.get() );
-
- pSurface = pScaledSurface;
-
- aMatrix.xx = aMatrix.yy = 1;
- cairo_set_matrix( mpCairo.get(), &aMatrix );
-
- rv = uno::Reference< rendering::XCachedPrimitive >(
- new CachedBitmap( pSurface, viewState, renderState,
- // cast away const, need to
- // change refcount (as this is
- // ~invisible to client code,
- // still logically const)
- const_cast< rendering::XCanvas* >(pCanvas)) );
- }
+ {
+ double dWidth, dHeight;
+
+ dWidth = basegfx::fround( rSize.Width * aMatrix.xx );
+ dHeight = basegfx::fround( rSize.Height* aMatrix.yy );
+ aBitmapSize.Width = static_cast<sal_Int32>( dWidth );
+ aBitmapSize.Height = static_cast<sal_Int32>( dHeight );
+
+ SurfaceSharedPtr pScaledSurface = mpSurfaceProvider->createSurface(
+ ::basegfx::B2ISize( aBitmapSize.Width, aBitmapSize.Height ),
+ bHasAlpha ? CAIRO_CONTENT_COLOR_ALPHA : CAIRO_CONTENT_COLOR );
+ CairoSharedPtr pCairo = pScaledSurface->getCairo();
+
+ cairo_set_operator( pCairo.get(), CAIRO_OPERATOR_SOURCE );
+ // add 0.5px to size to avoid rounding errors in cairo, leading sometimes to random data on the image right/bottom borders
+ cairo_scale( pCairo.get(), (dWidth+0.5)/rSize.Width, (dHeight+0.5)/rSize.Height );
+ cairo_set_source_surface( pCairo.get(), pSurface->getCairoSurface().get(), 0, 0 );
+ cairo_paint( pCairo.get() );
+
+ pSurface = pScaledSurface;
+
+ aMatrix.xx = aMatrix.yy = 1;
+ cairo_set_matrix( mpCairo.get(), &aMatrix );
+
+ rv = uno::Reference< rendering::XCachedPrimitive >(
+ new CachedBitmap( pSurface, viewState, renderState,
+ // cast away const, need to
+ // change refcount (as this is
+ // ~invisible to client code,
+ // still logically const)
+ const_cast< rendering::XCanvas* >(pCanvas)) );
+ }
if( !bHasAlpha && mbHaveAlpha )
{
@@ -1308,7 +1397,11 @@ namespace cairocanvas
cairo_set_operator( mpCairo.get(), CAIRO_OPERATOR_SOURCE );
cairo_rectangle( mpCairo.get(), 0, 0, aBitmapSize.Width, aBitmapSize.Height );
cairo_clip( mpCairo.get() );
- cairo_paint( mpCairo.get() );
+
+ if( bModulateColors )
+ cairo_paint_with_alpha( mpCairo.get(), renderState.DeviceColor[3] );
+ else
+ cairo_paint( mpCairo.get() );
cairo_restore( mpCairo.get() );
} else
OSL_TRACE ("CanvasHelper called after it was disposed");
@@ -1347,15 +1440,35 @@ namespace cairocanvas
return rv;
}
- uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawBitmapModulated( const rendering::XCanvas* ,
- const uno::Reference< rendering::XBitmap >& /*xBitmap*/,
- const rendering::ViewState& /*viewState*/,
- const rendering::RenderState& /*renderState*/ )
+ uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawBitmapModulated( const rendering::XCanvas* pCanvas,
+ const uno::Reference< rendering::XBitmap >& xBitmap,
+ const rendering::ViewState& viewState,
+ const rendering::RenderState& renderState )
{
- // TODO(F3): Implement modulated bitmap!
+#ifdef CAIRO_CANVAS_PERF_TRACE
+ struct timespec aTimer;
+ mxDevice->startPerfTrace( &aTimer );
+#endif
- // TODO(P1): Provide caching here.
- return uno::Reference< rendering::XCachedPrimitive >(NULL);
+ uno::Reference< rendering::XCachedPrimitive > rv;
+ unsigned char* data = NULL;
+ bool bHasAlpha = false;
+ SurfaceSharedPtr pSurface = surfaceFromXBitmap( xBitmap, mpSurfaceProvider, data, bHasAlpha );
+ geometry::IntegerSize2D aSize = xBitmap->getSize();
+
+ if( pSurface ) {
+ rv = implDrawBitmapSurface( pCanvas, pSurface, viewState, renderState, aSize, true, bHasAlpha );
+
+ if( data )
+ free( data );
+ } else
+ rv = uno::Reference< rendering::XCachedPrimitive >(NULL);
+
+#ifdef CAIRO_CANVAS_PERF_TRACE
+ mxDevice->stopPerfTrace( &aTimer, "drawBitmap" );
+#endif
+
+ return rv;
}
uno::Reference< rendering::XGraphicDevice > CanvasHelper::getDevice()
@@ -1678,12 +1791,12 @@ namespace cairocanvas
rendering::RGBColor* pOut( aRes.getArray() );
for( sal_Size i=0; i<nLen; i+=4 )
{
- const sal_Int8 nAlpha(pIn[3]);
- if( nAlpha )
+ const double fAlpha((sal_uInt8)pIn[3]);
+ if( fAlpha )
*pOut++ = rendering::RGBColor(
- vcl::unotools::toDoubleColor(pIn[2]/nAlpha),
- vcl::unotools::toDoubleColor(pIn[1]/nAlpha),
- vcl::unotools::toDoubleColor(pIn[0]/nAlpha));
+ pIn[2]/fAlpha,
+ pIn[1]/fAlpha,
+ pIn[0]/fAlpha);
else
*pOut++ = rendering::RGBColor(0,0,0);
pIn += 4;
@@ -1703,13 +1816,13 @@ namespace cairocanvas
rendering::ARGBColor* pOut( aRes.getArray() );
for( sal_Size i=0; i<nLen; i+=4 )
{
- const sal_Int8 nAlpha(pIn[3]);
- if( nAlpha )
+ const double fAlpha((sal_uInt8)pIn[3]);
+ if( fAlpha )
*pOut++ = rendering::ARGBColor(
- vcl::unotools::toDoubleColor(nAlpha),
- vcl::unotools::toDoubleColor(pIn[2]/nAlpha),
- vcl::unotools::toDoubleColor(pIn[1]/nAlpha),
- vcl::unotools::toDoubleColor(pIn[0]/nAlpha));
+ fAlpha/255.0,
+ pIn[2]/fAlpha,
+ pIn[1]/fAlpha,
+ pIn[0]/fAlpha);
else
*pOut++ = rendering::ARGBColor(0,0,0,0);
pIn += 4;
diff --git a/canvas/source/cairo/cairo_spritecanvas.hxx b/canvas/source/cairo/cairo_spritecanvas.hxx
index 0c942cac1ed3..fcc0ae76839b 100644
--- a/canvas/source/cairo/cairo_spritecanvas.hxx
+++ b/canvas/source/cairo/cairo_spritecanvas.hxx
@@ -39,7 +39,6 @@
#include <com/sun/star/rendering/XIntegerBitmap.hpp>
#include <com/sun/star/rendering/XGraphicDevice.hpp>
#include <com/sun/star/rendering/XBufferController.hpp>
-#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp>
#include <cppuhelper/compbase9.hxx>
#include <comphelper/uno3.hxx>
@@ -63,7 +62,7 @@ namespace cairocanvas
typedef ::cppu::WeakComponentImplHelper9< ::com::sun::star::rendering::XSpriteCanvas,
::com::sun::star::rendering::XIntegerBitmap,
::com::sun::star::rendering::XGraphicDevice,
- ::com::sun::star::rendering::XParametricPolyPolygon2DFactory,
+ ::com::sun::star::lang::XMultiServiceFactory,
::com::sun::star::rendering::XBufferController,
::com::sun::star::awt::XWindowListener,
::com::sun::star::util::XUpdatable,
diff --git a/canvas/source/cairo/makefile.mk b/canvas/source/cairo/makefile.mk
index 2c568a4efdbd..fbce9219fea9 100644
--- a/canvas/source/cairo/makefile.mk
+++ b/canvas/source/cairo/makefile.mk
@@ -87,7 +87,7 @@ SHL1STDLIBS= $(CPPULIB) $(TKLIB) $(SALLIB) $(VCLLIB) $(COMPHELPERLIB) $(CPPUHELP
.IF "$(SYSTEM_CAIRO)" == "YES"
SHL1STDLIBS+= $(CAIRO_LIBS)
.ELSE
-SHL1STDLIBS+= -lcairo
+SHL1STDLIBS+= -lcairo -lpixman-1
.ENDIF
.IF "$(GUIBASE)"=="aqua"
@@ -98,7 +98,7 @@ CFLAGSCXX+=$(OBJCXXFLAGS)
# Xlib
SLOFILES+= $(SLO)$/cairo_xlib_cairo.obj
-SHL1STDLIBS+= -lfontconfig -lX11 -lXrender -lpixman-1 $(FREETYPE_LIBS)
+SHL1STDLIBS+= -lfontconfig -lX11 -lXrender $(FREETYPE_LIBS)
CFLAGS+=$(FREETYPE_CFLAGS)
.ENDIF # "$(GUIBASE)"=="aqua"
diff --git a/canvas/source/directx/dx_canvas.hxx b/canvas/source/directx/dx_canvas.hxx
index aca9873387dc..be15b875c4b6 100644
--- a/canvas/source/directx/dx_canvas.hxx
+++ b/canvas/source/directx/dx_canvas.hxx
@@ -38,7 +38,6 @@
#include <com/sun/star/rendering/XIntegerBitmap.hpp>
#include <com/sun/star/rendering/XGraphicDevice.hpp>
#include <com/sun/star/rendering/XBufferController.hpp>
-#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp>
#include <cppuhelper/compbase7.hxx>
#include <cppuhelper/compbase6.hxx>
@@ -59,7 +58,7 @@ namespace dxcanvas
{
typedef ::cppu::WeakComponentImplHelper6< ::com::sun::star::rendering::XCanvas,
::com::sun::star::rendering::XGraphicDevice,
- ::com::sun::star::rendering::XParametricPolyPolygon2DFactory,
+ ::com::sun::star::lang::XMultiServiceFactory,
::com::sun::star::util::XUpdatable,
::com::sun::star::beans::XPropertySet,
::com::sun::star::lang::XServiceName > GraphicDeviceBase1_Base;
@@ -116,7 +115,7 @@ namespace dxcanvas
typedef ::cppu::WeakComponentImplHelper7< ::com::sun::star::rendering::XBitmapCanvas,
::com::sun::star::rendering::XIntegerBitmap,
::com::sun::star::rendering::XGraphicDevice,
- ::com::sun::star::rendering::XParametricPolyPolygon2DFactory,
+ ::com::sun::star::lang::XMultiServiceFactory,
::com::sun::star::util::XUpdatable,
::com::sun::star::beans::XPropertySet,
::com::sun::star::lang::XServiceName > GraphicDeviceBase2_Base;
diff --git a/canvas/source/directx/dx_canvashelper_texturefill.cxx b/canvas/source/directx/dx_canvashelper_texturefill.cxx
index 8aa21853db1a..60d62dad338a 100755
--- a/canvas/source/directx/dx_canvashelper_texturefill.cxx
+++ b/canvas/source/directx/dx_canvashelper_texturefill.cxx
@@ -38,7 +38,10 @@
#include <basegfx/point/b2dpoint.hxx>
#include <basegfx/range/b2drectangle.hxx>
#include <basegfx/numeric/ftools.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
#include <basegfx/tools/tools.hxx>
+#include <basegfx/tools/lerp.hxx>
+#include <basegfx/tools/keystoplerp.hxx>
#include <basegfx/tools/canvastools.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx>
@@ -49,6 +52,8 @@
#include "dx_impltools.hxx"
#include <boost/scoped_ptr.hpp>
+#include <boost/bind.hpp>
+#include <boost/tuple/tuple.hpp>
using namespace ::com::sun::star;
@@ -59,26 +64,31 @@ namespace dxcanvas
{
typedef ::boost::shared_ptr< Gdiplus::PathGradientBrush > PathGradientBrushSharedPtr;
- bool fillLinearGradient( GraphicsSharedPtr& rGraphics,
- const Gdiplus::Color& rColor1,
- const Gdiplus::Color& rColor2,
- const GraphicsPathSharedPtr& rFillPath,
- const rendering::Texture& texture )
+ bool fillLinearGradient( GraphicsSharedPtr& rGraphics,
+ const ::canvas::ParametricPolyPolygon::Values& /*rValues*/,
+ const std::vector< Gdiplus::Color >& rColors,
+ const std::vector< Gdiplus::REAL >& rStops,
+ const GraphicsPathSharedPtr& rFillPath,
+ const rendering::Texture& texture )
{
- // setup a linear gradient with two colors
- // ---------------------------------------
+ // setup a linear gradient with given colors
+ // -----------------------------------------
Gdiplus::LinearGradientBrush aBrush(
Gdiplus::PointF(0.0f,
0.5f),
Gdiplus::PointF(1.0f,
0.5f),
- rColor1,
- rColor2 );
+ rColors[0],
+ rColors[1] );
+
+ aBrush.SetInterpolationColors(&rColors[0],
+ &rStops[0],
+ rColors.size());
// render background color, as LinearGradientBrush does not
// properly support the WrapModeClamp repeat mode
- Gdiplus::SolidBrush aBackgroundBrush( rColor1 );
+ Gdiplus::SolidBrush aBackgroundBrush( rColors[0] );
rGraphics->FillPath( &aBackgroundBrush, rFillPath.get() );
// TODO(F2): This does not yet support other repeat modes
@@ -152,7 +162,7 @@ namespace dxcanvas
return false;
}
- Gdiplus::SolidBrush aBackgroundBrush2( rColor2 );
+ Gdiplus::SolidBrush aBackgroundBrush2( rColors.back() );
rGraphics->FillPath( &aBackgroundBrush2, &aSolidFillPath );
// generate clip polygon from the extended parallelogram
@@ -188,167 +198,33 @@ namespace dxcanvas
return true;
}
- bool fillAxialGradient( GraphicsSharedPtr& rGraphics,
- const Gdiplus::Color& rColor1,
- const Gdiplus::Color& rColor2,
- const GraphicsPathSharedPtr& rFillPath,
- const rendering::Texture& texture )
+ int numColorSteps( const Gdiplus::Color& rColor1, const Gdiplus::Color& rColor2 )
{
- // setup a linear gradient with three colors
- // -----------------------------------------
-
- Gdiplus::LinearGradientBrush aBrush(
- Gdiplus::PointF(0.0f,
- 0.5f),
- Gdiplus::PointF(1.0f,
- 0.5f),
- rColor1,
- rColor1 );
-
- Gdiplus::Color aColors[] =
- {
- rColor1, // at 0.0
- rColor2, // at 0.5
- rColor1 // at 1.0
- };
-
- Gdiplus::REAL aPositions[] =
- {
- 0.0,
- 0.5,
- 1.0
- };
-
- if( Gdiplus::Ok != aBrush.SetInterpolationColors( aColors,
- aPositions,
- sizeof( aPositions ) / sizeof(Gdiplus::REAL) ) )
- {
- return false;
- }
-
- // render background color, as LinearGradientBrush does not
- // properly support the WrapModeClamp repeat mode
- Gdiplus::SolidBrush aBackgroundBrush( rColor1 );
- rGraphics->FillPath( &aBackgroundBrush, rFillPath.get() );
-
- // TODO(F2): This does not yet support other repeat modes
- // except clamp, and probably also no multi-texturing
-
- // calculate parallelogram of gradient in object space, extend
- // top and bottom of it such that they cover the whole fill
- // path bound area
- ::basegfx::B2DHomMatrix aTextureTransform;
- ::basegfx::unotools::homMatrixFromAffineMatrix( aTextureTransform,
- texture.AffineTransform );
-
- ::basegfx::B2DPoint aLeftTop( 0.0, 0.0 );
- ::basegfx::B2DPoint aLeftBottom( 0.0, 1.0 );
- ::basegfx::B2DPoint aRightTop( 1.0, 0.0 );
- ::basegfx::B2DPoint aRightBottom( 1.0, 1.0 );
-
- aLeftTop *= aTextureTransform;
- aLeftBottom *= aTextureTransform;
- aRightTop *= aTextureTransform;
- aRightBottom*= aTextureTransform;
-
- Gdiplus::RectF aBounds;
- rFillPath->GetBounds( &aBounds, NULL, NULL );
-
- // now, we potentially have to enlarge our gradient area
- // atop and below the transformed [0,1]x[0,1] unit rect,
- // for the gradient to fill the complete bound rect.
- ::basegfx::tools::infiniteLineFromParallelogram( aLeftTop,
- aLeftBottom,
- aRightTop,
- aRightBottom,
- tools::b2dRangeFromGdiPlusRectF( aBounds ) );
-
- // generate clip polygon from the extended parallelogram
- // (exploit the feature that distinct lines in a figure are
- // automatically closed by a straight line)
- Gdiplus::GraphicsPath aClipPath;
- aClipPath.AddLine( static_cast<Gdiplus::REAL>(aLeftTop.getX()),
- static_cast<Gdiplus::REAL>(aLeftTop.getY()),
- static_cast<Gdiplus::REAL>(aRightTop.getX()),
- static_cast<Gdiplus::REAL>(aRightTop.getY()) );
- aClipPath.AddLine( static_cast<Gdiplus::REAL>(aRightBottom.getX()),
- static_cast<Gdiplus::REAL>(aRightBottom.getY()),
- static_cast<Gdiplus::REAL>(aLeftBottom.getX()),
- static_cast<Gdiplus::REAL>(aLeftBottom.getY()) );
- aClipPath.CloseFigure();
-
- // limit output to a _single_ strip of the gradient (have to
- // clip here, since GDI+ wrapmode clamp does not work here)
- if( Gdiplus::Ok != rGraphics->SetClip( rFillPath.get(),
- Gdiplus::CombineModeIntersect ) )
- {
- return false;
- }
- if( Gdiplus::Ok != rGraphics->SetClip( &aClipPath,
- Gdiplus::CombineModeIntersect ) )
- {
- return false;
- }
-
- // now, finally, output the gradient
- Gdiplus::Matrix aMatrix;
- tools::gdiPlusMatrixFromAffineMatrix2D( aMatrix,
- texture.AffineTransform );
- aBrush.SetTransform( &aMatrix );
-
- rGraphics->FillRectangle( &aBrush, aBounds );
-
- return true;
- }
-
- PathGradientBrushSharedPtr createPathGradientBrush( const GraphicsPathSharedPtr& rGradientPath,
- const Gdiplus::Color& rColor1,
- const Gdiplus::Color& rColor2 )
- {
- PathGradientBrushSharedPtr pGradientBrush(
- new Gdiplus::PathGradientBrush( rGradientPath.get() ) );
-
- Gdiplus::Color aColors[] =
- {
- rColor1
- };
-
- INT nCount(1);
-
- pGradientBrush->SetSurroundColors( aColors,
- &nCount );
- pGradientBrush->SetCenterColor( rColor2 );
-
- return pGradientBrush;
+ return ::std::max(
+ labs( rColor1.GetRed() - rColor2.GetRed() ),
+ ::std::max(
+ labs( rColor1.GetGreen() - rColor2.GetGreen() ),
+ labs( rColor1.GetBlue() - rColor2.GetBlue() ) ) );
}
bool fillPolygonalGradient( const ::canvas::ParametricPolyPolygon::Values& rValues,
+ const std::vector< Gdiplus::Color >& rColors,
+ const std::vector< Gdiplus::REAL >& rStops,
GraphicsSharedPtr& rGraphics,
- const Gdiplus::Color& rColor1,
- const Gdiplus::Color& rColor2,
const GraphicsPathSharedPtr& rPath,
+ const rendering::ViewState& viewState,
+ const rendering::RenderState& renderState,
const rendering::Texture& texture )
{
- Gdiplus::Matrix aMatrix;
- tools::gdiPlusMatrixFromAffineMatrix2D( aMatrix,
- texture.AffineTransform );
-
// copy original fill path object, might have to change it
// below
GraphicsPathSharedPtr pFillPath( rPath );
-
- // clone original gradient path object, we need to change it
- // below
- GraphicsPathSharedPtr pGradientPath(
- tools::graphicsPathFromB2DPolygon( rValues.maGradientPoly ) );
-
- ENSURE_OR_RETURN( pGradientPath.get(),
- "ParametricPolyPolygon::fillPolygonalGradient(): Could not clone path" );
+ const ::basegfx::B2DPolygon& rGradientPoly( rValues.maGradientPoly );
PathGradientBrushSharedPtr pGradientBrush;
// fill background uniformly with end color
- Gdiplus::SolidBrush aBackgroundBrush( rColor1 );
+ Gdiplus::SolidBrush aBackgroundBrush( rColors[0] );
rGraphics->FillPath( &aBackgroundBrush, pFillPath.get() );
// scale focus according to aspect ratio: for wider-than-tall
@@ -377,8 +253,6 @@ namespace dxcanvas
return false;
}
- rGraphics->MultiplyTransform( &aMatrix );
-
// disable anti-aliasing, if any
const Gdiplus::SmoothingMode eOldAAMode( rGraphics->GetSmoothingMode() );
rGraphics->SetSmoothingMode( Gdiplus::SmoothingModeHighSpeed );
@@ -388,105 +262,107 @@ namespace dxcanvas
// --------------------------------
// TODO(Q2): Unify step calculations with VCL canvas
- const int nColorSteps(
- ::std::max(
- labs( rColor1.GetRed() - rColor2.GetRed() ),
- ::std::max(
- labs( rColor1.GetGreen() - rColor2.GetGreen() ),
- labs( rColor1.GetBlue() - rColor2.GetBlue() ) ) ) );
-
- Gdiplus::Matrix aWorldTransformMatrix;
- rGraphics->GetTransform( &aWorldTransformMatrix );
-
- Gdiplus::RectF aBounds;
- pGradientPath->GetBounds( &aBounds, &aWorldTransformMatrix, NULL );
-
- // longest line in gradient bound rect
- const int nGradientSize(
- static_cast<int>( hypot( aBounds.Width, aBounds.Height ) + 1.0 ) );
-
- // typical number for pixel of the same color (strip size)
- const int nStripSize( 2 );
-
- // use at least three steps, and at utmost the number of
- // color steps.
- const int nStepCount(
- ::std::max(
- 3,
- ::std::min(
- nGradientSize / nStripSize,
- nColorSteps ) ) + 1 );
-
-
- Gdiplus::SolidBrush aFillBrush( rColor1 );
- Gdiplus::Matrix aGDIScaleMatrix;
- ::basegfx::B2DHomMatrix aScaleMatrix;
-
- // calc relative size for anisotrophic polygon scaling:
- // when the aspect ratio is e.g. 2.0, that denotes a
- // gradient which is twice as wide as high. Then, to
- // generate a symmetric gradient, the x direction is only
- // scaled to 0.5 times the gradient width. Similarly, when
- // the aspect ratio is 4.0, the focus has 3/4 the width of
- // the overall gradient.
- const double nRelativeFocusSize( rValues.mnAspectRatio > 1.0 ?
- 1.0 - 1.0/rValues.mnAspectRatio :
- 1.0 - rValues.mnAspectRatio );
+ int nColorSteps = 0;
+ for( size_t i=0; i<rColors.size()-1; ++i )
+ nColorSteps += numColorSteps(rColors[i],rColors[i+1]);
+ ::basegfx::B2DHomMatrix aTotalTransform;
+ const int nStepCount=
+ ::canvas::tools::calcGradientStepCount(aTotalTransform,
+ viewState,
+ renderState,
+ texture,
+ nColorSteps);
+
+ ::basegfx::B2DHomMatrix aTextureTransform;
+ ::basegfx::unotools::homMatrixFromAffineMatrix( aTextureTransform,
+ texture.AffineTransform );
+ // determine overall transformation for inner polygon (might
+ // have to be prefixed by anisotrophic scaling)
+ ::basegfx::B2DHomMatrix aInnerPolygonTransformMatrix;
+
+ // For performance reasons, we create a temporary VCL polygon
+ // here, keep it all the way and only change the vertex values
+ // in the loop below (as ::Polygon is a pimpl class, creating
+ // one every loop turn would really stress the mem allocator)
+ ::basegfx::B2DPolygon aOuterPoly( rGradientPoly );
+ ::basegfx::B2DPolygon aInnerPoly;
+
+ // subdivide polygon _before_ rendering, would otherwise have
+ // to be performed on every loop turn.
+ if( aOuterPoly.areControlPointsUsed() )
+ aOuterPoly = ::basegfx::tools::adaptiveSubdivideByAngle(aOuterPoly);
+
+ aInnerPoly = aOuterPoly;
+ aOuterPoly.transform(aTextureTransform);
+
+
+ // apply scaling (possibly anisotrophic) to inner polygon
+ // ------------------------------------------------------
+
+ // scale inner polygon according to aspect ratio: for
+ // wider-than-tall bounds (nAspectRatio > 1.0), the inner
+ // polygon, representing the gradient focus, must have
+ // non-zero width. Specifically, a bound rect twice as wide as
+ // tall has a focus polygon of half it's width.
+ const double nAspectRatio( rValues.mnAspectRatio );
+ if( nAspectRatio > 1.0 )
+ {
+ // width > height case
+ aInnerPolygonTransformMatrix.scale( 1.0 - 1.0/nAspectRatio,
+ 0.0 );
+ }
+ else if( nAspectRatio < 1.0 )
+ {
+ // width < height case
+ aInnerPolygonTransformMatrix.scale( 0.0,
+ 1.0 - nAspectRatio );
+ }
+ else
+ {
+ // isotrophic case
+ aInnerPolygonTransformMatrix.scale( 0.0, 0.0 );
+ }
+
+ // and finally, add texture transform to it.
+ aInnerPolygonTransformMatrix *= aTextureTransform;
+ // apply final matrix to polygon
+ aInnerPoly.transform( aInnerPolygonTransformMatrix );
+
+ Gdiplus::GraphicsPath aCurrPath;
+ Gdiplus::SolidBrush aFillBrush( rColors[0] );
+ const sal_uInt32 nNumPoints( aOuterPoly.count() );
+ basegfx::tools::KeyStopLerp aLerper(rValues.maStops);
for( int i=1; i<nStepCount; ++i )
{
- // lerp color. Funnily, the straight-forward integer
- // lerp ((nStepCount - i)*val + i*val)/nStepCount gets
- // fully botched by MSVC, at least for anything that
- // really inlines inlines (i.e. every compile without
- // debug=t)
- const double nFrac( (double)i/nStepCount );
+ std::ptrdiff_t nIndex;
+ double fAlpha;
+ const double fT( i/double(nStepCount) );
+ boost::tuples::tie(nIndex,fAlpha)=aLerper.lerp(fT);
const Gdiplus::Color aFillColor(
- static_cast<BYTE>( (1.0 - nFrac)*rColor1.GetRed() + nFrac*rColor2.GetRed() ),
- static_cast<BYTE>( (1.0 - nFrac)*rColor1.GetGreen() + nFrac*rColor2.GetGreen() ),
- static_cast<BYTE>( (1.0 - nFrac)*rColor1.GetBlue() + nFrac*rColor2.GetBlue() ) );
+ static_cast<BYTE>( basegfx::tools::lerp(rColors[nIndex].GetRed(),rColors[nIndex+1].GetRed(),fAlpha) ),
+ static_cast<BYTE>( basegfx::tools::lerp(rColors[nIndex].GetGreen(),rColors[nIndex+1].GetGreen(),fAlpha) ),
+ static_cast<BYTE>( basegfx::tools::lerp(rColors[nIndex].GetBlue(),rColors[nIndex+1].GetBlue(),fAlpha) ) );
aFillBrush.SetColor( aFillColor );
-
- const double nCurrScale( (nStepCount-i)/(double)nStepCount );
- aScaleMatrix = basegfx::tools::createTranslateB2DHomMatrix(-0.5, -0.5);
-
- // handle anisotrophic polygon scaling
- if( rValues.mnAspectRatio < 1.0 )
- {
- // height > width case
- aScaleMatrix.scale( nCurrScale,
- // lerp with nCurrScale
- // between 1.0 and
- // relative focus height
- nCurrScale + (1.0-nCurrScale)*nRelativeFocusSize );
- }
- else if( rValues.mnAspectRatio > 1.0 )
- {
- // width > height case
- aScaleMatrix.scale( nCurrScale + (1.0-nCurrScale)*nRelativeFocusSize,
- // lerp with nCurrScale
- // between 1.0 and
- // relative focus width
- nCurrScale );
- }
- else
+ aCurrPath.Reset(); aCurrPath.StartFigure();
+ for( unsigned int p=1; p<nNumPoints; ++p )
{
- aScaleMatrix.scale( nCurrScale,
- nCurrScale );
+ const ::basegfx::B2DPoint& rOuterPoint1( aOuterPoly.getB2DPoint(p-1) );
+ const ::basegfx::B2DPoint& rInnerPoint1( aInnerPoly.getB2DPoint(p-1) );
+ const ::basegfx::B2DPoint& rOuterPoint2( aOuterPoly.getB2DPoint(p) );
+ const ::basegfx::B2DPoint& rInnerPoint2( aInnerPoly.getB2DPoint(p) );
+
+ aCurrPath.AddLine(
+ Gdiplus::REAL(fT*rInnerPoint1.getX() + (1-fT)*rOuterPoint1.getX()),
+ Gdiplus::REAL(fT*rInnerPoint1.getY() + (1-fT)*rOuterPoint1.getY()),
+ Gdiplus::REAL(fT*rInnerPoint2.getX() + (1-fT)*rOuterPoint2.getX()),
+ Gdiplus::REAL(fT*rInnerPoint2.getY() + (1-fT)*rOuterPoint2.getY()));
}
+ aCurrPath.CloseFigure();
- aScaleMatrix.translate( 0.5, 0.5 );
-
- tools::gdiPlusMatrixFromB2DHomMatrix( aGDIScaleMatrix,
- aScaleMatrix );
-
- GraphicsPathSharedPtr pScaledGradientPath(
- tools::graphicsPathFromB2DPolygon( rValues.maGradientPoly ) );
- pScaledGradientPath->Transform( &aGDIScaleMatrix );
-
- rGraphics->FillPath( &aFillBrush, pScaledGradientPath.get() );
+ rGraphics->FillPath( &aFillBrush, &aCurrPath );
}
// reset to old anti-alias mode
@@ -507,18 +383,24 @@ namespace dxcanvas
// one sets both, only the translational components of the
// texture is respected.
+ Gdiplus::Matrix aMatrix;
+ tools::gdiPlusMatrixFromAffineMatrix2D( aMatrix,
+ texture.AffineTransform );
+ GraphicsPathSharedPtr pGradientPath(
+ tools::graphicsPathFromB2DPolygon( rValues.maGradientPoly ));
pGradientPath->Transform( &aMatrix );
- pGradientBrush = createPathGradientBrush(
- pGradientPath,
- rColor1,
- rColor2 );
+ pGradientBrush.reset(
+ new Gdiplus::PathGradientBrush( pGradientPath.get() ) );
+ pGradientBrush->SetInterpolationColors( &rColors[0],
+ &rStops[0],
+ rStops.size() );
// explicitely setup center point. Since the center of GDI+
// gradients are by default the _centroid_ of the path
// (i.e. the weighted sum of edge points), it will not
// necessarily coincide with our notion of center.
- Gdiplus::PointF aCenterPoint(0.5, 0.5);
+ Gdiplus::PointF aCenterPoint(0, 0);
aMatrix.TransformPoints( &aCenterPoint );
pGradientBrush->SetCenterPoint( aCenterPoint );
@@ -554,38 +436,35 @@ namespace dxcanvas
}
bool fillGradient( const ::canvas::ParametricPolyPolygon::Values& rValues,
- const Gdiplus::Color& rColor1,
- const Gdiplus::Color& rColor2,
+ const std::vector< Gdiplus::Color >& rColors,
+ const std::vector< Gdiplus::REAL >& rStops,
GraphicsSharedPtr& rGraphics,
const GraphicsPathSharedPtr& rPath,
+ const rendering::ViewState& viewState,
+ const rendering::RenderState& renderState,
const rendering::Texture& texture )
{
switch( rValues.meType )
{
case ::canvas::ParametricPolyPolygon::GRADIENT_LINEAR:
fillLinearGradient( rGraphics,
- rColor1,
- rColor2,
+ rValues,
+ rColors,
+ rStops,
rPath,
texture );
break;
- case ::canvas::ParametricPolyPolygon::GRADIENT_AXIAL:
- fillAxialGradient( rGraphics,
- rColor1,
- rColor2,
- rPath,
- texture );
- break;
-
case ::canvas::ParametricPolyPolygon::GRADIENT_ELLIPTICAL:
// FALLTHROUGH intended
case ::canvas::ParametricPolyPolygon::GRADIENT_RECTANGULAR:
fillPolygonalGradient( rValues,
+ rColors,
+ rStops,
rGraphics,
- rColor1,
- rColor2,
rPath,
+ viewState,
+ renderState,
texture );
break;
@@ -606,13 +485,13 @@ namespace dxcanvas
rTexture.RepeatModeY,
"CanvasHelper::fillBitmap(): GDI+ cannot handle differing X/Y repeat mode." );
- const bool bClamp( rTexture.RepeatModeX == rendering::TexturingMode::CLAMP &&
- rTexture.RepeatModeY == rendering::TexturingMode::CLAMP );
+ const bool bClamp( rTexture.RepeatModeX == rendering::TexturingMode::NONE &&
+ rTexture.RepeatModeY == rendering::TexturingMode::NONE );
const geometry::IntegerSize2D aBmpSize( xBitmap->getSize() );
ENSURE_ARG_OR_THROW( aBmpSize.Width != 0 &&
- aBmpSize.Height != 0,
- "CanvasHelper::fillBitmap(): zero-sized texture bitmap" );
+ aBmpSize.Height != 0,
+ "CanvasHelper::fillBitmap(): zero-sized texture bitmap" );
// TODO(P3): Detect case that path is rectangle and
// bitmap is just scaled into that. Then, we can
@@ -624,7 +503,6 @@ namespace dxcanvas
tools::bitmapFromXBitmap( xBitmap ) );
TextureBrushSharedPtr pBrush;
-
if( ::rtl::math::approxEqual( rTexture.Alpha,
1.0 ) )
{
@@ -662,9 +540,9 @@ namespace dxcanvas
// scale down bitmap to [0,1]x[0,1] rect, as required
// from the XCanvas interface.
+ pBrush->MultiplyTransform( &aTextureTransform );
pBrush->ScaleTransform( static_cast< Gdiplus::REAL >(1.0/aBmpSize.Width),
static_cast< Gdiplus::REAL >(1.0/aBmpSize.Height) );
- pBrush->MultiplyTransform( &aTextureTransform );
// TODO(F1): FillRule
ENSURE_OR_THROW(
@@ -706,17 +584,29 @@ namespace dxcanvas
const ::canvas::ParametricPolyPolygon::Values& rValues(
pGradient->getValues() );
- // TODO: use all the colors and place them on given positions/stops
- const Gdiplus::Color aColor1(tools::sequenceToArgb(rValues.maColors[0]));
- const Gdiplus::Color aColor2(tools::sequenceToArgb(rValues.maColors[rValues.maColors.getLength () - 1] ));
+ OSL_ASSERT(rValues.maColors.getLength() == rValues.maStops.getLength()
+ && rValues.maColors.getLength() > 1);
+
+ std::vector< Gdiplus::Color > aColors(rValues.maColors.getLength());
+ std::transform(&rValues.maColors[0],
+ &rValues.maColors[0]+rValues.maColors.getLength(),
+ aColors.begin(),
+ boost::bind(
+ (Gdiplus::ARGB (*)( const uno::Sequence< double >& ))(
+ &tools::sequenceToArgb),
+ _1));
+ std::vector< Gdiplus::REAL > aStops;
+ comphelper::sequenceToContainer(aStops,rValues.maStops);
// TODO(E1): Return value
// TODO(F1): FillRule
fillGradient( rValues,
- aColor1,
- aColor2,
+ aColors,
+ aStops,
pGraphics,
tools::graphicsPathFromXPolyPolygon2D( xPolyPolygon ),
+ viewState,
+ renderState,
textures[0] );
}
}
diff --git a/canvas/source/directx/dx_impltools.cxx b/canvas/source/directx/dx_impltools.cxx
index 30bd11a2271a..c298fb9238f9 100755
--- a/canvas/source/directx/dx_impltools.cxx
+++ b/canvas/source/directx/dx_impltools.cxx
@@ -196,7 +196,7 @@ namespace dxcanvas
{
const sal_uInt32 nPoints( rPoly.count() );
- if( !nPoints )
+ if( nPoints < 2 )
return;
rOutput->StartFigure();
diff --git a/canvas/source/directx/dx_spritecanvas.hxx b/canvas/source/directx/dx_spritecanvas.hxx
index 5d5e65c23230..b14d79050ccf 100755
--- a/canvas/source/directx/dx_spritecanvas.hxx
+++ b/canvas/source/directx/dx_spritecanvas.hxx
@@ -39,7 +39,6 @@
#include <com/sun/star/rendering/XIntegerBitmap.hpp>
#include <com/sun/star/rendering/XGraphicDevice.hpp>
#include <com/sun/star/rendering/XBufferController.hpp>
-#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp>
#include <cppuhelper/compbase9.hxx>
#include <comphelper/uno3.hxx>
@@ -58,14 +57,14 @@
namespace dxcanvas
{
typedef ::cppu::WeakComponentImplHelper9< ::com::sun::star::rendering::XSpriteCanvas,
- ::com::sun::star::rendering::XIntegerBitmap,
- ::com::sun::star::rendering::XGraphicDevice,
- ::com::sun::star::rendering::XParametricPolyPolygon2DFactory,
- ::com::sun::star::rendering::XBufferController,
- ::com::sun::star::awt::XWindowListener,
- ::com::sun::star::util::XUpdatable,
- ::com::sun::star::beans::XPropertySet,
- ::com::sun::star::lang::XServiceName > WindowGraphicDeviceBase_Base;
+ ::com::sun::star::rendering::XIntegerBitmap,
+ ::com::sun::star::rendering::XGraphicDevice,
+ ::com::sun::star::lang::XMultiServiceFactory,
+ ::com::sun::star::rendering::XBufferController,
+ ::com::sun::star::awt::XWindowListener,
+ ::com::sun::star::util::XUpdatable,
+ ::com::sun::star::beans::XPropertySet,
+ ::com::sun::star::lang::XServiceName > WindowGraphicDeviceBase_Base;
typedef ::canvas::BufferedGraphicDeviceBase< ::canvas::BaseMutexHelper< WindowGraphicDeviceBase_Base >,
SpriteDeviceHelper,
::osl::MutexGuard,
diff --git a/canvas/source/java/BackBuffer.java b/canvas/source/java/BackBuffer.java
deleted file mode 100644
index 472f6603c33c..000000000000
--- a/canvas/source/java/BackBuffer.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Java AWT
-import java.awt.*;
-import java.awt.image.*;
-
-public class BackBuffer
-{
- private BufferedImage backBuffer;
- //private VolatileImage backBuffer;
- private Graphics2D backBufferGraphics;
- private Graphics2D referenceDevice;
-
- public BackBuffer( Graphics2D _referenceDevice,
- int width,
- int height )
- {
- referenceDevice = _referenceDevice;
- setSize( width, height );
- }
-
- public Graphics2D getGraphics()
- {
- return backBufferGraphics;
- }
-
- public void setSize( int width,
- int height )
- {
- if( backBuffer != null &&
- width == backBuffer.getWidth() &&
- height == backBuffer.getHeight() )
- {
- return;
- }
-
- if( backBufferGraphics != null )
- backBufferGraphics.dispose();
-
- if( backBuffer != null )
- backBuffer.flush();
-
- // TODO: Maybe VolatileImage with another BufferedImage as a backup is
- // a tad faster here.
- backBuffer = referenceDevice.getDeviceConfiguration().createCompatibleImage(width,
- height);
-// backBuffer = referenceDevice.getDeviceConfiguration().createCompatibleVolatileImage(width,
-// height);
-
- backBufferGraphics = backBuffer.createGraphics();
- CanvasUtils.initGraphics( backBufferGraphics );
-
- // clear the buffer to white (to have a defined state here)
- backBufferGraphics.setColor( java.awt.Color.white );
- backBufferGraphics.fillRect( 0,0,width,height );
- }
-
- public void redraw( Graphics2D graph )
- {
- if( graph != null &&
- backBuffer != null )
- {
- CanvasUtils.printLog("BackBuffer.redraw(): using buffer of size (" +
- backBuffer.getWidth() + "," + backBuffer.getHeight() + ")" );
-
- graph.drawImage(backBuffer, 0, 0, null);
-
- // TODO: this is just twiddled to work. I cannot be sure
- // that this volatile backbuffer will survive in the first
- // place, nor that it wise to leave it in VRAM.
-
- // only flush non-volatile images
- // CanvasUtils.postRenderImageTreatment( backBuffer );
- }
- }
-
- public java.awt.Image getBackBuffer()
- {
- return backBuffer;
- }
-
- public void dispose()
- {
- backBufferGraphics.dispose();
- backBuffer.flush();
- }
-}
diff --git a/canvas/source/java/BezierPolyPolygon.java b/canvas/source/java/BezierPolyPolygon.java
deleted file mode 100644
index ed6c08a21abc..000000000000
--- a/canvas/source/java/BezierPolyPolygon.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Canvas
-import com.sun.star.rendering.*;
-import com.sun.star.geometry.*;
-
-public class BezierPolyPolygon
- extends com.sun.star.lib.uno.helper.ComponentBase
- implements com.sun.star.lang.XServiceInfo,
- com.sun.star.rendering.XBezierPolyPolygon2D
-{
- private java.awt.geom.GeneralPath path;
-
- //----------------------------------------------------------------------------------
-
- public BezierPolyPolygon( RealBezierSegment2D[][] points )
- {
- setBezierSegments( points, 0 );
- }
-
- public java.awt.geom.GeneralPath getJavaPath()
- {
- return path;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XPolyPolygon implementation
- // ===========================
- //
- public void addPolyPolygon( RealPoint2D position, XPolyPolygon2D polyPolygon )
- {
- }
-
- public int getNumberOfPolygons( )
- {
- return 0;
- }
-
- public int getNumberOfPolygonPoints( int polygon )
- {
- return 0;
- }
-
- public FillRule getFillRule( )
- {
- if( path.getWindingRule() == java.awt.geom.GeneralPath.WIND_EVEN_ODD )
- return FillRule.EVEN_ODD;
- else
- return FillRule.NON_ZERO;
- }
-
- public void setFillRule( FillRule fillRule )
- {
- if( fillRule == FillRule.EVEN_ODD )
- path.setWindingRule( java.awt.geom.GeneralPath.WIND_EVEN_ODD );
- else
- path.setWindingRule( java.awt.geom.GeneralPath.WIND_NON_ZERO );
- }
-
- public boolean isClosed( int index )
- {
- // TODO
- return false;
- }
-
- public void setClosed( int index, boolean closedState )
- {
- // TODO
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XBezierPolyPolygon implementation
- // =================================
- //
- public RealBezierSegment2D[][] getBezierSegments( int nPolygonIndex, int nNumberOfPolygons, int nPointIndex, int nNumberOfPoints )
- {
- return null;
- }
-
- public void setBezierSegments( RealBezierSegment2D[][] points, int nPolygonIndex )
- {
- if( nPolygonIndex != 0 )
- CanvasUtils.printLog( "LinePolyPolygon.setPoints: subset not yet implemented!" );
-
- path = CanvasUtils.makeGenPathFromBezierPoints( points );
- }
-
- public RealBezierSegment2D getBezierSegment( int nPolygonIndex, int nPointIndex )
- {
- return null;
- }
-
- public void setBezierSegment( RealBezierSegment2D point, int nPolygonIndex, int nPointIndex )
- {
- CanvasUtils.printLog( "LinePolyPolygon.setPoint: not yet implemented!" );
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XServiceInfo impl
- // =================
- //
-
- private static final String s_implName = "XBezierPolyPolygon2D.java.impl";
- private static final String s_serviceName = "com.sun.star.rendering.BezierPolyPolygon2D";
-
- public String getImplementationName()
- {
- return s_implName;
- }
-
- public String [] getSupportedServiceNames()
- {
- return new String [] { s_serviceName };
- }
-
- public boolean supportsService( String serviceName )
- {
- return serviceName.equals( s_serviceName );
- }
-}
diff --git a/canvas/source/java/BitmapCanvas.java b/canvas/source/java/BitmapCanvas.java
deleted file mode 100644
index f40c9bf34c3a..000000000000
--- a/canvas/source/java/BitmapCanvas.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// UNO
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.XComponentContext;
-import com.sun.star.uno.AnyConverter;
-import com.sun.star.uno.IQueryInterface;
-import com.sun.star.lang.XInitialization;
-import com.sun.star.lib.uno.helper.WeakBase;
-
-// OOo AWT
-import com.sun.star.awt.*;
-
-// Canvas
-import com.sun.star.rendering.*;
-import com.sun.star.geometry.*;
-
-// Java AWT
-import java.awt.*;
-import java.awt.image.*;
-import java.awt.geom.*;
-
-public class BitmapCanvas
- extends CanvasBase
- implements com.sun.star.rendering.XBitmapCanvas,
- com.sun.star.lang.XServiceInfo
-{
- private Graphics2D graphics;
-
- public Graphics2D getGraphics()
- {
- return graphics;
- }
-
- //----------------------------------------------------------------------------------
-
- public BitmapCanvas( Graphics2D _graphics )
- {
- graphics = _graphics;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XBitmapCanvas impl
- // ==================
- //
-
- public synchronized void copyRect( com.sun.star.rendering.XBitmapCanvas sourceCanvas,
- com.sun.star.geometry.RealRectangle2D sourceRect,
- com.sun.star.rendering.ViewState sourceViewState,
- com.sun.star.rendering.RenderState sourceRenderState,
- com.sun.star.geometry.RealRectangle2D destRect,
- com.sun.star.rendering.ViewState destViewState,
- com.sun.star.rendering.RenderState destRenderState )
- {
- // TODO: create temp image when transform is non-trivial
-
- if( sourceCanvas == this )
- {
- // copy rectangle within the canvas
- graphics.copyArea((int)sourceRect.X1,
- (int)sourceRect.Y1,
- (int)(sourceRect.X2 - sourceRect.X1),
- (int)(sourceRect.Y2 - sourceRect.Y1),
- (int)(destRect.X1 - sourceRect.X1),
- (int)(destRect.Y1 - sourceRect.Y1) );
- }
- else
- {
- if( sourceCanvas instanceof JavaCanvas )
- {
- // cache
- CanvasUtils.setupGraphicsState( graphics, destViewState, destRenderState, CanvasUtils.alsoSetupPaint );
-
- // TODO: really extract correct source rect here
- BufferedImage backBuffer = ((BufferedGraphics2D)((JavaCanvas)sourceCanvas).getGraphics()).getBackBuffer();
- graphics.drawImage( backBuffer, 0, 0, null );
- CanvasUtils.postRenderImageTreatment( backBuffer );
-
- }
- // TODO: foreign canvas
- }
- }
-
- //----------------------------------------------------------------------------------
-
- private static final String s_implName = "XBitmapCanvas.java.impl";
- private static final String s_serviceName = "com.sun.star.rendering.BitmapCanvas";
-
- //----------------------------------------------------------------------------------
-
- //
- // XServiceInfo impl
- // =================
- //
- public String getImplementationName()
- {
- return s_implName;
- }
-
- public String [] getSupportedServiceNames()
- {
- return new String [] { s_serviceName };
- }
-
- public boolean supportsService( String serviceName )
- {
- return serviceName.equals( s_serviceName );
- }
-}
diff --git a/canvas/source/java/BufferedGraphics2D.java b/canvas/source/java/BufferedGraphics2D.java
deleted file mode 100644
index 88691351809e..000000000000
--- a/canvas/source/java/BufferedGraphics2D.java
+++ /dev/null
@@ -1,600 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Java AWT
-import java.awt.*;
-import java.awt.geom.*;
-import java.awt.image.*;
-import java.awt.image.renderable.*;
-import java.awt.font.*;
-import java.text.*;
-import java.util.*;
-
-
-public class BufferedGraphics2D
- extends java.awt.Graphics2D
-{
- // TODO: Somehow, get rid of this duplicate graphics (the graphics member,
- // and this object itself, extending a Graphics2D)
- private Graphics2D graphics;
- private BufferedImage backBuffer;
- private Graphics2D backBufferGraphics;
-
- //----------------------------------------------------------------------------------
-
- public BufferedGraphics2D( java.awt.Graphics2D _graphics, int width, int height )
- {
- setGraphics( _graphics, Math.max(1,width), Math.max(1,height) );
- }
-
- public void redraw( Graphics2D graph )
- {
- if( graph != null &&
- backBuffer != null )
- {
- CanvasUtils.printLog("BufferedGraphics2D.redraw: using buffer of size (" +
- backBuffer.getWidth() + "," + backBuffer.getHeight() + ")" );
-
- // set transform to identity
- graph.setTransform( new AffineTransform() );
- graph.drawImage(backBuffer, 0, 0, null);
- CanvasUtils.postRenderImageTreatment( backBuffer );
- }
- }
-
- public BufferedImage getBackBuffer()
- {
- return backBuffer;
- }
-
- public void setSize( int width, int height )
- {
- if( backBuffer != null &&
- width == backBuffer.getWidth() &&
- height == backBuffer.getHeight() )
- {
- return;
- }
-
- if( backBufferGraphics != null )
- backBufferGraphics.dispose();
-
- if( backBuffer != null )
- backBuffer.flush();
-
- // TODO: Maybe VolatileImage with another BufferedImage as a backup is
- // a tad faster here.
- backBuffer = graphics.getDeviceConfiguration().createCompatibleImage(width,
- height);
-
- backBufferGraphics = backBuffer.createGraphics();
- CanvasUtils.initGraphics( backBufferGraphics );
-
- // clear the buffer to white (to have a defined state here)
- backBufferGraphics.setColor( java.awt.Color.white );
- backBufferGraphics.fillRect( 0,0,width,height );
- }
-
- public void setGraphics( Graphics2D _graphics, int width, int height )
- {
- if( graphics != null )
- graphics.dispose();
-
- graphics = _graphics;
-
- setSize(width,height);
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // Graphics
- // ========
- //
- public void clearRect(int x, int y, int width, int height)
- {
- graphics.clearRect(x,y,width,height);
- backBufferGraphics.clearRect(x,y,width,height);
- }
-
- public void clipRect(int x, int y, int width, int height)
- {
- graphics.clipRect(x,y,width,height);
- backBufferGraphics.clipRect(x,y,width,height);
- }
-
- public void copyArea(int x, int y, int width, int height, int dx, int dy)
- {
- graphics.copyArea(x,y,width,height,dx,dy);
- backBufferGraphics.copyArea(x,y,width,height,dx,dy);
- }
-
- public Graphics create()
- {
- return null;
- }
-
- public Graphics create(int x, int y, int width, int height)
- {
- return null;
- }
-
- public void dispose()
- {
- graphics.dispose();
- backBufferGraphics.dispose();
- backBuffer.flush();
- }
-
- public void draw3DRect(int x, int y, int width, int height, boolean raised)
- {
- graphics.draw3DRect(x,y,width,height,raised);
- backBufferGraphics.draw3DRect(x,y,width,height,raised);
- }
-
- public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
- {
- graphics.drawArc(x,y,width,height,startAngle,arcAngle);
- backBufferGraphics.drawArc(x,y,width,height,startAngle,arcAngle);
- }
-
- public void drawBytes(byte[] data, int offset, int length, int x, int y)
- {
- graphics.drawBytes(data,offset,length,x,y);
- backBufferGraphics.drawBytes(data,offset,length,x,y);
- }
-
- public void drawChars(char[] data, int offset, int length, int x, int y)
- {
- graphics.drawChars(data,offset,length,x,y);
- backBufferGraphics.drawChars(data,offset,length,x,y);
- }
-
- public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)
- {
- backBufferGraphics.drawImage(img,x,y,bgcolor,observer);
- return graphics.drawImage(img,x,y,bgcolor,observer);
- }
-
- public boolean drawImage(Image img, int x, int y, ImageObserver observer)
- {
- backBufferGraphics.drawImage(img,x,y,observer);
- return graphics.drawImage(img,x,y,observer);
- }
-
- public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer)
- {
- backBufferGraphics.drawImage(img,x,y,width,height,bgcolor,observer);
- return graphics.drawImage(img,x,y,width,height,bgcolor,observer);
- }
-
- public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)
- {
- backBufferGraphics.drawImage(img,x,y,width,height,observer);
- return graphics.drawImage(img,x,y,width,height,observer);
- }
-
- public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer)
- {
- backBufferGraphics.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,bgcolor,observer);
- return graphics.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,bgcolor,observer);
- }
-
- public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
- {
- backBufferGraphics.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,observer);
- return graphics.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,observer);
- }
-
- public void drawLine(int x1, int y1, int x2, int y2)
- {
- graphics.drawLine(x1,y1,x2,y2);
- backBufferGraphics.drawLine(x1,y1,x2,y2);
- }
-
- public void drawOval(int x, int y, int width, int height)
- {
- graphics.drawOval(x,y,width,height);
- backBufferGraphics.drawOval(x,y,width,height);
- }
-
- public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
- {
- graphics.drawPolygon(xPoints,yPoints,nPoints);
- backBufferGraphics.drawPolygon(xPoints,yPoints,nPoints);
- }
-
- public void drawPolygon(Polygon p)
- {
- graphics.drawPolygon(p);
- backBufferGraphics.drawPolygon(p);
- }
-
- public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
- {
- graphics.drawPolyline(xPoints,yPoints,nPoints);
- backBufferGraphics.drawPolyline(xPoints,yPoints,nPoints);
- }
-
- public void drawRect(int x, int y, int width, int height)
- {
- graphics.drawRect(x,y,width,height);
- backBufferGraphics.drawRect(x,y,width,height);
- }
-
- public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
- {
- graphics.drawRoundRect(x,y,width,height,arcWidth,arcHeight);
- backBufferGraphics.drawRoundRect(x,y,width,height,arcWidth,arcHeight);
- }
-
- public void drawString(AttributedCharacterIterator iterator, int x, int y)
- {
- graphics.drawString(iterator,x,y);
- backBufferGraphics.drawString(iterator,x,y);
- }
-
- public void drawString(String str, int x, int y)
- {
- graphics.drawString(str,x,y);
- backBufferGraphics.drawString(str,x,y);
- }
-
- public void fill3DRect(int x, int y, int width, int height, boolean raised)
- {
- graphics.fill3DRect(x,y,width,height,raised);
- backBufferGraphics.fill3DRect(x,y,width,height,raised);
- }
-
- public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
- {
- graphics.fillArc(x,y,width,height,startAngle,arcAngle);
- backBufferGraphics.fillArc(x,y,width,height,startAngle,arcAngle);
- }
-
- public void fillOval(int x, int y, int width, int height)
- {
- graphics.fillOval(x,y,width,height);
- backBufferGraphics.fillOval(x,y,width,height);
- }
-
- public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
- {
- graphics.fillPolygon(xPoints,yPoints,nPoints);
- backBufferGraphics.fillPolygon(xPoints,yPoints,nPoints);
- }
-
- public void fillPolygon(Polygon p)
- {
- graphics.fillPolygon(p);
- backBufferGraphics.fillPolygon(p);
- }
-
- public void fillRect(int x, int y, int width, int height)
- {
- graphics.fillRect(x,y,width,height);
- backBufferGraphics.fillRect(x,y,width,height);
- }
-
- public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
- {
- graphics.fillRoundRect(x,y,width,height,arcWidth,arcHeight);
- backBufferGraphics.fillRoundRect(x,y,width,height,arcWidth,arcHeight);
- }
-
- public Shape getClip()
- {
- return graphics.getClip();
- }
-
- public Rectangle getClipBounds()
- {
- return graphics.getClipBounds();
- }
-
- public Rectangle getClipBounds(Rectangle r)
- {
- return graphics.getClipBounds(r);
- }
-
- public Rectangle getClipRect()
- {
- return graphics.getClipRect();
- }
-
- public Color getColor()
- {
- return getColor();
- }
-
- public Font getFont()
- {
- return getFont();
- }
-
- public FontMetrics getFontMetrics()
- {
- return getFontMetrics();
- }
-
- public FontMetrics getFontMetrics(Font f)
- {
- return getFontMetrics(f);
- }
-
- public boolean hitClip(int x, int y, int width, int height)
- {
- return graphics.hitClip(x,y,width,height);
- }
-
- public void setClip(int x, int y, int width, int height)
- {
- graphics.setClip(x,y,width,height);
- backBufferGraphics.setClip(x,y,width,height);
- }
-
- public void setClip(Shape clip)
- {
- graphics.setClip(clip);
- backBufferGraphics.setClip(clip);
- }
-
- public void setColor(Color c)
- {
- graphics.setColor(c);
- backBufferGraphics.setColor(c);
- }
-
- public void setFont(Font font)
- {
- graphics.setFont(font);
- backBufferGraphics.setFont(font);
- }
-
- public void setPaintMode()
- {
- graphics.setPaintMode();
- backBufferGraphics.setPaintMode();
- }
-
- public void setXORMode(Color c1)
- {
- graphics.setXORMode(c1);
- backBufferGraphics.setXORMode(c1);
- }
-
- public String toString()
- {
- return graphics.toString();
- }
-
- public void translate(int x, int y)
- {
- graphics.translate(x,y);
- backBufferGraphics.translate(x,y);
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // Graphics2D
- // ==========
- //
- public void addRenderingHints(Map hints)
- {
- graphics.addRenderingHints(hints);
- backBufferGraphics.addRenderingHints(hints);
- }
-
- public void clip(Shape s)
- {
- graphics.clip(s);
- backBufferGraphics.clip(s);
- }
-
- public void draw(Shape s)
- {
- graphics.draw(s);
- backBufferGraphics.draw(s);
- }
-
- public void drawGlyphVector(GlyphVector g, float x, float y)
- {
- graphics.drawGlyphVector(g,x,y);
- backBufferGraphics.drawGlyphVector(g,x,y);
- }
-
- public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y)
- {
- graphics.drawImage(img,op,x,y);
- backBufferGraphics.drawImage(img,op,x,y);
- }
-
- public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs)
- {
- backBufferGraphics.drawImage(img,xform,obs);
- return graphics.drawImage(img,xform,obs);
- }
-
- public void drawRenderableImage(RenderableImage img, AffineTransform xform)
- {
- graphics.drawRenderableImage(img,xform);
- backBufferGraphics.drawRenderableImage(img,xform);
- }
-
- public void drawRenderedImage(RenderedImage img, AffineTransform xform)
- {
- graphics.drawRenderedImage(img,xform);
- backBufferGraphics.drawRenderedImage(img,xform);
- }
-
- public void drawString(AttributedCharacterIterator iterator, float x, float y)
- {
- graphics.drawString(iterator,x,y);
- backBufferGraphics.drawString(iterator,x,y);
- }
-
- public void drawString(String s, float x, float y)
- {
- graphics.drawString(s,x,y);
- backBufferGraphics.drawString(s,x,y);
- }
-
- public void fill(Shape s)
- {
- graphics.fill(s);
- backBufferGraphics.fill(s);
- }
-
- public Color getBackground()
- {
- return graphics.getBackground();
- }
-
- public Composite getComposite()
- {
- return graphics.getComposite();
- }
-
- public GraphicsConfiguration getDeviceConfiguration()
- {
- return graphics.getDeviceConfiguration();
- }
-
- public FontRenderContext getFontRenderContext()
- {
- return graphics.getFontRenderContext();
- }
-
- public Paint getPaint()
- {
- return graphics.getPaint();
- }
-
- public Object getRenderingHint(RenderingHints.Key hintKey)
- {
- return graphics.getRenderingHint(hintKey);
- }
-
- public RenderingHints getRenderingHints()
- {
- return graphics.getRenderingHints();
- }
-
- public Stroke getStroke()
- {
- return graphics.getStroke();
- }
-
- public AffineTransform getTransform()
- {
- return graphics.getTransform();
- }
-
- public boolean hit(Rectangle rect, Shape s, boolean onStroke)
- {
- return graphics.hit(rect,s,onStroke);
- }
-
- public void rotate(double theta)
- {
- graphics.rotate(theta);
- backBufferGraphics.rotate(theta);
- }
-
- public void rotate(double theta, double x, double y)
- {
- graphics.rotate(theta,x,y);
- backBufferGraphics.rotate(theta,x,y);
- }
-
- public void scale(double sx, double sy)
- {
- graphics.scale(sx,sy);
- backBufferGraphics.scale(sx,sy);
- }
-
- public void setBackground(Color color)
- {
- graphics.setBackground(color);
- backBufferGraphics.setBackground(color);
- }
-
- public void setComposite(Composite comp)
- {
- graphics.setComposite(comp);
- backBufferGraphics.setComposite(comp);
- }
-
- public void setPaint(Paint paint)
- {
- graphics.setPaint(paint);
- backBufferGraphics.setPaint(paint);
- }
-
- public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
- {
- graphics.setRenderingHint(hintKey,hintValue);
- backBufferGraphics.setRenderingHint(hintKey,hintValue);
- }
-
- public void setRenderingHints(Map hints)
- {
- graphics.setRenderingHints(hints);
- backBufferGraphics.setRenderingHints(hints);
- }
-
- public void setStroke(Stroke s)
- {
- graphics.setStroke(s);
- backBufferGraphics.setStroke(s);
- }
-
- public void setTransform(AffineTransform Tx)
- {
- graphics.setTransform(Tx);
- backBufferGraphics.setTransform(Tx);
- }
-
- public void shear(double shx, double shy)
- {
- graphics.shear(shx,shy);
- backBufferGraphics.shear(shx,shy);
- }
-
- public void transform(AffineTransform Tx)
- {
- graphics.transform(Tx);
- backBufferGraphics.transform(Tx);
- }
-
- public void translate(double tx, double ty)
- {
- graphics.translate(tx,ty);
- backBufferGraphics.translate(tx,ty);
- }
-}
diff --git a/canvas/source/java/CanvasBase.java b/canvas/source/java/CanvasBase.java
deleted file mode 100644
index 2df796d06f84..000000000000
--- a/canvas/source/java/CanvasBase.java
+++ /dev/null
@@ -1,341 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Canvas
-import com.sun.star.rendering.*;
-import com.sun.star.geometry.*;
-
-// Java AWT
-import java.awt.*;
-import java.awt.geom.*;
-
-public abstract class CanvasBase
- extends com.sun.star.lib.uno.helper.ComponentBase
- implements com.sun.star.rendering.XCanvas
-{
- // to be overridden
- public abstract Graphics2D getGraphics();
-
- //----------------------------------------------------------------------------------
-
- //
- // XCanvas interface
- // =================
- //
- public synchronized void clear()
- {
- Graphics2D graphics = getGraphics();
- // TODO(F3): retrieve true dimensions of the Graphics
- graphics.clearRect(0,0,1000,1000);
- }
-
- public synchronized void drawPoint( RealPoint2D aPoint,
- ViewState viewState,
- RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException
- {
- // cache
- Graphics2D graphics = getGraphics();
-
- // initialize the Graphics2D
- CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint );
-
- // calculate the domain value for a single device pixel. we're
- // using delta mapping here, to avoid later subtraction of two
- // mapped values (as we really only need a transformed size,
- // not a transformed point).
- AffineTransform transform = graphics.getTransform();
- AffineTransform inverse;
- try
- {
- inverse = transform.createInverse();
- }
- catch( NoninvertibleTransformException e )
- {
- // transformation not invertible. Nothing to render then.
- return;
- }
-
- java.awt.geom.Point2D.Double pointSize = new java.awt.geom.Point2D.Double(1.0,1.0);
- java.awt.geom.Point2D.Double domainPointSize = new java.awt.geom.Point2D.Double();
- inverse.deltaTransform( pointSize, domainPointSize );
-
- // render a circle one device pixel wide
- Ellipse2D.Double ellipse = new Ellipse2D.Double(aPoint.X, aPoint.Y, domainPointSize.x, domainPointSize.y);
-
- // render, at last
- graphics.fill( ellipse );
-
- CanvasUtils.printLog( "XCanvas: drawPoint called" );
- }
-
- public synchronized void drawLine( RealPoint2D aStartPoint,
- RealPoint2D aEndPoint,
- ViewState viewState,
- RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException
- {
- // cache
- Graphics2D graphics = getGraphics();
-
- // initialize the Graphics2D
- CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint );
- graphics.setStroke( new BasicStroke() );
-
- // setup line object
- Line2D.Double line = new Line2D.Double(aStartPoint.X, aStartPoint.Y, aEndPoint.X, aEndPoint.Y);
-
- // render, at last
- graphics.draw( line );
-
- CanvasUtils.printLog( "XCanvas: drawLine called" );
- }
-
- public synchronized void drawBezier( RealBezierSegment2D aBezierSegment,
- RealPoint2D aEndPoint,
- ViewState viewState,
- RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException
- {
- // cache
- Graphics2D graphics = getGraphics();
-
- // initialize the Graphics2D
- CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint );
- graphics.setStroke( new BasicStroke() );
-
- // setup bezier object
- CubicCurve2D.Double curve = new CubicCurve2D.Double(aBezierSegment.Px, aBezierSegment.Py,
- aBezierSegment.C1x, aBezierSegment.C1y,
- aBezierSegment.C2x, aBezierSegment.C2y,
- aEndPoint.X, aEndPoint.Y);
-
- // render, at last
- graphics.draw( curve );
-
- CanvasUtils.printLog( "XCanvas: drawbezier called" );
- }
-
- public synchronized XCachedPrimitive drawPolyPolygon( XPolyPolygon2D xPolyPolygon,
- ViewState viewState,
- RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException
- {
- CanvasUtils.printLog( "CanvasBase.drawPolyPolygon() called" );
-
- // cache
- Graphics2D graphics = getGraphics();
-
- // initialize the Graphics2D
- CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint );
- graphics.setStroke( new BasicStroke() );
-
- // render the polygon
- // TODO: maybe use Graphics.drawPolyline here!
- graphics.draw( CanvasUtils.makeGeneralPath(xPolyPolygon) );
-
- CanvasUtils.printLog( "XCanvas: drawPolyPolygon called" );
-
- return null;
- }
-
- public synchronized XCachedPrimitive strokePolyPolygon( XPolyPolygon2D xPolyPolygon,
- ViewState viewState,
- RenderState renderState,
- StrokeAttributes strokeAttributes ) throws com.sun.star.lang.IllegalArgumentException
- {
- // cache
- Graphics2D graphics = getGraphics();
-
- // initialize the Graphics2D
- CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint );
- CanvasUtils.applyStrokeAttributes( graphics, strokeAttributes );
-
- // stroke the polygon
- graphics.draw( CanvasUtils.makeGeneralPath(xPolyPolygon) );
-
- CanvasUtils.printLog( "XCanvas: strokePolyPolygon called" );
-
- return null;
- }
-
- public synchronized XCachedPrimitive strokeTexturedPolyPolygon( XPolyPolygon2D xPolyPolygon,
- ViewState viewState,
- RenderState renderState,
- Texture[] textures,
- StrokeAttributes strokeAttributes ) throws com.sun.star.lang.IllegalArgumentException, VolatileContentDestroyedException
- {
- return null;
- }
-
- public synchronized XCachedPrimitive strokeTextureMappedPolyPolygon( XPolyPolygon2D xPolyPolygon,
- ViewState viewState,
- RenderState renderState,
- Texture[] textures,
- com.sun.star.geometry.XMapping2D xMapping,
- StrokeAttributes strokeAttributes ) throws com.sun.star.lang.IllegalArgumentException, VolatileContentDestroyedException
- {
- return null;
- }
-
- public synchronized XPolyPolygon2D queryStrokeShapes( com.sun.star.rendering.XPolyPolygon2D xPolyPolygon,
- com.sun.star.rendering.ViewState viewState,
- com.sun.star.rendering.RenderState renderState,
- com.sun.star.rendering.StrokeAttributes strokeAttributes ) throws com.sun.star.lang.IllegalArgumentException
- {
- return null;
- }
-
- public synchronized XCachedPrimitive fillPolyPolygon( com.sun.star.rendering.XPolyPolygon2D xPolyPolygon,
- com.sun.star.rendering.ViewState viewState,
- com.sun.star.rendering.RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException
- {
- CanvasUtils.printLog( "CanvasBase.fillPolyPolygon() called" );
-
- // cache
- Graphics2D graphics = getGraphics();
-
- // initialize the Graphics2D
- CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint );
-
- // fill the polygon
- graphics.fill( CanvasUtils.makeGeneralPath(xPolyPolygon) );
-
- CanvasUtils.printLog( "XCanvas: fillPolyPolygon called" );
-
- return null;
- }
-
- public synchronized XCachedPrimitive fillTexturedPolyPolygon( com.sun.star.rendering.XPolyPolygon2D xPolyPolygon,
- com.sun.star.rendering.ViewState viewState,
- com.sun.star.rendering.RenderState renderState,
- com.sun.star.rendering.Texture [] textures ) throws com.sun.star.lang.IllegalArgumentException
- {
- return null;
- }
-
- public synchronized XCachedPrimitive fillTextureMappedPolyPolygon( XPolyPolygon2D xPolyPolygon,
- ViewState viewState,
- RenderState renderState,
- Texture[] textures,
- com.sun.star.geometry.XMapping2D xMapping ) throws com.sun.star.lang.IllegalArgumentException, VolatileContentDestroyedException
- {
- return null;
- }
-
- public synchronized XCanvasFont createFont( FontRequest fontRequest, com.sun.star.beans.PropertyValue[] extraFontProperties, com.sun.star.geometry.Matrix2D fontMatrix ) throws com.sun.star.lang.IllegalArgumentException
- {
- // TODO: support extra arguments
- return new CanvasFont( fontRequest, this );
- }
-
- public FontInfo[] queryAvailableFonts( FontInfo aFilter, com.sun.star.beans.PropertyValue[] aFontProperties ) throws com.sun.star.lang.IllegalArgumentException
- {
- // TODO
- return null;
- }
-
- public XCachedPrimitive drawText( StringContext text, XCanvasFont xFont, ViewState viewState, RenderState renderState, byte textDirection ) throws com.sun.star.lang.IllegalArgumentException
- {
- CanvasUtils.printLog( "CanvasBase.drawText() called" );
-
- // cache
- Graphics2D graphics = getGraphics();
-
- CanvasUtils.printLog( "XCanvas: drawText called" );
-
- CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint );
- CanvasUtils.setupGraphicsFont( graphics, viewState, renderState, xFont );
-
- CanvasUtils.printLog( "XCanvas: drawText rendering \""+ text.Text.substring(text.StartPosition, text.StartPosition+text.Length) + "\"" );
-
- graphics.drawString( text.Text.substring(text.StartPosition, text.StartPosition+text.Length), (float)0.0, (float)0.0 );
- return null;
- }
-
- public XCachedPrimitive drawTextLayout( XTextLayout layoutetText, ViewState viewState, RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException
- {
- CanvasUtils.printLog( "CanvasBase.drawOffsettedText() called" );
-
- // cache
- Graphics2D graphics = getGraphics();
-
- CanvasUtils.printLog( "XCanvas: drawOffsettedText called" );
-
- CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint );
- CanvasUtils.setupGraphicsFont( graphics, viewState, renderState, layoutetText.getFont() );
-
- CanvasUtils.printLog( "XCanvas: drawOffsettedText canvas setup done" );
-
- if( layoutetText instanceof TextLayout )
- {
- ((TextLayout)layoutetText).draw( graphics );
- }
- else
- {
- CanvasUtils.printLog( "drawTextLayout: mismatching TextLayout object." );
- throw new com.sun.star.lang.IllegalArgumentException();
- }
-
- return null;
- }
-
- public synchronized XCachedPrimitive drawBitmap( com.sun.star.rendering.XBitmap xBitmap,
- com.sun.star.rendering.ViewState viewState,
- com.sun.star.rendering.RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException
- {
- CanvasUtils.printLog( "CanvasBase.drawBitmap() called" );
-
- // cache
- Graphics2D graphics = getGraphics();
-
- CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint );
-
- java.awt.image.BufferedImage bitmap = CanvasUtils.getBufferedImage( xBitmap );
-
- if( !graphics.drawImage(bitmap, 0, 0, null) )
- CanvasUtils.printLog( "CanvasBase.drawBitmap: image paint incomplete" );
-
- CanvasUtils.postRenderImageTreatment( bitmap );
-
- return null;
- }
-
- public synchronized XCachedPrimitive drawBitmapModulated( com.sun.star.rendering.XBitmap xBitmap,
- com.sun.star.rendering.ViewState viewState,
- com.sun.star.rendering.RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException
- {
- CanvasUtils.printLog( "CanvasBase.drawBitmapModulated() called" );
-
- // TODO(F3): Implement channel modulation
- return drawBitmap(xBitmap,
- viewState,
- renderState);
- }
-
- public synchronized XGraphicDevice getDevice()
- {
- CanvasUtils.printLog( "CanvasBase.getDevice() called" );
- return new CanvasGraphicDevice( getGraphics() );
- }
-}
diff --git a/canvas/source/java/CanvasBitmap.java b/canvas/source/java/CanvasBitmap.java
deleted file mode 100644
index cfb7617dc094..000000000000
--- a/canvas/source/java/CanvasBitmap.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Canvas
-import com.sun.star.rendering.*;
-import com.sun.star.geometry.*;
-
-public class CanvasBitmap
- extends CanvasBase
- implements com.sun.star.lang.XServiceInfo,
- com.sun.star.rendering.XBitmapCanvas,
- com.sun.star.rendering.XIntegerBitmap
-{
- private java.awt.image.BufferedImage bitmap;
- private java.awt.Graphics2D graphics;
-
- public CanvasBitmap( java.awt.image.BufferedImage _bitmap )
- {
- bitmap = _bitmap;
- graphics = bitmap.createGraphics();
- }
-
- public CanvasBitmap( IntegerSize2D mySize )
- {
- bitmap = new java.awt.image.BufferedImage(mySize.Width, mySize.Height,
- java.awt.image.BufferedImage.TYPE_4BYTE_ABGR);
- graphics = bitmap.createGraphics();
- }
-
- public CanvasBitmap( RealSize2D newSize, boolean beFast, CanvasBitmap source )
- {
-// java.awt.geom.AffineTransform transform = new java.awt.geom.AffineTransform();
-// transform.scale( newSize.width/size.Width, newSize.height/size.Height );
-
-// // TODO: Maybe keep the image returned via
-// // bitmap.getScaledInstance, and do scaling lazy.
-// bitmap = new java.awt.image.BufferedImage((int)(newSize.width+.5),
-// (int)(newSize.height+.5),
-// java.awt.image.BufferedImage.TYPE_4BYTE_ABGR);
-
-// java.awt.image.AffineTransformOp transformer =
-// new java.awt.image.AffineTransformOp( transform,
-// java.awt.image.AffineTransformOp.TYPE_BILINEAR);
-
-// transformer.filter(source.getBufferedImage(), bitmap);
- }
-
- public synchronized java.awt.image.BufferedImage getBufferedImage()
- {
- return bitmap;
- }
-
- public java.awt.Graphics2D getGraphics()
- {
- return graphics;
- }
-
- //
- // XBitmap implementation
- // ======================
- //
-
- public synchronized IntegerSize2D getSize()
- {
- return new IntegerSize2D( bitmap.getWidth(),
- bitmap.getHeight() );
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized XBitmapCanvas queryBitmapCanvas()
- {
- return this;
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized com.sun.star.rendering.XBitmap getScaledBitmap( RealSize2D newSize, boolean beFast ) throws com.sun.star.lang.IllegalArgumentException, VolatileContentDestroyedException
- {
- return new CanvasBitmap( newSize, beFast, this );
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized boolean hasAlpha()
- {
- // TODO
- return false;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XBitmapCanvas impl
- // ==================
- //
-
- public synchronized void copyRect( com.sun.star.rendering.XBitmapCanvas sourceCanvas,
- com.sun.star.geometry.RealRectangle2D sourceRect,
- com.sun.star.rendering.ViewState sourceViewState,
- com.sun.star.rendering.RenderState sourceRenderState,
- com.sun.star.geometry.RealRectangle2D destRect,
- com.sun.star.rendering.ViewState destViewState,
- com.sun.star.rendering.RenderState destRenderState )
- {
- CanvasUtils.printLog( "JavaCanvas.copyRect() called" );
-
- // TODO: create temp image when transform is non-trivial
-
- if( sourceCanvas == this )
- {
- // copy rectangle within the canvas
- getGraphics().copyArea((int)sourceRect.X1,
- (int)sourceRect.Y1,
- (int)(sourceRect.X2 - sourceRect.X1),
- (int)(sourceRect.Y2 - sourceRect.Y1),
- (int)(destRect.X1 - sourceRect.X1),
- (int)(destRect.Y1 - sourceRect.Y1) );
- }
- else
- {
- if( sourceCanvas instanceof JavaCanvas )
- {
- // cache
- CanvasUtils.setupGraphicsState( getGraphics(), destViewState, destRenderState, CanvasUtils.alsoSetupPaint );
-
- java.awt.Image backBuffer = ((JavaCanvas)sourceCanvas).backBuffer.getBackBuffer();
-
- // TODO: really extract correct source rect here
- getGraphics().drawImage( backBuffer, 0, 0, null);
- CanvasUtils.postRenderImageTreatment( backBuffer );
- }
- // TODO: foreign canvas
- }
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XIntegerBitmap implementation
- // =============================
- //
-
- public synchronized byte[] getData( IntegerBitmapLayout[] bitmapLayout,
- IntegerRectangle2D rect )
- {
- int [] pixelData = bitmap.getRGB( rect.X1, rect.Y1, rect.X2 - rect.X1, rect.Y1 - rect.Y2, null, 0, 0 );
-
- return CanvasUtils.int2byte( pixelData );
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized void setData( byte[] data, IntegerBitmapLayout bitmapLayout, com.sun.star.geometry.IntegerRectangle2D rect )
- {
- int [] pixelData = CanvasUtils.byte2int( data );
- bitmap.setRGB( rect.X1, rect.Y1, rect.X2 - rect.X1, rect.Y2 - rect.Y1, pixelData, 0, bitmap.getWidth() );
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized void setPixel( byte[] color, IntegerBitmapLayout bitmapLayout, com.sun.star.geometry.IntegerPoint2D pos )
- {
- if( color.length != 4 )
- CanvasUtils.printLog( "CanvasBitmap.setPixel: Wrong color format" );
-
- int pixel = color[0] + (color[1] + (color[2] + color[3]*256)*256)*256;
- bitmap.setRGB( pos.X, pos.Y, pixel );
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized byte[] getPixel( IntegerBitmapLayout[] bitmapLayout,
- IntegerPoint2D pos )
- {
- int pixel = bitmap.getRGB( pos.X, pos.Y );
-
- byte[] res = new byte[4];
- res[0] = (byte)(pixel & 255);
- res[1] = (byte)((pixel/256) & 255);
- res[2] = (byte)((pixel/256/256) & 255);
- res[3] = (byte)((pixel/256/256/256) & 255);
-
- return res;
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized XBitmapPalette getPalette()
- {
- return null;
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized IntegerBitmapLayout getMemoryLayout()
- {
- // TODO: finish that one
- IntegerBitmapLayout layout = new IntegerBitmapLayout();
-
- return layout;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XServiceInfo impl
- // =================
- //
-
- private static final String s_implName = "XIntegerBitmap.java.impl";
- private static final String s_serviceName = "com.sun.star.rendering.IntegerBitmap";
-
- public String getImplementationName()
- {
- return s_implName;
- }
-
- public String [] getSupportedServiceNames()
- {
- return new String [] { s_serviceName };
- }
-
- public boolean supportsService( String serviceName )
- {
- return serviceName.equals( s_serviceName );
- }
-}
diff --git a/canvas/source/java/CanvasClonedSprite.java b/canvas/source/java/CanvasClonedSprite.java
deleted file mode 100644
index d5f85678db4f..000000000000
--- a/canvas/source/java/CanvasClonedSprite.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Canvas
-import com.sun.star.rendering.*;
-import com.sun.star.geometry.*;
-
-// Java AWT
-import java.awt.geom.*;
-
-public class CanvasClonedSprite
- extends com.sun.star.lib.uno.helper.ComponentBase
- implements com.sun.star.rendering.XSprite,
- com.sun.star.lang.XServiceInfo,
- SpriteBase
-{
- private JavaCanvas canvas;
- private double alpha;
- private java.awt.geom.Point2D.Double outputPosition;
- private SpriteRep spriteRep;
- private SpriteBase original;
-
- //----------------------------------------------------------------------------------
-
- public CanvasClonedSprite( JavaCanvas _canvas,
- XSprite _original )
- {
- CanvasUtils.printLog( "CanvasClonesSprite constructor called!" );
-
- canvas = _canvas;
-
- if( _original instanceof SpriteBase )
- {
- original = (SpriteBase)_original;
- }
-
- alpha = 0.0;
- outputPosition = new java.awt.geom.Point2D.Double(0.0,0.0);
-
- // TODO: throw on error here!
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // SpriteBase
- // ==========
- //
- public SpriteRep getSpriteRep()
- {
- if( spriteRep == null )
- {
- spriteRep = new SpriteRep( original.getSpriteRep() );
-
- spriteRep.moveSprite( outputPosition );
- spriteRep.setSpriteAlpha( alpha );
-
- // TODO: Check for spriteRep.buffer != null here, throw otherwise
- }
- return spriteRep;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XComponent
- // ==========
- //
- public void dispose()
- {
- canvas = null;
- spriteRep = null;
- original = null;
-
- super.dispose();
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XSprite impl
- // ==================
- //
-
- public synchronized void setPriority( double nPriority )
- {
- // TODO
- }
-
- public synchronized void setAlpha( double _alpha )
- {
- alpha = _alpha;
-
- if( spriteRep != null )
- {
- spriteRep.setSpriteAlpha( alpha );
- }
- }
-
- public synchronized void move( RealPoint2D _aNewPos,
- ViewState _viewState,
- RenderState _renderState )
- {
- // transform given point with concatenated transformation
- AffineTransform transform = CanvasUtils.ViewConcatRenderTransform( _viewState, _renderState );
- transform.transform( new java.awt.geom.Point2D.Double(_aNewPos.X,
- _aNewPos.Y),
- outputPosition );
-
- if( spriteRep != null )
- {
- spriteRep.moveSprite( outputPosition );
- }
- }
-
- public synchronized void transform( AffineMatrix2D aTransformation ) throws com.sun.star.lang.IllegalArgumentException
- {
- // TODO
- }
-
- public synchronized void clip( XPolyPolygon2D aClip )
- {
- // TODO
- }
-
- public synchronized void show()
- {
- canvas.showSprite( this );
- canvas.updateScreen( false );
- }
-
- public synchronized void hide()
- {
- canvas.hideSprite( this );
- }
- //----------------------------------------------------------------------------------
-
- private static final String s_implName = "XSprite.java.impl";
- private static final String s_serviceName = "com.sun.star.rendering.Sprite";
-
- //----------------------------------------------------------------------------------
-
- //
- // XServiceInfo impl
- // =================
- //
- public String getImplementationName()
- {
- return s_implName;
- }
-
- public String [] getSupportedServiceNames()
- {
- return new String [] { s_serviceName };
- }
-
- public boolean supportsService( String serviceName )
- {
- return serviceName.equals( s_serviceName );
- }
-}
diff --git a/canvas/source/java/CanvasCustomSprite.java b/canvas/source/java/CanvasCustomSprite.java
deleted file mode 100644
index c3165fa68e80..000000000000
--- a/canvas/source/java/CanvasCustomSprite.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Canvas
-import com.sun.star.rendering.*;
-import com.sun.star.geometry.*;
-
-// Java AWT
-import java.awt.*;
-import java.awt.geom.*;
-
-public class CanvasCustomSprite
- extends com.sun.star.lib.uno.helper.ComponentBase
- implements com.sun.star.rendering.XCustomSprite,
- com.sun.star.lang.XServiceInfo,
- SpriteBase
-{
- private JavaCanvas canvas;
- private RealSize2D spriteSize;
- private Graphics2D referenceGraphics;
- private double alpha;
- private java.awt.geom.Point2D.Double outputPosition;
- private SpriteRep spriteRep;
-
- //----------------------------------------------------------------------------------
-
- public CanvasCustomSprite( RealSize2D _spriteSize,
- JavaCanvas _canvas,
- Graphics2D _referenceGraphics )
- {
- CanvasUtils.printLog( "CanvasCustomSprite constructor called, size is (" + _spriteSize.Width + ", " + _spriteSize.Height + ")" );
-
- canvas = _canvas;
- spriteSize = _spriteSize;
- referenceGraphics = _referenceGraphics;
- alpha = 0.0;
- outputPosition = new java.awt.geom.Point2D.Double(0.0,0.0);
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // SpriteBase
- // ==========
- //
- public synchronized SpriteRep getSpriteRep()
- {
- if( spriteRep == null )
- {
- spriteRep = new SpriteRep();
-
- spriteRep.setupBuffer(referenceGraphics, (int)(spriteSize.Width+.5), (int)(spriteSize.Height+.5) );
-
- spriteRep.moveSprite( outputPosition );
- spriteRep.setSpriteAlpha( alpha );
- }
- return spriteRep;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XComponent
- // ==========
- //
- public void dispose()
- {
- if( spriteRep != null )
- spriteRep.dispose();
-
- canvas = null;
- referenceGraphics = null;
- spriteRep = null;
-
- super.dispose();
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XCustomSprite impl
- // ==================
- //
-
- public synchronized void setPriority( double nPriority )
- {
- // TODO
- }
-
- public synchronized void setAlpha( double _alpha )
- {
- CanvasUtils.printLog( "CanvasCustomSprite.setAlpha() called" );
-
- alpha = _alpha;
-
- if( spriteRep != null )
- {
- spriteRep.setSpriteAlpha( alpha );
- }
- }
-
- public synchronized void move( RealPoint2D _aNewPos,
- ViewState _viewState,
- RenderState _renderState )
- {
- CanvasUtils.printLog( "CanvasCustomSprite.move() called" );
-
- // transform given point with concatenated transformation
- AffineTransform transform = CanvasUtils.ViewConcatRenderTransform( _viewState, _renderState );
- transform.transform( new java.awt.geom.Point2D.Double(_aNewPos.X,
- _aNewPos.Y),
- outputPosition );
-
- if( spriteRep != null )
- {
- spriteRep.moveSprite( outputPosition );
- }
- }
-
- public synchronized void transform( AffineMatrix2D aTransformation ) throws com.sun.star.lang.IllegalArgumentException
- {
- // TODO
- }
-
- public synchronized void clip( XPolyPolygon2D aClip )
- {
- // TODO
- }
-
- public synchronized void show()
- {
- CanvasUtils.printLog( "CanvasCustomSprite.show() called" );
-
- canvas.showSprite( this );
- canvas.updateScreen( false );
- }
-
- public synchronized void hide()
- {
- CanvasUtils.printLog( "CanvasCustomSprite.hide() called" );
-
- canvas.hideSprite( this );
-
- // do _not_ dispose clear SpriteRep, since we cannot actively
- // repaint ourselves
- }
-
- public synchronized com.sun.star.rendering.XCanvas getContentCanvas()
- {
- CanvasUtils.printLog( "CanvasCustomSprite.getContentCanvas() called" );
-
- return getSpriteRep().getContentCanvas();
- }
-
- //----------------------------------------------------------------------------------
-
- private static final String s_implName = "XCustomSprite.java.impl";
- private static final String s_serviceName = "com.sun.star.rendering.CustomSprite";
-
- //----------------------------------------------------------------------------------
-
- //
- // XServiceInfo impl
- // =================
- //
- public String getImplementationName()
- {
- return s_implName;
- }
-
- public String [] getSupportedServiceNames()
- {
- return new String [] { s_serviceName };
- }
-
- public boolean supportsService( String serviceName )
- {
- return serviceName.equals( s_serviceName );
- }
-}
diff --git a/canvas/source/java/CanvasFont.java b/canvas/source/java/CanvasFont.java
deleted file mode 100644
index 1ca2cc1aa3ec..000000000000
--- a/canvas/source/java/CanvasFont.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Canvas
-import com.sun.star.rendering.*;
-
-public class CanvasFont
- extends com.sun.star.lib.uno.helper.ComponentBase
- implements com.sun.star.lang.XServiceInfo,
- com.sun.star.rendering.XCanvasFont
-{
- private CanvasBase associatedCanvas;
- private com.sun.star.rendering.FontRequest fontRequest;
- private java.awt.Font font;
-
- //----------------------------------------------------------------------------------
-
- public CanvasFont( com.sun.star.rendering.FontRequest _fontRequest,
- CanvasBase _canvas )
- {
- associatedCanvas = _canvas;
- fontRequest = _fontRequest;
-
- // TODO: Use proper attributes here, first of all, use fractional point font size
- font = new java.awt.Font( fontRequest.FontDescription.FamilyName, java.awt.Font.PLAIN, (int)(fontRequest.CellSize + .5) );
- }
-
- public java.awt.Font getFont()
- {
- return font;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XCanvasFont implementation
- // ===========================
- //
-
- public XTextLayout createTextLayout( StringContext aText, byte nDirection, long nRandomSeed )
- {
- return new TextLayout( aText, nDirection, nRandomSeed, this, associatedCanvas );
- }
-
- public FontRequest getFontRequest( )
- {
- return fontRequest;
- }
-
- public FontMetrics getFontMetrics( )
- {
- // TODO
- return null;
- }
-
- public double[] getAvailableSizes( )
- {
- // TODO
- return null;
- }
-
- public com.sun.star.beans.PropertyValue[] getExtraFontProperties( )
- {
- // TODO
- return null;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XServiceInfo impl
- // =================
- //
-
- private static final String s_implName = "CanvasFont.java.impl";
- private static final String s_serviceName = "com.sun.star.rendering.XCanvasFont";
-
- public String getImplementationName()
- {
- return s_implName;
- }
-
- public String [] getSupportedServiceNames()
- {
- return new String [] { s_serviceName };
- }
-
- public boolean supportsService( String serviceName )
- {
- return serviceName.equals( s_serviceName );
- }
-}
diff --git a/canvas/source/java/CanvasGraphicDevice.java b/canvas/source/java/CanvasGraphicDevice.java
deleted file mode 100644
index c521d627f1a9..000000000000
--- a/canvas/source/java/CanvasGraphicDevice.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Canvas
-import com.sun.star.rendering.*;
-import com.sun.star.geometry.*;
-
-// Java AWT
-import java.awt.*;
-
-public class CanvasGraphicDevice
- extends com.sun.star.lib.uno.helper.ComponentBase
- implements com.sun.star.lang.XServiceInfo,
- com.sun.star.beans.XPropertySet,
- com.sun.star.rendering.XGraphicDevice
-{
- private java.awt.Graphics2D graphics;
- private java.awt.GraphicsConfiguration graphicsConfig;
-
- //----------------------------------------------------------------------------------
-
- public CanvasGraphicDevice( java.awt.Graphics2D _graphics )
- {
- graphics = _graphics;
- graphicsConfig = graphics.getDeviceConfiguration();
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // GraphicsDevice implementation
- // =============================
- //
- public synchronized XBufferController getBufferController()
- {
- // Use java.awt.image.BufferStrategy to implement XBufferController
- CanvasUtils.printLog( "CanvasGraphicDevice.getBufferController!" );
- return null;
- }
-
- public synchronized XColorSpace getDeviceColorSpace()
- {
- CanvasUtils.printLog( "CanvasGraphicDevice.getDeviceColorSpace!" );
- return null;
- }
-
- public synchronized com.sun.star.geometry.RealSize2D getPhysicalResolution()
- {
- CanvasUtils.printLog( "CanvasGraphicDevice.getPhysicalResolution!" );
- // TODO: getDefaultTransform + getNormalizingTransform
- return new com.sun.star.geometry.RealSize2D(100,100);
- }
-
- public synchronized com.sun.star.geometry.RealSize2D getPhysicalSize()
- {
- CanvasUtils.printLog( "CanvasGraphicDevice.getSize!" );
- java.awt.Rectangle bounds = graphicsConfig.getBounds();
-
- return new com.sun.star.geometry.RealSize2D(bounds.width, bounds.height);
- }
-
- public synchronized XLinePolyPolygon2D createCompatibleLinePolyPolygon( RealPoint2D[][] points )
- {
- CanvasUtils.printLog( "createCompatibleLinePolyPolygon" );
- return new LinePolyPolygon( points );
- }
-
- public synchronized XBezierPolyPolygon2D createCompatibleBezierPolyPolygon( RealBezierSegment2D[][] points )
- {
- CanvasUtils.printLog( "createCompatibleBezierPolyPolygon" );
- return new BezierPolyPolygon( points );
- }
-
- public synchronized com.sun.star.rendering.XBitmap createCompatibleBitmap( IntegerSize2D size )
- {
- CanvasUtils.printLog( "createCompatibleBitmap called with size (" + size.Width + ", " + size.Height + ")" );
- return new CanvasBitmap( graphicsConfig.createCompatibleImage( size.Width,
- size.Height,
- Transparency.OPAQUE ) );
- }
-
- public synchronized com.sun.star.rendering.XVolatileBitmap createVolatileBitmap( IntegerSize2D size )
- {
- CanvasUtils.printLog( "createVolatileBitmap called with size (" + size.Width + ", " + size.Height + ")" );
- //return new CanvasBitmap( graphicsConfig.createCompatibleVolatileImage( size.Width, size.Height ) );
- return null;
- }
-
- public synchronized com.sun.star.rendering.XBitmap createCompatibleAlphaBitmap( IntegerSize2D size )
- {
- CanvasUtils.printLog( "createCompatibleBitmap called with size (" + size.Width + ", " + size.Height + ")" );
- return new CanvasBitmap( graphicsConfig.createCompatibleImage( size.Width,
- size.Height,
- Transparency.TRANSLUCENT ) );
- }
-
- public synchronized com.sun.star.rendering.XVolatileBitmap createVolatileAlphaBitmap( IntegerSize2D size )
- {
- CanvasUtils.printLog( "createVolatileBitmap called with size (" + size.Width + ", " + size.Height + ")" );
- //return new CanvasBitmap( graphicsConfig.createCompatibleVolatileImage( size.Width, size.Height ) );
- return null;
- }
-
- public synchronized com.sun.star.rendering.XParametricPolyPolygon2DFactory getParametricPolyPolygonFactory()
- {
- // TODO
- return null;
- }
-
- public synchronized com.sun.star.beans.XPropertySetInfo getPropertySetInfo()
- {
- // This is a stealth property set
- return null;
- }
-
- public synchronized void setPropertyValue( String aPropertyName, java.lang.Object aValue ) throws com.sun.star.beans.PropertyVetoException
- {
- // all our properties are read-only
- throw new com.sun.star.beans.PropertyVetoException();
- }
-
- public synchronized java.lang.Object getPropertyValue( String PropertyName ) throws com.sun.star.beans.UnknownPropertyException
- {
- if( PropertyName == "DeviceHandle" )
- return graphics;
-
- throw new com.sun.star.beans.UnknownPropertyException();
- }
-
- public synchronized void addPropertyChangeListener( String aPropertyName, com.sun.star.beans.XPropertyChangeListener xListener ) throws com.sun.star.beans.UnknownPropertyException
- {
- if( aPropertyName == "DeviceHandle" )
- return;
-
- throw new com.sun.star.beans.UnknownPropertyException();
- }
-
- public synchronized void removePropertyChangeListener( String aPropertyName, com.sun.star.beans.XPropertyChangeListener aListener ) throws com.sun.star.beans.UnknownPropertyException
- {
- if( aPropertyName == "DeviceHandle" )
- return;
-
- throw new com.sun.star.beans.UnknownPropertyException();
- }
-
- public synchronized void addVetoableChangeListener( String PropertyName, com.sun.star.beans.XVetoableChangeListener aListener ) throws com.sun.star.beans.UnknownPropertyException
- {
- if( PropertyName == "DeviceHandle" )
- return;
-
- throw new com.sun.star.beans.UnknownPropertyException();
- }
-
- public synchronized void removeVetoableChangeListener( String PropertyName, com.sun.star.beans.XVetoableChangeListener aListener ) throws com.sun.star.beans.UnknownPropertyException
- {
- if( PropertyName == "DeviceHandle" )
- return;
-
- throw new com.sun.star.beans.UnknownPropertyException();
- }
-
-
- public synchronized boolean hasFullScreenMode()
- {
- return graphicsConfig.getDevice().isFullScreenSupported();
- }
-
- public synchronized boolean enterFullScreenMode( boolean bEnter )
- {
- return false;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XServiceInfo impl
- // =================
- //
-
- private static final String s_implName = "XGraphicsDevice.java.impl";
- private static final String s_serviceName = "com.sun.star.rendering.GraphicsDevice";
-
- public String getImplementationName()
- {
- return s_implName;
- }
-
- public String [] getSupportedServiceNames()
- {
- return new String [] { s_serviceName };
- }
-
- public boolean supportsService( String serviceName )
- {
- return serviceName.equals( s_serviceName );
- }
-
-}
diff --git a/canvas/source/java/CanvasSprite.java b/canvas/source/java/CanvasSprite.java
deleted file mode 100644
index 9b2cfc0debad..000000000000
--- a/canvas/source/java/CanvasSprite.java
+++ /dev/null
@@ -1,308 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Canvas
-import com.sun.star.rendering.*;
-import com.sun.star.geometry.*;
-
-// Java AWT
-import java.awt.*;
-import java.awt.geom.*;
-
-public class CanvasSprite
- extends com.sun.star.lib.uno.helper.ComponentBase
- implements com.sun.star.rendering.XAnimatedSprite,
- com.sun.star.lang.XServiceInfo,
- SpriteBase
-{
- private XAnimation spriteAnimation;
- private JavaCanvas canvas;
- private Graphics2D referenceGraphics;
- private SpriteRunner runner;
- private ViewState viewState;
- private double alpha;
- private java.awt.geom.Point2D.Double outputPosition;
- private SpriteRep spriteRep;
-
- //----------------------------------------------------------------------------------
-
- public CanvasSprite( XAnimation _animation, JavaCanvas _canvas, Graphics2D _referenceGraphics )
- {
- CanvasUtils.printLog( "CanvasSprite constructor called!" );
-
- spriteAnimation = _animation;
- canvas = _canvas;
- referenceGraphics = _referenceGraphics;
- alpha = 0.0;
- outputPosition = new java.awt.geom.Point2D.Double(0.0,0.0);
-
- runner = new SpriteRunner( this, spriteAnimation, canvas );
- }
-
- public synchronized ViewState getViewState()
- {
- return viewState;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // SpriteBase
- // ==========
- //
- public synchronized SpriteRep getSpriteRep()
- {
- if( spriteRep == null )
- {
- spriteRep = new SpriteRep();
-
- setupSpriteBuffering( CanvasUtils.makeTransform( getViewState().AffineTransform ) );
-
- spriteRep.moveSprite( outputPosition );
- spriteRep.setSpriteAlpha( alpha );
-
- // render initial sprite content
- updateAnimation();
- }
- return spriteRep;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XComponent
- // ==========
- //
- public void dispose()
- {
- // end the animation thread
- if( runner != null )
- {
- runner.quit();
- try
- {
- runner.join(0); // and wait until it's really over
- }
- catch( java.lang.InterruptedException e ) {}
- }
-
- if( spriteRep != null )
- spriteRep.dispose();
-
- canvas = null;
- spriteAnimation = null;
- runner = null;
- referenceGraphics = null;
- spriteRep = null;
-
- super.dispose();
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XSprite impl
- // ============
- //
-
- public synchronized void startAnimation( double speed )
- {
- runner.startAnimation( speed );
- }
-
- public synchronized void stopAnimation()
- {
- runner.stopAnimation();
- }
-
- public synchronized void resetAnimation()
- {
- runner.resetAnimation();
- }
-
- public synchronized void updateAnimation()
- {
- // only call render explicitely, if animation not
- // running. Otherwise, next animation render will update
- // anyway.
- if( spriteRep != null &&
- !runner.isAnimationActive() )
- {
- spriteRep.renderAnimation( spriteAnimation, getViewState(), runner.getCurrentT() );
- }
- }
-
- public synchronized void setPriority( double nPriority )
- {
- // TODO
- }
-
- public synchronized void setAlpha( double _alpha )
- {
- alpha = _alpha;
-
- if( spriteRep != null )
- {
- spriteRep.setSpriteAlpha( alpha );
- }
- }
-
- public synchronized void move( com.sun.star.geometry.RealPoint2D _aNewPos,
- com.sun.star.rendering.ViewState _viewState,
- com.sun.star.rendering.RenderState _renderState )
- {
- // transform given point with concatenated transformation
- AffineTransform transform = CanvasUtils.ViewConcatRenderTransform( _viewState, _renderState );
- transform.transform( new java.awt.geom.Point2D.Double(_aNewPos.X,
- _aNewPos.Y),
- outputPosition );
-
- if( spriteRep != null )
- {
- spriteRep.moveSprite( outputPosition );
- }
- }
-
- public synchronized void transform( AffineMatrix2D aTransformation ) throws com.sun.star.lang.IllegalArgumentException
- {
- // TODO
- }
-
- public synchronized void clip( XPolyPolygon2D aClip )
- {
- // TODO
- }
-
- public synchronized void show()
- {
- canvas.showSprite( this );
- canvas.updateScreen( false );
- }
-
- public synchronized void hide()
- {
- canvas.hideSprite( this );
-
- // dispose and clear SpriteRep, animation content can be
- // regenerated at any time
- if( spriteRep != null )
- spriteRep.dispose();
-
- spriteRep = null;
- }
-
- public synchronized void setViewState( ViewState _viewState )
- {
- viewState = CanvasUtils.createAnimationViewState(_viewState,
- getAnimationAttributes());
-
- CanvasUtils.printTransform( CanvasUtils.makeTransform( viewState.AffineTransform ),
- "CanvasSprite.setViewState" );
-
- if( spriteRep != null )
- {
- // calculate bounds of view-transformed animation output rectangle
- setupSpriteBuffering( CanvasUtils.makeTransform(getViewState().AffineTransform) );
- updateAnimation();
- }
- }
-
- public synchronized AnimationAttributes getAnimationAttributes()
- {
- return spriteAnimation.getAnimationAttributes();
- }
-
- public synchronized void setAll( RealPoint2D _aNewPos,
- ViewState _viewState,
- RenderState _renderState,
- double _alpha,
- boolean bUpdateAnimation )
- {
- alpha = _alpha;
-
- // transform given point with concatenated transformation
- AffineTransform transform = CanvasUtils.ViewConcatRenderTransform( _viewState, _renderState );
- transform.transform( new java.awt.geom.Point2D.Double(_aNewPos.X,
- _aNewPos.Y),
- outputPosition );
-
- if( spriteRep != null )
- {
- spriteRep.setSpriteAlpha( alpha );
- spriteRep.moveSprite( outputPosition );
-
- if( bUpdateAnimation )
- updateAnimation();
- }
- }
-
- //----------------------------------------------------------------------------------
-
- private void setupSpriteBuffering( AffineTransform _viewTransform )
- {
- // determine bounds of view-transformed animation output rectangle
- com.sun.star.geometry.RealSize2D animSize = getAnimationAttributes().UntransformedSize;
-
- java.awt.geom.Rectangle2D.Double aTransformedBounds =
- CanvasUtils.calcTransformedRectBounds( new java.awt.geom.Rectangle2D.Double(0.0,0.0,
- animSize.Width,
- animSize.Height),
- _viewTransform );
- CanvasUtils.printTransform( _viewTransform, "setupSpriteBuffering" );
- CanvasUtils.printLog( "setupSpriteBuffering: bounds are (" + aTransformedBounds.width + ", " + aTransformedBounds.height + ")" );
-
- // create a buffer of the appropriate size
- spriteRep.setupBuffer(referenceGraphics, (int)(aTransformedBounds.width+.5),
- (int)(aTransformedBounds.height+.5) );
- }
-
- //----------------------------------------------------------------------------------
-
- private static final String s_implName = "XSprite.java.impl";
- private static final String s_serviceName = "com.sun.star.rendering.Sprite";
-
- //----------------------------------------------------------------------------------
-
- //
- // XServiceInfo impl
- // =================
- //
- public String getImplementationName()
- {
- return s_implName;
- }
-
- public String [] getSupportedServiceNames()
- {
- return new String [] { s_serviceName };
- }
-
- public boolean supportsService( String serviceName )
- {
- return serviceName.equals( s_serviceName );
- }
-}
diff --git a/canvas/source/java/CanvasTest_perftest.java b/canvas/source/java/CanvasTest_perftest.java
deleted file mode 100644
index 047c9de3b16b..000000000000
--- a/canvas/source/java/CanvasTest_perftest.java
+++ /dev/null
@@ -1,676 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// UNO
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.XComponentContext;
-import com.sun.star.uno.AnyConverter;
-import com.sun.star.uno.IQueryInterface;
-import com.sun.star.lang.XInitialization;
-import com.sun.star.lib.uno.helper.WeakBase;
-
-// OOo AWT
-import com.sun.star.awt.*;
-
-// Canvas
-import com.sun.star.rendering.*;
-
-// Java AWT
-import java.awt.*;
-import java.awt.image.*;
-import java.awt.geom.*;
-
-public class CanvasTest
- extends CanvasBase
- implements com.sun.star.awt.XWindow,
- com.sun.star.rendering.XSpriteCanvas,
- com.sun.star.lang.XServiceInfo,
- com.sun.star.lang.XInitialization
-{
- private WindowAdapter dummyFrame;
- private BackBuffer backBuffer;
- private java.awt.image.BufferStrategy bufferStrategy;
-
- private java.awt.Font fpsFont;
- private long lastTime;
-
-
- // TEST ONLY {
- private static int testWidth = 1600;
- private static int testHeight = 1200;
- private BufferedImage backgroundBuffer;
- private BufferedImage buffer;
- private BufferedImage buffer2;
- private Graphics2D backBufGraphics;
- private Graphics2D bufferGraphics;
- private Graphics2D buffer2Graphics;
- private float currAlpha;
- // TEST ONLY }
-
-
-
- public Graphics2D getGraphics()
- {
- return backBuffer.getGraphics();
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XInitialization
- // ===============
- //
- public void initialize( java.lang.Object[] arguments )
- {
- CanvasUtils.printLog( "CanvasTest.initialize called!" );
-
- // Do that as the very first thing. The Java2D internal
- // classes choose their render path at initialization time,
- // thus this must happen before doing _any_ GUI.
-
- // TODO: Put those flags into javarc/java.ini, we're maybe
- // coming late into a running JVM!
-
- // now, we're getting slightly system dependent here.
- String os = (String) System.getProperty("os.name");
-
- CanvasUtils.printLog( "System detected: " + os );
-
- // tweak some speed knobs...
- if( os.startsWith("Windows") )
- {
- System.setProperty("sun.java2d.translaccel", "true");
- System.setProperty("sun.java2d.ddforcevram", "true");
- //System.setProperty("sun.java2d.accthreshold", "0");
-
- CanvasUtils.printLog( "Optimizing for Windows" );
- }
- else
- {
- System.setProperty("sun.java2d.opengl", "true");
-
- CanvasUtils.printLog( "Optimizing for Unix" );
- }
-
- /* we're initialized with the following array of anys:
-
- arguments[0] = pointer to VCL window
- arguments[1] = Integer (operating system window handle)
- arguments[2] = com.sun.star.awt.Rectangle (position and size within that OS window)
- arguments[3] = boolean (fullsize window or not)
-
- We then generate a dummy Java frame with that window as the
- parent, to fake a root window for the Java implementation.
- */
- try
- {
- com.sun.star.awt.Rectangle boundRect = (com.sun.star.awt.Rectangle) arguments[2];
-
- //boolean isFullScreen = arguments[1];
- boolean isFullScreen = true;
- //AnyConverter.toBoolean( arguments[3] ) );
-
- // fake a root for Java in VCL window. Pass the flag
- // whether we shall run fullscreen, too.
- dummyFrame = new WindowAdapter( AnyConverter.toInt( arguments[1] ), isFullScreen );
-
- if( isFullScreen )
- {
- // blow window up to fullscreen. Otherwise, we cannot clear the whole screen,
- // which results in ugly flickering
- Dimension screenSize = dummyFrame.frame.getToolkit().getScreenSize();
- boundRect.X = 0;
- boundRect.Y = 0;
- boundRect.Width = screenSize.width-1;
- boundRect.Height = screenSize.height-1;
- }
-
- dummyFrame.setPosSize( boundRect.X, boundRect.Y, boundRect.Width, boundRect.Height, (short)0 );
- CanvasUtils.printLog( "Window size: " + boundRect.Width + ", " + boundRect.Height );
-
- // TEST
- if( true )
- {
- backBuffer = new BackBuffer( (Graphics2D) dummyFrame.frame.getGraphics(),
- Math.max(1,boundRect.Width),
- Math.max(1,boundRect.Height) );
- }
- else
- {
- backBuffer = new BackBuffer( (Graphics2D) dummyFrame.frame.getGraphics(),
- 10, 10 );
- }
-
- // TODO: Maybe delay double buffer init until first sprite creation
- dummyFrame.frame.createBufferStrategy(2);
- bufferStrategy = dummyFrame.frame.getBufferStrategy();
-
- if( bufferStrategy.getCapabilities().isPageFlipping() )
- CanvasUtils.printLog( "CanvasTest.initialize double buffering is using page flipping!" );
- else
- CanvasUtils.printLog( "CanvasTest.initialize double buffering is using blitting!" );
-
- lastTime = System.currentTimeMillis();
- fpsFont = new java.awt.Font( "Times", Font.PLAIN, 20 );
-
-
- if( false )
- {
- // TEST ONLY {
- Graphics2D frameGraphics= (Graphics2D) dummyFrame.frame.getGraphics();
- backgroundBuffer = frameGraphics.getDeviceConfiguration().createCompatibleImage(testWidth,testHeight); // TODO: size dynamic
- buffer = frameGraphics.getDeviceConfiguration().createCompatibleImage(testWidth,testHeight,
- Transparency.TRANSLUCENT);
- buffer2 = frameGraphics.getDeviceConfiguration().createCompatibleImage(testWidth,testHeight,
- Transparency.TRANSLUCENT);
- bufferGraphics = (Graphics2D)buffer.getGraphics();
- buffer2Graphics = (Graphics2D)buffer2.getGraphics();
- backBufGraphics = (Graphics2D)backgroundBuffer.getGraphics();
- currAlpha = 0.1f;
-
- // init content
- Font font = new Font( "Times", Font.PLAIN, 100 );
-
- bufferGraphics.setComposite( AlphaComposite.getInstance(AlphaComposite.CLEAR));
- bufferGraphics.fillRect( 0,0,testWidth,testHeight );
-
- bufferGraphics.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
- bufferGraphics.setColor( Color.red );
- bufferGraphics.fillRect( 0,0,testWidth/2,testHeight/2 );
- bufferGraphics.setColor( Color.green );
- bufferGraphics.fillRect( testWidth/2,0,testWidth,testHeight/2 );
- bufferGraphics.setColor( Color.blue );
- bufferGraphics.fillRect( 0,testHeight/2,testWidth/2,testHeight );
-
- buffer2Graphics.setColor( Color.red );
- buffer2Graphics.fillRect( 0,0,testWidth/2,testHeight/2 );
- buffer2Graphics.setColor( Color.green );
- buffer2Graphics.fillRect( testWidth/2,0,testWidth,testHeight/2 );
- buffer2Graphics.setColor( Color.blue );
- buffer2Graphics.fillRect( 0,testHeight/2,testWidth/2,testHeight );
-
- backBufGraphics.setColor( Color.white );
- backBufGraphics.fillRect(0,0,testWidth,testHeight);
- backBufGraphics.setColor( Color.red );
- backBufGraphics.setFont( font );
- int i, turns=15;
- for(i=0; i<turns; ++i)
- {
- backBufGraphics.drawString( "Crossfade test", testWidth*i/turns, testHeight*i/turns );
- }
- // TEST ONLY }
- }
-
- CanvasUtils.printLog( "CanvasTest.initialize finished!" );
- }
- catch( com.sun.star.lang.IllegalArgumentException e )
- {
- CanvasUtils.printLog( "Cannot create EmbeddedFrame within VCL window hierarchy!" );
- }
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XComponent
- // ==========
- //
- public void dispose()
- {
- CanvasUtils.printLog( "CanvasTest: disposed!" );
-
- // destroy all active sprites
- java.util.Set entries = activeSprites.entrySet();
- java.util.Iterator iter = entries.iterator();
-
- while( iter.hasNext() )
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)iter.next();
- if( entry.getValue() != null )
- ((SpriteRep)entry.getValue()).dispose();
- }
-
- if( bufferStrategy != null )
- bufferStrategy.getDrawGraphics().dispose(); // really necessary?
-
- if( dummyFrame != null )
- dummyFrame.dispose();
-
- if( backBuffer != null)
- backBuffer.dispose();
-
- bufferStrategy = null;
- dummyFrame = null;
- backBuffer = null;
-
- super.dispose();
- }
-
- //----------------------------------------------------------------------------------
-
- public CanvasTest( XComponentContext xContext )
- {
- CanvasUtils.printLog( "CanvasTest constructor called!" );
- activeSprites = new java.util.HashMap( 33 );
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XWindow interface
- // =================
- //
- // This is delegated to WindowAdapter!
- //
- public synchronized void setPosSize( int X, int Y, int Width, int Height, short Flags )
- {
- if( dummyFrame != null )
- {
- dummyFrame.setPosSize( X, Y, Width, Height, Flags );
-
- Width = Math.max(1,Width);
- Height= Math.max(1,Height);
-
- CanvasUtils.printLog( "CanvasTest graphics set to " + Width + "," + Height );
- backBuffer.setSize(Width,Height);
- }
- }
-
- public synchronized com.sun.star.awt.Rectangle getPosSize( )
- {
- if( dummyFrame != null )
- return dummyFrame.getPosSize();
-
- return new com.sun.star.awt.Rectangle();
- }
-
- public synchronized void setVisible( boolean visible )
- {
- if( dummyFrame != null )
- dummyFrame.setVisible( visible );
- }
-
- public synchronized void setEnable( boolean enable )
- {
- if( dummyFrame != null )
- dummyFrame.setEnable( enable );
- }
-
- public synchronized void setFocus()
- {
- if( dummyFrame != null )
- dummyFrame.setFocus();
- }
-
- public synchronized void addWindowListener( XWindowListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addWindowListener( xListener );
- }
-
- public synchronized void removeWindowListener( XWindowListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removeWindowListener( xListener );
- }
-
- public synchronized void addFocusListener( XFocusListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addFocusListener( xListener );
- }
-
- public synchronized void removeFocusListener( XFocusListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removeFocusListener( xListener );
- }
-
- public synchronized void addKeyListener( XKeyListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addKeyListener( xListener );
- }
-
- public synchronized void removeKeyListener( XKeyListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removeKeyListener( xListener );
- }
-
- public synchronized void addMouseListener( XMouseListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addMouseListener( xListener );
- }
-
- public synchronized void removeMouseListener( XMouseListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removeMouseListener( xListener );
- }
-
- public synchronized void addMouseMotionListener( XMouseMotionListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addMouseMotionListener( xListener );
- }
-
- public synchronized void removeMouseMotionListener( XMouseMotionListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removeMouseMotionListener( xListener );
- }
-
- public synchronized void addPaintListener( XPaintListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addPaintListener( xListener );
- }
-
- public synchronized void removePaintListener( XPaintListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removePaintListener( xListener );
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XBitmapCanvas impl
- // ==================
- //
-
- public synchronized void copyRect( com.sun.star.rendering.XBitmapCanvas sourceCanvas,
- com.sun.star.rendering.Rectangle2D sourceRect,
- com.sun.star.rendering.ViewState sourceViewState,
- com.sun.star.rendering.RenderState sourceRenderState,
- com.sun.star.rendering.Rectangle2D destRect,
- com.sun.star.rendering.ViewState destViewState,
- com.sun.star.rendering.RenderState destRenderState )
- {
- CanvasUtils.printLog( "CanvasTest.copyRect() called" );
-
- // TODO: create temp image when transform is non-trivial
-
- if( sourceCanvas == this )
- {
- // copy rectangle within the canvas
- getGraphics().copyArea((int)sourceRect.x1,
- (int)sourceRect.y1,
- (int)(sourceRect.x2 - sourceRect.x1),
- (int)(sourceRect.y2 - sourceRect.y1),
- (int)(destRect.x1 - sourceRect.x1),
- (int)(destRect.y1 - sourceRect.y1) );
- }
- else
- {
- if( sourceCanvas instanceof CanvasTest )
- {
- // cache
- CanvasUtils.setupGraphicsState( getGraphics(), destViewState, destRenderState, CanvasUtils.alsoSetupPaint );
-
- java.awt.Image backBuffer = ((CanvasTest)sourceCanvas).backBuffer.getBackBuffer();
-
- // TODO: really extract correct source rect here
- getGraphics().drawImage( backBuffer, 0, 0, null);
- CanvasUtils.postRenderImageTreatment( backBuffer );
- }
- // TODO: foreign canvas
- }
- }
-
- //----------------------------------------------------------------------------------
-
- // a map of SpriteReps, with Sprite object as keys. Contains all
- // active (i.e. visible) sprites, the SpriteReps are used to
- // repaint the sprite content at any time.
- private java.util.HashMap activeSprites;
-
- //
- // XSpriteCanvas impl
- // ==================
- //
-
- public synchronized com.sun.star.rendering.XAnimatedSprite createSpriteFromAnimation( XAnimation animation )
- {
- CanvasUtils.printLog( "CanvasTest.createSpriteFromAnimation called" );
-
- return new CanvasSprite( animation, this, (Graphics2D)dummyFrame.frame.getGraphics() );
- }
-
- public synchronized XAnimatedSprite createSpriteFromBitmaps( com.sun.star.rendering.XBitmap[] animationBitmaps,
- short interpolationMode )
- {
- return null;
- }
-
- public synchronized XCustomSprite createCustomSprite( Size2D spriteSize )
- {
- CanvasUtils.printLog( "CanvasTest.createCustomSprite called" );
-
- return new CanvasCustomSprite( spriteSize, this, (Graphics2D)dummyFrame.frame.getGraphics() );
- }
-
- public synchronized XSprite createClonedSprite( XSprite original )
- {
- return new CanvasClonedSprite( this, original );
- }
-
- public synchronized void updateScreen()
- {
- redrawAllLayers();
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XSpriteCanvas helper
- // ====================
- //
- public synchronized void renderAnimation( CanvasSprite sprite, XAnimation animation, double t )
- {
- SpriteRep spriteRep = (SpriteRep)activeSprites.get( sprite );
- if( spriteRep != null )
- {
- //Graphics2D graph = getWindowGraphics();
-
- // TODO: ensure update of graphics object externally, e.g. when
- // VCL moves the toplevel window.
- //java.awt.Rectangle bounds = dummyFrame.frame.getBounds();
- //graphics.setGraphics(graph, bounds.width, bounds.height);
-
- spriteRep.renderAnimation( animation, sprite.getViewState(), t );
- }
- else
- {
- CanvasUtils.printLog( "CanvasTest.renderAnimation sprite not active!" );
- }
- }
-
- public synchronized void showSprite( SpriteBase sprite )
- {
- CanvasUtils.printLog( "CanvasTest.showSprite() called" );
-
- SpriteRep spriteRep = (SpriteRep)activeSprites.get( sprite );
- if( spriteRep != null )
- {
- CanvasUtils.printLog( "CanvasTest.showSprite sprite already active!" );
- }
- else
- {
- spriteRep = sprite.getSpriteRep();
-
- // a valid SpriteRep for a given Sprite in the
- // activeSprites hash denotes 'sprite active'
- activeSprites.put( sprite, spriteRep );
-
- // TODO: TEMP! Just for testing! Set empty cursor for presentation
-// dummyFrame.frame.setCursor( dummyFrame.frame.getToolkit().createCustomCursor(new java.awt.image.BufferedImage(0,0,
-// java.awt.image.BufferedImage.TYPE_INT_RGB),
-// new java.awt.Point(0,0),
-// "") );
- }
- }
-
- public synchronized void hideSprite( SpriteBase sprite )
- {
- CanvasUtils.printLog( "CanvasTest.hideSprite() called" );
-
- SpriteRep spriteRep = (SpriteRep)activeSprites.get( sprite );
- if( spriteRep != null )
- {
- activeSprites.put( sprite, null );
- redrawAllLayers();
- }
- else
- {
- CanvasUtils.printLog( "CanvasTest.hideSprite sprite not active!" );
- }
- }
-
- private void redrawAllLayers()
- {
- // fetch the Graphics object to draw into (we're doing double
- // buffering here, the content is later shown via
- // bufferStrategy.show().
- Graphics2D graph = null;
-
- try
- {
- graph = (Graphics2D)bufferStrategy.getDrawGraphics();
-
- GraphicsDevice device = graph.getDeviceConfiguration().getDevice();
- CanvasUtils.printLog( "Available vram: " + device.getAvailableAcceleratedMemory() );
-
- if( false )
- {
- // TEST ONLY {
- // repaint background
- graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER) );
- graph.drawImage(backgroundBuffer, 0, 0, null);
- //backgroundBuffer.flush();
-
- // alpha-composite foreground on top of that
- graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER, currAlpha) );
-
- graph.drawImage(buffer, 0, 0, null);
- //buffer.flush();
-
- currAlpha += 0.1f; if( currAlpha > 1.0 ) currAlpha = 0.1f;
- // TEST ONLY }
- }
-
- if( true )
- {
- // repaint background
- backBuffer.redraw( graph );
-
- // repaint all active sprites
- java.util.Set entries = activeSprites.entrySet();
- java.util.Iterator iter = entries.iterator();
- while( iter.hasNext() )
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)iter.next();
- if( entry.getValue() != null )
- ((SpriteRep)entry.getValue()).redraw(graph);
- }
- }
-
- long currTime = System.currentTimeMillis();
- graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER) );
- graph.setFont( fpsFont );
- graph.setColor( java.awt.Color.black );
-
- try
- {
- String fps = new String( String.valueOf(1000.0/(currTime-lastTime)) );
- graph.drawString( fps.substring(0,5) + " fps", 0, 20);
- CanvasUtils.printLog( fps.substring(0,5) + " fps" );
- }
- catch( Exception e )
- {
- graph.drawString( "0 fps", 0, 20);
- }
-
- lastTime = currTime;
- }
- finally
- {
- if( graph != null )
- graph.dispose();
- }
-
- bufferStrategy.show();
- }
-
- //----------------------------------------------------------------------------------
-
- private static final String s_implName = "XCanvas.java.impl";
- private static final String s_serviceName = "com.sun.star.rendering.Canvas";
-
- //----------------------------------------------------------------------------------
-
- //
- // XServiceInfo impl
- // =================
- //
- public synchronized String getImplementationName()
- {
- return s_implName;
- }
-
- public synchronized String [] getSupportedServiceNames()
- {
- return new String [] { s_serviceName };
- }
-
- public synchronized boolean supportsService( String serviceName )
- {
- return serviceName.equals( s_serviceName );
- }
-
- public static com.sun.star.lang.XSingleServiceFactory __getServiceFactory(
- String implName,
- com.sun.star.lang.XMultiServiceFactory multiFactory,
- com.sun.star.registry.XRegistryKey regKey )
- {
- if (implName.equals( s_implName ))
- {
- return com.sun.star.comp.loader.FactoryHelper.getServiceFactory(
- CanvasTest.class, s_serviceName, multiFactory, regKey );
- }
- return null;
- }
-
- public static boolean __writeRegistryServiceInfo(
- com.sun.star.registry.XRegistryKey regKey )
- {
- return com.sun.star.comp.loader.FactoryHelper.writeRegistryServiceInfo(
- s_implName, s_serviceName, regKey );
- }
-}
diff --git a/canvas/source/java/CanvasUtils.java b/canvas/source/java/CanvasUtils.java
deleted file mode 100644
index 8b2245176e03..000000000000
--- a/canvas/source/java/CanvasUtils.java
+++ /dev/null
@@ -1,627 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// UNO
-import com.sun.star.uno.UnoRuntime;
-
-// Canvas
-import com.sun.star.rendering.*;
-import com.sun.star.geometry.*;
-
-// Java AWT
-import java.awt.*;
-import java.awt.geom.*;
-
-public class CanvasUtils
-{
- //
- // Canvas utilities
- // ================
- //
- public static java.awt.geom.AffineTransform makeTransform( AffineMatrix2D ooTransform )
- {
- return new AffineTransform( ooTransform.m00,
- ooTransform.m10,
- ooTransform.m01,
- ooTransform.m11,
- ooTransform.m02,
- ooTransform.m12 );
- }
-
- public static AffineMatrix2D makeAffineMatrix2D( java.awt.geom.AffineTransform transform )
- {
- double[] matrix = new double[6];
- transform.getMatrix( matrix );
-
- return new AffineMatrix2D( matrix[0], matrix[2], matrix[4],
- matrix[1], matrix[3], matrix[5] );
- }
-
- public static void initGraphics( Graphics2D graphics )
- {
- if( graphics != null )
- {
- java.awt.RenderingHints hints = new java.awt.RenderingHints(null);
- boolean hq = true;
-
- if( hq )
- {
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_FRACTIONALMETRICS,
- java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_ON ) );
-// hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION,
-// java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY) );
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION,
- java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED) );
-// hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_INTERPOLATION,
-// java.awt.RenderingHints.VALUE_INTERPOLATION_BICUBIC) );
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_INTERPOLATION,
- java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR) );
-// hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_RENDERING,
-// java.awt.RenderingHints.VALUE_RENDER_QUALITY) );
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_RENDERING,
- java.awt.RenderingHints.VALUE_RENDER_SPEED) );
-// hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_STROKE_CONTROL,
-// java.awt.RenderingHints.VALUE_STROKE_NORMALIZE) );
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_STROKE_CONTROL,
- java.awt.RenderingHints.VALUE_STROKE_DEFAULT) );
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_ANTIALIASING,
- java.awt.RenderingHints.VALUE_ANTIALIAS_ON) );
- }
- else
- {
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION,
- java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED) );
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_INTERPOLATION,
- java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR) );
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_RENDERING,
- java.awt.RenderingHints.VALUE_RENDER_SPEED) );
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_STROKE_CONTROL,
- java.awt.RenderingHints.VALUE_STROKE_DEFAULT) );
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_ANTIALIASING,
- java.awt.RenderingHints.VALUE_ANTIALIAS_OFF) );
- }
-
- // the least common denominator standard
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_FRACTIONALMETRICS,
- java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_ON) );
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_TEXT_ANTIALIASING,
- java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON) );
-
- graphics.setRenderingHints( hints );
- }
- }
-
- //----------------------------------------------------------------------------------
-
- public static java.awt.geom.GeneralPath makeGenPathFromBezierPoints( RealBezierSegment2D [][] points )
- {
- java.awt.geom.GeneralPath path = new java.awt.geom.GeneralPath();
-
- // extract every polygon into GeneralPath object
- for( int i=0; i<points.length; ++i )
- {
- if( points[i].length > 0 )
- path.moveTo((float) points[i][0].Px, (float) points[i][0].Py);
-
- for( int j=1; j<points[i].length; ++j )
- {
- CanvasUtils.printLog( "makeGenPathFromBezierPoints: point added." );
- path.curveTo((float)(points[i][j-1].C1x), (float)(points[i][j-1].C1y),
- (float)(points[i][j-1].C2x), (float)(points[i][j-1].C2y),
- (float) points[i][j].Px, (float) points[i][j].Py );
- }
-
- // TODO: closePath?
- }
-
- return path;
- }
-
- public static java.awt.geom.GeneralPath makeGenPathFromBezierPoly( com.sun.star.rendering.XBezierPolyPolygon2D poly )
- {
- try
- {
- com.sun.star.geometry.RealBezierSegment2D [][] points = poly.getBezierSegments(0,-1,0,-1);
-
- return makeGenPathFromBezierPoints( points );
- }
- catch( com.sun.star.lang.IndexOutOfBoundsException e )
- {
- }
-
- return new java.awt.geom.GeneralPath();
- }
-
- public static java.awt.geom.GeneralPath makeGenPathFromLinePoints( RealPoint2D [][] points )
- {
- java.awt.geom.GeneralPath path = new java.awt.geom.GeneralPath();
-
- // extract every polygon into GeneralPath object
- for( int i=0; i<points.length; ++i )
- {
- if( points[i].length > 0 )
- path.moveTo((float) points[i][0].X, (float) points[i][0].Y);
-
- for( int j=1; j<points[i].length; ++j )
- {
- CanvasUtils.printLog( "makeGenPathFromLinePoints: point (" +
- points[i][j].X + "," + points[i][j].Y + ") added." );
- path.lineTo((float) points[i][j].X, (float) points[i][j].Y );
- }
-
- // TODO: closePath?
- }
-
- return path;
- }
-
- public static java.awt.geom.GeneralPath makeGenPathFromLinePoly( com.sun.star.rendering.XLinePolyPolygon2D poly )
- {
- try
- {
- com.sun.star.geometry.RealPoint2D [][] points = poly.getPoints(0,-1,0,-1);
-
- return makeGenPathFromLinePoints( points );
- }
- catch( com.sun.star.lang.IndexOutOfBoundsException e )
- {
- }
-
- return new java.awt.geom.GeneralPath();
- }
-
- public static java.awt.geom.GeneralPath makeGeneralPath( com.sun.star.rendering.XPolyPolygon2D poly )
- {
- if( poly instanceof BezierPolyPolygon )
- {
- CanvasUtils.printLog( "makeGeneralPath: bezier impl used." );
- return ((BezierPolyPolygon)poly).getJavaPath();
- }
-
- if( poly instanceof LinePolyPolygon )
- {
- CanvasUtils.printLog( "makeGeneralPath: line impl used." );
- return ((LinePolyPolygon)poly).getJavaPath();
- }
-
- XBezierPolyPolygon2D bezierPoly = (XBezierPolyPolygon2D) UnoRuntime.queryInterface(XBezierPolyPolygon2D.class, poly);
-
- if( bezierPoly != null )
- {
- // extract polygon data. Prefer bezier interface, because
- // that's the more high-level data.
- return makeGenPathFromBezierPoly( bezierPoly );
- }
-
- XLinePolyPolygon2D linePoly = (XLinePolyPolygon2D) UnoRuntime.queryInterface(XLinePolyPolygon2D.class, poly);
-
- if( linePoly != null )
- {
- // extract polygon data. Fallback to line polygon, if no
- // curves are available.
- return makeGenPathFromLinePoly( linePoly );
- }
-
- // Only opaque general interface. No chance to get to the
- // data. Empty path, then
- CanvasUtils.printLog( "makeGeneralPath: Cannot access polygon data, given interface has class" + poly.getClass().getName() );
- return new GeneralPath();
- }
-
- public static java.awt.image.BufferedImage getBufferedImage( com.sun.star.rendering.XBitmap bitmap )
- {
- if( bitmap instanceof CanvasBitmap )
- {
- CanvasUtils.printLog( "getBufferedImage: CanvasBitmap impl used." );
- return ((CanvasBitmap)bitmap).getBufferedImage();
- }
-
- XIntegerBitmap integerBitmap = (XIntegerBitmap) UnoRuntime.queryInterface(XIntegerBitmap.class, bitmap);
-
- if( integerBitmap != null )
- {
- // extract bitmap data. TODO.
- return null;
- }
-
- // check other types. TODO.
- return null;
- }
-
- public static byte [] int2byte( int [] input )
- {
- byte [] output = new byte[4*input.length];
-
- int i, j;
- for( i=0, j=0; i<input.length; ++i )
- {
- output[j] = (byte)(input[i] & 255);
- output[j+1] = (byte)((input[i]/256) & 255);
- output[j+2] = (byte)((input[i]/256/256) & 255);
- output[j+3] = (byte)((input[i]/256/256/256) & 255);
- j += 4;
- }
-
- return output;
- }
-
- public static int [] byte2int( byte [] input )
- {
- int [] output = new int[(input.length+3)/4];
-
- int i, j;
- for( i=0,j=0; j<output.length; ++j )
- {
- output[j] = input[i] + (input[i+1] + (input[i+2] + input[i+3]*256)*256)*256;
- i += 4;
- }
-
- return output;
- }
-
- public static int javaRuleFromCompositeOp( byte compositeOp )
- {
- // TODO: Finish mapping of Canvas and Java compositing magics
- int rule = java.awt.AlphaComposite.SRC_OVER;
- switch( compositeOp )
- {
- case com.sun.star.rendering.CompositeOperation.CLEAR:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: clear selected" );
- rule = java.awt.AlphaComposite.CLEAR;
- break;
-
- case com.sun.star.rendering.CompositeOperation.SOURCE:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: src selected" );
- rule = java.awt.AlphaComposite.SRC;
- break;
-
- case com.sun.star.rendering.CompositeOperation.DESTINATION:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: dst selected" );
- rule = java.awt.AlphaComposite.DST;
- break;
-
- case com.sun.star.rendering.CompositeOperation.OVER:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: over selected" );
- rule = java.awt.AlphaComposite.SRC_OVER;
- break;
-
- case com.sun.star.rendering.CompositeOperation.UNDER:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: under selected" );
- rule = java.awt.AlphaComposite.DST_OVER;
- break;
-
- case com.sun.star.rendering.CompositeOperation.INSIDE:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: inside selected" );
- rule = java.awt.AlphaComposite.CLEAR;
- break;
-
- case com.sun.star.rendering.CompositeOperation.INSIDE_REVERSE:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: inReverse selected" );
- rule = java.awt.AlphaComposite.CLEAR;
- break;
-
- case com.sun.star.rendering.CompositeOperation.OUTSIDE:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: outside selected" );
- rule = java.awt.AlphaComposite.CLEAR;
- break;
-
- case com.sun.star.rendering.CompositeOperation.OUTSIDE_REVERSE:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: outReverse selected" );
- rule = java.awt.AlphaComposite.CLEAR;
- break;
-
- case com.sun.star.rendering.CompositeOperation.XOR:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: xor selected" );
- rule = java.awt.AlphaComposite.CLEAR;
- break;
-
- case com.sun.star.rendering.CompositeOperation.ADD:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: add selected" );
- rule = java.awt.AlphaComposite.CLEAR;
- break;
-
- case com.sun.star.rendering.CompositeOperation.SATURATE:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: saturate selected" );
- rule = java.awt.AlphaComposite.CLEAR;
- break;
-
- default:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: Unexpected compositing rule" );
- break;
- }
-
- return rule;
- }
-
- public static java.awt.AlphaComposite makeAlphaComposite( byte compositeOp )
- {
- return java.awt.AlphaComposite.getInstance( javaRuleFromCompositeOp( compositeOp ) );
- }
-
- public static java.awt.AlphaComposite makeAlphaCompositeAlpha( byte compositeOp, double alpha )
- {
- return java.awt.AlphaComposite.getInstance( javaRuleFromCompositeOp( compositeOp ), (float)alpha );
- }
-
- // when given to setupGraphicsState, makes that method to also
- // setup the Paint with the color specified in the render state.
- public static final byte alsoSetupPaint=0;
-
- // when given to setupGraphicsState, makes that method to _not_
- // setup the Paint with the color specified in the render state.
- public static final byte dontSetupPaint=1;
-
- public static java.awt.geom.AffineTransform ViewConcatRenderTransform( ViewState viewState,
- RenderState renderState )
- {
- // calculate overall affine transform
- AffineTransform transform = makeTransform( viewState.AffineTransform );
- transform.concatenate( makeTransform( renderState.AffineTransform ) );
-
- printTransform( transform, "ViewConcatRenderTransform" );
-
- return transform;
- }
-
- public static void setupGraphicsState( java.awt.Graphics2D graphics,
- ViewState viewState,
- RenderState renderState,
- byte paintTouchMode )
- {
- // calculate overall affine transform
- graphics.setTransform( ViewConcatRenderTransform(viewState, renderState ) );
-
- // setup overall clip polyPolygon
- if( viewState.Clip != null )
- {
- Area clipArea = new Area( makeGeneralPath( viewState.Clip ) );
-
- if( renderState.Clip != null )
- clipArea.intersect( new Area( makeGeneralPath( renderState.Clip ) ) );
-
- graphics.setClip( clipArea );
- }
- else if( renderState.Clip != null )
- {
- Area clipArea = new Area( makeGeneralPath( renderState.Clip ) );
- graphics.setClip( clipArea );
- }
- else
- {
- // TODO: HACK! Use true visible area here!
- graphics.setClip( new java.awt.Rectangle(-1000000,-1000000,2000000,2000000) );
- }
-
- // setup current output color
- // TODO: Complete color handling here
- if( paintTouchMode == alsoSetupPaint )
- {
- switch( renderState.DeviceColor.length )
- {
- case 3:
- CanvasUtils.printLog( "setupGraphicsState: Color(" +
- renderState.DeviceColor[0] + "," +
- renderState.DeviceColor[1] + "," +
- renderState.DeviceColor[2] + ") set." );
- graphics.setColor( new Color( (float)renderState.DeviceColor[0],
- (float)renderState.DeviceColor[1],
- (float)renderState.DeviceColor[2] ) );
- break;
-
- case 4:
- CanvasUtils.printLog( "setupGraphicsState: Color(" +
- renderState.DeviceColor[0] + "," +
- renderState.DeviceColor[1] + "," +
- renderState.DeviceColor[2] + "," +
- renderState.DeviceColor[3] + ") set." );
- graphics.setColor( new Color( (float)renderState.DeviceColor[0],
- (float)renderState.DeviceColor[1],
- (float)renderState.DeviceColor[2],
- (float)renderState.DeviceColor[3] ) );
- break;
-
- default:
- CanvasUtils.printLog( "setupGraphicsState: unexpected number of " +
- renderState.DeviceColor.length + " color components!" );
- break;
- }
- }
-
- // setup current composite mode
- graphics.setComposite( makeAlphaComposite( renderState.CompositeOperation ) );
- }
-
- public static void applyStrokeAttributes( java.awt.Graphics2D graphics,
- StrokeAttributes attributes )
- {
- int cap = java.awt.BasicStroke.CAP_BUTT;
-
- if( attributes.StartCapType != attributes.EndCapType )
- CanvasUtils.printLog( "applyStrokeAttributes: different start and end caps are not yet supported!" );
-
- if( attributes.LineArray.length != 0 )
- CanvasUtils.printLog( "applyStrokeAttributes: multi-strokes are not yet supported!" );
-
- if( attributes.StartCapType == PathCapType.BUTT )
- cap = java.awt.BasicStroke.CAP_BUTT;
- else if( attributes.StartCapType == PathCapType.ROUND )
- cap = java.awt.BasicStroke.CAP_ROUND;
- else if( attributes.StartCapType == PathCapType.SQUARE )
- cap = java.awt.BasicStroke.CAP_SQUARE;
-
- int join = java.awt.BasicStroke.JOIN_MITER;
-
- if( attributes.JoinType == PathJoinType.MITER )
- cap = java.awt.BasicStroke.JOIN_MITER;
- else if( attributes.JoinType == PathJoinType.ROUND )
- cap = java.awt.BasicStroke.JOIN_ROUND;
- else if( attributes.JoinType == PathJoinType.BEVEL )
- cap = java.awt.BasicStroke.JOIN_BEVEL;
- else
- CanvasUtils.printLog( "applyStrokeAttributes: current join type not yet supported!" );
-
- float [] dashArray = null;
-
- if( attributes.DashArray.length != 0 )
- {
- dashArray = new float [attributes.DashArray.length];
-
- for( int i=0; i<attributes.DashArray.length; ++i )
- dashArray[i] = (float)attributes.DashArray[i];
- }
-
- graphics.setStroke( new java.awt.BasicStroke( (float)attributes.StrokeWidth,
- cap,
- join,
- (float)attributes.MiterLimit,
- dashArray,
- 0) );
- }
-
- public static void setupGraphicsFont( java.awt.Graphics2D graphics,
- ViewState viewState,
- RenderState renderState,
- com.sun.star.rendering.XCanvasFont xFont )
- {
- if( xFont instanceof CanvasFont )
- {
- CanvasUtils.printLog( "setupGraphicsFont: font impl used." );
- graphics.setFont( ((CanvasFont)xFont).getFont() );
- }
- else
- {
- CanvasUtils.printLog( "setupGraphicsFont: creating Java font anew." );
- CanvasFont canvasFont;
- canvasFont = new CanvasFont( xFont.getFontRequest(), null );
- graphics.setFont( canvasFont.getFont() );
- }
- }
-
- static java.awt.geom.Rectangle2D.Double calcTransformedRectBounds( java.awt.geom.Rectangle2D.Double aRect,
- AffineTransform aTransform )
- {
- // transform rect by given transformation
- java.awt.geom.Point2D.Double aPointTopLeft = new java.awt.geom.Point2D.Double(aRect.x, aRect.y);
- aTransform.transform(aPointTopLeft, aPointTopLeft);
-
- java.awt.geom.Point2D.Double aPointTopRight = new java.awt.geom.Point2D.Double(aRect.x + aRect.width,
- aRect.y);
- aTransform.transform(aPointTopRight, aPointTopRight);
-
- java.awt.geom.Point2D.Double aPointBottomLeft = new java.awt.geom.Point2D.Double(aRect.x,
- aRect.y + aRect.height);
- aTransform.transform(aPointBottomLeft, aPointBottomLeft);
-
- java.awt.geom.Point2D.Double aPointBottomRight = new java.awt.geom.Point2D.Double(aRect.x + aRect.width,
- aRect.y + aRect.height);
- aTransform.transform(aPointBottomRight, aPointBottomRight);
-
- // calc bounding rect of those four points
- java.awt.geom.Point2D.Double aResTopLeft = new java.awt.geom.Point2D.Double( Math.min(aPointTopLeft.x,
- Math.min(aPointTopRight.x,
- Math.min(aPointBottomLeft.x,aPointBottomRight.x))),
- Math.min(aPointTopLeft.y,
- Math.min(aPointTopRight.y,
- Math.min(aPointBottomLeft.y,aPointBottomRight.y))) );
-
- java.awt.geom.Point2D.Double aResBottomRight = new java.awt.geom.Point2D.Double( Math.max(aPointTopLeft.x,
- Math.max(aPointTopRight.x,
- Math.max(aPointBottomLeft.x,aPointBottomRight.x))),
- Math.max(aPointTopLeft.y,
- Math.max(aPointTopRight.y,
- Math.max(aPointBottomLeft.y,aPointBottomRight.y))) );
- return new java.awt.geom.Rectangle2D.Double( aResTopLeft.x, aResTopLeft.y,
- aResBottomRight.x - aResTopLeft.x,
- aResBottomRight.y - aResTopLeft.y );
- }
-
- // Create a corrected view transformation out of the give one,
- // which ensures that the rectangle given by (0,0) and
- // attributes.untransformedSize is mapped with its left,top corner
- // to (0,0) again. This is required to properly render sprite
- // animations to buffer bitmaps.
- public static ViewState createAnimationViewState( ViewState inputViewState,
- AnimationAttributes attributes )
- {
- // TODO: Properly respect clip here. Might have to be transformed, too.
-
- AffineTransform aViewTransform = makeTransform( inputViewState.AffineTransform );
-
- // transform Rect(0,0,attributes.untransformedSize) by
- // viewTransform
- java.awt.geom.Rectangle2D.Double aTransformedRect =
- calcTransformedRectBounds( new java.awt.geom.Rectangle2D.Double(0.0, 0.0,
- attributes.UntransformedSize.Width,
- attributes.UntransformedSize.Height),
- aViewTransform );
-
- printTransform( aViewTransform, "createAnimationViewState" );
-
- CanvasUtils.printLog( "createAnimationViewState: transformed origin is: (" + aTransformedRect.x + ", " + aTransformedRect.y + ")" );
-
- // now move resulting left,top point of bounds to (0,0)
- AffineTransform animationViewTransform = new AffineTransform();
- animationViewTransform.translate( -aTransformedRect.x, -aTransformedRect.y );
- animationViewTransform.concatenate( aViewTransform );
-
- printTransform( animationViewTransform, "createAnimationViewState" );
-
- return new ViewState( makeAffineMatrix2D( animationViewTransform ), inputViewState.Clip );
- }
-
- public static void postRenderImageTreatment( Image buffer )
- {
- // TODO: This is specific to Sun's JREs 1.4 and upwards. Make this more portable
- buffer.flush(); // as long as we force images to VRAM,
- // we need to flush them afterwards, to
- // avoid eating up all VRAM.
- }
-
- public static void printTransform( AffineTransform transform,
- String stringPrefix )
- {
- CanvasUtils.printLog( stringPrefix + ": Transform is" );
- double [] matrix = new double[6];
- transform.getMatrix(matrix);
- int i;
- for( i=0; i<6; ++i )
- System.err.print( matrix[i] + ", " );
- CanvasUtils.printLog( "" );
- }
-
- public static void preCondition( boolean bCondition,
- String methodName )
- {
- if( !bCondition )
- printLog("Precondition violated: " + methodName);
- }
-
- public static void printLog( String s )
- {
- System.err.println( s );
- }
-}
diff --git a/canvas/source/java/JavaCanvas.java b/canvas/source/java/JavaCanvas.java
deleted file mode 100644
index fbee763fc272..000000000000
--- a/canvas/source/java/JavaCanvas.java
+++ /dev/null
@@ -1,675 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// UNO
-import com.sun.star.uno.XComponentContext;
-import com.sun.star.uno.AnyConverter;
-
-// OOo AWT
-import com.sun.star.awt.*;
-
-// Canvas
-import com.sun.star.rendering.*;
-import com.sun.star.geometry.*;
-
-// Java AWT
-import java.awt.*;
-
-public class JavaCanvas
- extends CanvasBase
- implements com.sun.star.awt.XWindow,
- com.sun.star.rendering.XSpriteCanvas,
- com.sun.star.rendering.XIntegerBitmap,
- com.sun.star.lang.XServiceInfo,
- com.sun.star.lang.XInitialization
-{
- private WindowAdapter dummyFrame;
- public BackBuffer backBuffer;
- private java.awt.image.BufferStrategy bufferStrategy;
-
- private java.awt.Font fpsFont;
- private long lastTime;
- private com.sun.star.awt.Rectangle boundRect;
-
- public Graphics2D getGraphics()
- {
- return backBuffer.getGraphics();
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XInitialization
- // ===============
- //
- public void initialize( java.lang.Object[] arguments )
- {
- CanvasUtils.printLog( "JavaCanvas.initialize called!" );
-
- // Do that as the very first thing. The Java2D internal
- // classes choose their render path at initialization time,
- // thus this must happen before doing _any_ GUI.
-
- // TODO: Put those flags into javarc/java.ini, we're maybe
- // coming late into a running JVM!
-
- // now, we're getting slightly system dependent here.
- String os = (String) System.getProperty("os.name");
-
- CanvasUtils.printLog( "System detected: " + os );
-
- // tweak some speed knobs...
-// if( os.startsWith("Windows") )
-// {
-// System.setProperty("sun.java2d.translaccel", "true");
-// System.setProperty("sun.java2d.ddforcevram", "true");
-// //System.setProperty("sun.java2d.accthreshold", "0");
-
-// CanvasUtils.printLog( "Optimizing for Windows" );
-// }
-// else
-// {
-// System.setProperty("sun.java2d.opengl", "true");
-
-// CanvasUtils.printLog( "Optimizing for Unix" );
-// }
-
- /* we're initialized with the following array of anys:
-
- arguments[0] = pointer to VCL window
- arguments[1] = Integer (operating system window handle)
- arguments[2] = com.sun.star.awt.Rectangle (position and size within that OS window)
- arguments[3] = boolean (fullsize window or not)
-
- We then generate a dummy Java frame with that window as the
- parent, to fake a root window for the Java implementation.
- */
- try
- {
- boundRect = (com.sun.star.awt.Rectangle) arguments[2];
-
- //boolean isFullScreen = arguments[1];
- boolean isFullScreen = true;
- //AnyConverter.toBoolean( arguments[3] ) );
-
- // fake a root for Java in VCL window. Pass the flag
- // whether we shall run fullscreen, too.
- dummyFrame = new WindowAdapter( AnyConverter.toInt( arguments[1] ), isFullScreen );
-
- if( isFullScreen )
- {
- // blow window up to fullscreen. Otherwise, we cannot clear the whole screen,
- // which results in ugly flickering
- Dimension screenSize = dummyFrame.frame.getToolkit().getScreenSize();
- boundRect.X = 0;
- boundRect.Y = 0;
- boundRect.Width = screenSize.width-1;
- boundRect.Height = screenSize.height-1;
- }
-
- dummyFrame.setPosSize( boundRect.X, boundRect.Y, boundRect.Width, boundRect.Height, (short)0 );
- CanvasUtils.printLog( "Window size: " + boundRect.Width + ", " + boundRect.Height );
-
- backBuffer = new BackBuffer( (Graphics2D) dummyFrame.frame.getGraphics(),
- Math.max(1,boundRect.Width),
- Math.max(1,boundRect.Height) );
-
- // TODO: Maybe delay double buffer init until first sprite creation
- dummyFrame.frame.createBufferStrategy(2);
- bufferStrategy = dummyFrame.frame.getBufferStrategy();
-
- if( bufferStrategy.getCapabilities().isPageFlipping() )
- CanvasUtils.printLog( "JavaCanvas.initialize double buffering is using page flipping!" );
- else
- CanvasUtils.printLog( "JavaCanvas.initialize double buffering is using blitting!" );
-
- lastTime = System.currentTimeMillis();
- fpsFont = new java.awt.Font( "Times", Font.PLAIN, 20 );
-
- CanvasUtils.printLog( "JavaCanvas.initialize finished!" );
- }
- catch( com.sun.star.lang.IllegalArgumentException e )
- {
- CanvasUtils.printLog( "Cannot create EmbeddedFrame within VCL window hierarchy!" );
- }
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XComponent
- // ==========
- //
- public void dispose()
- {
- CanvasUtils.printLog( "JavaCanvas: disposed!" );
-
- // destroy all active sprites
- java.util.Set entries = activeSprites.entrySet();
- java.util.Iterator iter = entries.iterator();
-
- while( iter.hasNext() )
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)iter.next();
- if( entry.getValue() != null )
- ((SpriteRep)entry.getValue()).dispose();
- }
-
- if( bufferStrategy != null )
- bufferStrategy.getDrawGraphics().dispose(); // really necessary?
-
- if( dummyFrame != null )
- dummyFrame.dispose();
-
- if( backBuffer != null)
- backBuffer.dispose();
-
- bufferStrategy = null;
- dummyFrame = null;
- backBuffer = null;
-
- super.dispose();
- }
-
- //----------------------------------------------------------------------------------
-
- public JavaCanvas( XComponentContext xContext )
- {
- CanvasUtils.printLog( "JavaCanvas constructor called!" );
- activeSprites = new java.util.HashMap( 33 );
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XWindow interface
- // =================
- //
- // This is delegated to WindowAdapter!
- //
- public synchronized void setPosSize( int X, int Y, int Width, int Height, short Flags )
- {
- if( dummyFrame != null )
- {
- dummyFrame.setPosSize( X, Y, Width, Height, Flags );
-
- Width = Math.max(1,Width);
- Height= Math.max(1,Height);
-
- CanvasUtils.printLog( "JavaCanvas graphics set to " + Width + "," + Height );
- backBuffer.setSize(Width,Height);
- }
- }
-
- public synchronized com.sun.star.awt.Rectangle getPosSize( )
- {
- if( dummyFrame != null )
- return dummyFrame.getPosSize();
-
- return new com.sun.star.awt.Rectangle();
- }
-
- public synchronized void setVisible( boolean visible )
- {
- if( dummyFrame != null )
- dummyFrame.setVisible( visible );
- }
-
- public synchronized void setEnable( boolean enable )
- {
- if( dummyFrame != null )
- dummyFrame.setEnable( enable );
- }
-
- public synchronized void setFocus()
- {
- if( dummyFrame != null )
- dummyFrame.setFocus();
- }
-
- public synchronized void addWindowListener( XWindowListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addWindowListener( xListener );
- }
-
- public synchronized void removeWindowListener( XWindowListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removeWindowListener( xListener );
- }
-
- public synchronized void addFocusListener( XFocusListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addFocusListener( xListener );
- }
-
- public synchronized void removeFocusListener( XFocusListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removeFocusListener( xListener );
- }
-
- public synchronized void addKeyListener( XKeyListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addKeyListener( xListener );
- }
-
- public synchronized void removeKeyListener( XKeyListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removeKeyListener( xListener );
- }
-
- public synchronized void addMouseListener( XMouseListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addMouseListener( xListener );
- }
-
- public synchronized void removeMouseListener( XMouseListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removeMouseListener( xListener );
- }
-
- public synchronized void addMouseMotionListener( XMouseMotionListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addMouseMotionListener( xListener );
- }
-
- public synchronized void removeMouseMotionListener( XMouseMotionListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removeMouseMotionListener( xListener );
- }
-
- public synchronized void addPaintListener( XPaintListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addPaintListener( xListener );
- }
-
- public synchronized void removePaintListener( XPaintListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removePaintListener( xListener );
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XBitmapCanvas impl
- // ==================
- //
-
- public synchronized void copyRect( com.sun.star.rendering.XBitmapCanvas sourceCanvas,
- com.sun.star.geometry.RealRectangle2D sourceRect,
- com.sun.star.rendering.ViewState sourceViewState,
- com.sun.star.rendering.RenderState sourceRenderState,
- com.sun.star.geometry.RealRectangle2D destRect,
- com.sun.star.rendering.ViewState destViewState,
- com.sun.star.rendering.RenderState destRenderState )
- {
- CanvasUtils.printLog( "JavaCanvas.copyRect() called" );
-
- // TODO: create temp image when transform is non-trivial
-
- if( sourceCanvas == this )
- {
- // copy rectangle within the canvas
- getGraphics().copyArea((int)sourceRect.X1,
- (int)sourceRect.Y1,
- (int)(sourceRect.X2 - sourceRect.X1),
- (int)(sourceRect.Y2 - sourceRect.Y1),
- (int)(destRect.X1 - sourceRect.X1),
- (int)(destRect.Y1 - sourceRect.Y1) );
- }
- else
- {
- if( sourceCanvas instanceof JavaCanvas )
- {
- // cache
- CanvasUtils.setupGraphicsState( getGraphics(), destViewState, destRenderState, CanvasUtils.alsoSetupPaint );
-
- java.awt.Image backBuffer = ((JavaCanvas)sourceCanvas).backBuffer.getBackBuffer();
-
- // TODO: really extract correct source rect here
- getGraphics().drawImage( backBuffer, 0, 0, null);
- CanvasUtils.postRenderImageTreatment( backBuffer );
- }
- // TODO: foreign canvas
- }
- }
-
- //----------------------------------------------------------------------------------
-
- // a map of SpriteReps, with Sprite object as keys. Contains all
- // active (i.e. visible) sprites, the SpriteReps are used to
- // repaint the sprite content at any time.
- private java.util.HashMap activeSprites;
-
- //
- // XSpriteCanvas impl
- // ==================
- //
-
- public synchronized com.sun.star.rendering.XAnimatedSprite createSpriteFromAnimation( XAnimation animation )
- {
- CanvasUtils.printLog( "JavaCanvas.createSpriteFromAnimation called" );
-
- return new CanvasSprite( animation, this, (Graphics2D)dummyFrame.frame.getGraphics() );
- }
-
- public synchronized XAnimatedSprite createSpriteFromBitmaps( com.sun.star.rendering.XBitmap[] animationBitmaps,
- byte interpolationMode )
- {
- return null;
- }
-
- public synchronized XCustomSprite createCustomSprite( RealSize2D spriteSize )
- {
- CanvasUtils.printLog( "JavaCanvas.createCustomSprite called" );
-
- return new CanvasCustomSprite( spriteSize, this, (Graphics2D)dummyFrame.frame.getGraphics() );
- }
-
- public synchronized XSprite createClonedSprite( XSprite original )
- {
- return new CanvasClonedSprite( this, original );
- }
-
- public synchronized boolean updateScreen( boolean bUpdateAll )
- {
- redrawAllLayers();
-
- return true;
- }
-
- //
- // XBitmap implementation
- // ======================
- //
-
- public synchronized IntegerSize2D getSize()
- {
- return new IntegerSize2D( boundRect.Width,
- boundRect.Height );
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized XBitmapCanvas queryBitmapCanvas()
- {
- return this;
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized com.sun.star.rendering.XBitmap getScaledBitmap( RealSize2D newSize, boolean beFast ) throws com.sun.star.lang.IllegalArgumentException, VolatileContentDestroyedException
- {
- // TODO
- return null;
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized boolean hasAlpha()
- {
- // TODO
- return false;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XIntegerBitmap implementation
- // =============================
- //
-
- public synchronized byte[] getData( IntegerBitmapLayout[] bitmapLayout,
- IntegerRectangle2D rect )
- {
- // TODO
- return null;
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized void setData( byte[] data, IntegerBitmapLayout bitmapLayout, com.sun.star.geometry.IntegerRectangle2D rect )
- {
- // TODO
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized void setPixel( byte[] color, IntegerBitmapLayout bitmapLayout, com.sun.star.geometry.IntegerPoint2D pos )
- {
- // TODO
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized byte[] getPixel( IntegerBitmapLayout[] bitmapLayout,
- IntegerPoint2D pos )
- {
- // TODO
- return null;
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized XBitmapPalette getPalette()
- {
- // TODO
- return null;
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized IntegerBitmapLayout getMemoryLayout()
- {
- // TODO: finish that one
- IntegerBitmapLayout layout = new IntegerBitmapLayout();
-
- return layout;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XSpriteCanvas helper
- // ====================
- //
- public synchronized void renderAnimation( CanvasSprite sprite, XAnimation animation, double t )
- {
- SpriteRep spriteRep = (SpriteRep)activeSprites.get( sprite );
- if( spriteRep != null )
- {
- //Graphics2D graph = getWindowGraphics();
-
- // TODO: ensure update of graphics object externally, e.g. when
- // VCL moves the toplevel window.
- //java.awt.Rectangle bounds = dummyFrame.frame.getBounds();
- //graphics.setGraphics(graph, bounds.width, bounds.height);
-
- spriteRep.renderAnimation( animation, sprite.getViewState(), t );
- }
- else
- {
- CanvasUtils.printLog( "JavaCanvas.renderAnimation sprite not active!" );
- }
- }
-
- public synchronized void showSprite( SpriteBase sprite )
- {
- CanvasUtils.printLog( "JavaCanvas.showSprite() called" );
-
- SpriteRep spriteRep = (SpriteRep)activeSprites.get( sprite );
- if( spriteRep != null )
- {
- CanvasUtils.printLog( "JavaCanvas.showSprite sprite already active!" );
- }
- else
- {
- spriteRep = sprite.getSpriteRep();
-
- // a valid SpriteRep for a given Sprite in the
- // activeSprites hash denotes 'sprite active'
- activeSprites.put( sprite, spriteRep );
-
- // TODO: TEMP! Just for testing! Set empty cursor for presentation
-// dummyFrame.frame.setCursor( dummyFrame.frame.getToolkit().createCustomCursor(new java.awt.image.BufferedImage(0,0,
-// java.awt.image.BufferedImage.TYPE_INT_RGB),
-// new java.awt.Point(0,0),
-// "") );
- }
- }
-
- public synchronized void hideSprite( SpriteBase sprite )
- {
- CanvasUtils.printLog( "JavaCanvas.hideSprite() called" );
-
- SpriteRep spriteRep = (SpriteRep)activeSprites.get( sprite );
- if( spriteRep != null )
- {
- activeSprites.put( sprite, null );
- redrawAllLayers();
- }
- else
- {
- CanvasUtils.printLog( "JavaCanvas.hideSprite sprite not active!" );
- }
- }
-
- private void redrawAllLayers()
- {
- // fetch the Graphics object to draw into (we're doing double
- // buffering here, the content is later shown via
- // bufferStrategy.show().
- Graphics2D graph = null;
-
- try
- {
- graph = (Graphics2D)bufferStrategy.getDrawGraphics();
-
- GraphicsDevice device = graph.getDeviceConfiguration().getDevice();
- CanvasUtils.printLog( "Available vram: " + device.getAvailableAcceleratedMemory() );
-
- // repaint background
- backBuffer.redraw( graph );
-
- // repaint all active sprites
- java.util.Set entries = activeSprites.entrySet();
- java.util.Iterator iter = entries.iterator();
- while( iter.hasNext() )
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)iter.next();
- if( entry.getValue() != null )
- ((SpriteRep)entry.getValue()).redraw(graph);
- }
-
- long currTime = System.currentTimeMillis();
- graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER) );
- graph.setFont( fpsFont );
- graph.setColor( java.awt.Color.black );
-
- try
- {
- String fps = new String( String.valueOf(1000.0/(currTime-lastTime)) );
- graph.drawString( fps.substring(0,5) + " fps", 0, 20);
- CanvasUtils.printLog( fps.substring(0,5) + " fps" );
- }
- catch( Exception e )
- {
- graph.drawString( "0 fps", 0, 20);
- }
-
- lastTime = currTime;
- }
- catch( Exception e )
- {
- CanvasUtils.printLog( "Exception thrown in redrawAllLayers" );
- }
- finally
- {
- if( graph != null )
- graph.dispose();
- }
-
- bufferStrategy.show();
- }
-
- //----------------------------------------------------------------------------------
-
- private static final String s_implName = "XCanvas.java.impl";
- private static final String s_serviceName = "com.sun.star.rendering.JavaCanvas";
-
- //----------------------------------------------------------------------------------
-
- //
- // XServiceInfo impl
- // =================
- //
- public synchronized String getImplementationName()
- {
- return s_implName;
- }
-
- public synchronized String [] getSupportedServiceNames()
- {
- return new String [] { s_serviceName };
- }
-
- public synchronized boolean supportsService( String serviceName )
- {
- return serviceName.equals( s_serviceName );
- }
-
- public static com.sun.star.lang.XSingleServiceFactory __getServiceFactory(
- String implName,
- com.sun.star.lang.XMultiServiceFactory multiFactory,
- com.sun.star.registry.XRegistryKey regKey )
- {
- if (implName.equals( s_implName ))
- {
- return com.sun.star.comp.loader.FactoryHelper.getServiceFactory(
- JavaCanvas.class, s_serviceName, multiFactory, regKey );
- }
- return null;
- }
-
- public static boolean __writeRegistryServiceInfo(
- com.sun.star.registry.XRegistryKey regKey )
- {
- return com.sun.star.comp.loader.FactoryHelper.writeRegistryServiceInfo(
- s_implName, s_serviceName, regKey );
- }
-}
diff --git a/canvas/source/java/LinePolyPolygon.java b/canvas/source/java/LinePolyPolygon.java
deleted file mode 100644
index 3ab19d97ba19..000000000000
--- a/canvas/source/java/LinePolyPolygon.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Canvas
-import com.sun.star.rendering.*;
-import com.sun.star.geometry.*;
-
-public class LinePolyPolygon
- extends com.sun.star.lib.uno.helper.ComponentBase
- implements com.sun.star.lang.XServiceInfo,
- com.sun.star.rendering.XLinePolyPolygon2D
-{
- private java.awt.geom.GeneralPath path;
-
- //----------------------------------------------------------------------------------
-
- public LinePolyPolygon( RealPoint2D[][] points )
- {
- setPoints( points, 0 );
- }
-
- public java.awt.geom.GeneralPath getJavaPath()
- {
- return path;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XPolyPolygon implementation
- // ===========================
- //
- public synchronized void addPolyPolygon( RealPoint2D position, XPolyPolygon2D polyPolygon )
- {
- }
-
- public synchronized int getNumberOfPolygons( )
- {
- return 0;
- }
-
- public synchronized int getNumberOfPolygonPoints( int polygon )
- {
- return 0;
- }
-
- public synchronized FillRule getFillRule( )
- {
- if( path.getWindingRule() == java.awt.geom.GeneralPath.WIND_EVEN_ODD )
- return FillRule.EVEN_ODD;
- else
- return FillRule.NON_ZERO;
- }
-
- public synchronized void setFillRule( FillRule fillRule )
- {
- if( fillRule == FillRule.EVEN_ODD )
- path.setWindingRule( java.awt.geom.GeneralPath.WIND_EVEN_ODD );
- else
- path.setWindingRule( java.awt.geom.GeneralPath.WIND_NON_ZERO );
- }
-
- public synchronized boolean isClosed( int index )
- {
- // TODO
- return false;
- }
-
- public synchronized void setClosed( int index, boolean closedState )
- {
- // TODO
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XLinePolyPolygon implementation
- // ===============================
- //
- public synchronized RealPoint2D[][] getPoints( int nPolygonIndex, int nNumberOfPolygons, int nPointIndex, int nNumberOfPoints )
- {
- // TODO: Implement subsetting
-
-// double [] points = new double[6];
-
-// // BAH! Use util.Vector here!
-
-// // find number of subpaths
-// PathIterator aIter = path.getPathIterator( new AffineTransform() );
-// int nNumSubPaths = 0;
-// while( !aIter.isDone() )
-// {
-// if( aIter.currentSegment(points) == SEG_MOVETO )
-// ++nNumSubPaths;
-
-// aIter.next();
-// }
-
-// Point2D [][] aRes = new Point2D[nNumSubPaths][];
-// aIter = path.getPathIterator( new AffineTransform() );
-// while( !aIter.isDone() )
-// {
-// switch( aIter.currentSegment(points) )
-// {
-// case SEG_MOVETO:
-// break;
-
-// case SEG_LINETO:
-// break;
-
-// case SEG_CLOSE:
-// break;
-
-// default:
-// CanvasUtils.printLog( "LinePolyPolygon.getPoints(): unexpected path type" );
-// break;
-// }
-
-// aIter.next();
-// }
-// double [] points = new double[6];
-
- return null;
- }
-
- public synchronized void setPoints( RealPoint2D[][] points, int nPolygonIndex )
- {
- if( nPolygonIndex != 0 )
- CanvasUtils.printLog( "LinePolyPolygon.setPoints: subset not yet implemented!" );
-
- path = CanvasUtils.makeGenPathFromLinePoints( points );
- }
-
- public synchronized RealPoint2D getPoint( int nPolygonIndex, int nPointIndex )
- {
- return null;
- }
-
- public synchronized void setPoint( RealPoint2D point, int nPolygonIndex, int nPointIndex )
- {
- CanvasUtils.printLog( "LinePolyPolygon.setPoint: not yet implemented!" );
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XServiceInfo impl
- // =================
- //
-
- private static final String s_implName = "XLinePolyPolygon2D.java.impl";
- private static final String s_serviceName = "com.sun.star.rendering.LinePolyPolygon2D";
-
- public String getImplementationName()
- {
- return s_implName;
- }
-
- public String [] getSupportedServiceNames()
- {
- return new String [] { s_serviceName };
- }
-
- public boolean supportsService( String serviceName )
- {
- return serviceName.equals( s_serviceName );
- }
-}
diff --git a/canvas/source/java/SpriteBase.java b/canvas/source/java/SpriteBase.java
deleted file mode 100644
index 5f2ed3c57ecc..000000000000
--- a/canvas/source/java/SpriteBase.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Canvas
-
-public interface SpriteBase
-{
- // to be overridden
- public SpriteRep getSpriteRep();
-}
diff --git a/canvas/source/java/SpriteRep.java b/canvas/source/java/SpriteRep.java
deleted file mode 100644
index 046a45f2d9bb..000000000000
--- a/canvas/source/java/SpriteRep.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Canvas
-import com.sun.star.rendering.*;
-
-// Java AWT
-import java.awt.*;
-import java.awt.geom.*;
-
-public class SpriteRep
-{
- private java.awt.image.BufferedImage buffer;
- private CanvasBitmap canvasBitmap;
- private double alpha;
- private java.awt.geom.Point2D.Double outputPosition;
- private boolean bufferOwned;
-
- //----------------------------------------------------------------------------------
-
- // TODO: Everything in this class
- // TODO: Implement lifetime control for buffer object, which is shared between SpriteReps
- public SpriteRep()
- {
- CanvasUtils.printLog( "SpriteRep constructor called!" );
-
- alpha = 0.0;
- outputPosition = new java.awt.geom.Point2D.Double(0.0,0.0);
- bufferOwned = true; // the buffer member is our own, and has to be disposed
- }
-
- public SpriteRep( SpriteRep original )
- {
- CanvasUtils.printLog( "SpriteRep clone constructor called!" );
-
- alpha = 0.0;
- outputPosition = new java.awt.geom.Point2D.Double(0.0,0.0);
- cloneBuffer( original );
- bufferOwned = false; // the buffer member is not our own, and must not be disposed
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized void renderAnimation( XAnimation animation, ViewState viewState, double t )
- {
- if( canvasBitmap != null )
- {
- // clear buffer with all transparent
- Graphics2D bitmapGraphics = canvasBitmap.getGraphics();
-
- // before that, setup _everything_ we might have changed in CanvasUtils.setupGraphicsState
- bitmapGraphics.setColor( new Color( 0.0f, 0.0f, 0.0f, 1.0f ) );
- bitmapGraphics.setComposite(
- java.awt.AlphaComposite.getInstance(java.awt.AlphaComposite.CLEAR));
- bitmapGraphics.setTransform( new AffineTransform() );
- bitmapGraphics.setClip( new java.awt.Rectangle(0,0,buffer.getWidth(),buffer.getHeight()) );
- bitmapGraphics.fillRect(0,0,buffer.getWidth(),buffer.getHeight());
-
- try
- {
- // now push the animation at time instance t into the
- // virginal graphics
- animation.render(canvasBitmap, viewState, t);
- }
- catch( com.sun.star.lang.IllegalArgumentException e )
- {
- CanvasUtils.printLog( "Cannot create EmbeddedFrame within VCL window hierarchy!" );
- }
- }
- }
-
- public synchronized void setSpriteAlpha( double _alpha )
- {
- CanvasUtils.printLog("SpriteRep.setSpriteAlpha called with alpha=" + alpha);
- alpha = _alpha;
- }
-
- public synchronized void moveSprite( java.awt.geom.Point2D.Double aNewPos )
- {
- outputPosition = aNewPos;
- CanvasUtils.printLog( "SpriteRep.moveSprite: moving to (" + outputPosition.x + ", " + outputPosition.y + ")" );
- }
-
- public synchronized void redraw( Graphics2D output )
- {
- if( buffer != null )
- {
- CanvasUtils.printLog( "SpriteRep.redraw: compositing with alpha=" + alpha );
- output.setComposite( java.awt.AlphaComposite.getInstance(java.awt.AlphaComposite.SRC_OVER, (float)alpha) );
-
- output.drawImage( buffer,
- (int)(outputPosition.getX() + .5),
- (int)(outputPosition.getY() + .5),
- null );
-
- //CanvasUtils.postRenderImageTreatment( buffer );
-
- CanvasUtils.printLog( "SpriteRep.redraw called, output rect is (" +
- outputPosition.getX() + ", " +
- outputPosition.getY() + ", " +
- buffer.getWidth() + ", " +
- buffer.getHeight() + ")" );
- }
- }
-
- public synchronized void setupBuffer( java.awt.Graphics2D graphics, int width, int height )
- {
- if( canvasBitmap != null )
- canvasBitmap.dispose();
-
- if( buffer != null )
- buffer.flush();
-
- buffer = graphics.getDeviceConfiguration().createCompatibleImage(Math.max(1,width),
- Math.max(1,height),
- Transparency.TRANSLUCENT);
- canvasBitmap = new CanvasBitmap( buffer );
- CanvasUtils.initGraphics( canvasBitmap.getGraphics() );
-
- CanvasUtils.printLog( "SpriteRep.setupBuffer called, with dimensions (" + width + ", " + height + ")" );
- }
-
- public synchronized void cloneBuffer( SpriteRep original )
- {
- buffer = original.buffer;
- }
-
- public synchronized com.sun.star.rendering.XCanvas getContentCanvas()
- {
- CanvasUtils.printLog( "SpriteRep.getContentCanvas() called" );
-
- Graphics2D graphics = canvasBitmap.getGraphics();
- graphics.setTransform( new AffineTransform() );
- graphics.setComposite( AlphaComposite.getInstance(AlphaComposite.CLEAR));
- graphics.fillRect( 0,0,buffer.getWidth(),buffer.getHeight() );
-
- return canvasBitmap;
- }
-
- public void dispose()
- {
- if( canvasBitmap != null )
- canvasBitmap.dispose();
-
- if( buffer != null && bufferOwned )
- buffer.flush();
-
- canvasBitmap = null;
- buffer = null;
- }
-}
diff --git a/canvas/source/java/SpriteRunner.java b/canvas/source/java/SpriteRunner.java
deleted file mode 100644
index 17e472e7e5c7..000000000000
--- a/canvas/source/java/SpriteRunner.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Canvas
-import com.sun.star.rendering.*;
-
-//
-// HOWTO get a Graphics2D from a window
-//
-
-// import javax.swing.*;
-// import java.awt.*;
-// import java.awt.geom.*;
-
-// public class Stroke1 extends JFrame {
-// Stroke drawingStroke = new BasicStroke(5);
-// Rectangle2D rect =
-// new Rectangle2D.Double(20, 40, 100, 40);
-
-// public void paint(Graphics g) {
-// Graphics2D g2d = (Graphics2D)g;
-// g2d.setStroke(drawingStroke);
-// g2d.draw(rect);
-// }
-
-// public static void main(String args[]) {
-// JFrame frame = new Stroke1();
-// frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
-// frame.setSize(200, 100);
-// frame.show();
-// }
-// }
-
-
-public class SpriteRunner
- extends Thread
-{
- private CanvasSprite sprite;
- private XAnimation spriteAnimation;
- private JavaCanvas canvas;
- private double startTime;
- private double currentSpeed;
- private double currentT;
- private boolean animationActive;
- private boolean stayAlive;
-
- //----------------------------------------------------------------------------------
-
- public SpriteRunner( CanvasSprite _sprite, XAnimation _animation, JavaCanvas _canvas )
- {
- CanvasUtils.printLog( "SpriteRunner constructor called!" );
-
- sprite = _sprite;
- spriteAnimation = _animation;
- canvas = _canvas;
- startTime = 0.0;
- currentSpeed = 0.0;
- currentT = 0.0;
- animationActive = false;
- stayAlive = true;
-
- // Set priority to lower-than-normal, as this thread runs the
- // animation in a busy loop.
- setPriority( MIN_PRIORITY );
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // Thread
- // ======
- //
- // Overriding
- //
- public void run()
- {
- // perform the animation rendering (as fast as possible, for now)
-
- while( stayAlive )
- {
- while( animationActive )
- {
- // to determine the current animation step to render, calc the
- // elapsed time since this animation was started
- double elapsedTime = getCurrentTime() - startTime;
-
- // the frame to render is determined by mapping the cycle
- // duration (currentSpeed) to the [0,1] range of the animation.
- currentT = (elapsedTime % currentSpeed) / currentSpeed;
-
- // delegate animation rendering to SpriteCanvas, as
- // only this instance can enforce consistency (on-time
- // saving of background etc.)
- canvas.renderAnimation( sprite, spriteAnimation, currentT );
-
- // TODO: Consolidate _all_ sprites per canvas into one
- // thread, call updateScreen() only after all sprites
- // have been processed.
-
- //Make changes visible
- canvas.updateScreen( false );
-
- // TODO: Evaluate vs. setPriority and other means
-// try
-// {
-// // give other tasks some time to breathe (10ms - this is only meant symbolically)
-// sleep(10);
-// } catch( InterruptedException e ) { }
- }
-
- // wait until animation is activated again
- try
- {
- wait();
- }
- catch( InterruptedException e ) { }
- catch( IllegalMonitorStateException e ) { }
- }
- }
-
- public synchronized void startAnimation( double speed )
- {
- resetAnimation();
- currentSpeed = speed;
-
- // start us, if not done already
- if( !isAlive() )
- start();
-
- // enable animation thread
- animationActive = true;
-
- try
- {
- notify();
- } catch( IllegalMonitorStateException e ) { }
- }
-
- public synchronized void stopAnimation()
- {
- // stop animation after the current frame has been completely
- // rendered
- animationActive = false;
- }
-
- public synchronized void resetAnimation()
- {
- startTime = getCurrentTime();
- }
-
- public synchronized boolean isAnimationActive()
- {
- return animationActive;
- }
-
- public synchronized void quit()
- {
- stayAlive = false;
- stopAnimation();
- }
-
- public synchronized double getCurrentT()
- {
- return currentT;
- }
-
- //----------------------------------------------------------------------------------
-
- // helper
- static double getCurrentTime()
- {
- // determine current time in seconds
- java.util.Calendar cal = new java.util.GregorianCalendar();
- return cal.getTimeInMillis() / 1000.0;
- }
-}
diff --git a/canvas/source/java/TextLayout.java b/canvas/source/java/TextLayout.java
deleted file mode 100644
index 1a443fcbeeac..000000000000
--- a/canvas/source/java/TextLayout.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Canvas
-import com.sun.star.rendering.*;
-
-public class TextLayout
- extends com.sun.star.lib.uno.helper.ComponentBase
- implements com.sun.star.lang.XServiceInfo,
- com.sun.star.rendering.XTextLayout
-{
- private double[] advancements;
- private StringContext text;
- private byte direction;
- private CanvasBase associatedCanvas;
- private CanvasFont font;
-
- //----------------------------------------------------------------------------------
-
- public TextLayout( StringContext aText,
- byte nDirection,
- long nRandomSeed,
- CanvasFont _font,
- CanvasBase _canvas )
- {
- text = aText;
- direction = nDirection;
- associatedCanvas = _canvas;
- font = _font;
- }
-
- //
- // XTextLayout implementation
- // ==========================
- //
-
- public XPolyPolygon2D[] queryTextShapes( )
- {
- // TODO
- return null;
- }
-
- public com.sun.star.geometry.RealRectangle2D[] queryInkMeasures( )
- {
- // TODO
- return null;
- }
-
- public com.sun.star.geometry.RealRectangle2D[] queryMeasures( )
- {
- // TODO
- return null;
- }
-
- public double[] queryLogicalAdvancements( )
- {
- // TODO
- return null;
- }
-
- public void applyLogicalAdvancements( double[] aAdvancements ) throws com.sun.star.lang.IllegalArgumentException
- {
- if( aAdvancements.length != text.Length )
- throw new com.sun.star.lang.IllegalArgumentException();
-
- advancements = aAdvancements;
- }
-
- public com.sun.star.geometry.RealRectangle2D queryTextBounds( )
- {
- // TODO
- return null;
- }
-
- public double justify( double nSize ) throws com.sun.star.lang.IllegalArgumentException
- {
- // TODO
- return 0;
- }
-
- public double combinedJustify( XTextLayout[] aNextLayouts, double nSize ) throws com.sun.star.lang.IllegalArgumentException
- {
- // TODO
- return 0;
- }
-
- public TextHit getTextHit( /*IN*/com.sun.star.geometry.RealPoint2D aHitPoint )
- {
- // TODO
- return null;
- }
-
- public Caret getCaret( int nInsertionIndex, boolean bExcludeLigatures ) throws com.sun.star.lang.IndexOutOfBoundsException
- {
- // TODO
- return null;
- }
-
- public int getNextInsertionIndex( int nStartIndex, int nCaretAdvancement, boolean bExcludeLigatures ) throws com.sun.star.lang.IndexOutOfBoundsException
- {
- // TODO
- return 0;
- }
-
- public XPolyPolygon2D queryVisualHighlighting( int nStartIndex, int nEndIndex ) throws com.sun.star.lang.IndexOutOfBoundsException
- {
- // TODO
- return null;
- }
-
- public XPolyPolygon2D queryLogicalHighlighting( int nStartIndex, int nEndIndex ) throws com.sun.star.lang.IndexOutOfBoundsException
- {
- // TODO
- return null;
- }
-
- public double getBaselineOffset( )
- {
- // TODO
- return 0.0;
- }
-
- public byte getMainTextDirection( )
- {
- return direction;
- }
-
- public XCanvasFont getFont( )
- {
- return font;
- }
-
- public StringContext getText( )
- {
- return text;
- }
-
- public boolean draw( java.awt.Graphics2D graphics )
- {
- // TODO: use proper advancement. Text direction need not be horizontal!
- // TODO: given text string need not have a one-to-one relationship between code point and glyph (offset)!
- graphics.drawString( text.Text.substring(text.StartPosition, text.StartPosition + 1), (float)0.0, (float)0.0 );
- for( int i=1; i<advancements.length && i<text.Length; ++i )
- {
- CanvasUtils.printLog( "XCanvas: drawOffsettedText rendering a \"" +
- text.Text.substring(text.StartPosition + i,
- text.StartPosition + i + 1) +
- "\" (position " + (text.StartPosition + i) +
- " of " + text.Text + ", offset " + advancements[i] + ")" );
-
- graphics.drawString( text.Text.substring(text.StartPosition + i, text.StartPosition + i + 1), (float)advancements[i-1], (float)0.0 );
- }
-
- return true;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XServiceInfo impl
- // =================
- //
-
- private static final String s_implName = "CanvasFont.java.impl";
- private static final String s_serviceName = "com.sun.star.rendering.XCanvasFont";
-
- public String getImplementationName()
- {
- return s_implName;
- }
-
- public String [] getSupportedServiceNames()
- {
- return new String [] { s_serviceName };
- }
-
- public boolean supportsService( String serviceName )
- {
- return serviceName.equals( s_serviceName );
- }
-}
diff --git a/canvas/source/java/aqua/WindowAdapter.java b/canvas/source/java/aqua/WindowAdapter.java
deleted file mode 100644
index 2529bb56e55c..000000000000
--- a/canvas/source/java/aqua/WindowAdapter.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// UNO
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.XComponentContext;
-import com.sun.star.uno.AnyConverter;
-import com.sun.star.lang.XInitialization;
-import com.sun.star.lib.uno.helper.WeakBase;
-
-// OOo AWT
-import com.sun.star.awt.*;
-
-// system-dependent stuff
-import sun.awt.*;
-
-//Apple specifics
-import apple.awt.*;
-
-
-public class WindowAdapter
-// defacto implementing the interface, but not deriving from it, since
-// we're no real XInterface here
-// implements com.sun.star.awt.XWindow
-{
- public java.awt.Frame frame;
- private boolean fullscreen;
-
- public WindowAdapter( int windowHandle,
- boolean _fullscreen )
- {
- fullscreen = false;
-
- if( _fullscreen )
- {
- // create a normal Java frame, and set it into fullscreen mode
- frame = new javax.swing.JFrame( "Presentation" );
- frame.setUndecorated( true );
- frame.setVisible( true );
-
- java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics();
- if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() )
- {
- CanvasUtils.printLog( "WindowAdapter(Aqua): entering fullscreen mode" );
- graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( frame );
- fullscreen = true;
- }
- else
- {
- CanvasUtils.printLog( "WindowAdapter(Aqua): fullscreen not supported" );
- }
-
- graphics.dispose();
- }
- else
- {
- // we're initialized with the operating system window handle
- // as the parameter. We then generate a dummy Java frame with
- // that window as the parent, to fake a root window for the
- // Java implementation.
-
- // now, we're getting slightly system dependent here.
- String os = (String) System.getProperty("os.name");
-
- // create the embedded frame
- if( os.startsWith("Mac OS X") )
- frame = new apple.awt.CEmbeddedFrame( windowHandle );
- else
- throw new com.sun.star.uno.RuntimeException();
-
-
-// frame = new javax.swing.JFrame( "Test window" );
-
-// // resize it according to the given bounds
-// frame.setBounds( boundRect );
-// frame.setVisible( true );
- }
- }
-
- //----------------------------------------------------------------------------------
-
- public void dispose()
- {
- if( fullscreen )
- {
- java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics();
- if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() )
- {
- CanvasUtils.printLog( "WindowAdapter(Aqua): leaving fullscreen mode" );
- graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( null );
- }
- graphics.dispose();
- }
-
- if( frame != null )
- frame.dispose();
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XWindow interface
- // =================
- //
- public void setPosSize( int X, int Y, int Width, int Height, short Flags )
- {
- frame.setBounds( new java.awt.Rectangle( X, Y, Width, Height ) );
- }
-
- public com.sun.star.awt.Rectangle getPosSize( )
- {
- java.awt.Rectangle bounds = frame.getBounds();
-
- return new com.sun.star.awt.Rectangle( bounds.x, bounds.y, bounds.width, bounds.height );
- }
-
- public void setVisible( boolean visible )
- {
- frame.setVisible( visible );
- }
-
- public void setEnable( boolean enable )
- {
- frame.setEnabled( enable );
- }
-
- public void setFocus()
- {
- }
-
- public void addWindowListener( XWindowListener xListener )
- {
- }
-
- public void removeWindowListener( XWindowListener xListener )
- {
- }
-
- public void addFocusListener( XFocusListener xListener )
- {
- }
-
- public void removeFocusListener( XFocusListener xListener )
- {
- }
-
- public void addKeyListener( XKeyListener xListener )
- {
- }
-
- public void removeKeyListener( XKeyListener xListener )
- {
- }
-
- public void addMouseListener( XMouseListener xListener )
- {
- }
-
- public void removeMouseListener( XMouseListener xListener )
- {
- }
-
- public void addMouseMotionListener( XMouseMotionListener xListener )
- {
- }
-
- public void removeMouseMotionListener( XMouseMotionListener xListener )
- {
- }
-
- public void addPaintListener( XPaintListener xListener )
- {
- }
-
- public void removePaintListener( XPaintListener xListener )
- {
- }
-}
diff --git a/canvas/source/java/java_Service.java b/canvas/source/java/java_Service.java
deleted file mode 100644
index 6fcaa1581ca8..000000000000
--- a/canvas/source/java/java_Service.java
+++ /dev/null
@@ -1,118 +0,0 @@
-
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.XComponentContext;
-import com.sun.star.awt.*;
-
-public class java_Service
- extends com.sun.star.lib.uno.helper.WeakBase
- implements com.sun.star.lang.XServiceInfo, foo.XBar
-{
- private XToolkit m_xToolkit;
- private XVclWindowPeer m_xPeer;
- private javax.swing.JFrame m_frame;
-
- public java_Service( XComponentContext xContext )
- {
- try
- {
- m_xToolkit =
- (XToolkit) UnoRuntime.queryInterface(
- XToolkit.class,
- xContext.getServiceManager().createInstanceWithContext(
- "com.sun.star.awt.Toolkit", xContext ) );
- }
- catch (com.sun.star.uno.Exception exc)
- {
- throw new com.sun.star.uno.RuntimeException(
- "exception occured gettin toolkit: " + exc, this );
- }
- }
-
- // XBar impl
- public void raiseAndCloseWindows( foo.XBar [] seq )
- throws com.sun.star.uno.Exception
- {
- for ( int nPos = 0; nPos < seq.length; ++nPos )
- seq[ nPos ].raiseWindows( "called by Java code" );
-
- // modal dialog before closing
- javax.swing.JOptionPane.showMessageDialog(
- null, "[Java] all windows created." );
-
- for ( int nPos = 0; nPos < seq.length; ++nPos )
- seq[ nPos ].closeWindows();
- }
-
- public void raiseWindows( String msg )
- throws com.sun.star.uno.Exception
- {
- // create java frame
- m_frame = new javax.swing.JFrame(
- "[java frame created by Java code] " + msg );
- m_frame.setSize( 500, 50 );
- m_frame.setLocation( 200, 500 );
- m_frame.setVisible( true );
-
- // create office workwindow
- m_xPeer = (XVclWindowPeer) UnoRuntime.queryInterface(
- XVclWindowPeer.class,
- m_xToolkit.createWindow(
- new WindowDescriptor(
- WindowClass.TOP, "workwindow", null, (short) -1,
- new Rectangle( 800, 500, 500, 50 ),
- WindowAttribute.SHOW |
- WindowAttribute.BORDER |
- WindowAttribute.SIZEABLE |
- WindowAttribute.MOVEABLE |
- WindowAttribute.CLOSEABLE ) ) );
- m_xPeer.setProperty(
- "Title", "[office window created by Java code] " + msg );
- }
-
- public void closeWindows()
- throws com.sun.star.uno.Exception
- {
- m_frame.dispose();
- m_xPeer.dispose();
- }
-
-
- private static final String s_implName = "foo.java.impl";
- private static final String s_serviceName = "foo.java";
-
- // XServiceInfo impl
- public String getImplementationName()
- {
- return s_implName;
- }
-
- public String [] getSupportedServiceNames()
- {
- return new String [] { s_serviceName };
- }
-
- public boolean supportsService( String serviceName )
- {
- return serviceName.equals( s_serviceName );
- }
-
- public static com.sun.star.lang.XSingleServiceFactory __getServiceFactory(
- String implName,
- com.sun.star.lang.XMultiServiceFactory multiFactory,
- com.sun.star.registry.XRegistryKey regKey )
- {
- if (implName.equals( s_implName ))
- {
- return com.sun.star.comp.loader.FactoryHelper.getServiceFactory(
- java_Service.class, s_serviceName, multiFactory, regKey );
- }
- return null;
- }
-
- public static boolean __writeRegistryServiceInfo(
- com.sun.star.registry.XRegistryKey regKey )
- {
- return com.sun.star.comp.loader.FactoryHelper.writeRegistryServiceInfo(
- s_implName, s_serviceName, regKey );
- }
-}
diff --git a/canvas/source/java/makefile.mk b/canvas/source/java/makefile.mk
deleted file mode 100644
index 86f329e4fe3b..000000000000
--- a/canvas/source/java/makefile.mk
+++ /dev/null
@@ -1,93 +0,0 @@
-#*************************************************************************
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# Copyright 2000, 2010 Oracle and/or its affiliates.
-#
-# OpenOffice.org - a multi-platform office productivity suite
-#
-# This file is part of OpenOffice.org.
-#
-# OpenOffice.org is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License version 3
-# only, as published by the Free Software Foundation.
-#
-# OpenOffice.org is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License version 3 for more details
-# (a copy is included in the LICENSE file that accompanied this code).
-#
-# You should have received a copy of the GNU Lesser General Public License
-# version 3 along with OpenOffice.org. If not, see
-# <http://www.openoffice.org/license.html>
-# for a copy of the LGPLv3 License.
-#
-#*************************************************************************
-
-# Builds the Java Canvas implementation.
-
-PRJNAME = canvas
-PRJ = ..$/..
-TARGET = javacanvas
-PACKAGE = canvas
-
-USE_JAVAVER:=TRUE
-
-# --- Settings -----------------------------------------------------
-
-.INCLUDE: settings.mk
-
-.IF "$(SOLAR_JAVA)"=="TRUE"
-# Since Canvas needs newer features like
-# e.g. java.awt.image.BufferStrategy,
-# disabled for now for everything <1.4
-.IF "$(JAVANUMVER:s/.//)" >= "000100040000"
-
-JAVAFILES = \
- SpriteBase.java \
- JavaCanvas.java \
- CanvasGraphicDevice.java \
- CanvasUtils.java \
- CanvasFont.java \
- CanvasBitmap.java \
- CanvasSprite.java \
- CanvasCustomSprite.java \
- CanvasClonedSprite.java \
- TextLayout.java \
- BackBuffer.java \
- LinePolyPolygon.java \
- BezierPolyPolygon.java \
- SpriteRunner.java
-
-.IF "$(GUIBASE)"=="unx"
-
-JAVAFILES += x11/WindowAdapter.java
-
-.ELIF "$(GUIBASE)"=="aqua"
-
-JAVAFILES += aqua/WindowAdapter.java
-
-.ELSE
-
-JAVAFILES += win/WindowAdapter.java
-
-.ENDIF # "$(GUIBASE)"=="unx"
-
-JARFILES = jurt.jar unoil.jar ridl.jar juh.jar java_uno.jar
-#JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
-
-JARTARGET = $(TARGET).uno.jar
-JARCOMPRESS = TRUE
-#JARCLASSDIRS = $(PACKAGE)
-CUSTOMMANIFESTFILE = manifest
-
-.ENDIF # "$(JAVANUMVER:s/.//)" >= "000100040000"
-.ENDIF # "$(SOLAR_JAVA)"=="TRUE"
-
-# --- Targets ------------------------------------------------------
-
-.INCLUDE: target.mk
-
-#dist: $(JAVA_FILES:b:+".class")
-# +jar -cvfm $(CLASSDIR)/JavaCanvas.jar $(JARMANIFEST) $(JAVACLASSFILES)
diff --git a/canvas/source/java/manifest b/canvas/source/java/manifest
deleted file mode 100644
index 6ddc3ab0ae51..000000000000
--- a/canvas/source/java/manifest
+++ /dev/null
@@ -1 +0,0 @@
-RegistrationClassName: JavaCanvas
diff --git a/canvas/source/java/perftest/PerfTest.java b/canvas/source/java/perftest/PerfTest.java
deleted file mode 100644
index 98e3cc5c3de5..000000000000
--- a/canvas/source/java/perftest/PerfTest.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-import java.awt.*;
-import java.awt.image.*;
-import java.awt.geom.*;
-
-
-public class PerfTest
-{
- // the frame object we're generating. TODO: Remove public access.
- private Frame frame;
- private boolean fullscreen;
-
- public PerfTest()
- {
- fullscreen = false;
-
- // create a normal Java frame, and set it into fullscreen mode
- frame = new javax.swing.JFrame( "PerformanceTest" );
- frame.setBounds( new Rectangle(0,0,1600,1200) );
- frame.setUndecorated( true );
- frame.setVisible( true );
-
- Graphics2D graphics = (Graphics2D)frame.getGraphics();
- if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() )
- {
- System.err.println( "entering fullscreen mode" );
- graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( frame );
- fullscreen = true;
- }
- else
- {
- System.err.println( "fullscreen not supported" );
- }
-
- graphics.dispose();
- }
-
- //----------------------------------------------------------------------------------
-
- public void dispose()
- {
- if( fullscreen )
- {
- Graphics2D graphics = (Graphics2D)frame.getGraphics();
- if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() )
- {
- System.err.println( "leaving fullscreen mode" );
- graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( null );
- }
- graphics.dispose();
- }
-
- if( frame != null )
- frame.dispose();
- }
-
- //----------------------------------------------------------------------------------
-
- public static void initGraphics( Graphics2D graphics )
- {
- if( graphics != null )
- {
- RenderingHints hints = new RenderingHints(null);
- boolean hq = true;
-
- if( hq )
- {
- hints.add( new RenderingHints( RenderingHints.KEY_FRACTIONALMETRICS,
- RenderingHints.VALUE_FRACTIONALMETRICS_ON ) );
-// hints.add( new RenderingHints( RenderingHints.KEY_ALPHA_INTERPOLATION,
-// RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY) );
- hints.add( new RenderingHints( RenderingHints.KEY_ALPHA_INTERPOLATION,
- RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED) );
-// hints.add( new RenderingHints( RenderingHints.KEY_INTERPOLATION,
-// RenderingHints.VALUE_INTERPOLATION_BICUBIC) );
- hints.add( new RenderingHints( RenderingHints.KEY_INTERPOLATION,
- RenderingHints.VALUE_INTERPOLATION_BILINEAR) );
-// hints.add( new RenderingHints( RenderingHints.KEY_RENDERING,
-// RenderingHints.VALUE_RENDER_QUALITY) );
- hints.add( new RenderingHints( RenderingHints.KEY_RENDERING,
- RenderingHints.VALUE_RENDER_SPEED) );
-// hints.add( new RenderingHints( RenderingHints.KEY_STROKE_CONTROL,
-// RenderingHints.VALUE_STROKE_NORMALIZE) );
- hints.add( new RenderingHints( RenderingHints.KEY_STROKE_CONTROL,
- RenderingHints.VALUE_STROKE_DEFAULT) );
- hints.add( new RenderingHints( RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON) );
- }
- else
- {
- hints.add( new RenderingHints( RenderingHints.KEY_ALPHA_INTERPOLATION,
- RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED) );
- hints.add( new RenderingHints( RenderingHints.KEY_INTERPOLATION,
- RenderingHints.VALUE_INTERPOLATION_BILINEAR) );
- hints.add( new RenderingHints( RenderingHints.KEY_RENDERING,
- RenderingHints.VALUE_RENDER_SPEED) );
- hints.add( new RenderingHints( RenderingHints.KEY_STROKE_CONTROL,
- RenderingHints.VALUE_STROKE_DEFAULT) );
- hints.add( new RenderingHints( RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_OFF) );
- }
-
- // the least common denominator standard
- hints.add( new RenderingHints( RenderingHints.KEY_FRACTIONALMETRICS,
- RenderingHints.VALUE_FRACTIONALMETRICS_ON) );
- hints.add( new RenderingHints( RenderingHints.KEY_TEXT_ANTIALIASING,
- RenderingHints.VALUE_TEXT_ANTIALIAS_ON) );
-
- graphics.setRenderingHints( hints );
- }
- }
-
- public void run()
- {
- frame.createBufferStrategy(2);
- BufferStrategy bufferStrategy = frame.getBufferStrategy();
-
- if( bufferStrategy.getCapabilities().isPageFlipping() )
- System.err.println( "double buffering is using page flipping" );
- else
- System.err.println( "double buffering is using blitting" );
-
- int width = 1600;
- int height = 1200;
- Graphics2D graphics = (Graphics2D)frame.getGraphics();
- VolatileImage backBuffer = graphics.getDeviceConfiguration().createCompatibleVolatileImage(width,height); // TODO: size dynamic
- BufferedImage buffer = graphics.getDeviceConfiguration().createCompatibleImage(width,height,
- Transparency.TRANSLUCENT);
- BufferedImage buffer2 = graphics.getDeviceConfiguration().createCompatibleImage(width,height,
- Transparency.TRANSLUCENT);
- BufferedImage buffer3 = graphics.getDeviceConfiguration().createCompatibleImage(width,height,
- Transparency.TRANSLUCENT);
-
- GraphicsDevice device = graphics.getDeviceConfiguration().getDevice();
- System.err.println( "Images generated. Available vram: " + device.getAvailableAcceleratedMemory() );
-
- Graphics2D bufferGraphics = (Graphics2D)buffer.getGraphics();
- Graphics2D buffer2Graphics = (Graphics2D)buffer2.getGraphics();
- Graphics2D buffer3Graphics = (Graphics2D)buffer3.getGraphics();
- Graphics2D backBufGraphics = (Graphics2D)backBuffer.getGraphics();
-
- System.err.println( "Image graphics generated. Available vram: " + device.getAvailableAcceleratedMemory() );
-
- // init Graphics
- initGraphics( graphics );
- initGraphics( bufferGraphics );
- initGraphics( buffer2Graphics );
- initGraphics( backBufGraphics );
-
- // init content
- Font font = new Font( "Times", Font.PLAIN, 100 );
- Font fpsFont = new Font( "Times", Font.PLAIN, 20 );
-
- bufferGraphics.setComposite( AlphaComposite.getInstance(AlphaComposite.CLEAR));
- bufferGraphics.fillRect( 0,0,width,height );
-
- bufferGraphics.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
- bufferGraphics.setColor( Color.red );
- bufferGraphics.fillRect( 0,0,width/2,height/2 );
- bufferGraphics.setColor( Color.green );
- bufferGraphics.fillRect( width/2,0,width,height/2 );
- bufferGraphics.setColor( Color.blue );
- bufferGraphics.fillRect( 0,height/2,width/2,height );
-
- buffer2Graphics.setColor( Color.red );
- buffer2Graphics.fillRect( 0,0,width/2,height/2 );
- buffer2Graphics.setColor( Color.green );
- buffer2Graphics.fillRect( width/2,0,width,height/2 );
- buffer2Graphics.setColor( Color.blue );
- buffer2Graphics.fillRect( 0,height/2,width/2,height );
-
- buffer3Graphics.setColor( Color.blue );
- buffer3Graphics.fillRect( 0,0,width/2,height/2 );
- buffer3Graphics.setColor( Color.white );
- buffer3Graphics.fillRect( width/2,0,width,height/2 );
- buffer3Graphics.setColor( Color.gray );
- buffer3Graphics.fillRect( 0,height/2,width/2,height );
-
- backBufGraphics.setColor( Color.white );
- backBufGraphics.fillRect(0,0,width,height);
- backBufGraphics.setColor( Color.red );
- backBufGraphics.setFont( font );
- int i, turns=15;
- for(i=0; i<turns; ++i)
- {
- backBufGraphics.drawString( "Crossfade test", width*i/turns, height*i/turns );
- }
-
- System.err.println( "Images filled with content. Available vram: " + device.getAvailableAcceleratedMemory() );
-
- long lastTime = System.currentTimeMillis();
- int turn, numTurns = 100;
- for(turn=0; turn<numTurns; ++turn)
- {
- // fetch the Graphics object to draw into (we're doing double
- // buffering here, the content is later shown via
- // bufferStrategy.show().
- Graphics2D graph = null;
-
- try
- {
- graph = (Graphics2D)bufferStrategy.getDrawGraphics();
-
- try
- {
- // repaint background
- graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER) );
- graph.drawImage(backBuffer, 0, 0, null);
-
- // alpha-composite foreground on top of that
- float alpha = turn/(float)numTurns;
- graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha) );
-
- graph.drawImage(buffer, 0, 0, null);
- buffer.flush();
- graph.drawImage(buffer2, 100, 100, null);
- buffer2.flush();
-
- long currTime = System.currentTimeMillis();
- graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER) );
- graph.setFont( fpsFont );
- graph.setColor( Color.black );
- String fps = new String( String.valueOf(1000.0/(currTime-lastTime)) );
- System.err.println( "Images composited. Framerate: " + fps + " fps" );
- graph.drawString( fps.substring(0,5) + " fps", 0, 20);
- lastTime = currTime;
-
- System.err.println( "Available vram: " + device.getAvailableAcceleratedMemory() );
- }
- catch( Exception e )
- {
- }
-
- System.err.println( "Turn: " + turn );
- }
- finally
- {
- if( graph != null )
- graph.dispose();
- }
-
- bufferStrategy.show();
- }
-
- try
- {
- Thread.sleep(2000);
- }
- catch( Exception e )
- {
- }
- }
-
- //----------------------------------------------------------------------------------
-
- public static void main(String[] args)
- {
- // now, we're getting slightly system dependent here.
- String os = (String) System.getProperty("os.name");
-
- System.err.println( "System detected: " + os );
-
- // tweak some speed knobs...
- if( os.startsWith("Windows") )
- {
- System.setProperty("sun.java2d.translaccel", "true");
- System.setProperty("sun.java2d.ddforcevram", "true");
- //System.setProperty("sun.java2d.accthreshold", "0");
-
- System.err.println( "Optimizing for Windows" );
- }
- else
- {
- System.setProperty("sun.java2d.opengl", "true");
-
- System.err.println( "Optimizing for Unix" );
- }
-
- PerfTest test = new PerfTest();
-
- test.run();
-
- test.dispose();
- }
-
- //----------------------------------------------------------------------------------
-
-}
diff --git a/canvas/source/java/perftest/WindowAdapter.java b/canvas/source/java/perftest/WindowAdapter.java
deleted file mode 100644
index fa34e6720fc7..000000000000
--- a/canvas/source/java/perftest/WindowAdapter.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-import sun.awt.*;
-import com.sun.star.awt.*;
-
-
-public class WindowAdapter
-// defacto implementing the interface, but not deriving from it, since
-// we're no real XInterface here
-// implements com.sun.star.awt.XWindow
-{
- // the frame object we're generating. TODO: Remove public access.
- public java.awt.Frame frame;
- private boolean fullscreen;
-
- public WindowAdapter( int windowHandle,
- boolean _fullscreen )
- {
- CanvasUtils.printLog( "WindowAdapter(X11): constructor called" );
- fullscreen = false;
-
- if( _fullscreen )
- {
- // create a normal Java frame, and set it into fullscreen mode
- frame = new javax.swing.JFrame( "Presentation" );
- frame.setUndecorated( true );
- frame.setVisible( true );
-
- java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics();
- if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() )
- {
- CanvasUtils.printLog( "WindowAdapter(X11): entering fullscreen mode" );
- graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( frame );
- fullscreen = true;
- }
- else
- {
- CanvasUtils.printLog( "WindowAdapter(X11): fullscreen not supported" );
- }
-
- graphics.dispose();
- }
- else
- {
- // we're initialized with the operating system window handle
- // as the parameter. We then generate a dummy Java frame with
- // that window as the parent, to fake a root window for the
- // Java implementation.
-
- // now, we're getting slightly system dependent here.
- String os = (String) System.getProperty("os.name");
-
- System.err.println("WindowAdapter created");
-
- // create the embedded frame
- if( os.startsWith("Linux") )
- {
- // create a java frame from that
- // TODO: Maybe that's the reason why we crash on Linux 1.5beta
- // immediately: Try XAWT here, or naked X: sun.awt.X11.XEmbeddedFrame
-
- //frame = new sun.awt.motif.MEmbeddedFrame( windowHandle );
- //frame = new sun.awt.X11.XEmbeddedFrame( windowHandle ); // cannot currently compile
- CanvasUtils.printLog( "WindowAdapter(X11): no frame created for now" );
- frame = null;
- }
- else
- {
- throw new com.sun.star.uno.RuntimeException();
- }
- }
- }
-
- //----------------------------------------------------------------------------------
-
- public void dispose()
- {
- if( fullscreen )
- {
- java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics();
- if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() )
- {
- CanvasUtils.printLog( "WindowAdapter(X11): leaving fullscreen mode" );
- graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( null );
- }
- graphics.dispose();
- }
-
- if( frame != null )
- frame.dispose();
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XWindow interface
- // =================
- //
- public void setPosSize( int X, int Y, int Width, int Height, short Flags )
- {
- frame.setBounds( new java.awt.Rectangle( X, Y, Width, Height ) );
- }
-
- public com.sun.star.awt.Rectangle getPosSize( )
- {
- java.awt.Rectangle bounds = frame.getBounds();
-
- return new com.sun.star.awt.Rectangle( bounds.x, bounds.y, bounds.width, bounds.height );
- }
-
- public void setVisible( boolean visible )
- {
- frame.setVisible( visible );
- }
-
- public void setEnable( boolean enable )
- {
- frame.setEnabled( enable );
- }
-
- public void setFocus()
- {
- }
-
- public void addWindowListener( XWindowListener xListener )
- {
- }
-
- public void removeWindowListener( XWindowListener xListener )
- {
- }
-
- public void addFocusListener( XFocusListener xListener )
- {
- }
-
- public void removeFocusListener( XFocusListener xListener )
- {
- }
-
- public void addKeyListener( XKeyListener xListener )
- {
- }
-
- public void removeKeyListener( XKeyListener xListener )
- {
- }
-
- public void addMouseListener( XMouseListener xListener )
- {
- }
-
- public void removeMouseListener( XMouseListener xListener )
- {
- }
-
- public void addMouseMotionListener( XMouseMotionListener xListener )
- {
- }
-
- public void removeMouseMotionListener( XMouseMotionListener xListener )
- {
- }
-
- public void addPaintListener( XPaintListener xListener )
- {
- }
-
- public void removePaintListener( XPaintListener xListener )
- {
- }
-}
diff --git a/canvas/source/java/perftest/makefile.mk b/canvas/source/java/perftest/makefile.mk
deleted file mode 100644
index 787a42adfb74..000000000000
--- a/canvas/source/java/perftest/makefile.mk
+++ /dev/null
@@ -1,55 +0,0 @@
-#*************************************************************************
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# Copyright 2000, 2010 Oracle and/or its affiliates.
-#
-# OpenOffice.org - a multi-platform office productivity suite
-#
-# This file is part of OpenOffice.org.
-#
-# OpenOffice.org is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License version 3
-# only, as published by the Free Software Foundation.
-#
-# OpenOffice.org is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License version 3 for more details
-# (a copy is included in the LICENSE file that accompanied this code).
-#
-# You should have received a copy of the GNU Lesser General Public License
-# version 3 along with OpenOffice.org. If not, see
-# <http://www.openoffice.org/license.html>
-# for a copy of the LGPLv3 License.
-#
-#*************************************************************************
-
-# Builds the Java Canvas implementation.
-
-PRJNAME = canvas
-PRJ = ../../..
-TARGET = PerfTest
-PACKAGE = test
-
-# --- Settings -----------------------------------------------------
-
-.INCLUDE: settings.mk
-
-JAVAFILES = \
- PerfTest.java
-
-JARFILES = jurt.jar unoil.jar ridl.jar juh.jar java_uno.jar
-JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
-
-JARTARGET = $(TARGET).jar
-JARCOMPRESS = TRUE
-#JARCLASSDIRS = $(PACKAGE)
-CUSTOMMANIFESTFILE = manifest
-
-# --- Targets ------------------------------------------------------
-
-.INCLUDE: target.mk
-
-#dist: $(JAVA_FILES:b:+".class")
-# +jar -cvfm $(CLASSDIR)/PerfTest.jar $(JARMANIFEST) $(JAVACLASSFILES)
diff --git a/canvas/source/java/perftest/manifest b/canvas/source/java/perftest/manifest
deleted file mode 100644
index 805a87d47b57..000000000000
--- a/canvas/source/java/perftest/manifest
+++ /dev/null
@@ -1 +0,0 @@
-RegistrationClassName: PerfTest
diff --git a/canvas/source/java/win/WindowAdapter.java b/canvas/source/java/win/WindowAdapter.java
deleted file mode 100644
index 6cfe54db5991..000000000000
--- a/canvas/source/java/win/WindowAdapter.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// UNO
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.XComponentContext;
-import com.sun.star.uno.AnyConverter;
-import com.sun.star.lang.XInitialization;
-import com.sun.star.lib.uno.helper.WeakBase;
-
-// OOo AWT
-import com.sun.star.awt.*;
-
-// system-dependent stuff
-import sun.awt.*;
-
-
-public class WindowAdapter
-// defacto implementing the interface, but not deriving from it, since
-// we're no real XInterface here
-// implements com.sun.star.awt.XWindow
-{
- public java.awt.Frame frame;
- private boolean fullscreen;
-
- public WindowAdapter( int windowHandle,
- boolean _fullscreen )
- {
- fullscreen = false;
-
- if( _fullscreen )
- {
- // create a normal Java frame, and set it into fullscreen mode
- frame = new javax.swing.JFrame( "Presentation" );
- frame.setUndecorated( true );
- frame.setVisible( true );
-
- java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics();
- if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() )
- {
- CanvasUtils.printLog( "WindowAdapter(Win32): entering fullscreen mode" );
- graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( frame );
- fullscreen = true;
- }
- else
- {
- CanvasUtils.printLog( "WindowAdapter(Win32): fullscreen not supported" );
- }
-
- graphics.dispose();
- }
- else
- {
- // we're initialized with the operating system window handle
- // as the parameter. We then generate a dummy Java frame with
- // that window as the parent, to fake a root window for the
- // Java implementation.
-
- // now, we're getting slightly system dependent here.
- String os = (String) System.getProperty("os.name");
-
- // create the embedded frame
- if( os.startsWith("Windows") )
- frame = new sun.awt.windows.WEmbeddedFrame( windowHandle );
- else
- throw new com.sun.star.uno.RuntimeException();
-
-
-// frame = new javax.swing.JFrame( "Test window" );
-
-// // resize it according to the given bounds
-// frame.setBounds( boundRect );
-// frame.setVisible( true );
- }
- }
-
- //----------------------------------------------------------------------------------
-
- public void dispose()
- {
- if( fullscreen )
- {
- java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics();
- if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() )
- {
- CanvasUtils.printLog( "WindowAdapter(Win32): leaving fullscreen mode" );
- graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( null );
- }
- graphics.dispose();
- }
-
- if( frame != null )
- frame.dispose();
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XWindow interface
- // =================
- //
- public void setPosSize( int X, int Y, int Width, int Height, short Flags )
- {
- frame.setBounds( new java.awt.Rectangle( X, Y, Width, Height ) );
- }
-
- public com.sun.star.awt.Rectangle getPosSize( )
- {
- java.awt.Rectangle bounds = frame.getBounds();
-
- return new com.sun.star.awt.Rectangle( bounds.x, bounds.y, bounds.width, bounds.height );
- }
-
- public void setVisible( boolean visible )
- {
- frame.setVisible( visible );
- }
-
- public void setEnable( boolean enable )
- {
- frame.setEnabled( enable );
- }
-
- public void setFocus()
- {
- }
-
- public void addWindowListener( XWindowListener xListener )
- {
- }
-
- public void removeWindowListener( XWindowListener xListener )
- {
- }
-
- public void addFocusListener( XFocusListener xListener )
- {
- }
-
- public void removeFocusListener( XFocusListener xListener )
- {
- }
-
- public void addKeyListener( XKeyListener xListener )
- {
- }
-
- public void removeKeyListener( XKeyListener xListener )
- {
- }
-
- public void addMouseListener( XMouseListener xListener )
- {
- }
-
- public void removeMouseListener( XMouseListener xListener )
- {
- }
-
- public void addMouseMotionListener( XMouseMotionListener xListener )
- {
- }
-
- public void removeMouseMotionListener( XMouseMotionListener xListener )
- {
- }
-
- public void addPaintListener( XPaintListener xListener )
- {
- }
-
- public void removePaintListener( XPaintListener xListener )
- {
- }
-}
diff --git a/canvas/source/java/x11/WindowAdapter.java b/canvas/source/java/x11/WindowAdapter.java
deleted file mode 100644
index 555f6c8ca1b8..000000000000
--- a/canvas/source/java/x11/WindowAdapter.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-import com.sun.star.awt.*;
-
-
-public class WindowAdapter
-// defacto implementing the interface, but not deriving from it, since
-// we're no real XInterface here
-// implements com.sun.star.awt.XWindow
-{
- // the frame object we're generating. TODO: Remove public access.
- public java.awt.Frame frame;
- private boolean fullscreen;
-
- public WindowAdapter( int windowHandle,
- boolean _fullscreen )
- {
- CanvasUtils.printLog( "WindowAdapter(X11): constructor called" );
- fullscreen = false;
-
- if( _fullscreen )
- {
- // create a normal Java frame, and set it into fullscreen mode
- frame = new javax.swing.JFrame( "Presentation" );
- frame.setUndecorated( true );
- frame.setVisible( true );
-
- java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics();
- if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() )
- {
- CanvasUtils.printLog( "WindowAdapter(X11): entering fullscreen mode" );
- graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( frame );
- fullscreen = true;
- }
- else
- {
- CanvasUtils.printLog( "WindowAdapter(X11): fullscreen not supported" );
- }
-
- graphics.dispose();
- }
- else
- {
- // we're initialized with the operating system window handle
- // as the parameter. We then generate a dummy Java frame with
- // that window as the parent, to fake a root window for the
- // Java implementation.
-
- // now, we're getting slightly system dependent here.
- String os = (String) System.getProperty("os.name");
-
- System.err.println("WindowAdapter created");
-
- // create the embedded frame
- if( os.startsWith("Linux") )
- {
- // create a java frame from that
- // TODO: Maybe that's the reason why we crash on Linux 1.5beta
- // immediately: Try XAWT here, or naked X: sun.awt.X11.XEmbeddedFrame
-
- // TODO
- //frame = new sun.awt.motif.MEmbeddedFrame( windowHandle ); // Crashes 1.5, because class is unknown
- //frame = new sun.awt.X11.XEmbeddedFrame( windowHandle ); // cannot currently compile, because class is not in 1.4.
- CanvasUtils.printLog( "WindowAdapter(X11): no frame created for now" );
- frame = null; // disabled for now
- }
- else
- {
- throw new com.sun.star.uno.RuntimeException();
- }
- }
- }
-
- //----------------------------------------------------------------------------------
-
- public void dispose()
- {
- if( fullscreen )
- {
- java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics();
- if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() )
- {
- CanvasUtils.printLog( "WindowAdapter(X11): leaving fullscreen mode" );
- graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( null );
- }
- graphics.dispose();
- }
-
- if( frame != null )
- frame.dispose();
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XWindow interface
- // =================
- //
- public void setPosSize( int X, int Y, int Width, int Height, short Flags )
- {
- frame.setBounds( new java.awt.Rectangle( X, Y, Width, Height ) );
- }
-
- public com.sun.star.awt.Rectangle getPosSize( )
- {
- java.awt.Rectangle bounds = frame.getBounds();
-
- return new com.sun.star.awt.Rectangle( bounds.x, bounds.y, bounds.width, bounds.height );
- }
-
- public void setVisible( boolean visible )
- {
- frame.setVisible( visible );
- }
-
- public void setEnable( boolean enable )
- {
- frame.setEnabled( enable );
- }
-
- public void setFocus()
- {
- }
-
- public void addWindowListener( XWindowListener xListener )
- {
- }
-
- public void removeWindowListener( XWindowListener xListener )
- {
- }
-
- public void addFocusListener( XFocusListener xListener )
- {
- }
-
- public void removeFocusListener( XFocusListener xListener )
- {
- }
-
- public void addKeyListener( XKeyListener xListener )
- {
- }
-
- public void removeKeyListener( XKeyListener xListener )
- {
- }
-
- public void addMouseListener( XMouseListener xListener )
- {
- }
-
- public void removeMouseListener( XMouseListener xListener )
- {
- }
-
- public void addMouseMotionListener( XMouseMotionListener xListener )
- {
- }
-
- public void removeMouseMotionListener( XMouseMotionListener xListener )
- {
- }
-
- public void addPaintListener( XPaintListener xListener )
- {
- }
-
- public void removePaintListener( XPaintListener xListener )
- {
- }
-}
diff --git a/canvas/source/null/null_spritecanvas.hxx b/canvas/source/null/null_spritecanvas.hxx
index 662897a3df10..136e09a291db 100644
--- a/canvas/source/null/null_spritecanvas.hxx
+++ b/canvas/source/null/null_spritecanvas.hxx
@@ -38,7 +38,7 @@
#include <com/sun/star/rendering/XIntegerBitmap.hpp>
#include <com/sun/star/rendering/XGraphicDevice.hpp>
#include <com/sun/star/rendering/XBufferController.hpp>
-#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <cppuhelper/compbase8.hxx>
#include <comphelper/uno3.hxx>
@@ -57,7 +57,7 @@ namespace nullcanvas
typedef ::cppu::WeakComponentImplHelper8< ::com::sun::star::rendering::XSpriteCanvas,
::com::sun::star::rendering::XIntegerBitmap,
::com::sun::star::rendering::XGraphicDevice,
- ::com::sun::star::rendering::XParametricPolyPolygon2DFactory,
+ ::com::sun::star::lang::XMultiServiceFactory,
::com::sun::star::rendering::XBufferController,
::com::sun::star::awt::XWindowListener,
::com::sun::star::beans::XPropertySet,
diff --git a/canvas/source/tools/canvastools.cxx b/canvas/source/tools/canvastools.cxx
index 7ce8d02038b9..ad833cc3ca40 100644..100755
--- a/canvas/source/tools/canvastools.cxx
+++ b/canvas/source/tools/canvastools.cxx
@@ -991,6 +991,54 @@ namespace canvas
return aPolyPoly;
}
+ int calcGradientStepCount( ::basegfx::B2DHomMatrix& rTotalTransform,
+ const rendering::ViewState& viewState,
+ const rendering::RenderState& renderState,
+ const rendering::Texture& texture,
+ int nColorSteps )
+ {
+ // calculate overall texture transformation (directly from
+ // texture to device space).
+ ::basegfx::B2DHomMatrix aMatrix;
+
+ rTotalTransform.identity();
+ ::basegfx::unotools::homMatrixFromAffineMatrix( rTotalTransform,
+ texture.AffineTransform );
+ ::canvas::tools::mergeViewAndRenderTransform(aMatrix,
+ viewState,
+ renderState);
+ rTotalTransform *= aMatrix; // prepend total view/render transformation
+
+ // determine size of gradient in device coordinate system
+ // (to e.g. determine sensible number of gradient steps)
+ ::basegfx::B2DPoint aLeftTop( 0.0, 0.0 );
+ ::basegfx::B2DPoint aLeftBottom( 0.0, 1.0 );
+ ::basegfx::B2DPoint aRightTop( 1.0, 0.0 );
+ ::basegfx::B2DPoint aRightBottom( 1.0, 1.0 );
+
+ aLeftTop *= rTotalTransform;
+ aLeftBottom *= rTotalTransform;
+ aRightTop *= rTotalTransform;
+ aRightBottom*= rTotalTransform;
+
+ // longest line in gradient bound rect
+ const int nGradientSize(
+ static_cast<int>(
+ ::std::max(
+ ::basegfx::B2DVector(aRightBottom-aLeftTop).getLength(),
+ ::basegfx::B2DVector(aRightTop-aLeftBottom).getLength() ) + 1.0 ) );
+
+ // typical number for pixel of the same color (strip size)
+ const int nStripSize( nGradientSize < 50 ? 2 : 4 );
+
+ // use at least three steps, and at utmost the number of color
+ // steps
+ return ::std::max( 3,
+ ::std::min(
+ nGradientSize / nStripSize,
+ nColorSteps ) );
+ }
+
} // namespace tools
} // namespace canvas
diff --git a/canvas/source/tools/image.cxx b/canvas/source/tools/image.cxx
index 2b7d38abc8ea..b6183e463e99 100644
--- a/canvas/source/tools/image.cxx
+++ b/canvas/source/tools/image.cxx
@@ -1512,7 +1512,7 @@ void Image::fillGradientImpl( const ParametricPolyPolygon::Values& rValues,
typedef color_generator_adaptor<color_type> color_generator_type;
unsigned int dwNumSteps = static_cast<unsigned int>(rBounds.getWidth());
color_generator_type colors(color1,color2,dwNumSteps);
- colors.set_linear(rValues.meType != ParametricPolyPolygon::GRADIENT_AXIAL);
+ colors.set_linear(true);
// color = f(x,y)
gradient_polymorphic_wrapper<agg::gradient_x> gf_x;
diff --git a/canvas/source/tools/parametricpolypolygon.cxx b/canvas/source/tools/parametricpolypolygon.cxx
index db449f6c15f8..368f04a572e3 100644
--- a/canvas/source/tools/parametricpolypolygon.cxx
+++ b/canvas/source/tools/parametricpolypolygon.cxx
@@ -50,68 +50,126 @@ using namespace ::com::sun::star;
namespace canvas
{
- ParametricPolyPolygon* ParametricPolyPolygon::createLinearHorizontalGradient(
- const uno::Reference< rendering::XGraphicDevice >& rDevice,
- const uno::Sequence< uno::Sequence< double > >& colors,
- const uno::Sequence< double >& stops )
+ uno::Sequence<rtl::OUString> ParametricPolyPolygon::getAvailableServiceNames()
{
- // TODO(P2): hold gradient brush statically, and only setup
- // the colors
- return new ParametricPolyPolygon( rDevice, GRADIENT_LINEAR, colors, stops );
+ uno::Sequence<rtl::OUString> aRet(3);
+ aRet[0] = rtl::OUString::createFromAscii("LinearGradient");
+ aRet[1] = rtl::OUString::createFromAscii("EllipticalGradient");
+ aRet[2] = rtl::OUString::createFromAscii("RectangularGradient");
+
+ return aRet;
+ }
+
+ ParametricPolyPolygon* ParametricPolyPolygon::create(
+ const uno::Reference< rendering::XGraphicDevice >& rDevice,
+ const ::rtl::OUString& rServiceName,
+ const uno::Sequence< uno::Any >& rArgs )
+ {
+ uno::Sequence< uno::Sequence< double > > colorSequence(2);
+ uno::Sequence< double > colorStops(2);
+ double fAspectRatio=1.0;
+
+ // defaults
+ uno::Sequence< rendering::RGBColor > rgbColors(1);
+ rgbColors[0] = rendering::RGBColor(0,0,0);
+ colorSequence[0] = rDevice->getDeviceColorSpace()->convertFromRGB(rgbColors);
+ rgbColors[0] = rendering::RGBColor(1,1,1);
+ colorSequence[1] = rDevice->getDeviceColorSpace()->convertFromRGB(rgbColors);
+ colorStops[0] = 0;
+ colorStops[1] = 1;
+
+ // extract args
+ for( sal_Int32 i=0; i<rArgs.getLength(); ++i )
+ {
+ beans::PropertyValue aProp;
+ if( (rArgs[i] >>= aProp) )
+ {
+ if( aProp.Name.equalsAscii("Colors") )
+ {
+ aProp.Value >>= colorSequence;
+ }
+ else if( aProp.Name.equalsAscii("Stops") )
+ {
+ aProp.Value >>= colorStops;
+ }
+ else if( aProp.Name.equalsAscii("AspectRatio") )
+ {
+ aProp.Value >>= fAspectRatio;
+ }
+ }
+ }
+
+ if( rServiceName.equalsAscii("LinearGradient") )
+ {
+ return createLinearHorizontalGradient(rDevice, colorSequence, colorStops);
+ }
+ else if( rServiceName.equalsAscii("EllipticalGradient") )
+ {
+ return createEllipticalGradient(rDevice, colorSequence, colorStops, fAspectRatio);
+ }
+ else if( rServiceName.equalsAscii("RectangularGradient") )
+ {
+ return createRectangularGradient(rDevice, colorSequence, colorStops, fAspectRatio);
+ }
+ else if( rServiceName.equalsAscii("VerticalLineHatch") )
+ {
+ // TODO: NYI
+ }
+ else if( rServiceName.equalsAscii("OrthogonalLinesHatch") )
+ {
+ // TODO: NYI
+ }
+ else if( rServiceName.equalsAscii("ThreeCrossingLinesHatch") )
+ {
+ // TODO: NYI
+ }
+ else if( rServiceName.equalsAscii("FourCrossingLinesHatch") )
+ {
+ // TODO: NYI
+ }
+
+ return NULL;
}
- ParametricPolyPolygon* ParametricPolyPolygon::createAxialHorizontalGradient(
+ ParametricPolyPolygon* ParametricPolyPolygon::createLinearHorizontalGradient(
const uno::Reference< rendering::XGraphicDevice >& rDevice,
const uno::Sequence< uno::Sequence< double > >& colors,
const uno::Sequence< double >& stops )
{
// TODO(P2): hold gradient brush statically, and only setup
// the colors
- return new ParametricPolyPolygon( rDevice, GRADIENT_AXIAL, colors, stops );
- }
-
- namespace
- {
- double calcAspectRatio( const geometry::RealRectangle2D& rBoundRect )
- {
- const double nWidth( rBoundRect.X2 - rBoundRect.X1 );
- const double nHeight( rBoundRect.Y2 - rBoundRect.Y1 );
-
- return ::basegfx::fTools::equalZero( nHeight ) ? 1.0 : fabs( nWidth / nHeight );
- }
+ return new ParametricPolyPolygon( rDevice, GRADIENT_LINEAR, colors, stops );
}
ParametricPolyPolygon* ParametricPolyPolygon::createEllipticalGradient(
const uno::Reference< rendering::XGraphicDevice >& rDevice,
const uno::Sequence< uno::Sequence< double > >& colors,
const uno::Sequence< double >& stops,
- const geometry::RealRectangle2D& boundRect )
+ double fAspectRatio )
{
// TODO(P2): hold gradient polygon statically, and only setup
// the colors
return new ParametricPolyPolygon(
rDevice,
::basegfx::tools::createPolygonFromCircle(
- ::basegfx::B2DPoint( 0.5, 0.5), 0.5 ),
+ ::basegfx::B2DPoint(0,0), 1 ),
GRADIENT_ELLIPTICAL,
- colors, stops,
- calcAspectRatio( boundRect ) );
+ colors, stops, fAspectRatio );
}
ParametricPolyPolygon* ParametricPolyPolygon::createRectangularGradient( const uno::Reference< rendering::XGraphicDevice >& rDevice,
const uno::Sequence< uno::Sequence< double > >& colors,
const uno::Sequence< double >& stops,
- const geometry::RealRectangle2D& boundRect )
+ double fAspectRatio )
{
// TODO(P2): hold gradient polygon statically, and only setup
// the colors
return new ParametricPolyPolygon(
rDevice,
::basegfx::tools::createPolygonFromRect(
- ::basegfx::B2DRectangle( 0.0, 0.0, 1.0, 1.0 ) ),
+ ::basegfx::B2DRectangle( -1, -1, 1, 1 ) ),
GRADIENT_RECTANGULAR,
- colors, stops,
- calcAspectRatio( boundRect ) );
+ colors, stops, fAspectRatio );
}
void SAL_CALL ParametricPolyPolygon::disposing()
diff --git a/canvas/source/tools/verifyinput.cxx b/canvas/source/tools/verifyinput.cxx
index c2ee4ed968a0..42ab1c7aee19 100644
--- a/canvas/source/tools/verifyinput.cxx
+++ b/canvas/source/tools/verifyinput.cxx
@@ -426,7 +426,7 @@ namespace canvas
#endif
}
- if( texture.RepeatModeX < rendering::TexturingMode::CLAMP ||
+ if( texture.RepeatModeX < rendering::TexturingMode::NONE ||
texture.RepeatModeX > rendering::TexturingMode::REPEAT )
{
#if OSL_DEBUG_LEVEL > 0
@@ -442,7 +442,7 @@ namespace canvas
#endif
}
- if( texture.RepeatModeY < rendering::TexturingMode::CLAMP ||
+ if( texture.RepeatModeY < rendering::TexturingMode::NONE ||
texture.RepeatModeY > rendering::TexturingMode::REPEAT )
{
#if OSL_DEBUG_LEVEL > 0
diff --git a/canvas/source/vcl/canvas.hxx b/canvas/source/vcl/canvas.hxx
index f7667d8f2c19..adda8d8eea40 100644
--- a/canvas/source/vcl/canvas.hxx
+++ b/canvas/source/vcl/canvas.hxx
@@ -38,7 +38,6 @@
#include <com/sun/star/rendering/XIntegerBitmap.hpp>
#include <com/sun/star/rendering/XGraphicDevice.hpp>
#include <com/sun/star/rendering/XBufferController.hpp>
-#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp>
#include <cppuhelper/compbase7.hxx>
#include <comphelper/uno3.hxx>
@@ -60,7 +59,7 @@ namespace vclcanvas
typedef ::cppu::WeakComponentImplHelper7< ::com::sun::star::rendering::XBitmapCanvas,
::com::sun::star::rendering::XIntegerBitmap,
::com::sun::star::rendering::XGraphicDevice,
- ::com::sun::star::rendering::XParametricPolyPolygon2DFactory,
+ ::com::sun::star::lang::XMultiServiceFactory,
::com::sun::star::util::XUpdatable,
::com::sun::star::beans::XPropertySet,
::com::sun::star::lang::XServiceName > GraphicDeviceBase_Base;
diff --git a/canvas/source/vcl/canvashelper_texturefill.cxx b/canvas/source/vcl/canvashelper_texturefill.cxx
index 11350c0b4f9f..023ceb2b5005 100644..100755
--- a/canvas/source/vcl/canvashelper_texturefill.cxx
+++ b/canvas/source/vcl/canvashelper_texturefill.cxx
@@ -54,6 +54,8 @@
#include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <basegfx/polygon/b2dlinegeometry.hxx>
#include <basegfx/tools/tools.hxx>
+#include <basegfx/tools/lerp.hxx>
+#include <basegfx/tools/keystoplerp.hxx>
#include <basegfx/tools/canvastools.hxx>
#include <basegfx/numeric/ftools.hxx>
@@ -62,6 +64,9 @@
#include <canvas/canvastools.hxx>
#include <canvas/parametricpolypolygon.hxx>
+#include <boost/bind.hpp>
+#include <boost/tuple/tuple.hpp>
+
#include "spritecanvas.hxx"
#include "canvashelper.hxx"
#include "impltools.hxx"
@@ -115,17 +120,13 @@ namespace vclcanvas
Since most of the code for linear and axial gradients are
the same, we've a unified method here
*/
- void fillGeneralLinearGradient( OutputDevice& rOutDev,
- const ::basegfx::B2DHomMatrix& rTextureTransform,
- const ::Rectangle& rBounds,
- int nStepCount,
- const ::Color& rColor1,
- const ::Color& rColor2,
- bool bFillNonOverlapping,
- bool bAxialGradient )
+ void fillLinearGradient( OutputDevice& rOutDev,
+ const ::basegfx::B2DHomMatrix& rTextureTransform,
+ const ::Rectangle& rBounds,
+ unsigned int nStepCount,
+ const ::canvas::ParametricPolyPolygon::Values& rValues,
+ const std::vector< ::Color >& rColors )
{
- (void)bFillNonOverlapping;
-
// determine general position of gradient in relation to
// the bound rect
// =====================================================
@@ -204,36 +205,26 @@ namespace vclcanvas
// iteratively render all other strips
// -----------------------------------
- // ensure that nStepCount is odd, to have a well-defined
- // middle index for axial gradients.
- if( bAxialGradient && !(nStepCount % 2) )
+ // ensure that nStepCount matches color stop parity, to
+ // have a well-defined middle color e.g. for axial
+ // gradients.
+ if( (rColors.size() % 2) != (nStepCount % 2) )
++nStepCount;
- const int nStepCountHalved( nStepCount / 2 );
+ basegfx::tools::KeyStopLerp aLerper(rValues.maStops);
// only iterate nStepCount-1 steps, as the last strip is
// explicitely painted below
- for( int i=0; i<nStepCount-1; ++i )
+ for( unsigned int i=0; i<nStepCount-1; ++i )
{
- // lerp color
- if( bAxialGradient )
- {
- // axial gradient has a triangle-like interpolation function
- const int iPrime( i<=nStepCountHalved ? i : nStepCount-i-1);
+ std::ptrdiff_t nIndex;
+ double fAlpha;
+ boost::tuples::tie(nIndex,fAlpha)=aLerper.lerp(double(i)/nStepCount);
- rOutDev.SetFillColor(
- Color( (UINT8)(((nStepCountHalved - iPrime)*rColor1.GetRed() + iPrime*rColor2.GetRed())/nStepCountHalved),
- (UINT8)(((nStepCountHalved - iPrime)*rColor1.GetGreen() + iPrime*rColor2.GetGreen())/nStepCountHalved),
- (UINT8)(((nStepCountHalved - iPrime)*rColor1.GetBlue() + iPrime*rColor2.GetBlue())/nStepCountHalved) ) );
- }
- else
- {
- // linear gradient has a plain lerp between start and end color
- rOutDev.SetFillColor(
- Color( (UINT8)(((nStepCount - i)*rColor1.GetRed() + i*rColor2.GetRed())/nStepCount),
- (UINT8)(((nStepCount - i)*rColor1.GetGreen() + i*rColor2.GetGreen())/nStepCount),
- (UINT8)(((nStepCount - i)*rColor1.GetBlue() + i*rColor2.GetBlue())/nStepCount) ) );
- }
+ rOutDev.SetFillColor(
+ Color( (UINT8)(basegfx::tools::lerp(rColors[nIndex].GetRed(),rColors[nIndex+1].GetRed(),fAlpha)),
+ (UINT8)(basegfx::tools::lerp(rColors[nIndex].GetGreen(),rColors[nIndex+1].GetGreen(),fAlpha)),
+ (UINT8)(basegfx::tools::lerp(rColors[nIndex].GetBlue(),rColors[nIndex+1].GetBlue(),fAlpha)) ));
// copy right egde of polygon to left edge (and also
// copy the closing point)
@@ -280,59 +271,18 @@ namespace vclcanvas
aTempPoly[3] = ::Point( ::basegfx::fround( rPoint4.getX() ),
::basegfx::fround( rPoint4.getY() ) );
- if( bAxialGradient )
- rOutDev.SetFillColor( rColor1 );
- else
- rOutDev.SetFillColor( rColor2 );
+ rOutDev.SetFillColor( rColors.back() );
rOutDev.DrawPolygon( aTempPoly );
}
-
- inline void fillLinearGradient( OutputDevice& rOutDev,
- const ::Color& rColor1,
- const ::Color& rColor2,
- const ::basegfx::B2DHomMatrix& rTextureTransform,
- const ::Rectangle& rBounds,
- int nStepCount,
- bool bFillNonOverlapping )
- {
- fillGeneralLinearGradient( rOutDev,
- rTextureTransform,
- rBounds,
- nStepCount,
- rColor1,
- rColor2,
- bFillNonOverlapping,
- false );
- }
-
- inline void fillAxialGradient( OutputDevice& rOutDev,
- const ::Color& rColor1,
- const ::Color& rColor2,
- const ::basegfx::B2DHomMatrix& rTextureTransform,
- const ::Rectangle& rBounds,
- int nStepCount,
- bool bFillNonOverlapping )
- {
- fillGeneralLinearGradient( rOutDev,
- rTextureTransform,
- rBounds,
- nStepCount,
- rColor1,
- rColor2,
- bFillNonOverlapping,
- true );
- }
-
void fillPolygonalGradient( OutputDevice& rOutDev,
- const ::canvas::ParametricPolyPolygon::Values& rValues,
- const ::Color& rColor1,
- const ::Color& rColor2,
const ::basegfx::B2DHomMatrix& rTextureTransform,
const ::Rectangle& rBounds,
- int nStepCount,
- bool bFillNonOverlapping )
+ unsigned int nStepCount,
+ bool bFillNonOverlapping,
+ const ::canvas::ParametricPolyPolygon::Values& rValues,
+ const std::vector< ::Color >& rColors )
{
const ::basegfx::B2DPolygon& rGradientPoly( rValues.maGradientPoly );
@@ -366,9 +316,6 @@ namespace vclcanvas
// apply scaling (possibly anisotrophic) to inner polygon
// ------------------------------------------------------
- // move center of scaling to origin
- aInnerPolygonTransformMatrix.translate( -0.5, -0.5 );
-
// scale inner polygon according to aspect ratio: for
// wider-than-tall bounds (nAspectRatio > 1.0), the inner
// polygon, representing the gradient focus, must have
@@ -393,9 +340,6 @@ namespace vclcanvas
aInnerPolygonTransformMatrix.scale( 0.0, 0.0 );
}
- // move origin back to former center of polygon
- aInnerPolygonTransformMatrix.translate( 0.5, 0.5 );
-
// and finally, add texture transform to it.
aInnerPolygonTransformMatrix *= rTextureTransform;
@@ -403,8 +347,8 @@ namespace vclcanvas
aInnerPoly.transform( aInnerPolygonTransformMatrix );
- const sal_Int32 nNumPoints( aOuterPoly.count() );
- ::Polygon aTempPoly( static_cast<USHORT>(nNumPoints+1) );
+ const sal_uInt32 nNumPoints( aOuterPoly.count() );
+ ::Polygon aTempPoly( static_cast<USHORT>(nNumPoints+1) );
// increase number of steps by one: polygonal gradients have
// the outermost polygon rendered in rColor2, and the
@@ -422,37 +366,42 @@ namespace vclcanvas
// color).
++nStepCount;
+ basegfx::tools::KeyStopLerp aLerper(rValues.maStops);
+
if( !bFillNonOverlapping )
{
// fill background
- rOutDev.SetFillColor( rColor1 );
+ rOutDev.SetFillColor( rColors.front() );
rOutDev.DrawRect( rBounds );
// render polygon
// ==============
- for( int i=1,p; i<nStepCount; ++i )
+ for( unsigned int i=1,p; i<nStepCount; ++i )
{
+ const double fT( i/double(nStepCount) );
+
+ std::ptrdiff_t nIndex;
+ double fAlpha;
+ boost::tuples::tie(nIndex,fAlpha)=aLerper.lerp(fT);
+
// lerp color
rOutDev.SetFillColor(
- Color( (UINT8)(((nStepCount - i)*rColor1.GetRed() + i*rColor2.GetRed())/nStepCount),
- (UINT8)(((nStepCount - i)*rColor1.GetGreen() + i*rColor2.GetGreen())/nStepCount),
- (UINT8)(((nStepCount - i)*rColor1.GetBlue() + i*rColor2.GetBlue())/nStepCount) ) );
+ Color( (UINT8)(basegfx::tools::lerp(rColors[nIndex].GetRed(),rColors[nIndex+1].GetRed(),fAlpha)),
+ (UINT8)(basegfx::tools::lerp(rColors[nIndex].GetGreen(),rColors[nIndex+1].GetGreen(),fAlpha)),
+ (UINT8)(basegfx::tools::lerp(rColors[nIndex].GetBlue(),rColors[nIndex+1].GetBlue(),fAlpha)) ));
// scale and render polygon, by interpolating between
// outer and inner polygon.
- // calc interpolation parameter in [0,1] range
- const double nT( (nStepCount-i)/double(nStepCount) );
-
for( p=0; p<nNumPoints; ++p )
{
const ::basegfx::B2DPoint& rOuterPoint( aOuterPoly.getB2DPoint(p) );
const ::basegfx::B2DPoint& rInnerPoint( aInnerPoly.getB2DPoint(p) );
aTempPoly[(USHORT)p] = ::Point(
- basegfx::fround( (1.0-nT)*rInnerPoint.getX() + nT*rOuterPoint.getX() ),
- basegfx::fround( (1.0-nT)*rInnerPoint.getY() + nT*rOuterPoint.getY() ) );
+ basegfx::fround( fT*rInnerPoint.getX() + (1-fT)*rOuterPoint.getX() ),
+ basegfx::fround( fT*rInnerPoint.getY() + (1-fT)*rOuterPoint.getY() ) );
}
// close polygon explicitely
@@ -486,13 +435,19 @@ namespace vclcanvas
aTempPolyPoly.Insert( aTempPoly );
aTempPolyPoly.Insert( aTempPoly2 );
- for( int i=0,p; i<nStepCount; ++i )
+ for( unsigned int i=0,p; i<nStepCount; ++i )
{
+ const double fT( (i+1)/double(nStepCount) );
+
+ std::ptrdiff_t nIndex;
+ double fAlpha;
+ boost::tuples::tie(nIndex,fAlpha)=aLerper.lerp(fT);
+
// lerp color
rOutDev.SetFillColor(
- Color( (UINT8)(((nStepCount - i)*rColor1.GetRed() + i*rColor2.GetRed())/nStepCount),
- (UINT8)(((nStepCount - i)*rColor1.GetGreen() + i*rColor2.GetGreen())/nStepCount),
- (UINT8)(((nStepCount - i)*rColor1.GetBlue() + i*rColor2.GetBlue())/nStepCount) ) );
+ Color( (UINT8)(basegfx::tools::lerp(rColors[nIndex].GetRed(),rColors[nIndex+1].GetRed(),fAlpha)),
+ (UINT8)(basegfx::tools::lerp(rColors[nIndex].GetGreen(),rColors[nIndex+1].GetGreen(),fAlpha)),
+ (UINT8)(basegfx::tools::lerp(rColors[nIndex].GetBlue(),rColors[nIndex+1].GetBlue(),fAlpha)) ));
#if defined(VERBOSE) && OSL_DEBUG_LEVEL > 0
if( i && !(i % 10) )
@@ -503,17 +458,14 @@ namespace vclcanvas
// calculate the inner polygon, which is actually the
// start of the _next_ color strip. Thus, i+1
- // calc interpolation parameter in [0,1] range
- const double nT( (nStepCount-i-1)/double(nStepCount) );
-
for( p=0; p<nNumPoints; ++p )
{
const ::basegfx::B2DPoint& rOuterPoint( aOuterPoly.getB2DPoint(p) );
const ::basegfx::B2DPoint& rInnerPoint( aInnerPoly.getB2DPoint(p) );
aTempPoly[(USHORT)p] = ::Point(
- basegfx::fround( (1.0-nT)*rInnerPoint.getX() + nT*rOuterPoint.getX() ),
- basegfx::fround( (1.0-nT)*rInnerPoint.getY() + nT*rOuterPoint.getY() ) );
+ basegfx::fround( fT*rInnerPoint.getX() + (1-fT)*rOuterPoint.getX() ),
+ basegfx::fround( fT*rInnerPoint.getY() + (1-fT)*rOuterPoint.getY() ) );
}
// close polygon explicitely
@@ -546,46 +498,33 @@ namespace vclcanvas
void doGradientFill( OutputDevice& rOutDev,
const ::canvas::ParametricPolyPolygon::Values& rValues,
- const ::Color& rColor1,
- const ::Color& rColor2,
+ const std::vector< ::Color >& rColors,
const ::basegfx::B2DHomMatrix& rTextureTransform,
const ::Rectangle& rBounds,
- int nStepCount,
+ unsigned int nStepCount,
bool bFillNonOverlapping )
{
switch( rValues.meType )
{
case ::canvas::ParametricPolyPolygon::GRADIENT_LINEAR:
fillLinearGradient( rOutDev,
- rColor1,
- rColor2,
rTextureTransform,
rBounds,
nStepCount,
- bFillNonOverlapping );
- break;
-
- case ::canvas::ParametricPolyPolygon::GRADIENT_AXIAL:
- fillAxialGradient( rOutDev,
- rColor1,
- rColor2,
- rTextureTransform,
- rBounds,
- nStepCount,
- bFillNonOverlapping );
+ rValues,
+ rColors );
break;
case ::canvas::ParametricPolyPolygon::GRADIENT_ELLIPTICAL:
// FALLTHROUGH intended
case ::canvas::ParametricPolyPolygon::GRADIENT_RECTANGULAR:
fillPolygonalGradient( rOutDev,
- rValues,
- rColor1,
- rColor2,
rTextureTransform,
rBounds,
nStepCount,
- bFillNonOverlapping );
+ bFillNonOverlapping,
+ rValues,
+ rColors );
break;
default:
@@ -594,11 +533,19 @@ namespace vclcanvas
}
}
+ int numColorSteps( const ::Color& rColor1, const ::Color& rColor2 )
+ {
+ return ::std::max(
+ labs( rColor1.GetRed() - rColor2.GetRed() ),
+ ::std::max(
+ labs( rColor1.GetGreen() - rColor2.GetGreen() ),
+ labs( rColor1.GetBlue() - rColor2.GetBlue() ) ) );
+ }
+
bool gradientFill( OutputDevice& rOutDev,
OutputDevice* p2ndOutDev,
const ::canvas::ParametricPolyPolygon::Values& rValues,
- const ::Color& rColor1,
- const ::Color& rColor2,
+ const std::vector< ::Color >& rColors,
const PolyPolygon& rPoly,
const rendering::ViewState& viewState,
const rendering::RenderState& renderState,
@@ -612,65 +559,27 @@ namespace vclcanvas
// deadlocks, canvashelper calls this method with locked own
// mutex.
- // calculate overall texture transformation (directly from
- // texture to device space).
- ::basegfx::B2DHomMatrix aMatrix;
- ::basegfx::B2DHomMatrix aTextureTransform;
-
- ::basegfx::unotools::homMatrixFromAffineMatrix( aTextureTransform,
- texture.AffineTransform );
- ::canvas::tools::mergeViewAndRenderTransform(aMatrix,
- viewState,
- renderState);
- aTextureTransform *= aMatrix; // prepend total view/render transformation
-
- // determine maximal bound rect of gradient-filled polygon
- const ::Rectangle aPolygonDeviceRectOrig(
- rPoly.GetBoundRect() );
-
- // determine size of gradient in device coordinate system
- // (to e.g. determine sensible number of gradient steps)
- ::basegfx::B2DPoint aLeftTop( 0.0, 0.0 );
- ::basegfx::B2DPoint aLeftBottom( 0.0, 1.0 );
- ::basegfx::B2DPoint aRightTop( 1.0, 0.0 );
- ::basegfx::B2DPoint aRightBottom( 1.0, 1.0 );
-
- aLeftTop *= aTextureTransform;
- aLeftBottom *= aTextureTransform;
- aRightTop *= aTextureTransform;
- aRightBottom*= aTextureTransform;
-
-
// calc step size
// --------------
- const int nColorSteps(
- ::std::max(
- labs( rColor1.GetRed() - rColor2.GetRed() ),
- ::std::max(
- labs( rColor1.GetGreen() - rColor2.GetGreen() ),
- labs( rColor1.GetBlue() - rColor2.GetBlue() ) ) ) );
-
- // longest line in gradient bound rect
- const int nGradientSize(
- static_cast<int>(
- ::std::max(
- ::basegfx::B2DVector(aRightBottom-aLeftTop).getLength(),
- ::basegfx::B2DVector(aRightTop-aLeftBottom).getLength() ) + 1.0 ) );
-
- // typical number for pixel of the same color (strip size)
- const int nStripSize( nGradientSize < 50 ? 2 : 4 );
-
- // use at least three steps, and at utmost the number of color
- // steps
- const int nStepCount(
- ::std::max(
- 3,
- ::std::min(
- nGradientSize / nStripSize,
- nColorSteps ) ) );
+ int nColorSteps = 0;
+ for( size_t i=0; i<rColors.size()-1; ++i )
+ nColorSteps += numColorSteps(rColors[i],rColors[i+1]);
+
+ ::basegfx::B2DHomMatrix aTotalTransform;
+ const int nStepCount=
+ ::canvas::tools::calcGradientStepCount(aTotalTransform,
+ viewState,
+ renderState,
+ texture,
+ nColorSteps);
rOutDev.SetLineColor();
+ // determine maximal bound rect of texture-filled
+ // polygon
+ const ::Rectangle aPolygonDeviceRectOrig(
+ rPoly.GetBoundRect() );
+
if( tools::isRectangle( rPoly ) )
{
// use optimized output path
@@ -687,9 +596,8 @@ namespace vclcanvas
rOutDev.IntersectClipRegion( aPolygonDeviceRectOrig );
doGradientFill( rOutDev,
rValues,
- rColor1,
- rColor2,
- aTextureTransform,
+ rColors,
+ aTotalTransform,
aPolygonDeviceRectOrig,
nStepCount,
false );
@@ -701,9 +609,8 @@ namespace vclcanvas
p2ndOutDev->IntersectClipRegion( aPolygonDeviceRectOrig );
doGradientFill( *p2ndOutDev,
rValues,
- rColor1,
- rColor2,
- aTextureTransform,
+ rColors,
+ aTotalTransform,
aPolygonDeviceRectOrig,
nStepCount,
false );
@@ -720,9 +627,8 @@ namespace vclcanvas
doGradientFill( rOutDev,
rValues,
- rColor1,
- rColor2,
- aTextureTransform,
+ rColors,
+ aTotalTransform,
aPolygonDeviceRectOrig,
nStepCount,
false );
@@ -734,9 +640,8 @@ namespace vclcanvas
p2ndOutDev->SetClipRegion( aPolyClipRegion );
doGradientFill( *p2ndOutDev,
rValues,
- rColor1,
- rColor2,
- aTextureTransform,
+ rColors,
+ aTotalTransform,
aPolygonDeviceRectOrig,
nStepCount,
false );
@@ -750,9 +655,8 @@ namespace vclcanvas
rOutDev.SetRasterOp( ROP_XOR );
doGradientFill( rOutDev,
rValues,
- rColor1,
- rColor2,
- aTextureTransform,
+ rColors,
+ aTotalTransform,
aPolygonDeviceRectOrig,
nStepCount,
true );
@@ -762,9 +666,8 @@ namespace vclcanvas
rOutDev.SetRasterOp( ROP_XOR );
doGradientFill( rOutDev,
rValues,
- rColor1,
- rColor2,
- aTextureTransform,
+ rColors,
+ aTotalTransform,
aPolygonDeviceRectOrig,
nStepCount,
true );
@@ -776,9 +679,8 @@ namespace vclcanvas
p2ndOutDev->SetRasterOp( ROP_XOR );
doGradientFill( *p2ndOutDev,
rValues,
- rColor1,
- rColor2,
- aTextureTransform,
+ rColors,
+ aTotalTransform,
aPolygonDeviceRectOrig,
nStepCount,
true );
@@ -788,9 +690,8 @@ namespace vclcanvas
p2ndOutDev->SetRasterOp( ROP_XOR );
doGradientFill( *p2ndOutDev,
rValues,
- rColor1,
- rColor2,
- aTextureTransform,
+ rColors,
+ aTotalTransform,
aPolygonDeviceRectOrig,
nStepCount,
true );
@@ -852,33 +753,41 @@ namespace vclcanvas
::canvas::ParametricPolyPolygon* pGradient =
dynamic_cast< ::canvas::ParametricPolyPolygon* >( textures[0].Gradient.get() );
- if( pGradient )
+ if( pGradient && pGradient->getValues().maColors.getLength() )
{
// copy state from Gradient polypoly locally
// (given object might change!)
const ::canvas::ParametricPolyPolygon::Values& rValues(
pGradient->getValues() );
- // TODO: use all the colors and place them on given positions/stops
- const ::Color aColor1(
- ::vcl::unotools::stdColorSpaceSequenceToColor(
- rValues.maColors [0] ) );
- const ::Color aColor2(
- ::vcl::unotools::stdColorSpaceSequenceToColor(
- rValues.maColors [rValues.maColors.getLength () - 1] ) );
-
- // TODO(E1): Return value
- // TODO(F1): FillRule
- gradientFill( mpOutDev->getOutDev(),
- mp2ndOutDev.get() ? &mp2ndOutDev->getOutDev() : (OutputDevice*)NULL,
- rValues,
- aColor1,
- aColor2,
- aPolyPoly,
- viewState,
- renderState,
- textures[0],
- nTransparency );
+ if( rValues.maColors.getLength() < 2 )
+ {
+ rendering::RenderState aTempState=renderState;
+ aTempState.DeviceColor = rValues.maColors[0];
+ fillPolyPolygon(pCanvas, xPolyPolygon, viewState, aTempState);
+ }
+ else
+ {
+ std::vector< ::Color > aColors(rValues.maColors.getLength());
+ std::transform(&rValues.maColors[0],
+ &rValues.maColors[0]+rValues.maColors.getLength(),
+ aColors.begin(),
+ boost::bind(
+ &vcl::unotools::stdColorSpaceSequenceToColor,
+ _1));
+
+ // TODO(E1): Return value
+ // TODO(F1): FillRule
+ gradientFill( mpOutDev->getOutDev(),
+ mp2ndOutDev.get() ? &mp2ndOutDev->getOutDev() : (OutputDevice*)NULL,
+ rValues,
+ aColors,
+ aPolyPoly,
+ viewState,
+ renderState,
+ textures[0],
+ nTransparency );
+ }
}
else
{
@@ -889,10 +798,6 @@ namespace vclcanvas
}
else if( textures[0].Bitmap.is() )
{
-// OSL_ENSURE( textures[0].RepeatModeX == rendering::TexturingMode::REPEAT &&
-// textures[0].RepeatModeY == rendering::TexturingMode::REPEAT,
-// "CanvasHelper::fillTexturedPolyPolygon(): VCL canvas cannot currently clamp textures." );
-
const geometry::IntegerSize2D aBmpSize( textures[0].Bitmap->getSize() );
ENSURE_ARG_OR_THROW( aBmpSize.Width != 0 &&
@@ -967,23 +872,6 @@ namespace vclcanvas
aLocalState );
}
}
- else if ( textures[0].RepeatModeX == rendering::TexturingMode::CLAMP &&
- textures[0].RepeatModeY == rendering::TexturingMode::CLAMP )
- {
- rendering::RenderState aLocalState( renderState );
- ::canvas::tools::appendToRenderState(aLocalState,
- aTextureTransform);
- ::basegfx::B2DHomMatrix aScaleCorrection;
- aScaleCorrection.scale( 1.0/aBmpSize.Width,
- 1.0/aBmpSize.Height );
- ::canvas::tools::appendToRenderState(aLocalState,
- aScaleCorrection);
-
- return drawBitmap( pCanvas,
- textures[0].Bitmap,
- viewState,
- aLocalState );
- }
else
{
// No easy mapping to drawBitmap() - calculate
@@ -1117,15 +1005,21 @@ namespace vclcanvas
aSingleTextureRect,
aPureTotalTransform );
- const ::Point aPt( ::vcl::unotools::pointFromB2DPoint(
- aSingleDeviceTextureRect.getMinimum() ) );
+ const ::Point aPtRepeat( ::vcl::unotools::pointFromB2DPoint(
+ aSingleDeviceTextureRect.getMinimum() ) );
const ::Size aSz( ::basegfx::fround( aScale.getX() * aBmpSize.Width ),
::basegfx::fround( aScale.getY() * aBmpSize.Height ) );
const ::Size aIntegerNextTileX( ::vcl::unotools::sizeFromB2DSize(aNextTileX) );
const ::Size aIntegerNextTileY( ::vcl::unotools::sizeFromB2DSize(aNextTileY) );
- const sal_Int32 nTilesX( nX2 - nX1 );
- const sal_Int32 nTilesY( nY2 - nY1 );
+ const ::Point aPt( textures[0].RepeatModeX == rendering::TexturingMode::NONE ?
+ ::basegfx::fround( aOutputPos.getX() ) : aPtRepeat.X(),
+ textures[0].RepeatModeY == rendering::TexturingMode::NONE ?
+ ::basegfx::fround( aOutputPos.getY() ) : aPtRepeat.Y() );
+ const sal_Int32 nTilesX( textures[0].RepeatModeX == rendering::TexturingMode::NONE ?
+ 1 : nX2 - nX1 );
+ const sal_Int32 nTilesY( textures[0].RepeatModeX == rendering::TexturingMode::NONE ?
+ 1 : nY2 - nY1 );
OutputDevice& rOutDev( mpOutDev->getOutDev() );
@@ -1206,20 +1100,9 @@ namespace vclcanvas
aPolyPoly.Translate( ::Point( -aPolygonDeviceRect.Left(),
-aPolygonDeviceRect.Top() ) );
- aVDev.SetRasterOp( ROP_XOR );
- textureFill( aVDev,
- *pGrfObj,
- aOutPos,
- aIntegerNextTileX,
- aIntegerNextTileY,
- nTilesX,
- nTilesY,
- aSz,
- aGrfAttr );
- aVDev.SetFillColor( COL_BLACK );
- aVDev.SetRasterOp( ROP_0 );
- aVDev.DrawPolyPolygon( aPolyPoly );
- aVDev.SetRasterOp( ROP_XOR );
+ const Region aPolyClipRegion( aPolyPoly );
+
+ aVDev.SetClipRegion( aPolyClipRegion );
textureFill( aVDev,
*pGrfObj,
aOutPos,
@@ -1251,7 +1134,6 @@ namespace vclcanvas
aOutputBmpEx );
}
else
-#if defined(QUARTZ) // TODO: other ports should avoid the XOR-trick too (implementation vs. interface!)
{
const Region aPolyClipRegion( aPolyPoly );
@@ -1287,66 +1169,6 @@ namespace vclcanvas
r2ndOutDev.Pop();
}
}
-#else // TODO: remove once doing the XOR-trick in the canvas-layer becomes redundant
- {
- // output via repeated XORing
- rOutDev.Push( PUSH_RASTEROP );
- rOutDev.SetRasterOp( ROP_XOR );
- textureFill( rOutDev,
- *pGrfObj,
- aPt,
- aIntegerNextTileX,
- aIntegerNextTileY,
- nTilesX,
- nTilesY,
- aSz,
- aGrfAttr );
- rOutDev.SetFillColor( COL_BLACK );
- rOutDev.SetRasterOp( ROP_0 );
- rOutDev.DrawPolyPolygon( aPolyPoly );
- rOutDev.SetRasterOp( ROP_XOR );
- textureFill( rOutDev,
- *pGrfObj,
- aPt,
- aIntegerNextTileX,
- aIntegerNextTileY,
- nTilesX,
- nTilesY,
- aSz,
- aGrfAttr );
- rOutDev.Pop();
-
- if( mp2ndOutDev )
- {
- OutputDevice& r2ndOutDev( mp2ndOutDev->getOutDev() );
- r2ndOutDev.Push( PUSH_RASTEROP );
- r2ndOutDev.SetRasterOp( ROP_XOR );
- textureFill( r2ndOutDev,
- *pGrfObj,
- aPt,
- aIntegerNextTileX,
- aIntegerNextTileY,
- nTilesX,
- nTilesY,
- aSz,
- aGrfAttr );
- r2ndOutDev.SetFillColor( COL_BLACK );
- r2ndOutDev.SetRasterOp( ROP_0 );
- r2ndOutDev.DrawPolyPolygon( aPolyPoly );
- r2ndOutDev.SetRasterOp( ROP_XOR );
- textureFill( r2ndOutDev,
- *pGrfObj,
- aPt,
- aIntegerNextTileX,
- aIntegerNextTileY,
- nTilesX,
- nTilesY,
- aSz,
- aGrfAttr );
- r2ndOutDev.Pop();
- }
- }
-#endif // complex-clipping vs. XOR-trick
}
}
}
diff --git a/canvas/source/vcl/spritecanvas.hxx b/canvas/source/vcl/spritecanvas.hxx
index a5d4a6fe1e10..db4b05ddb9b2 100644
--- a/canvas/source/vcl/spritecanvas.hxx
+++ b/canvas/source/vcl/spritecanvas.hxx
@@ -39,7 +39,6 @@
#include <com/sun/star/rendering/XIntegerBitmap.hpp>
#include <com/sun/star/rendering/XGraphicDevice.hpp>
#include <com/sun/star/rendering/XBufferController.hpp>
-#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp>
#include <cppuhelper/compbase9.hxx>
#include <comphelper/uno3.hxx>
@@ -62,7 +61,7 @@ namespace vclcanvas
typedef ::cppu::WeakComponentImplHelper9< ::com::sun::star::rendering::XSpriteCanvas,
::com::sun::star::rendering::XIntegerBitmap,
::com::sun::star::rendering::XGraphicDevice,
- ::com::sun::star::rendering::XParametricPolyPolygon2DFactory,
+ ::com::sun::star::lang::XMultiServiceFactory,
::com::sun::star::rendering::XBufferController,
::com::sun::star::awt::XWindowListener,
::com::sun::star::util::XUpdatable,