Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <canvas/debug.hxx>
31 : : #include <tools/diagnose_ex.h>
32 : : #include <canvas/verbosetrace.hxx>
33 : : #include <canvas/canvastools.hxx>
34 : :
35 : : #include <osl/mutex.hxx>
36 : :
37 : : #include <com/sun/star/registry/XRegistryKey.hpp>
38 : : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
39 : : #include <com/sun/star/uno/XComponentContext.hpp>
40 : :
41 : : #include <cppuhelper/factory.hxx>
42 : : #include <cppuhelper/implementationentry.hxx>
43 : : #include <comphelper/servicedecl.hxx>
44 : :
45 : : #include <basegfx/matrix/b2dhommatrix.hxx>
46 : : #include <basegfx/point/b2dpoint.hxx>
47 : : #include <basegfx/tools/canvastools.hxx>
48 : : #include <basegfx/numeric/ftools.hxx>
49 : :
50 : : #include "null_spritecanvas.hxx"
51 : :
52 : :
53 : : using namespace ::com::sun::star;
54 : :
55 : : #define SERVICE_NAME "com.sun.star.rendering.NullCanvas"
56 : :
57 : : namespace nullcanvas
58 : : {
59 : 0 : SpriteCanvas::SpriteCanvas( const uno::Sequence< uno::Any >& aArguments,
60 : : const uno::Reference< uno::XComponentContext >& rxContext ) :
61 : : maArguments(aArguments),
62 : 0 : mxComponentContext( rxContext )
63 : : {
64 : 0 : }
65 : :
66 : 0 : void SpriteCanvas::initialize()
67 : : {
68 : : // #i64742# Only call initialize when not in probe mode
69 : 0 : if( maArguments.getLength() == 0 )
70 : 0 : return;
71 : :
72 : : VERBOSE_TRACE( "SpriteCanvas::initialize called" );
73 : :
74 : : // At index 1, we expect a system window handle here,
75 : : // containing a pointer to a valid window, on which to output
76 : : // At index 2, we expect the current window bound rect
77 : 0 : ENSURE_ARG_OR_THROW( maArguments.getLength() >= 4 &&
78 : : maArguments[1].getValueTypeClass() == uno::TypeClass_LONG,
79 : : "SpriteCanvas::initialize: wrong number of arguments, or wrong types" );
80 : :
81 : 0 : awt::Rectangle aRect;
82 : 0 : maArguments[2] >>= aRect;
83 : : const ::basegfx::B2ISize aSize(aRect.Width,
84 : 0 : aRect.Height);
85 : :
86 : 0 : sal_Bool bIsFullscreen( sal_False );
87 : 0 : maArguments[3] >>= bIsFullscreen;
88 : :
89 : : // setup helper
90 : : maDeviceHelper.init( *this,
91 : : aSize,
92 : 0 : bIsFullscreen );
93 : : maCanvasHelper.init( maRedrawManager,
94 : : *this,
95 : : aSize,
96 : 0 : false );
97 : :
98 : 0 : maArguments.realloc(0);
99 : : }
100 : :
101 : 0 : void SpriteCanvas::disposeThis()
102 : : {
103 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
104 : :
105 : 0 : mxComponentContext.clear();
106 : :
107 : : // forward to parent
108 : 0 : SpriteCanvasBaseT::disposeThis();
109 : 0 : }
110 : :
111 : 0 : ::sal_Bool SAL_CALL SpriteCanvas::showBuffer( ::sal_Bool bUpdateAll ) throw (uno::RuntimeException)
112 : : {
113 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
114 : :
115 : : // avoid repaints on hidden window (hidden: not mapped to
116 : : // screen). Return failure, since the screen really has _not_
117 : : // been updated (caller should try again later)
118 : 0 : return !mbIsVisible ? false : SpriteCanvasBaseT::showBuffer( bUpdateAll );
119 : : }
120 : :
121 : 0 : ::sal_Bool SAL_CALL SpriteCanvas::switchBuffer( ::sal_Bool bUpdateAll ) throw (uno::RuntimeException)
122 : : {
123 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
124 : :
125 : : // avoid repaints on hidden window (hidden: not mapped to
126 : : // screen). Return failure, since the screen really has _not_
127 : : // been updated (caller should try again later)
128 : 0 : return !mbIsVisible ? false : SpriteCanvasBaseT::switchBuffer( bUpdateAll );
129 : : }
130 : :
131 : 0 : sal_Bool SAL_CALL SpriteCanvas::updateScreen( sal_Bool bUpdateAll ) throw (uno::RuntimeException)
132 : : {
133 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
134 : :
135 : : // avoid repaints on hidden window (hidden: not mapped to
136 : : // screen). Return failure, since the screen really has _not_
137 : : // been updated (caller should try again later)
138 : : return !mbIsVisible ? false : maCanvasHelper.updateScreen(
139 : 0 : ::basegfx::unotools::b2IRectangleFromAwtRectangle(maBounds),
140 : : bUpdateAll,
141 : 0 : mbSurfaceDirty );
142 : : }
143 : :
144 : 0 : ::rtl::OUString SAL_CALL SpriteCanvas::getServiceName( ) throw (uno::RuntimeException)
145 : : {
146 : 0 : return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME ) );
147 : : }
148 : :
149 : 0 : static uno::Reference<uno::XInterface> initCanvas( SpriteCanvas* pCanvas )
150 : : {
151 : 0 : uno::Reference<uno::XInterface> xRet(static_cast<cppu::OWeakObject*>(pCanvas));
152 : 0 : pCanvas->initialize();
153 : 0 : return xRet;
154 : : }
155 : :
156 : : namespace sdecl = comphelper::service_decl;
157 : 0 : sdecl::class_<SpriteCanvas, sdecl::with_args<true> > serviceImpl(&initCanvas);
158 : 0 : const sdecl::ServiceDecl nullCanvasDecl(
159 : : serviceImpl,
160 : : "com.sun.star.comp.rendering.NullCanvas",
161 : : SERVICE_NAME );
162 : : }
163 : :
164 : : // The C shared lib entry points
165 : 0 : COMPHELPER_SERVICEDECL_EXPORTS1(nullcanvas, nullcanvas::nullCanvasDecl)
166 : :
167 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|