loplugin:unusedmethods remove unused code from canvas
which my plugin had previously been ignoring. Since that time, the plugin has gotten a little smarter, and makes less mistakes. Change-Id: Id791c932fd056ae7da833436c4dd2600b69a0bfa Reviewed-on: https://gerrit.libreoffice.org/51212 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -211,8 +211,6 @@ namespace cairocanvas
|
||||
|
||||
css::rendering::IntegerBitmapLayout getMemoryLayout();
|
||||
|
||||
bool hasAlpha() const { return mbHaveAlpha; }
|
||||
|
||||
enum ColorType
|
||||
{
|
||||
LINE_COLOR, FILL_COLOR, TEXT_COLOR, IGNORE_COLOR
|
||||
|
@@ -92,23 +92,6 @@ namespace oglcanvas
|
||||
|
||||
namespace
|
||||
{
|
||||
bool lcl_drawPoint( const CanvasHelper& /*rHelper*/,
|
||||
const ::basegfx::B2DHomMatrix& rTransform,
|
||||
GLenum eSrcBlend,
|
||||
GLenum eDstBlend,
|
||||
const rendering::ARGBColor& rColor,
|
||||
const geometry::RealPoint2D& rPoint )
|
||||
{
|
||||
TransformationPreserver aPreserver;
|
||||
setupState(rTransform, eSrcBlend, eDstBlend, rColor);
|
||||
|
||||
glBegin(GL_POINTS);
|
||||
glVertex2d(rPoint.X, rPoint.Y);
|
||||
glEnd();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool lcl_drawLine( const CanvasHelper& /*rHelper*/,
|
||||
const ::basegfx::B2DHomMatrix& rTransform,
|
||||
GLenum eSrcBlend,
|
||||
@@ -398,23 +381,6 @@ namespace oglcanvas
|
||||
mpRecordedActions->clear();
|
||||
}
|
||||
|
||||
void CanvasHelper::drawPoint( const rendering::XCanvas* /*pCanvas*/,
|
||||
const geometry::RealPoint2D& aPoint,
|
||||
const rendering::ViewState& viewState,
|
||||
const rendering::RenderState& renderState )
|
||||
{
|
||||
if( mpDevice )
|
||||
{
|
||||
mpRecordedActions->push_back( Action() );
|
||||
Action& rAct=mpRecordedActions->back();
|
||||
|
||||
setupGraphicsState( rAct, viewState, renderState );
|
||||
rAct.maFunction = std::bind(&lcl_drawPoint,
|
||||
_1,_2,_3,_4,_5,
|
||||
aPoint);
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasHelper::drawLine( const rendering::XCanvas* /*pCanvas*/,
|
||||
const geometry::RealPoint2D& aStartPoint,
|
||||
const geometry::RealPoint2D& aEndPoint,
|
||||
|
@@ -58,10 +58,6 @@ namespace oglcanvas
|
||||
// XCanvas (only providing, not implementing the
|
||||
// interface. Also note subtle method parameter differences)
|
||||
void clear();
|
||||
void drawPoint( const css::rendering::XCanvas* pCanvas,
|
||||
const css::geometry::RealPoint2D& aPoint,
|
||||
const css::rendering::ViewState& viewState,
|
||||
const css::rendering::RenderState& renderState );
|
||||
void drawLine( const css::rendering::XCanvas* pCanvas,
|
||||
const css::geometry::RealPoint2D& aStartPoint,
|
||||
const css::geometry::RealPoint2D& aEndPoint,
|
||||
|
@@ -115,8 +115,6 @@ namespace oglcanvas
|
||||
bool activateWindowContext();
|
||||
|
||||
private:
|
||||
void resize( const ::basegfx::B2IVector& rNewSize );
|
||||
|
||||
/** Phyical output device
|
||||
|
||||
Deliberately not a refcounted reference, because of
|
||||
|
@@ -176,12 +176,6 @@ namespace oglcanvas
|
||||
return maText;
|
||||
}
|
||||
|
||||
void TextLayout::draw( const rendering::ViewState& /*rViewState*/,
|
||||
const rendering::RenderState& /*rRenderState*/,
|
||||
const uno::Reference< rendering::XGraphicDevice >& /*xGraphicDevice*/ ) const
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@@ -61,11 +61,6 @@ namespace oglcanvas
|
||||
virtual css::uno::Reference< css::rendering::XCanvasFont > SAL_CALL getFont( ) override;
|
||||
virtual css::rendering::StringContext SAL_CALL getText( ) override;
|
||||
|
||||
void draw( const css::rendering::ViewState& rViewState,
|
||||
const css::rendering::RenderState& rRenderState,
|
||||
const css::uno::Reference<
|
||||
css::rendering::XGraphicDevice >& xGraphicDevice ) const;
|
||||
|
||||
private:
|
||||
css::rendering::StringContext maText;
|
||||
css::uno::Sequence< double > maLogicalAdvancements;
|
||||
|
@@ -134,7 +134,6 @@ namespace canvas
|
||||
bool mbIsDirty;
|
||||
|
||||
private:
|
||||
void refresh( canvas::IColorBuffer& rBuffer ) const;
|
||||
void prepareRendering();
|
||||
|
||||
basegfx::B2DRectangle getUVCoords() const;
|
||||
|
@@ -48,19 +48,6 @@ namespace vclcanvas
|
||||
{
|
||||
}
|
||||
|
||||
void CanvasBitmapHelper::setBitmap( const BitmapEx& rBitmap )
|
||||
{
|
||||
ENSURE_OR_THROW( mpOutDevProvider,
|
||||
"Invalid reference device" );
|
||||
|
||||
mpBackBuffer.reset( new BitmapBackBuffer( rBitmap,
|
||||
mpOutDevProvider->getOutDev() ) );
|
||||
|
||||
// tell canvas helper about the new target OutDev (don't
|
||||
// protect state, it's our own VirDev, anyways)
|
||||
setOutDev( mpBackBuffer, false );
|
||||
}
|
||||
|
||||
void CanvasBitmapHelper::init( const BitmapEx& rBitmap,
|
||||
rendering::XGraphicDevice& rDevice,
|
||||
const OutDevProviderSharedPtr& rOutDevReference )
|
||||
@@ -187,60 +174,6 @@ namespace vclcanvas
|
||||
return aRes;
|
||||
}
|
||||
|
||||
void CanvasBitmapHelper::setData( const uno::Sequence< sal_Int8 >& data,
|
||||
const rendering::IntegerBitmapLayout& rLayout,
|
||||
const geometry::IntegerRectangle2D& rect )
|
||||
{
|
||||
SAL_INFO( "canvas.vcl", "::vclcanvas::CanvasBitmapHelper::setData()" );
|
||||
|
||||
if( !mpBackBuffer )
|
||||
return; // we're disposed
|
||||
|
||||
const rendering::IntegerBitmapLayout aRefLayout( getMemoryLayout() );
|
||||
ENSURE_ARG_OR_THROW( aRefLayout.PlaneStride != rLayout.PlaneStride ||
|
||||
aRefLayout.ColorSpace != rLayout.ColorSpace ||
|
||||
aRefLayout.Palette != rLayout.Palette ||
|
||||
aRefLayout.IsMsbFirst != rLayout.IsMsbFirst,
|
||||
"Mismatching memory layout" );
|
||||
|
||||
// retrieve local copies from the BitmapEx, which are later
|
||||
// stored back. Unfortunately, the BitmapEx does not permit
|
||||
// in-place modifications, as they are necessary here.
|
||||
|
||||
BitmapEx newBitmap = vcl::bitmap::CanvasBitmapHelperSetData(data, rect, mpBackBuffer->getBitmapReference());
|
||||
setBitmap( newBitmap );
|
||||
}
|
||||
|
||||
void CanvasBitmapHelper::setPixel( const uno::Sequence< sal_Int8 >& color,
|
||||
const rendering::IntegerBitmapLayout& rLayout,
|
||||
const geometry::IntegerPoint2D& pos )
|
||||
{
|
||||
SAL_INFO( "canvas.vcl", "::vclcanvas::CanvasBitmapHelper::setPixel()" );
|
||||
|
||||
if( !mpBackBuffer )
|
||||
return; // we're disposed
|
||||
|
||||
const Size aBmpSize( mpBackBuffer->getBitmapReference().GetSizePixel() );
|
||||
|
||||
ENSURE_ARG_OR_THROW( pos.X >= 0 && pos.X < aBmpSize.Width(),
|
||||
"X coordinate out of bounds" );
|
||||
ENSURE_ARG_OR_THROW( pos.Y >= 0 && pos.Y < aBmpSize.Height(),
|
||||
"Y coordinate out of bounds" );
|
||||
ENSURE_ARG_OR_THROW( color.getLength() > 3,
|
||||
"not enough color components" );
|
||||
|
||||
const rendering::IntegerBitmapLayout aRefLayout( getMemoryLayout() );
|
||||
ENSURE_ARG_OR_THROW( aRefLayout.PlaneStride != rLayout.PlaneStride ||
|
||||
aRefLayout.ColorSpace != rLayout.ColorSpace ||
|
||||
aRefLayout.Palette != rLayout.Palette ||
|
||||
aRefLayout.IsMsbFirst != rLayout.IsMsbFirst,
|
||||
"Mismatching memory layout" );
|
||||
|
||||
|
||||
BitmapEx newBitmapEx = vcl::bitmap::CanvasBitmapHelperSetPixel(color, pos, mpBackBuffer->getBitmapReference());
|
||||
setBitmap( newBitmapEx );
|
||||
}
|
||||
|
||||
uno::Sequence< sal_Int8 > CanvasBitmapHelper::getPixel( rendering::IntegerBitmapLayout& rLayout,
|
||||
const geometry::IntegerPoint2D& pos )
|
||||
{
|
||||
|
@@ -90,14 +90,6 @@ namespace vclcanvas
|
||||
getData( css::rendering::IntegerBitmapLayout& bitmapLayout,
|
||||
const css::geometry::IntegerRectangle2D& rect );
|
||||
|
||||
void setData( const css::uno::Sequence< sal_Int8 >& data,
|
||||
const css::rendering::IntegerBitmapLayout& bitmapLayout,
|
||||
const css::geometry::IntegerRectangle2D& rect );
|
||||
|
||||
void setPixel( const css::uno::Sequence< sal_Int8 >& color,
|
||||
const css::rendering::IntegerBitmapLayout& bitmapLayout,
|
||||
const css::geometry::IntegerPoint2D& pos );
|
||||
|
||||
css::uno::Sequence< sal_Int8 >
|
||||
getPixel( css::rendering::IntegerBitmapLayout& bitmapLayout,
|
||||
const css::geometry::IntegerPoint2D& pos );
|
||||
@@ -109,8 +101,6 @@ namespace vclcanvas
|
||||
|
||||
private:
|
||||
|
||||
void setBitmap( const BitmapEx& rBitmap );
|
||||
|
||||
BitmapBackBufferSharedPtr mpBackBuffer;
|
||||
OutDevProviderSharedPtr mpOutDevReference;
|
||||
};
|
||||
|
@@ -189,28 +189,6 @@ namespace vclcanvas
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasHelper::drawPoint( const rendering::XCanvas* ,
|
||||
const geometry::RealPoint2D& aPoint,
|
||||
const rendering::ViewState& viewState,
|
||||
const rendering::RenderState& renderState )
|
||||
{
|
||||
// are we disposed?
|
||||
if( mpOutDevProvider )
|
||||
{
|
||||
// nope, render
|
||||
tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDevProvider );
|
||||
setupOutDevState( viewState, renderState, LINE_COLOR );
|
||||
|
||||
const Point aOutPoint( tools::mapRealPoint2D( aPoint,
|
||||
viewState, renderState ) );
|
||||
// TODO(F1): alpha
|
||||
mpOutDevProvider->getOutDev().DrawPixel( aOutPoint );
|
||||
|
||||
if( mp2ndOutDevProvider )
|
||||
mp2ndOutDevProvider->getOutDev().DrawPixel( aOutPoint );
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasHelper::drawLine( const rendering::XCanvas* ,
|
||||
const geometry::RealPoint2D& aStartRealPoint2D,
|
||||
const geometry::RealPoint2D& aEndRealPoint2D,
|
||||
@@ -987,173 +965,6 @@ namespace vclcanvas
|
||||
return aRes;
|
||||
}
|
||||
|
||||
void CanvasHelper::setData( const uno::Sequence< sal_Int8 >& data,
|
||||
const rendering::IntegerBitmapLayout& aLayout,
|
||||
const geometry::IntegerRectangle2D& rect )
|
||||
{
|
||||
if( !mpOutDevProvider.get() )
|
||||
return; // we're disposed
|
||||
|
||||
const rendering::IntegerBitmapLayout aRefLayout( getMemoryLayout() );
|
||||
ENSURE_ARG_OR_THROW( aRefLayout.PlaneStride != aLayout.PlaneStride ||
|
||||
aRefLayout.ColorSpace != aLayout.ColorSpace ||
|
||||
aRefLayout.Palette != aLayout.Palette ||
|
||||
aRefLayout.IsMsbFirst != aLayout.IsMsbFirst,
|
||||
"Mismatching memory layout" );
|
||||
|
||||
OutputDevice& rOutDev( mpOutDevProvider->getOutDev() );
|
||||
|
||||
tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDevProvider );
|
||||
rOutDev.EnableMapMode( false );
|
||||
rOutDev.SetAntialiasing( AntialiasingFlags::EnableB2dDraw );
|
||||
|
||||
const ::tools::Rectangle aRect( vcl::unotools::rectangleFromIntegerRectangle2D(rect) );
|
||||
const sal_uInt16 nBitCount( std::min( sal_uInt16(24), rOutDev.GetBitCount() ) );
|
||||
const BitmapPalette* pPalette = nullptr;
|
||||
|
||||
if( nBitCount <= 8 )
|
||||
{
|
||||
// TODO(Q1): Extract this to a common place, e.g. GraphicDevice
|
||||
|
||||
// try to determine palette from output device (by
|
||||
// extracting a 1,1 bitmap, and querying it)
|
||||
const Point aEmptyPoint;
|
||||
const Size aSize(1,1);
|
||||
Bitmap aTmpBitmap( rOutDev.GetBitmap( aEmptyPoint,
|
||||
aSize ) );
|
||||
|
||||
Bitmap::ScopedReadAccess pReadAccess( aTmpBitmap );
|
||||
|
||||
pPalette = &pReadAccess->GetPalette();
|
||||
}
|
||||
|
||||
// TODO(F2): Support alpha canvas here
|
||||
Bitmap aBitmap( aRect.GetSize(), nBitCount, pPalette );
|
||||
|
||||
bool bCopyBack( false ); // only copy something back, if we
|
||||
// actually changed some pixel
|
||||
{
|
||||
Bitmap::ScopedWriteAccess pWriteAccess( aBitmap );
|
||||
|
||||
ENSURE_OR_THROW( pWriteAccess.get() != nullptr,
|
||||
"Could not acquire write access to OutDev bitmap" );
|
||||
|
||||
// for the time being, always read as RGB
|
||||
const sal_Int32 nWidth( rect.X2 - rect.X1 );
|
||||
const sal_Int32 nHeight( rect.Y2 - rect.Y1 );
|
||||
int x, y, nCurrPos(0);
|
||||
for( y=0; y<nHeight; ++y )
|
||||
{
|
||||
switch( pWriteAccess->GetScanlineFormat() )
|
||||
{
|
||||
case ScanlineFormat::N8BitPal:
|
||||
{
|
||||
Scanline pScan = pWriteAccess->GetScanline( y );
|
||||
|
||||
for( x=0; x<nWidth; ++x )
|
||||
{
|
||||
*pScan++ = static_cast<sal_uInt8>(pWriteAccess->GetBestPaletteIndex(
|
||||
BitmapColor( data[ nCurrPos ],
|
||||
data[ nCurrPos+1 ],
|
||||
data[ nCurrPos+2 ] ) ));
|
||||
|
||||
nCurrPos += 4;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ScanlineFormat::N24BitTcBgr:
|
||||
{
|
||||
Scanline pScan = pWriteAccess->GetScanline( y );
|
||||
|
||||
for( x=0; x<nWidth; ++x )
|
||||
{
|
||||
*pScan++ = data[ nCurrPos+2 ];
|
||||
*pScan++ = data[ nCurrPos+1 ];
|
||||
*pScan++ = data[ nCurrPos ];
|
||||
|
||||
nCurrPos += 4;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ScanlineFormat::N24BitTcRgb:
|
||||
{
|
||||
Scanline pScan = pWriteAccess->GetScanline( y );
|
||||
|
||||
for( x=0; x<nWidth; ++x )
|
||||
{
|
||||
*pScan++ = data[ nCurrPos ];
|
||||
*pScan++ = data[ nCurrPos+1 ];
|
||||
*pScan++ = data[ nCurrPos+2 ];
|
||||
|
||||
nCurrPos += 4;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
Scanline pScan = pWriteAccess->GetScanline( y );
|
||||
|
||||
for( x=0; x<nWidth; ++x )
|
||||
{
|
||||
pWriteAccess->SetPixelOnData( pScan, x, BitmapColor( data[ nCurrPos ],
|
||||
data[ nCurrPos+1 ],
|
||||
data[ nCurrPos+2 ] ) );
|
||||
nCurrPos += 4;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bCopyBack = true;
|
||||
}
|
||||
|
||||
// copy back only here, since the BitmapAccessors must be
|
||||
// destroyed beforehand
|
||||
if( bCopyBack )
|
||||
{
|
||||
// TODO(F2): Support alpha canvas here
|
||||
rOutDev.DrawBitmap(aRect.TopLeft(), aBitmap);
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasHelper::setPixel( const uno::Sequence< sal_Int8 >& color,
|
||||
const rendering::IntegerBitmapLayout& rLayout,
|
||||
const geometry::IntegerPoint2D& pos )
|
||||
{
|
||||
if( !mpOutDevProvider.get() )
|
||||
return; // we're disposed
|
||||
|
||||
OutputDevice& rOutDev( mpOutDevProvider->getOutDev() );
|
||||
|
||||
tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDevProvider );
|
||||
rOutDev.EnableMapMode( false );
|
||||
rOutDev.SetAntialiasing( AntialiasingFlags::EnableB2dDraw );
|
||||
|
||||
const Size aBmpSize( rOutDev.GetOutputSizePixel() );
|
||||
|
||||
ENSURE_ARG_OR_THROW( pos.X >= 0 && pos.X < aBmpSize.Width(),
|
||||
"X coordinate out of bounds" );
|
||||
ENSURE_ARG_OR_THROW( pos.Y >= 0 && pos.Y < aBmpSize.Height(),
|
||||
"Y coordinate out of bounds" );
|
||||
ENSURE_ARG_OR_THROW( color.getLength() > 3,
|
||||
"not enough color components" );
|
||||
|
||||
const rendering::IntegerBitmapLayout aRefLayout( getMemoryLayout() );
|
||||
ENSURE_ARG_OR_THROW( aRefLayout.PlaneStride != rLayout.PlaneStride ||
|
||||
aRefLayout.ColorSpace != rLayout.ColorSpace ||
|
||||
aRefLayout.Palette != rLayout.Palette ||
|
||||
aRefLayout.IsMsbFirst != rLayout.IsMsbFirst,
|
||||
"Mismatching memory layout" );
|
||||
|
||||
// TODO(F2): Support alpha canvas here
|
||||
rOutDev.DrawPixel( vcl::unotools::pointFromIntegerPoint2D( pos ),
|
||||
::canvas::tools::stdIntSequenceToColor( color ));
|
||||
}
|
||||
|
||||
uno::Sequence< sal_Int8 > CanvasHelper::getPixel( rendering::IntegerBitmapLayout& rLayout,
|
||||
const geometry::IntegerPoint2D& pos )
|
||||
{
|
||||
|
@@ -104,10 +104,6 @@ namespace vclcanvas
|
||||
// XCanvas (only providing, not implementing the
|
||||
// interface. Also note subtle method parameter differences)
|
||||
void clear();
|
||||
void drawPoint( const css::rendering::XCanvas* rCanvas,
|
||||
const css::geometry::RealPoint2D& aPoint,
|
||||
const css::rendering::ViewState& viewState,
|
||||
const css::rendering::RenderState& renderState );
|
||||
void drawLine( const css::rendering::XCanvas* rCanvas,
|
||||
const css::geometry::RealPoint2D& aStartPoint,
|
||||
const css::geometry::RealPoint2D& aEndPoint,
|
||||
@@ -243,14 +239,6 @@ namespace vclcanvas
|
||||
getData( css::rendering::IntegerBitmapLayout& bitmapLayout,
|
||||
const css::geometry::IntegerRectangle2D& rect );
|
||||
|
||||
void setData( const css::uno::Sequence< sal_Int8 >& data,
|
||||
const css::rendering::IntegerBitmapLayout& bitmapLayout,
|
||||
const css::geometry::IntegerRectangle2D& rect );
|
||||
|
||||
void setPixel( const css::uno::Sequence< sal_Int8 >& color,
|
||||
const css::rendering::IntegerBitmapLayout& bitmapLayout,
|
||||
const css::geometry::IntegerPoint2D& pos );
|
||||
|
||||
css::uno::Sequence< sal_Int8 >
|
||||
getPixel( css::rendering::IntegerBitmapLayout& bitmapLayout,
|
||||
const css::geometry::IntegerPoint2D& pos );
|
||||
|
@@ -578,7 +578,6 @@ namespace vclcanvas
|
||||
{
|
||||
}
|
||||
|
||||
void operator()() { *mpTarget += mnIncrement; }
|
||||
void operator()( const ::canvas::Sprite::Reference& ) { *mpTarget += mnIncrement; }
|
||||
void operator()( T nIncrement ) { *mpTarget += nIncrement; }
|
||||
|
||||
|
@@ -141,12 +141,6 @@ for d in definitionSet:
|
||||
continue
|
||||
if method == "class tools::SvRef<class FontCharMap> FontCharMap::GetDefaultMap(_Bool)":
|
||||
continue
|
||||
# too much template magic here for my plugin
|
||||
if ( ("cairocanvas::" in d[1])
|
||||
or ("canvas::" in d[1])
|
||||
or ("oglcanvas::" in d[1])
|
||||
or ("vclcanvas::" in d[1])):
|
||||
continue
|
||||
# these are loaded by dlopen() from somewhere
|
||||
if "get_implementation" in d[1]:
|
||||
continue
|
||||
|
Reference in New Issue
Block a user