Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <canvas/debug.hxx>
21 : #include <canvas/canvastools.hxx>
22 : #include <toolkit/helper/vclunohelper.hxx>
23 : #include <vcl/canvastools.hxx>
24 : #include <basegfx/tools/canvastools.hxx>
25 : #include <vcl/dibtools.hxx>
26 :
27 : #include "spritedevicehelper.hxx"
28 : #include "spritecanvas.hxx"
29 : #include "spritecanvashelper.hxx"
30 : #include "canvasbitmap.hxx"
31 :
32 : using namespace ::com::sun::star;
33 :
34 : namespace vclcanvas
35 : {
36 0 : SpriteDeviceHelper::SpriteDeviceHelper() :
37 0 : mpBackBuffer()
38 : {
39 0 : }
40 :
41 0 : void SpriteDeviceHelper::init( const OutDevProviderSharedPtr& pOutDev )
42 : {
43 0 : DeviceHelper::init(pOutDev);
44 :
45 : // setup back buffer
46 0 : OutputDevice& rOutDev( pOutDev->getOutDev() );
47 0 : mpBackBuffer.reset( new BackBuffer( rOutDev ));
48 0 : mpBackBuffer->setSize( rOutDev.GetOutputSizePixel() );
49 :
50 : // #i95645#
51 : #if defined( MACOSX )
52 : // use AA on VCLCanvas for Mac
53 : mpBackBuffer->getOutDev().SetAntialiasing( AntialiasingFlags::EnableB2dDraw | mpBackBuffer->getOutDev().GetAntialiasing() );
54 : #else
55 : // switch off AA for WIN32 and UNIX, the VCLCanvas does not look good with it and
56 : // is not required to do AA. It would need to be adapted to use it correctly
57 : // (especially gradient painting). This will need extra work.
58 0 : mpBackBuffer->getOutDev().SetAntialiasing(mpBackBuffer->getOutDev().GetAntialiasing() & ~AntialiasingFlags::EnableB2dDraw);
59 : #endif
60 0 : }
61 :
62 0 : bool SpriteDeviceHelper::showBuffer( bool, bool )
63 : {
64 : OSL_FAIL("Not supposed to be called, handled by SpriteCanvas");
65 0 : return false;
66 : }
67 :
68 0 : bool SpriteDeviceHelper::switchBuffer( bool, bool )
69 : {
70 : OSL_FAIL("Not supposed to be called, handled by SpriteCanvas");
71 0 : return false;
72 : }
73 :
74 0 : void SpriteDeviceHelper::disposing()
75 : {
76 : // release all references
77 0 : mpBackBuffer.reset();
78 :
79 0 : DeviceHelper::disposing();
80 0 : }
81 :
82 0 : uno::Any SpriteDeviceHelper::isAccelerated() const
83 : {
84 0 : return DeviceHelper::isAccelerated();
85 : }
86 :
87 0 : uno::Any SpriteDeviceHelper::getDeviceHandle() const
88 : {
89 0 : return DeviceHelper::getDeviceHandle();
90 : }
91 :
92 0 : uno::Any SpriteDeviceHelper::getSurfaceHandle() const
93 : {
94 0 : if( !mpBackBuffer )
95 0 : return uno::Any();
96 :
97 : return uno::makeAny(
98 0 : reinterpret_cast< sal_Int64 >(&mpBackBuffer->getOutDev()) );
99 : }
100 :
101 0 : void SpriteDeviceHelper::notifySizeUpdate( const awt::Rectangle& rBounds )
102 : {
103 0 : if( mpBackBuffer )
104 : mpBackBuffer->setSize( ::Size(rBounds.Width,
105 0 : rBounds.Height) );
106 0 : }
107 :
108 0 : void SpriteDeviceHelper::dumpScreenContent() const
109 : {
110 0 : DeviceHelper::dumpScreenContent();
111 :
112 : static sal_Int32 nFilePostfixCount(0);
113 :
114 0 : if( mpBackBuffer )
115 : {
116 0 : OUString aFilename = "dbg_backbuffer" + OUString::number(nFilePostfixCount) + ".bmp";
117 :
118 0 : SvFileStream aStream( aFilename, STREAM_STD_READWRITE );
119 :
120 0 : const ::Point aEmptyPoint;
121 0 : mpBackBuffer->getOutDev().EnableMapMode( false );
122 0 : mpBackBuffer->getOutDev().SetAntialiasing( AntialiasingFlags::EnableB2dDraw );
123 0 : WriteDIB(mpBackBuffer->getOutDev().GetBitmap(aEmptyPoint, mpBackBuffer->getOutDev().GetOutputSizePixel()), aStream, false, true);
124 : }
125 :
126 0 : ++nFilePostfixCount;
127 0 : }
128 :
129 0 : }
130 :
131 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|