revert work in progress

Change-Id: I1387b0ed7b2d8bb9df801c03cf59efc9c0e1cfd3
This commit is contained in:
Caolán McNamara
2015-03-18 17:43:03 +00:00
parent 641b6f2037
commit 3d49571225
19 changed files with 19 additions and 250 deletions

View File

@@ -17,6 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <config_features.h>
#include <canvas/debug.hxx>
#include <canvas/verbosetrace.hxx>
#include <canvas/canvastools.hxx>
@@ -92,20 +94,18 @@ namespace cairocanvas
OutputDevice* pOutDev=getOutputDevice();
if (mpSurface && pOutDev->CanResizeCairoSurface())
{
// X11 only
#if HAVE_FEATURE_X11
// X11 only
if( mpSurface )
mpSurface->Resize( rSize.getX() + pOutDev->GetOutOffXPixel(),
rSize.getY() + pOutDev->GetOutOffYPixel() );
}
else
{
#endif
mpSurface = cairo::createSurface(
*pOutDev,
pOutDev->GetOutOffXPixel(),
pOutDev->GetOutOffYPixel(),
rSize.getX(), rSize.getY() );
}
}
geometry::RealSize2D DeviceHelper::getPhysicalResolution()

View File

@@ -324,103 +324,17 @@ namespace cairo
return X11SysData( rVirDev.GetSystemGfxData() );
}
/**
* Surface::Surface: Create Canvas surface from Window reference.
* @param x horizontal location of the new surface
* @param y vertical location of the new surface
* @param width width of the new surface
* @param height height of the new surface
*
* Set the mpSurface to the new surface or NULL
**/
Gtk3Surface::Gtk3Surface(const OutputDevice& rRefDevice, int x, int y, int width, int height)
: mpSurface(cairo_get_target(rRefDevice.GetCairoContext()), &cairo_surface_flush)
, mpDevice(&rRefDevice)
, mnWidth(width)
, mnHeight(height)
{
cairo_surface_set_device_offset(mpSurface.get(), x, y );
}
/**
* Surface::Surface: Create generic Canvas surface using given Cairo Surface
*
* @param pSurface Cairo Surface
*
* This constructor only stores data, it does no processing.
* It is used with e.g. cairo_image_surface_create_for_data()
*
* Set the mpSurface as pSurface
**/
Gtk3Surface::Gtk3Surface(const CairoSurfaceSharedPtr& pSurface, int width, int height)
: mpSurface(pSurface)
, mpDevice(NULL)
, mnWidth(width)
, mnHeight(height)
{
}
/**
* Surface::getCairo: Create Cairo (drawing object) for the Canvas surface
*
* @return new Cairo or NULL
**/
CairoSharedPtr Gtk3Surface::getCairo() const
{
return CairoSharedPtr(cairo_create(mpSurface.get()),
&cairo_destroy);
}
/**
* Surface::getSimilar: Create new similar Canvas surface
* @param aContent format of the new surface (cairo_content_t from cairo/src/cairo.h)
* @param width width of the new surface
* @param height height of the new surface
*
* Creates a new Canvas surface.
*
* Cairo surface from aContent (cairo_content_t)
*
* @return new surface or NULL
**/
SurfaceSharedPtr Gtk3Surface::getSimilar( Content aContent, int width, int height ) const
{
return SurfaceSharedPtr(
new Gtk3Surface(CairoSurfaceSharedPtr(
cairo_surface_create_similar( mpSurface.get(), aContent, width, height ),
&cairo_surface_destroy ), width, height));
}
/**
* Surface::Resize: Resizes the Canvas surface.
* @param width new width of the surface
* @param height new height of the surface
*
* Only used on X11.
*
* @return The new surface or NULL
**/
void Gtk3Surface::Resize( int /*width*/, int /*height*/ )
{
assert(false && "not supposed to be called!");
}
void Gtk3Surface::flush() const
{
cairo_surface_flush(mpSurface.get());
if (mpDevice)
mpDevice->FlushCairoContext(NULL);
}
boost::shared_ptr<VirtualDevice> Gtk3Surface::createVirtualDevice() const
{
return boost::shared_ptr<VirtualDevice>(new VirtualDevice(NULL, Size(mnWidth, mnHeight), 0));
}
SurfaceSharedPtr createSurface( const OutputDevice& rRefDevice,
int x, int y, int width, int height )
{
return SurfaceSharedPtr(new Gtk3Surface(rRefDevice, x, y, width, height));
if( rRefDevice.GetOutDevType() == OUTDEV_WINDOW )
return SurfaceSharedPtr(new X11Surface(getSysData(static_cast<const vcl::Window&>(rRefDevice)),
x,y,width,height));
else if( rRefDevice.GetOutDevType() == OUTDEV_VIRDEV )
return SurfaceSharedPtr(new X11Surface(getSysData(static_cast<const VirtualDevice&>(rRefDevice)),
x,y,width,height));
else
return SurfaceSharedPtr();
}
SurfaceSharedPtr createBitmapSurface( const OutputDevice& rRefDevice,

View File

@@ -97,29 +97,6 @@ namespace cairo {
void* getRenderFormat() const { return maSysData.pRenderFormat; }
long getDrawable() const { return mpPixmap ? mpPixmap->mhDrawable : maSysData.hDrawable; }
};
class Gtk3Surface : public Surface
{
CairoSurfaceSharedPtr mpSurface;
const OutputDevice* mpDevice;
int mnWidth;
int mnHeight;
public:
/// takes over ownership of passed cairo_surface
explicit Gtk3Surface(const CairoSurfaceSharedPtr& pSurface, int width, int height);
/// create surface on subarea of given drawable
explicit Gtk3Surface(const OutputDevice& rRefDevice, int x, int y, int width, int height);
// Surface interface
virtual CairoSharedPtr getCairo() const SAL_OVERRIDE;
virtual CairoSurfaceSharedPtr getCairoSurface() const SAL_OVERRIDE { return mpSurface; }
virtual SurfaceSharedPtr getSimilar( Content aContent, int width, int height ) const SAL_OVERRIDE;
virtual boost::shared_ptr<VirtualDevice> createVirtualDevice() const SAL_OVERRIDE;
virtual void Resize(int width, int height) SAL_OVERRIDE;
virtual void flush() const SAL_OVERRIDE;
};
}
#endif