1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski // MARKER(update_precomp.py): autogen include statement, do not remove 25*b1cdbd2cSJim Jagielski #include "precompiled_canvas.hxx" 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski #include <canvas/debug.hxx> 28*b1cdbd2cSJim Jagielski #include <tools/diagnose_ex.h> 29*b1cdbd2cSJim Jagielski #include <canvas/verbosetrace.hxx> 30*b1cdbd2cSJim Jagielski #include <canvas/canvastools.hxx> 31*b1cdbd2cSJim Jagielski 32*b1cdbd2cSJim Jagielski #include <osl/mutex.hxx> 33*b1cdbd2cSJim Jagielski 34*b1cdbd2cSJim Jagielski #include <com/sun/star/registry/XRegistryKey.hpp> 35*b1cdbd2cSJim Jagielski #include <com/sun/star/lang/XSingleServiceFactory.hpp> 36*b1cdbd2cSJim Jagielski #include <com/sun/star/uno/XComponentContext.hpp> 37*b1cdbd2cSJim Jagielski 38*b1cdbd2cSJim Jagielski #include <cppuhelper/factory.hxx> 39*b1cdbd2cSJim Jagielski #include <cppuhelper/implementationentry.hxx> 40*b1cdbd2cSJim Jagielski #include <comphelper/servicedecl.hxx> 41*b1cdbd2cSJim Jagielski 42*b1cdbd2cSJim Jagielski #include <basegfx/matrix/b2dhommatrix.hxx> 43*b1cdbd2cSJim Jagielski #include <basegfx/point/b2dpoint.hxx> 44*b1cdbd2cSJim Jagielski #include <basegfx/tools/canvastools.hxx> 45*b1cdbd2cSJim Jagielski #include <basegfx/numeric/ftools.hxx> 46*b1cdbd2cSJim Jagielski 47*b1cdbd2cSJim Jagielski #include "null_spritecanvas.hxx" 48*b1cdbd2cSJim Jagielski 49*b1cdbd2cSJim Jagielski 50*b1cdbd2cSJim Jagielski using namespace ::com::sun::star; 51*b1cdbd2cSJim Jagielski 52*b1cdbd2cSJim Jagielski #define SERVICE_NAME "com.sun.star.rendering.NullCanvas" 53*b1cdbd2cSJim Jagielski 54*b1cdbd2cSJim Jagielski namespace nullcanvas 55*b1cdbd2cSJim Jagielski { SpriteCanvas(const uno::Sequence<uno::Any> & aArguments,const uno::Reference<uno::XComponentContext> & rxContext)56*b1cdbd2cSJim Jagielski SpriteCanvas::SpriteCanvas( const uno::Sequence< uno::Any >& aArguments, 57*b1cdbd2cSJim Jagielski const uno::Reference< uno::XComponentContext >& rxContext ) : 58*b1cdbd2cSJim Jagielski maArguments(aArguments), 59*b1cdbd2cSJim Jagielski mxComponentContext( rxContext ) 60*b1cdbd2cSJim Jagielski { 61*b1cdbd2cSJim Jagielski } 62*b1cdbd2cSJim Jagielski initialize()63*b1cdbd2cSJim Jagielski void SpriteCanvas::initialize() 64*b1cdbd2cSJim Jagielski { 65*b1cdbd2cSJim Jagielski // #i64742# Only call initialize when not in probe mode 66*b1cdbd2cSJim Jagielski if( maArguments.getLength() == 0 ) 67*b1cdbd2cSJim Jagielski return; 68*b1cdbd2cSJim Jagielski 69*b1cdbd2cSJim Jagielski VERBOSE_TRACE( "SpriteCanvas::initialize called" ); 70*b1cdbd2cSJim Jagielski 71*b1cdbd2cSJim Jagielski // At index 1, we expect a system window handle here, 72*b1cdbd2cSJim Jagielski // containing a pointer to a valid window, on which to output 73*b1cdbd2cSJim Jagielski // At index 2, we expect the current window bound rect 74*b1cdbd2cSJim Jagielski ENSURE_ARG_OR_THROW( maArguments.getLength() >= 4 && 75*b1cdbd2cSJim Jagielski maArguments[1].getValueTypeClass() == uno::TypeClass_LONG, 76*b1cdbd2cSJim Jagielski "SpriteCanvas::initialize: wrong number of arguments, or wrong types" ); 77*b1cdbd2cSJim Jagielski 78*b1cdbd2cSJim Jagielski awt::Rectangle aRect; 79*b1cdbd2cSJim Jagielski maArguments[2] >>= aRect; 80*b1cdbd2cSJim Jagielski const ::basegfx::B2ISize aSize(aRect.Width, 81*b1cdbd2cSJim Jagielski aRect.Height); 82*b1cdbd2cSJim Jagielski 83*b1cdbd2cSJim Jagielski sal_Bool bIsFullscreen( sal_False ); 84*b1cdbd2cSJim Jagielski maArguments[3] >>= bIsFullscreen; 85*b1cdbd2cSJim Jagielski 86*b1cdbd2cSJim Jagielski // setup helper 87*b1cdbd2cSJim Jagielski maDeviceHelper.init( *this, 88*b1cdbd2cSJim Jagielski aSize, 89*b1cdbd2cSJim Jagielski bIsFullscreen ); 90*b1cdbd2cSJim Jagielski maCanvasHelper.init( maRedrawManager, 91*b1cdbd2cSJim Jagielski *this, 92*b1cdbd2cSJim Jagielski aSize, 93*b1cdbd2cSJim Jagielski false ); 94*b1cdbd2cSJim Jagielski 95*b1cdbd2cSJim Jagielski maArguments.realloc(0); 96*b1cdbd2cSJim Jagielski } 97*b1cdbd2cSJim Jagielski disposing()98*b1cdbd2cSJim Jagielski void SAL_CALL SpriteCanvas::disposing() 99*b1cdbd2cSJim Jagielski { 100*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex ); 101*b1cdbd2cSJim Jagielski 102*b1cdbd2cSJim Jagielski mxComponentContext.clear(); 103*b1cdbd2cSJim Jagielski 104*b1cdbd2cSJim Jagielski // forward to parent 105*b1cdbd2cSJim Jagielski SpriteCanvasBaseT::disposing(); 106*b1cdbd2cSJim Jagielski } 107*b1cdbd2cSJim Jagielski showBuffer(::sal_Bool bUpdateAll)108*b1cdbd2cSJim Jagielski ::sal_Bool SAL_CALL SpriteCanvas::showBuffer( ::sal_Bool bUpdateAll ) throw (uno::RuntimeException) 109*b1cdbd2cSJim Jagielski { 110*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex ); 111*b1cdbd2cSJim Jagielski 112*b1cdbd2cSJim Jagielski // avoid repaints on hidden window (hidden: not mapped to 113*b1cdbd2cSJim Jagielski // screen). Return failure, since the screen really has _not_ 114*b1cdbd2cSJim Jagielski // been updated (caller should try again later) 115*b1cdbd2cSJim Jagielski return !mbIsVisible ? false : SpriteCanvasBaseT::showBuffer( bUpdateAll ); 116*b1cdbd2cSJim Jagielski } 117*b1cdbd2cSJim Jagielski switchBuffer(::sal_Bool bUpdateAll)118*b1cdbd2cSJim Jagielski ::sal_Bool SAL_CALL SpriteCanvas::switchBuffer( ::sal_Bool bUpdateAll ) throw (uno::RuntimeException) 119*b1cdbd2cSJim Jagielski { 120*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex ); 121*b1cdbd2cSJim Jagielski 122*b1cdbd2cSJim Jagielski // avoid repaints on hidden window (hidden: not mapped to 123*b1cdbd2cSJim Jagielski // screen). Return failure, since the screen really has _not_ 124*b1cdbd2cSJim Jagielski // been updated (caller should try again later) 125*b1cdbd2cSJim Jagielski return !mbIsVisible ? false : SpriteCanvasBaseT::switchBuffer( bUpdateAll ); 126*b1cdbd2cSJim Jagielski } 127*b1cdbd2cSJim Jagielski updateScreen(sal_Bool bUpdateAll)128*b1cdbd2cSJim Jagielski sal_Bool SAL_CALL SpriteCanvas::updateScreen( sal_Bool bUpdateAll ) throw (uno::RuntimeException) 129*b1cdbd2cSJim Jagielski { 130*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex ); 131*b1cdbd2cSJim Jagielski 132*b1cdbd2cSJim Jagielski // avoid repaints on hidden window (hidden: not mapped to 133*b1cdbd2cSJim Jagielski // screen). Return failure, since the screen really has _not_ 134*b1cdbd2cSJim Jagielski // been updated (caller should try again later) 135*b1cdbd2cSJim Jagielski return !mbIsVisible ? false : maCanvasHelper.updateScreen( 136*b1cdbd2cSJim Jagielski ::basegfx::unotools::b2IRectangleFromAwtRectangle(maBounds), 137*b1cdbd2cSJim Jagielski bUpdateAll, 138*b1cdbd2cSJim Jagielski mbSurfaceDirty ); 139*b1cdbd2cSJim Jagielski } 140*b1cdbd2cSJim Jagielski getServiceName()141*b1cdbd2cSJim Jagielski ::rtl::OUString SAL_CALL SpriteCanvas::getServiceName( ) throw (uno::RuntimeException) 142*b1cdbd2cSJim Jagielski { 143*b1cdbd2cSJim Jagielski return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME ) ); 144*b1cdbd2cSJim Jagielski } 145*b1cdbd2cSJim Jagielski initCanvas(SpriteCanvas * pCanvas)146*b1cdbd2cSJim Jagielski static uno::Reference<uno::XInterface> initCanvas( SpriteCanvas* pCanvas ) 147*b1cdbd2cSJim Jagielski { 148*b1cdbd2cSJim Jagielski uno::Reference<uno::XInterface> xRet(static_cast<cppu::OWeakObject*>(pCanvas)); 149*b1cdbd2cSJim Jagielski pCanvas->initialize(); 150*b1cdbd2cSJim Jagielski return xRet; 151*b1cdbd2cSJim Jagielski } 152*b1cdbd2cSJim Jagielski 153*b1cdbd2cSJim Jagielski namespace sdecl = comphelper::service_decl; 154*b1cdbd2cSJim Jagielski sdecl::class_<SpriteCanvas, sdecl::with_args<true> > serviceImpl(&initCanvas); 155*b1cdbd2cSJim Jagielski const sdecl::ServiceDecl nullCanvasDecl( 156*b1cdbd2cSJim Jagielski serviceImpl, 157*b1cdbd2cSJim Jagielski "com.sun.star.comp.rendering.NullCanvas", 158*b1cdbd2cSJim Jagielski SERVICE_NAME ); 159*b1cdbd2cSJim Jagielski } 160*b1cdbd2cSJim Jagielski 161*b1cdbd2cSJim Jagielski // The C shared lib entry points 162*b1cdbd2cSJim Jagielski COMPHELPER_SERVICEDECL_EXPORTS1(nullcanvas::nullCanvasDecl) 163