LibreOffice Module canvas (master)
1
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
canvas
source
directx
dx_config.cxx
Go to the documentation of this file.
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
#include <
sal/log.hxx
>
22
23
#include <
basegfx/vector/b2ivector.hxx
>
24
#include <com/sun/star/uno/Any.hxx>
25
#include <com/sun/star/uno/Sequence.hxx>
26
#include <
comphelper/anytostring.hxx
>
27
#include <
cppuhelper/exc_hlp.hxx
>
28
#include <osl/diagnose.h>
29
#include <
tools/diagnose_ex.h
>
30
31
#include "
dx_config.hxx
"
32
33
using namespace
com::sun::star
;
34
35
namespace
dxcanvas
36
{
37
DXCanvasItem::DXCanvasItem() :
38
ConfigItem(
39
"Office.Canvas/DXCanvas"
,
40
ConfigItemMode
::
NONE
),
41
maValues
(),
42
maMaxTextureSize(),
43
mbDenylistCurrentDevice(false),
44
mbValuesDirty(false)
45
{
46
try
47
{
48
uno::Sequence< OUString >
aName
{
"DeviceDenylist"
};
49
50
uno::Sequence< uno::Any > aProps(
GetProperties
(
aName
));
51
uno::Sequence< sal_Int32 > aValues;
52
53
if
( aProps.getLength() > 0 &&
54
(aProps[0] >>= aValues) )
55
{
56
const
sal_Int32*
pValues
= aValues.getConstArray();
57
const
sal_Int32 nNumEntries( aValues.getLength()*
sizeof
(sal_Int32)/
sizeof
(
DeviceInfo
) );
58
for
( sal_Int32
i
=0;
i
<nNumEntries; ++
i
)
59
{
60
DeviceInfo
aInfo;
61
aInfo.
nVendorId
= *pValues++;
62
aInfo.
nDeviceId
= *pValues++;
63
aInfo.
nDeviceSubSysId
= *pValues++;
64
aInfo.
nDeviceRevision
= *pValues++;
65
aInfo.
nDriverId
= *pValues++;
66
aInfo.
nDriverVersion
= *pValues++;
67
aInfo.
nDriverSubVersion
= *pValues++;
68
aInfo.
nDriverBuildId
= *pValues++;
69
maValues
.insert(aInfo);
70
}
71
}
72
73
aName
[0] =
"DenylistCurrentDevice"
;
74
aProps =
GetProperties
(
aName
);
75
if
( aProps.getLength() > 0 )
76
aProps[0] >>=
mbDenylistCurrentDevice
;
77
78
aName
[0] =
"MaxTextureSize"
;
79
aProps =
GetProperties
(
aName
);
80
if
( aProps.getLength() > 0 )
81
maMaxTextureSize
= aProps[0].get<sal_Int32>();
82
else
83
maMaxTextureSize
.reset();
84
}
85
catch
(
const
uno::Exception& )
86
{
87
TOOLS_WARN_EXCEPTION
(
"canvas"
,
""
);
88
}
89
}
90
91
DXCanvasItem::~DXCanvasItem
()
92
{
93
if
( !
mbValuesDirty
)
94
return
;
95
96
try
97
{
98
uno::Sequence< sal_Int32 > aValues(
sizeof
(
DeviceInfo
)/
sizeof
(sal_Int32)*
maValues
.size() );
99
100
sal_Int32*
pValues
= aValues.getArray();
101
for
(
const
auto
& rValueSet :
maValues
)
102
{
103
const
DeviceInfo
& rInfo( rValueSet );
104
*pValues++ = rInfo.
nVendorId
;
105
*pValues++ = rInfo.
nDeviceId
;
106
*pValues++ = rInfo.
nDeviceSubSysId
;
107
*pValues++ = rInfo.
nDeviceRevision
;
108
*pValues++ = rInfo.
nDriverId
;
109
*pValues++ = rInfo.
nDriverVersion
;
110
*pValues++ = rInfo.
nDriverSubVersion
;
111
*pValues++ = rInfo.
nDriverBuildId
;
112
}
113
114
PutProperties
({
"DeviceDenylist"
}, {css::uno::Any(aValues)});
115
}
116
catch
(
const
uno::Exception& )
117
{
118
TOOLS_WARN_EXCEPTION
(
"canvas"
,
""
);
119
}
120
}
121
122
void
DXCanvasItem::Notify
(
const
css::uno::Sequence<OUString>& ) {}
123
void
DXCanvasItem::ImplCommit
() {}
124
125
bool
DXCanvasItem::isDeviceUsable
(
const
DeviceInfo
& rDeviceInfo )
const
126
{
127
return
maValues
.find(rDeviceInfo) ==
maValues
.end();
128
}
129
130
bool
DXCanvasItem::isDenylistCurrentDevice
()
const
131
{
132
return
mbDenylistCurrentDevice
;
133
}
134
135
void
DXCanvasItem::denylistDevice
(
const
DeviceInfo
& rDeviceInfo )
136
{
137
mbValuesDirty
=
true
;
138
maValues
.insert(rDeviceInfo);
139
}
140
141
void
DXCanvasItem::adaptMaxTextureSize
(
basegfx::B2IVector
& io_maxTextureSize )
const
142
{
143
if
(
maMaxTextureSize
)
144
{
145
io_maxTextureSize.
setX
(
146
std::min
( *
maMaxTextureSize
,
147
io_maxTextureSize.
getX
() ));
148
io_maxTextureSize.
setY
(
149
std::min
( *
maMaxTextureSize
,
150
io_maxTextureSize.
getY
() ));
151
}
152
}
153
154
}
155
156
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
dxcanvas::DXCanvasItem::~DXCanvasItem
~DXCanvasItem() override
Definition:
dx_config.cxx:91
basegfx::B2IVector
dxcanvas::DXCanvasItem::mbDenylistCurrentDevice
bool mbDenylistCurrentDevice
Definition:
dx_config.hxx:75
dxcanvas
Definition:
dx_9rm.cxx:65
dxcanvas::DXCanvasItem::DeviceInfo::nDeviceId
sal_Int32 nDeviceId
Definition:
dx_config.hxx:40
com::sun::star
dxcanvas::DXCanvasItem::maMaxTextureSize
std::optional< sal_Int32 > maMaxTextureSize
Definition:
dx_config.hxx:74
dxcanvas::DXCanvasItem::DeviceInfo::nDriverId
sal_Int32 nDriverId
Definition:
dx_config.hxx:44
basegfx::B2ITuple::setY
void setY(sal_Int32 fY)
ConfigItemMode
ConfigItemMode
dxcanvas::DXCanvasItem::DeviceInfo::nDriverVersion
sal_Int32 nDriverVersion
Definition:
dx_config.hxx:45
dxcanvas::DXCanvasItem::denylistDevice
void denylistDevice(const DeviceInfo &rDeviceInfo)
Definition:
dx_config.cxx:135
dxcanvas::DXCanvasItem::ImplCommit
virtual void ImplCommit() override
Definition:
dx_config.cxx:123
config.h
maValues
ValueVectorType maValues
NONE
NONE
dxcanvas::DXCanvasItem::DeviceInfo::nDeviceSubSysId
sal_Int32 nDeviceSubSysId
Definition:
dx_config.hxx:41
exc_hlp.hxx
min
#define min(a, b)
Definition:
dx_winstuff.hxx:48
dxcanvas::DXCanvasItem::Notify
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition:
dx_config.cxx:122
dxcanvas::DXCanvasItem::isDeviceUsable
bool isDeviceUsable(const DeviceInfo &rDeviceInfo) const
Definition:
dx_config.cxx:125
dxcanvas::DXCanvasItem::mbValuesDirty
bool mbValuesDirty
Definition:
dx_config.hxx:76
TOOLS_WARN_EXCEPTION
#define TOOLS_WARN_EXCEPTION(area, stream)
i
int i
utl::ConfigItem::PutProperties
bool PutProperties(const css::uno::Sequence< OUString > &rNames, const css::uno::Sequence< css::uno::Any > &rValues)
log.hxx
basegfx::B2ITuple::getX
sal_Int32 getX() const
diagnose_ex.h
dx_config.hxx
b2ivector.hxx
dxcanvas::DXCanvasItem::DeviceInfo::nVendorId
sal_Int32 nVendorId
Definition:
dx_config.hxx:39
dxcanvas::DXCanvasItem::adaptMaxTextureSize
void adaptMaxTextureSize(basegfx::B2IVector &io_maxTextureSize) const
Definition:
dx_config.cxx:141
utl::ConfigItem::GetProperties
css::uno::Sequence< css::uno::Any > GetProperties(const css::uno::Sequence< OUString > &rNames)
dxcanvas::DXCanvasItem::DeviceInfo
Definition:
dx_config.hxx:37
pValues
const PropertyValue * pValues
dxcanvas::DXCanvasItem::DeviceInfo::nDriverSubVersion
sal_Int32 nDriverSubVersion
Definition:
dx_config.hxx:46
aName
OUString aName
dxcanvas::DXCanvasItem::DeviceInfo::nDeviceRevision
sal_Int32 nDeviceRevision
Definition:
dx_config.hxx:42
basegfx::B2ITuple::getY
sal_Int32 getY() const
dxcanvas::DXCanvasItem::DeviceInfo::nDriverBuildId
sal_Int32 nDriverBuildId
Definition:
dx_config.hxx:47
anytostring.hxx
basegfx::B2ITuple::setX
void setX(sal_Int32 fX)
dxcanvas::DXCanvasItem::isDenylistCurrentDevice
bool isDenylistCurrentDevice() const
Definition:
dx_config.cxx:130
dxcanvas::DXCanvasItem::maValues
ValueSet maValues
Definition:
dx_config.hxx:73
Generated on Thu Jan 14 2021 06:25:54 for LibreOffice Module canvas (master) by
1.8.10