Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/canvas/source/vcl/spritedevicehelper.cxx
Line
Count
Source
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 <sal/config.h>
21
22
#include <osl/diagnose.h>
23
#include <vcl/bitmap.hxx>
24
#include <vcl/dibtools.hxx>
25
#include <tools/stream.hxx>
26
27
#include "spritedevicehelper.hxx"
28
#include "impltools.hxx"
29
30
using namespace ::com::sun::star;
31
32
namespace vclcanvas
33
{
34
    SpriteDeviceHelper::SpriteDeviceHelper()
35
0
    {
36
0
    }
37
38
    void SpriteDeviceHelper::init( const OutDevProviderSharedPtr& pOutDev )
39
0
    {
40
0
        DeviceHelper::init(pOutDev);
41
42
        // setup back buffer
43
0
        OutputDevice& rOutDev( pOutDev->getOutDev() );
44
0
        mpBackBuffer = std::make_shared<BackBuffer>( rOutDev );
45
0
        mpBackBuffer->setSize( rOutDev.GetOutputSizePixel() );
46
47
0
        vclcanvastools::SetDefaultDeviceAntiAliasing( &mpBackBuffer->getOutDev());
48
0
    }
49
50
    bool SpriteDeviceHelper::showBuffer( bool, bool )
51
0
    {
52
0
        OSL_FAIL("Not supposed to be called, handled by SpriteCanvas");
53
0
        return false;
54
0
    }
55
56
    bool SpriteDeviceHelper::switchBuffer( bool, bool )
57
0
    {
58
0
        OSL_FAIL("Not supposed to be called, handled by SpriteCanvas");
59
0
        return false;
60
0
    }
61
62
    void SpriteDeviceHelper::disposing()
63
0
    {
64
        // release all references
65
0
        mpBackBuffer.reset();
66
67
0
        DeviceHelper::disposing();
68
0
    }
69
70
    uno::Any SpriteDeviceHelper::isAccelerated() const
71
0
    {
72
0
        return DeviceHelper::isAccelerated();
73
0
    }
74
75
    uno::Any SpriteDeviceHelper::getDeviceHandle() const
76
0
    {
77
0
        return DeviceHelper::getDeviceHandle();
78
0
    }
79
80
    uno::Any SpriteDeviceHelper::getSurfaceHandle() const
81
0
    {
82
0
        if( !mpBackBuffer )
83
0
            return uno::Any();
84
85
0
        return uno::Any(
86
0
            reinterpret_cast< sal_Int64 >(&mpBackBuffer->getOutDev()) );
87
0
    }
88
89
    void SpriteDeviceHelper::notifySizeUpdate( const awt::Rectangle& rBounds )
90
0
    {
91
0
        if( mpBackBuffer )
92
0
            mpBackBuffer->setSize( ::Size(rBounds.Width,
93
0
                                          rBounds.Height) );
94
0
    }
95
96
    void SpriteDeviceHelper::dumpScreenContent() const
97
0
    {
98
0
        DeviceHelper::dumpScreenContent();
99
100
0
        static sal_Int32 nFilePostfixCount(0);
101
102
0
        if( mpBackBuffer )
103
0
        {
104
0
            OUString aFilename = "dbg_backbuffer" + OUString::number(nFilePostfixCount) + ".bmp";
105
106
0
            SvFileStream aStream( aFilename, StreamMode::STD_READWRITE );
107
108
0
            const ::Point aEmptyPoint;
109
0
            mpBackBuffer->getOutDev().EnableMapMode( false );
110
0
            mpBackBuffer->getOutDev().SetAntialiasing( AntialiasingFlags::Enable );
111
0
            WriteDIB(mpBackBuffer->getOutDev().GetBitmap(aEmptyPoint, mpBackBuffer->getOutDev().GetOutputSizePixel()), aStream, false);
112
0
        }
113
114
0
        ++nFilePostfixCount;
115
0
    }
116
117
}
118
119
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */