Kaydet (Commit) f7752495 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Noel Grandin

remove cppcanvas Color class

which actually does nothing useful. Looks like it was originally
intended to be used to implement color profiles, but since nothing
has happened on that front since it was created, safe to say it never
will. Probably not the right place in the graphics stack to do it
anyhow.

Change-Id: I36990db4036e3b4b2b75261fc430028562a6dbd9
Reviewed-on: https://gerrit.libreoffice.org/43240Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 6d7191a9
......@@ -71,7 +71,6 @@ $(eval $(call gb_Library_add_exception_objects,cppcanvas,\
cppcanvas/source/wrapper/implbitmap \
cppcanvas/source/wrapper/implbitmapcanvas \
cppcanvas/source/wrapper/implcanvas \
cppcanvas/source/wrapper/implcolor \
cppcanvas/source/wrapper/implcustomsprite \
cppcanvas/source/wrapper/implfont \
cppcanvas/source/wrapper/implpolypolygon \
......
......@@ -27,9 +27,9 @@ namespace cppcanvas
{
namespace tools
{
css::uno::Sequence< double > intSRGBAToDoubleSequence( Color::IntSRGBA );
css::uno::Sequence< double > intSRGBAToDoubleSequence( IntSRGBA );
Color::IntSRGBA doubleSequenceToIntSRGBA( const css::uno::Sequence< double >& rColor );
IntSRGBA doubleSequenceToIntSRGBA( const css::uno::Sequence< double >& rColor );
}
}
......
......@@ -2902,14 +2902,12 @@ namespace cppcanvas
tools::calcLogic2PixelAffineTransform( aStateStack.getState().mapModeTransform,
*aVDev.get() );
ColorSharedPtr pColor( getCanvas()->createColor() );
{
::cppcanvas::internal::OutDevState& rState = aStateStack.getState();
// setup default text color to black
rState.textColor =
rState.textFillColor =
rState.textLineColor = pColor->getDeviceColor( 0x000000FF );
rState.textLineColor = tools::intSRGBAToDoubleSequence( 0x000000FF );
}
// apply overrides from the Parameters struct
......@@ -2917,13 +2915,13 @@ namespace cppcanvas
{
::cppcanvas::internal::OutDevState& rState = aStateStack.getState();
rState.isFillColorSet = true;
rState.fillColor = pColor->getDeviceColor( *rParams.maFillColor );
rState.fillColor = tools::intSRGBAToDoubleSequence( *rParams.maFillColor );
}
if( rParams.maLineColor.is_initialized() )
{
::cppcanvas::internal::OutDevState& rState = aStateStack.getState();
rState.isLineColorSet = true;
rState.lineColor = pColor->getDeviceColor( *rParams.maLineColor );
rState.lineColor = tools::intSRGBAToDoubleSequence( *rParams.maLineColor );
}
if( rParams.maTextColor.is_initialized() )
{
......@@ -2932,7 +2930,7 @@ namespace cppcanvas
rState.isTextLineColorSet = true;
rState.textColor =
rState.textFillColor =
rState.textLineColor = pColor->getDeviceColor( *rParams.maTextColor );
rState.textLineColor = tools::intSRGBAToDoubleSequence( *rParams.maTextColor );
}
if( rParams.maFontName.is_initialized() ||
rParams.maFontWeight.is_initialized() ||
......
......@@ -27,7 +27,7 @@ namespace cppcanvas
{
namespace tools
{
uno::Sequence< double > intSRGBAToDoubleSequence( Color::IntSRGBA aColor )
uno::Sequence< double > intSRGBAToDoubleSequence( IntSRGBA aColor )
{
uno::Sequence< double > aRes( 4 );
......@@ -39,7 +39,7 @@ namespace cppcanvas
return aRes;
}
Color::IntSRGBA doubleSequenceToIntSRGBA( const uno::Sequence< double >& rColor )
IntSRGBA doubleSequenceToIntSRGBA( const uno::Sequence< double >& rColor )
{
return makeColor( static_cast<sal_uInt8>( 255*rColor[0] + .5 ),
static_cast<sal_uInt8>( 255*rColor[1] + .5 ),
......
......@@ -29,7 +29,6 @@
#include <cppcanvas/polypolygon.hxx>
#include "implfont.hxx"
#include "implcolor.hxx"
#include "implcanvas.hxx"
......@@ -84,11 +83,6 @@ namespace cppcanvas
return !maClipPolyPolygon ? nullptr : &(*maClipPolyPolygon);
}
ColorSharedPtr ImplCanvas::createColor() const
{
return ColorSharedPtr( new ImplColor( getUNOCanvas()->getDevice() ) );
}
CanvasSharedPtr ImplCanvas::clone() const
{
return CanvasSharedPtr( new ImplCanvas( *this ) );
......
......@@ -60,8 +60,6 @@ namespace cppcanvas
virtual void setClip() override;
virtual ::basegfx::B2DPolyPolygon const* getClip() const override;
virtual ColorSharedPtr createColor() const override;
virtual CanvasSharedPtr clone() const override;
virtual void clear() const override;
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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 .
*/
#include <implcolor.hxx>
#include <tools.hxx>
#include <osl/diagnose.h>
using namespace ::com::sun::star;
namespace cppcanvas
{
namespace internal
{
ImplColor::ImplColor( const uno::Reference< rendering::XGraphicDevice >& rDevice ) :
mxDevice( rDevice )
{
OSL_ENSURE( mxDevice.is(), "ImplColor::ImplColor(): Invalid graphic device" );
}
ImplColor::~ImplColor()
{
}
uno::Sequence< double > ImplColor::getDeviceColor( Color::IntSRGBA aSRGBA ) const
{
OSL_ENSURE( mxDevice.is(), "ImplColor::getDeviceColor(): Invalid graphic device" );
// TODO(F1): Color space handling
return tools::intSRGBAToDoubleSequence( aSRGBA );
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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 .
*/
#ifndef INCLUDED_CPPCANVAS_SOURCE_WRAPPER_IMPLCOLOR_HXX
#define INCLUDED_CPPCANVAS_SOURCE_WRAPPER_IMPLCOLOR_HXX
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/rendering/XGraphicDevice.hpp>
#include <cppcanvas/color.hxx>
/* Definition of Color class */
namespace cppcanvas
{
namespace internal
{
class ImplColor : public Color
{
public:
explicit ImplColor( const css::uno::Reference<
css::rendering::XGraphicDevice >& rDevice );
virtual ~ImplColor() override;
virtual css::uno::Sequence< double > getDeviceColor( IntSRGBA aSRGBA ) const override;
private:
css::uno::Reference< css::rendering::XGraphicDevice > mxDevice;
};
}
}
#endif // INCLUDED_CPPCANVAS_SOURCE_WRAPPER_IMPLCOLOR_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -62,19 +62,19 @@ namespace cppcanvas
{
}
void ImplPolyPolygon::setRGBAFillColor( Color::IntSRGBA aColor )
void ImplPolyPolygon::setRGBAFillColor( IntSRGBA aColor )
{
maFillColor = tools::intSRGBAToDoubleSequence( aColor );
mbFillColorSet = true;
}
void ImplPolyPolygon::setRGBALineColor( Color::IntSRGBA aColor )
void ImplPolyPolygon::setRGBALineColor( IntSRGBA aColor )
{
maStrokeColor = tools::intSRGBAToDoubleSequence( aColor );
mbStrokeColorSet = true;
}
Color::IntSRGBA ImplPolyPolygon::getRGBALineColor() const
IntSRGBA ImplPolyPolygon::getRGBALineColor() const
{
return tools::doubleSequenceToIntSRGBA( maStrokeColor );
}
......
......@@ -48,9 +48,9 @@ namespace cppcanvas
virtual ~ImplPolyPolygon() override;
virtual void setRGBAFillColor( Color::IntSRGBA ) override;
virtual void setRGBALineColor( Color::IntSRGBA ) override;
virtual Color::IntSRGBA getRGBALineColor() const override;
virtual void setRGBAFillColor( IntSRGBA ) override;
virtual void setRGBALineColor( IntSRGBA ) override;
virtual IntSRGBA getRGBALineColor() const override;
virtual void setStrokeWidth( const double& rStrokeWidth ) override;
virtual double getStrokeWidth() const override;
......
......@@ -83,8 +83,6 @@ namespace cppcanvas
*/
virtual ::basegfx::B2DPolyPolygon const* getClip() const = 0;
virtual ColorSharedPtr createColor() const = 0;
virtual CanvasSharedPtr clone() const = 0;
virtual void clear() const = 0;
......
......@@ -27,44 +27,34 @@
namespace cppcanvas
{
class Color
{
public:
/** Color in the sRGB color space, plus alpha channel
The four bytes of the sal_uInt32 are allocated as follows
to the color channels and alpha: 0xRRGGBBAA.
*/
typedef sal_uInt32 IntSRGBA;
virtual ~Color() {}
virtual css::uno::Sequence< double > getDeviceColor( IntSRGBA aSRGBA ) const = 0;
};
/** Color in the sRGB color space, plus alpha channel
typedef std::shared_ptr< ::cppcanvas::Color > ColorSharedPtr;
The four bytes of the sal_uInt32 are allocated as follows
to the color channels and alpha: 0xRRGGBBAA.
*/
typedef sal_uInt32 IntSRGBA;
inline sal_uInt8 getRed( Color::IntSRGBA nCol )
inline sal_uInt8 getRed( IntSRGBA nCol )
{
return static_cast<sal_uInt8>( (nCol&0xFF000000U) >> 24U );
}
inline sal_uInt8 getGreen( Color::IntSRGBA nCol )
inline sal_uInt8 getGreen( IntSRGBA nCol )
{
return static_cast<sal_uInt8>( (nCol&0x00FF0000U) >> 16U );
}
inline sal_uInt8 getBlue( Color::IntSRGBA nCol )
inline sal_uInt8 getBlue( IntSRGBA nCol )
{
return static_cast<sal_uInt8>( (nCol&0x0000FF00U) >> 8U );
}
inline sal_uInt8 getAlpha( Color::IntSRGBA nCol )
inline sal_uInt8 getAlpha( IntSRGBA nCol )
{
return static_cast<sal_uInt8>( nCol&0x000000FFU );
}
inline Color::IntSRGBA makeColor( sal_uInt8 nRed, sal_uInt8 nGreen, sal_uInt8 nBlue, sal_uInt8 nAlpha )
inline IntSRGBA makeColor( sal_uInt8 nRed, sal_uInt8 nGreen, sal_uInt8 nBlue, sal_uInt8 nAlpha )
{
return (nRed << 24U)|(nGreen << 16U)|(nBlue << 8U)|nAlpha;
}
......
......@@ -58,13 +58,13 @@ namespace cppcanvas
/** Set polygon fill color
*/
virtual void setRGBAFillColor( Color::IntSRGBA ) = 0;
virtual void setRGBAFillColor( IntSRGBA ) = 0;
/** Set polygon line color
*/
virtual void setRGBALineColor( Color::IntSRGBA ) = 0;
virtual void setRGBALineColor( IntSRGBA ) = 0;
/** Get polygon line color
*/
virtual Color::IntSRGBA getRGBALineColor() const = 0;
virtual IntSRGBA getRGBALineColor() const = 0;
virtual void setStrokeWidth( const double& rStrokeWidth ) = 0;
virtual double getStrokeWidth() const = 0;
......
......@@ -100,16 +100,16 @@ namespace cppcanvas
struct Parameters
{
/// Optionally forces the fill color attribute for all actions
::boost::optional< Color::IntSRGBA > maFillColor;
::boost::optional< IntSRGBA > maFillColor;
/// Optionally forces the line color attribute for all actions
::boost::optional< Color::IntSRGBA > maLineColor;
::boost::optional< IntSRGBA > maLineColor;
/// Optionally forces the text color attribute for all actions
::boost::optional< Color::IntSRGBA > maTextColor;
::boost::optional< IntSRGBA > maTextColor;
/// Optionally forces the given fontname for all text actions
::boost::optional< OUString > maFontName;
::boost::optional< OUString > maFontName;
/** Optionally transforms all text output actions with the
given matrix (in addition to the overall canvas
......
......@@ -277,7 +277,7 @@ namespace slideshow
{
}
RGBColor::RGBColor( ::cppcanvas::Color::IntSRGBA nRGBColor ) :
RGBColor::RGBColor( ::cppcanvas::IntSRGBA nRGBColor ) :
maRGBTriple( ::cppcanvas::getRed( nRGBColor ) / 255.0,
::cppcanvas::getGreen( nRGBColor ) / 255.0,
::cppcanvas::getBlue( nRGBColor ) / 255.0 )
......@@ -297,7 +297,7 @@ namespace slideshow
}
::cppcanvas::Color::IntSRGBA RGBColor::getIntegerColor() const
::cppcanvas::IntSRGBA RGBColor::getIntegerColor() const
{
return ::cppcanvas::makeColor( colorToInt( getRed() ),
colorToInt( getGreen() ),
......
......@@ -649,7 +649,7 @@ namespace slideshow
static_cast< sal_uInt8 >( nColor >> 24U ) ) );
}
sal_Int32 RGBAColor2UnoColor( ::cppcanvas::Color::IntSRGBA aColor )
sal_Int32 RGBAColor2UnoColor( ::cppcanvas::IntSRGBA aColor )
{
return ::cppcanvas::makeColorARGB(
// convert from IntSRGBA color to API color
......@@ -662,7 +662,7 @@ namespace slideshow
void fillRect( const ::cppcanvas::CanvasSharedPtr& rCanvas,
const ::basegfx::B2DRectangle& rRect,
::cppcanvas::Color::IntSRGBA aFillColor )
::cppcanvas::IntSRGBA aFillColor )
{
const ::basegfx::B2DPolygon aPoly(
::basegfx::utils::createPolygonFromRect( rRect ));
......
......@@ -37,7 +37,7 @@ namespace slideshow
{
public:
RGBColor();
explicit RGBColor( ::cppcanvas::Color::IntSRGBA nRGBColor );
explicit RGBColor( ::cppcanvas::IntSRGBA nRGBColor );
RGBColor( double nRed, double nGreen, double nBlue );
explicit RGBColor( const HSLColor& rColor );
......@@ -55,7 +55,7 @@ namespace slideshow
/** Create an integer sRGBA color.
*/
::cppcanvas::Color::IntSRGBA getIntegerColor() const;
::cppcanvas::IntSRGBA getIntegerColor() const;
struct RGBTriple
{
......
......@@ -261,13 +261,13 @@ namespace slideshow
RGBColor unoColor2RGBColor( sal_Int32 );
/** Convert an IntSRGBA to plain UNO API 32 bit int
*/
sal_Int32 RGBAColor2UnoColor( cppcanvas::Color::IntSRGBA );
sal_Int32 RGBAColor2UnoColor( cppcanvas::IntSRGBA );
/** Fill a plain rectangle on the given canvas with the given color
*/
void fillRect( const std::shared_ptr< cppcanvas::Canvas >& rCanvas,
const basegfx::B2DRange& rRect,
cppcanvas::Color::IntSRGBA aFillColor );
cppcanvas::IntSRGBA aFillColor );
/** Init canvas with default background (white)
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment