2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-10-08 10:00:18 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2007-11-01 16:56:28 +00:00
|
|
|
|
2015-08-10 14:04:31 -05:00
|
|
|
#include <sal/config.h>
|
2008-06-24 09:33:47 +00:00
|
|
|
|
2015-08-10 14:04:31 -05:00
|
|
|
#include <basegfx/vector/b2ivector.hxx>
|
2007-11-01 16:56:28 +00:00
|
|
|
#include <com/sun/star/uno/Any.hxx>
|
|
|
|
#include <com/sun/star/uno/Sequence.hxx>
|
|
|
|
#include <comphelper/anytostring.hxx>
|
|
|
|
#include <cppuhelper/exc_hlp.hxx>
|
2014-11-14 22:52:35 +01:00
|
|
|
#include <osl/diagnose.h>
|
2007-11-01 16:56:28 +00:00
|
|
|
|
2015-08-10 14:04:31 -05:00
|
|
|
#include "dx_config.hxx"
|
|
|
|
|
2007-11-01 16:56:28 +00:00
|
|
|
using namespace com::sun::star;
|
|
|
|
|
|
|
|
namespace dxcanvas
|
|
|
|
{
|
|
|
|
DXCanvasItem::DXCanvasItem() :
|
|
|
|
ConfigItem(
|
2013-02-19 19:49:47 +01:00
|
|
|
"Office.Canvas/DXCanvas",
|
2015-04-30 15:29:09 +02:00
|
|
|
ConfigItemMode::ImmediateUpdate ),
|
2007-11-01 16:56:28 +00:00
|
|
|
maValues(),
|
|
|
|
maMaxTextureSize(),
|
|
|
|
mbBlacklistCurrentDevice(false),
|
|
|
|
mbValuesDirty(false)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2015-11-15 08:43:35 +02:00
|
|
|
uno::Sequence< OUString > aName { "DeviceBlacklist" };
|
2007-11-01 16:56:28 +00:00
|
|
|
|
|
|
|
uno::Sequence< uno::Any > aProps( GetProperties( aName ));
|
|
|
|
uno::Sequence< sal_Int32 > aValues;
|
|
|
|
|
|
|
|
if( aProps.getLength() > 0 &&
|
|
|
|
(aProps[0] >>= aValues) )
|
|
|
|
{
|
|
|
|
const sal_Int32* pValues = aValues.getConstArray();
|
|
|
|
const sal_Int32 nNumEntries( aValues.getLength()*sizeof(sal_Int32)/sizeof(DeviceInfo) );
|
|
|
|
for( sal_Int32 i=0; i<nNumEntries; ++i )
|
|
|
|
{
|
|
|
|
DeviceInfo aInfo;
|
|
|
|
aInfo.nVendorId = *pValues++;
|
|
|
|
aInfo.nDeviceId = *pValues++;
|
|
|
|
aInfo.nDeviceSubSysId = *pValues++;
|
|
|
|
aInfo.nDeviceRevision = *pValues++;
|
|
|
|
aInfo.nDriverId = *pValues++;
|
|
|
|
aInfo.nDriverVersion = *pValues++;
|
|
|
|
aInfo.nDriverSubVersion = *pValues++;
|
|
|
|
aInfo.nDriverBuildId = *pValues++;
|
|
|
|
maValues.insert(aInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-19 19:49:47 +01:00
|
|
|
aName[0] = "BlacklistCurrentDevice";
|
2007-11-01 16:56:28 +00:00
|
|
|
aProps = GetProperties( aName );
|
|
|
|
if( aProps.getLength() > 0 )
|
|
|
|
aProps[0] >>= mbBlacklistCurrentDevice;
|
|
|
|
|
2013-02-19 19:49:47 +01:00
|
|
|
aName[0] = "MaxTextureSize";
|
2007-11-01 16:56:28 +00:00
|
|
|
aProps = GetProperties( aName );
|
|
|
|
if( aProps.getLength() > 0 )
|
|
|
|
maMaxTextureSize.reset( aProps[0].get<sal_Int32>() );
|
|
|
|
else
|
|
|
|
maMaxTextureSize.reset();
|
|
|
|
}
|
2011-11-30 11:05:16 +09:00
|
|
|
catch( const uno::Exception& )
|
2007-11-01 16:56:28 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OSL_FAIL( OUStringToOString(
|
2007-11-01 16:56:28 +00:00
|
|
|
comphelper::anyToString( cppu::getCaughtException() ),
|
|
|
|
RTL_TEXTENCODING_UTF8 ).getStr() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DXCanvasItem::~DXCanvasItem()
|
|
|
|
{
|
|
|
|
if( !mbValuesDirty )
|
|
|
|
return;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Sequence< sal_Int32 > aValues( sizeof(DeviceInfo)/sizeof(sal_Int32)*maValues.size() );
|
|
|
|
|
|
|
|
sal_Int32* pValues = aValues.getArray();
|
2015-08-25 12:24:33 -04:00
|
|
|
for( const auto& rValueSet : maValues )
|
2007-11-01 16:56:28 +00:00
|
|
|
{
|
2015-08-25 12:24:33 -04:00
|
|
|
const DeviceInfo& rInfo( rValueSet );
|
2007-11-01 16:56:28 +00:00
|
|
|
*pValues++ = rInfo.nVendorId;
|
|
|
|
*pValues++ = rInfo.nDeviceId;
|
|
|
|
*pValues++ = rInfo.nDeviceSubSysId;
|
|
|
|
*pValues++ = rInfo.nDeviceRevision;
|
|
|
|
*pValues++ = rInfo.nDriverId;
|
|
|
|
*pValues++ = rInfo.nDriverVersion;
|
|
|
|
*pValues++ = rInfo.nDriverSubVersion;
|
|
|
|
*pValues++ = rInfo.nDriverBuildId;
|
|
|
|
}
|
|
|
|
|
2016-06-28 14:50:49 +02:00
|
|
|
PutProperties({"DeviceBlacklist"}, {css::uno::Any(aValues)});
|
2007-11-01 16:56:28 +00:00
|
|
|
}
|
2011-11-30 11:05:16 +09:00
|
|
|
catch( const uno::Exception& )
|
2007-11-01 16:56:28 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OSL_FAIL( OUStringToOString(
|
2007-11-01 16:56:28 +00:00
|
|
|
comphelper::anyToString( cppu::getCaughtException() ),
|
|
|
|
RTL_TEXTENCODING_UTF8 ).getStr() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-21 12:16:45 +02:00
|
|
|
void DXCanvasItem::Notify( const css::uno::Sequence<OUString>& ) {}
|
2015-03-11 17:18:33 +00:00
|
|
|
void DXCanvasItem::ImplCommit() {}
|
2009-10-21 10:47:51 +02:00
|
|
|
|
2007-11-01 16:56:28 +00:00
|
|
|
bool DXCanvasItem::isDeviceUsable( const DeviceInfo& rDeviceInfo ) const
|
|
|
|
{
|
|
|
|
return maValues.find(rDeviceInfo) == maValues.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DXCanvasItem::isBlacklistCurrentDevice() const
|
|
|
|
{
|
|
|
|
return mbBlacklistCurrentDevice;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DXCanvasItem::blacklistDevice( const DeviceInfo& rDeviceInfo )
|
|
|
|
{
|
|
|
|
mbValuesDirty = true;
|
|
|
|
maValues.insert(rDeviceInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DXCanvasItem::adaptMaxTextureSize( basegfx::B2IVector& io_maxTextureSize ) const
|
|
|
|
{
|
|
|
|
if( maMaxTextureSize )
|
|
|
|
{
|
|
|
|
io_maxTextureSize.setX(
|
|
|
|
std::min( *maMaxTextureSize,
|
|
|
|
io_maxTextureSize.getX() ));
|
|
|
|
io_maxTextureSize.setY(
|
|
|
|
std::min( *maMaxTextureSize,
|
|
|
|
io_maxTextureSize.getY() ));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2010-10-14 08:27:31 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|