Kaydet (Commit) eb4f96c9 authored tarafından Thorsten Behrens's avatar Thorsten Behrens

Cleanup formatting in cairocanvas

White-space changes - code was in parts unreadable after tab/spaces
conversion. While at it, removed a few lines of commented-out code.
üst 80fe015a
......@@ -26,7 +26,6 @@
*
************************************************************************/
#include <canvas/debug.hxx>
#include <tools/diagnose_ex.h>
......
......@@ -56,12 +56,12 @@ namespace cairocanvas
virtual ::sal_Int8 doRedraw( const ::com::sun::star::rendering::ViewState& rNewState,
const ::com::sun::star::rendering::ViewState& rOldState,
const ::com::sun::star::uno::Reference<
::com::sun::star::rendering::XCanvas >& rTargetCanvas,
::com::sun::star::rendering::XCanvas >& rTargetCanvas,
bool bSameViewTransform );
::cairo::SurfaceSharedPtr mpSurface;
const ::com::sun::star::rendering::RenderState maRenderState;
::cairo::SurfaceSharedPtr mpSurface;
const ::com::sun::star::rendering::RenderState maRenderState;
};
}
......
......@@ -26,8 +26,6 @@
*
************************************************************************/
#include "cairo_cairo.hxx"
#include <vcl/sysdata.hxx>
......
......@@ -87,7 +87,7 @@ namespace cairo {
SurfaceSharedPtr createSurface( const OutputDevice& rRefDevice,
int x, int y, int width, int height );
/// Create Surface for given bitmap data
SurfaceSharedPtr createBitmapSurface( const OutputDevice& rRefDevice,
SurfaceSharedPtr createBitmapSurface( const OutputDevice& rRefDevice,
const BitmapSystemData& rData,
const Size& rSize );
......
......@@ -26,7 +26,6 @@
*
************************************************************************/
#include <canvas/debug.hxx>
#include <canvas/verbosetrace.hxx>
#include <canvas/canvastools.hxx>
......
......@@ -26,7 +26,6 @@
*
************************************************************************/
#include <canvas/debug.hxx>
#include <canvas/canvastools.hxx>
#include <tools/diagnose_ex.h>
......
......@@ -26,7 +26,6 @@
*
************************************************************************/
#include <canvas/debug.hxx>
#include <canvas/verbosetrace.hxx>
#include <tools/diagnose_ex.h>
......
......@@ -26,7 +26,6 @@
*
************************************************************************/
#include <canvas/debug.hxx>
#include <com/sun/star/rendering/PanoseProportion.hpp>
......
......@@ -152,13 +152,13 @@ namespace cairocanvas
::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
fillPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
const ::com::sun::star::uno::Reference<
::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
const ::com::sun::star::rendering::ViewState& viewState,
const ::com::sun::star::rendering::RenderState& renderState );
::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
fillTexturedPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
const ::com::sun::star::uno::Reference<
::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
const ::com::sun::star::rendering::ViewState& viewState,
const ::com::sun::star::rendering::RenderState& renderState,
const ::com::sun::star::uno::Sequence<
......@@ -172,7 +172,7 @@ namespace cairocanvas
const ::com::sun::star::uno::Sequence<
::com::sun::star::rendering::Texture >& textures,
const ::com::sun::star::uno::Reference<
::com::sun::star::geometry::XMapping2D >& xMapping );
::com::sun::star::geometry::XMapping2D >& xMapping );
::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvasFont > SAL_CALL
createFont( const ::com::sun::star::rendering::XCanvas* pCanvas,
......@@ -212,7 +212,7 @@ namespace cairocanvas
::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
drawBitmapModulated( const ::com::sun::star::rendering::XCanvas* pCanvas,
const ::com::sun::star::uno::Reference<
::com::sun::star::rendering::XBitmap >& xBitmap,
::com::sun::star::rendering::XBitmap >& xBitmap,
const ::com::sun::star::rendering::ViewState& viewState,
const ::com::sun::star::rendering::RenderState& renderState );
::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >
......@@ -272,14 +272,13 @@ namespace cairocanvas
LINE_COLOR, FILL_COLOR, TEXT_COLOR, IGNORE_COLOR
};
void doPolyPolygonPath( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
Operation aOperation,
bool bNoLineJoin = false,
const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::Texture >* pTextures=NULL,
::cairo::Cairo* pCairo=NULL ) const;
void doPolyPolygonPath( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
Operation aOperation,
bool bNoLineJoin = false,
const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::Texture >* pTextures=NULL,
::cairo::Cairo* pCairo=NULL ) const;
::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
implDrawBitmapSurface(
::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive > implDrawBitmapSurface(
const ::com::sun::star::rendering::XCanvas* pCanvas,
const ::cairo::SurfaceSharedPtr& pSurface,
const ::com::sun::star::rendering::ViewState& viewState,
......@@ -290,7 +289,7 @@ namespace cairocanvas
bool repaint( const ::cairo::SurfaceSharedPtr& pSurface,
const ::com::sun::star::rendering::ViewState& viewState,
const ::com::sun::star::rendering::RenderState& renderState );
const ::com::sun::star::rendering::RenderState& renderState );
protected:
/** Surface provider
......@@ -312,9 +311,9 @@ namespace cairocanvas
boost::shared_ptr<VirtualDevice> mpVirtualDevice;
void useStates( const ::com::sun::star::rendering::ViewState& viewState,
const ::com::sun::star::rendering::RenderState& renderState,
bool setColor );
void useStates( const ::com::sun::star::rendering::ViewState& viewState,
const ::com::sun::star::rendering::RenderState& renderState,
bool setColor );
/// When true, content is able to represent alpha
bool mbHaveAlpha;
......
......@@ -26,7 +26,6 @@
*
************************************************************************/
#include <canvas/debug.hxx>
#include <canvas/canvastools.hxx>
#include <tools/diagnose_ex.h>
......@@ -319,7 +318,7 @@ namespace cairocanvas
// change text direction and layout mode
sal_uLong nLayoutMode(0);
switch( textDirection )
{
{
case rendering::TextDirection::WEAK_LEFT_TO_RIGHT:
nLayoutMode |= TEXT_LAYOUT_BIDI_LTR;
// FALLTHROUGH intended
......@@ -335,7 +334,7 @@ namespace cairocanvas
nLayoutMode |= TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_BIDI_STRONG;
nLayoutMode |= TEXT_LAYOUT_TEXTORIGIN_RIGHT;
break;
}
}
// TODO(F2): alpha
mpVirtualDevice->SetLayoutMode( nLayoutMode );
......
......@@ -26,7 +26,6 @@
*
************************************************************************/
#if defined QUARTZ || defined IOS
/************************************************************************
* Mac OS X/Quartz and iOS surface backend for OpenOffice.org Cairo Canvas *
......@@ -145,10 +144,13 @@ namespace cairo
**/
CairoSharedPtr QuartzSurface::getCairo() const
{
if (mpSurface.get()){
if (mpSurface.get())
{
return CairoSharedPtr( cairo_create(mpSurface.get()),
&cairo_destroy );
} else {
}
else
{
return CairoSharedPtr();
}
}
......@@ -184,7 +186,7 @@ namespace cairo
*
* @return The new surface or NULL
**/
void QuartzSurface::Resize( int /* width */, int /* height */ )
void QuartzSurface::Resize( int /* width */, int /* height */ )
{
OSL_FAIL("not supposed to be called!");
}
......@@ -196,13 +198,15 @@ void QuartzSurface::Resize( int /* width */, int /* height */ )
void QuartzSurface::flush() const
{
// can only flush surfaces with NSView
if( !mpView ) return;
if( !mpView )
return;
OSL_TRACE("Canvas::cairo::QuartzSurface::flush(): flush to NSView");
CGContextRef mrContext = getCGContext();
if (!mrContext) return;
if (!mrContext)
return;
#ifndef IOS
[mpView lockFocus];
#endif
......@@ -236,8 +240,10 @@ void QuartzSurface::Resize( int /* width */, int /* height */ )
**/
int QuartzSurface::getDepth() const
{
if (mpSurface.get()) {
switch (cairo_surface_get_content (mpSurface.get())) {
if (mpSurface.get())
{
switch (cairo_surface_get_content (mpSurface.get()))
{
case CAIRO_CONTENT_ALPHA: return 8; break;
case CAIRO_CONTENT_COLOR: return 24; break;
case CAIRO_CONTENT_COLOR_ALPHA: return 32; break;
......
......@@ -34,10 +34,10 @@
#include "premac.h"
#include <TargetConditionals.h>
#if !defined(TARGET_OS_IPHONE) || !TARGET_OS_IPHONE
#include <Cocoa/Cocoa.h>
# include <Cocoa/Cocoa.h>
#else
#include <UIKit/UIKit.h>
#define NSView UIView
# include <UIKit/UIKit.h>
# define NSView UIView
#endif
#include <cairo-quartz.h>
#include "postmac.h"
......@@ -73,7 +73,6 @@ namespace cairo {
int getDepth() const;
CGContextRef getCGContext() const;
};
}
......
......@@ -26,7 +26,6 @@
*
************************************************************************/
#include <canvas/debug.hxx>
#include <canvas/verbosetrace.hxx>
#include <canvas/canvastools.hxx>
......
......@@ -26,7 +26,6 @@
*
************************************************************************/
#include <canvas/debug.hxx>
#include <canvas/verbosetrace.hxx>
#include <canvas/canvastools.hxx>
......
......@@ -26,7 +26,6 @@
*
************************************************************************/
#include <canvas/debug.hxx>
#include <canvas/verbosetrace.hxx>
#include <canvas/canvastools.hxx>
......
......@@ -26,7 +26,6 @@
*
************************************************************************/
#include <canvas/debug.hxx>
#include <canvas/verbosetrace.hxx>
#include <tools/diagnose_ex.h>
......@@ -90,7 +89,7 @@ namespace cairocanvas
CanvasCustomSpriteHelper::disposing();
}
void SpriteHelper::redraw( const CairoSharedPtr& pCairo,
void SpriteHelper::redraw( const CairoSharedPtr& pCairo,
const ::basegfx::B2DPoint& rPos,
bool& /*io_bSurfacesDirty*/,
bool /*bBufferedUpdate*/ ) const
......@@ -103,9 +102,11 @@ namespace cairocanvas
const double fAlpha( getAlpha() );
const ::basegfx::B2DHomMatrix aTransform( getTransformation() );
if( isActive() && !::basegfx::fTools::equalZero( fAlpha ) ) {
if( isActive() && !::basegfx::fTools::equalZero( fAlpha ) )
{
OSL_TRACE ("CanvasCustomSprite::redraw called");
if( pCairo ) {
if( pCairo )
{
basegfx::B2DVector aSize = getSizePixel();
cairo_save( pCairo.get() );
......@@ -114,7 +115,8 @@ namespace cairocanvas
fX = rPos.getX();
fY = rPos.getY();
if( !aTransform.isIdentity() ) {
if( !aTransform.isIdentity() )
{
cairo_matrix_t aMatrix, aInverseMatrix;
cairo_matrix_init( &aMatrix,
aTransform.get( 0, 0 ), aTransform.get( 1, 0 ), aTransform.get( 0, 1 ),
......
......@@ -26,7 +26,6 @@
*
************************************************************************/
#include <math.h>
#include <canvas/debug.hxx>
......@@ -309,11 +308,11 @@ namespace cairocanvas
void TextLayout::useFont( Cairo* pCairo )
{
rendering::FontRequest aFontRequest = mpFont->getFontRequest();
rendering::FontInfo aFontInfo = aFontRequest.FontDescription;
rendering::FontRequest aFontRequest = mpFont->getFontRequest();
rendering::FontInfo aFontInfo = aFontRequest.FontDescription;
cairo_select_font_face( pCairo, ::rtl::OUStringToOString( aFontInfo.FamilyName, RTL_TEXTENCODING_UTF8 ).getStr(), CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL );
cairo_set_font_size( pCairo, aFontRequest.CellSize );
cairo_select_font_face( pCairo, ::rtl::OUStringToOString( aFontInfo.FamilyName, RTL_TEXTENCODING_UTF8 ).getStr(), CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL );
cairo_set_font_size( pCairo, aFontRequest.CellSize );
}
/** TextLayout:draw
......@@ -352,11 +351,13 @@ namespace cairocanvas
{
#if defined UNX && !defined QUARTZ && !defined IOS
// is font usable?
if (!aSysFontData.nFontId) return false;
if (!aSysFontData.nFontId)
return false;
#endif
// vertical glyph rendering is not supported in cairo for now
if (aSysFontData.bVerticalCharacterType) {
if (aSysFontData.bVerticalCharacterType)
{
OSL_TRACE(":cairocanvas::TextLayout::isCairoRenderable(): ***************** VERTICAL CHARACTER STYLE!!! ****************");
return false;
}
......@@ -455,7 +456,8 @@ namespace cairocanvas
}
}
if (aSysLayoutData.rGlyphData.empty()) return false; //??? false?
if (aSysLayoutData.rGlyphData.empty())
return false; //??? false?
/**
* Setup platform independent glyph vector into cairo-based glyphs vector.
......@@ -481,11 +483,11 @@ namespace cairocanvas
cairo_glyph_t aGlyph;
aGlyph.index = systemGlyph.index;
#ifdef CAIRO_HAS_WIN32_SURFACE
#ifdef CAIRO_HAS_WIN32_SURFACE
// Cairo requires standard glyph indexes (ETO_GLYPH_INDEX), while vcl/win/* uses ucs4 chars.
// Convert to standard indexes
aGlyph.index = cairo::ucs4toindex((unsigned int) aGlyph.index, rSysFontData.hFont);
#endif
#endif
aGlyph.x = systemGlyph.x;
aGlyph.y = systemGlyph.y;
cairo_glyphs.push_back(aGlyph);
......@@ -499,30 +501,29 @@ namespace cairocanvas
**/
cairo_font_face_t* font_face = NULL;
#ifdef CAIRO_HAS_QUARTZ_SURFACE
#ifdef QUARTZ
#ifdef CAIRO_HAS_QUARTZ_SURFACE
# ifdef QUARTZ
// TODO: use cairo_quartz_font_face_create_for_cgfont(cgFont)
// when CGFont (Mac OS X 10.5 API) is provided by the AQUA VCL backend.
font_face = cairo_quartz_font_face_create_for_atsu_font_id((ATSUFontID) rSysFontData.aATSUFontID);
#else // iOS
# else // iOS
font_face = cairo_quartz_font_face_create_for_cgfont( rSysFontData.rFont);
#endif
# endif
#elif defined CAIRO_HAS_WIN32_SURFACE
#if (OSL_DEBUG_LEVEL > 1)
#elif defined CAIRO_HAS_WIN32_SURFACE
# if (OSL_DEBUG_LEVEL > 1)
GetObjectW( rSysFontData.hFont, sizeof(logfont), &logfont );
#endif
# endif
// Note: cairo library uses logfont fallbacks when lfEscapement, lfOrientation and lfWidth are not zero.
// VCL always has non-zero value for lfWidth
font_face = cairo_win32_font_face_create_for_hfont(rSysFontData.hFont);
#elif defined CAIRO_HAS_XLIB_SURFACE
#elif defined CAIRO_HAS_XLIB_SURFACE
font_face = cairo_ft_font_face_create_for_ft_face((FT_Face)rSysFontData.nFontId,
rSysFontData.nFontFlags);
#else
# error Native API needed.
#endif
#else
# error Native API needed.
#endif
CairoSharedPtr pSCairo = pSurface->getCairo();
......@@ -531,7 +532,8 @@ namespace cairocanvas
// create default font options. cairo_get_font_options() does not retrieve the surface defaults,
// only what has been set before with cairo_set_font_options()
cairo_font_options_t* options = cairo_font_options_create();
if (rSysFontData.bAntialias) {
if (rSysFontData.bAntialias)
{
// CAIRO_ANTIALIAS_GRAY provides more similar result to VCL Canvas,
// so we're not using CAIRO_ANTIALIAS_SUBPIXEL
cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_GRAY);
......@@ -557,9 +559,12 @@ namespace cairocanvas
// see issue #101566
//proper scale calculation across platforms
if (aFont.GetWidth() == 0) {
if (aFont.GetWidth() == 0)
{
nWidth = aFont.GetHeight();
} else {
}
else
{
// any scaling needs to be relative to the platform-dependent definition
// of height of the font
nWidth = aFont.GetWidth() * aFont.GetHeight() / aMetric.GetHeight();
......@@ -567,20 +572,22 @@ namespace cairocanvas
cairo_matrix_init_identity(&m);
if (aSysLayoutData.orientation) cairo_matrix_rotate(&m, (3600 - aSysLayoutData.orientation) * M_PI / 1800.0);
if (aSysLayoutData.orientation)
cairo_matrix_rotate(&m, (3600 - aSysLayoutData.orientation) * M_PI / 1800.0);
cairo_matrix_scale(&m, nWidth, aFont.GetHeight());
//faux italics
if (rSysFontData.bFakeItalic) m.xy = -m.xx * 0x6000L / 0x10000L;
if (rSysFontData.bFakeItalic)
m.xy = -m.xx * 0x6000L / 0x10000L;
cairo_set_font_matrix(pSCairo.get(), &m);
#if (defined CAIRO_HAS_WIN32_SURFACE) && (OSL_DEBUG_LEVEL > 1)
#define TEMP_TRACE_FONT ::rtl::OUStringToOString( reinterpret_cast<const sal_Unicode*> (logfont.lfFaceName), RTL_TEXTENCODING_UTF8 ).getStr()
#else
#define TEMP_TRACE_FONT ::rtl::OUStringToOString( aFont.GetName(), RTL_TEXTENCODING_UTF8 ).getStr()
#endif
#if (defined CAIRO_HAS_WIN32_SURFACE) && (OSL_DEBUG_LEVEL > 1)
# define TEMP_TRACE_FONT ::rtl::OUStringToOString( reinterpret_cast<const sal_Unicode*> (logfont.lfFaceName), RTL_TEXTENCODING_UTF8 ).getStr()
#else
# define TEMP_TRACE_FONT ::rtl::OUStringToOString( aFont.GetName(), RTL_TEXTENCODING_UTF8 ).getStr()
#endif
OSL_TRACE("\r\n:cairocanvas::TextLayout::draw(S,O,p,v,r): Size:(%d,%d), W:%d->%d, Pos (%d,%d), G(%d,%d,%d) %s%s%s%s || Name:%s - %s",
aFont.GetWidth(),
aFont.GetHeight(),
......@@ -599,18 +606,21 @@ namespace cairocanvas
::rtl::OUStringToOString( maText.Text.copy( maText.StartPosition, maText.Length ),
RTL_TEXTENCODING_UTF8 ).getStr()
);
#undef TEMP_TRACE_FONT
#undef TEMP_TRACE_FONT
cairo_show_glyphs(pSCairo.get(), &cairo_glyphs[0], cairo_glyphs.size());
//faux bold
if (rSysFontData.bFakeBold) {
if (rSysFontData.bFakeBold)
{
double bold_dx = 0.5 * sqrt( 0.7 * aFont.GetHeight() );
int total_steps = 2 * ((int) (bold_dx + 0.5));
// loop to draw the text for every half pixel of displacement
for (int nSteps = 0; nSteps < total_steps; nSteps++) {
for(int nGlyphIdx = 0; nGlyphIdx < (int) cairo_glyphs.size(); nGlyphIdx++) {
for (int nSteps = 0; nSteps < total_steps; nSteps++)
{
for(int nGlyphIdx = 0; nGlyphIdx < (int) cairo_glyphs.size(); nGlyphIdx++)
{
cairo_glyphs[nGlyphIdx].x += bold_dx * nSteps / total_steps;
}
cairo_show_glyphs(pSCairo.get(), &cairo_glyphs[0], cairo_glyphs.size());
......
......@@ -28,7 +28,6 @@
#define _WIN32_WINNT 0x0500
#ifdef WNT
/************************************************************************
* Win32 surface backend for OpenOffice.org Cairo Canvas *
......@@ -101,7 +100,8 @@ namespace cairo
{
OSL_ASSERT(rBmpData.pDIB == NULL);
if(rBmpData.pDIB != NULL) {
if(rBmpData.pDIB != NULL)
{
// So just leave mpSurface to NULL, little else we can do at
// this stage. Hopefully the Win32 patch to
// cairocanvas::DeviceHelper::getSurface(BitmapSystemData&,
......@@ -182,8 +182,10 @@ namespace cairo
**/
int Win32Surface::getDepth() const
{
if (mpSurface) {
switch (cairo_surface_get_content (mpSurface.get())) {
if (mpSurface)
{
switch (cairo_surface_get_content (mpSurface.get()))
{
case CAIRO_CONTENT_ALPHA: return 8; break;
case CAIRO_CONTENT_COLOR: return 24; break;
case CAIRO_CONTENT_COLOR_ALPHA: return 32; break;
......@@ -295,7 +297,8 @@ namespace cairo
hdc = CreateCompatibleDC (NULL);
if (!hdc) return 0;
if (!SetGraphicsMode (hdc, GM_ADVANCED)) {
if (!SetGraphicsMode (hdc, GM_ADVANCED))
{
DeleteDC (hdc);
return 0;
}
......@@ -305,7 +308,8 @@ namespace cairo
unicode[0] = ucs4;
unicode[1] = 0;
if (GetGlyphIndicesW (hdc, unicode, 1, &glyph_index, 0) == GDI_ERROR) {
if (GetGlyphIndicesW (hdc, unicode, 1, &glyph_index, 0) == GDI_ERROR)
{
glyph_index = 0;
}
......
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