1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski // MARKER(update_precomp.py): autogen include statement, do not remove 25*b1cdbd2cSJim Jagielski #include "precompiled_canvas.hxx" 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski #ifdef QUARTZ 28*b1cdbd2cSJim Jagielski /************************************************************************ 29*b1cdbd2cSJim Jagielski * Mac OS X/Quartz surface backend for OpenOffice.org Cairo Canvas * 30*b1cdbd2cSJim Jagielski ************************************************************************/ 31*b1cdbd2cSJim Jagielski 32*b1cdbd2cSJim Jagielski #include <osl/diagnose.h> 33*b1cdbd2cSJim Jagielski #include <vcl/sysdata.hxx> 34*b1cdbd2cSJim Jagielski #include <vcl/bitmap.hxx> 35*b1cdbd2cSJim Jagielski #include <vcl/virdev.hxx> 36*b1cdbd2cSJim Jagielski 37*b1cdbd2cSJim Jagielski #include "cairo_cairo.hxx" 38*b1cdbd2cSJim Jagielski 39*b1cdbd2cSJim Jagielski #if defined CAIRO_HAS_QUARTZ_SURFACE 40*b1cdbd2cSJim Jagielski 41*b1cdbd2cSJim Jagielski #include "cairo_quartz_cairo.hxx" 42*b1cdbd2cSJim Jagielski 43*b1cdbd2cSJim Jagielski namespace cairo 44*b1cdbd2cSJim Jagielski { IsCairoWorking(OutputDevice *)45*b1cdbd2cSJim Jagielski bool IsCairoWorking( OutputDevice* ) 46*b1cdbd2cSJim Jagielski { 47*b1cdbd2cSJim Jagielski // trivially true for Mac 48*b1cdbd2cSJim Jagielski return true; 49*b1cdbd2cSJim Jagielski } 50*b1cdbd2cSJim Jagielski 51*b1cdbd2cSJim Jagielski /** 52*b1cdbd2cSJim Jagielski * QuartzSurface::Surface: Create generic Canvas surface using given Cairo Surface 53*b1cdbd2cSJim Jagielski * 54*b1cdbd2cSJim Jagielski * @param pSurface Cairo Surface 55*b1cdbd2cSJim Jagielski * 56*b1cdbd2cSJim Jagielski * This constructor only stores data, it does no processing. 57*b1cdbd2cSJim Jagielski * It is used with e.g. cairo_image_surface_create_for_data() 58*b1cdbd2cSJim Jagielski * and QuartzSurface::getSimilar() 59*b1cdbd2cSJim Jagielski * 60*b1cdbd2cSJim Jagielski * Set the mpSurface to the new surface or NULL 61*b1cdbd2cSJim Jagielski **/ QuartzSurface(const CairoSurfaceSharedPtr & pSurface)62*b1cdbd2cSJim Jagielski QuartzSurface::QuartzSurface( const CairoSurfaceSharedPtr& pSurface ) : 63*b1cdbd2cSJim Jagielski mpView(NULL), 64*b1cdbd2cSJim Jagielski mpSurface( pSurface ) 65*b1cdbd2cSJim Jagielski { 66*b1cdbd2cSJim Jagielski // Necessary, context is lost otherwise 67*b1cdbd2cSJim Jagielski CGContextRetain( getCGContext() ); // == NULL for non-native surfaces 68*b1cdbd2cSJim Jagielski } 69*b1cdbd2cSJim Jagielski 70*b1cdbd2cSJim Jagielski /** 71*b1cdbd2cSJim Jagielski * QuartzSurface::Surface: Create Canvas surface from Window reference. 72*b1cdbd2cSJim Jagielski * @param NSView 73*b1cdbd2cSJim Jagielski * @param x horizontal location of the new surface 74*b1cdbd2cSJim Jagielski * @param y vertical location of the new surface 75*b1cdbd2cSJim Jagielski * @param width width of the new surface 76*b1cdbd2cSJim Jagielski * @param height height of the new surface 77*b1cdbd2cSJim Jagielski * 78*b1cdbd2cSJim Jagielski * pSysData contains the platform native Window reference. 79*b1cdbd2cSJim Jagielski * pSysData is used to create a surface on the Window 80*b1cdbd2cSJim Jagielski * 81*b1cdbd2cSJim Jagielski * Set the mpSurface to the new surface or NULL 82*b1cdbd2cSJim Jagielski **/ QuartzSurface(NSView * pView,int x,int y,int width,int height)83*b1cdbd2cSJim Jagielski QuartzSurface::QuartzSurface( NSView* pView, int x, int y, int width, int height ) : 84*b1cdbd2cSJim Jagielski mpView(pView), 85*b1cdbd2cSJim Jagielski mpSurface() 86*b1cdbd2cSJim Jagielski { 87*b1cdbd2cSJim Jagielski OSL_TRACE("Canvas::cairo::Surface(NSView*, x:%d, y:%d, w:%d, h:%d): New Surface for window", x, y, width, height); 88*b1cdbd2cSJim Jagielski 89*b1cdbd2cSJim Jagielski // on Mac OS X / Quartz we are not drawing directly to the screen, but via regular CGContextRef. 90*b1cdbd2cSJim Jagielski // The actual drawing to NSView (i.e. screen) is done in QuartzSurface::flush() 91*b1cdbd2cSJim Jagielski 92*b1cdbd2cSJim Jagielski // HACK: currently initial size for windowsurface is 0x0, which is not possible for us. 93*b1cdbd2cSJim Jagielski if (width == 0 || height == 0) { 94*b1cdbd2cSJim Jagielski width = [mpView bounds].size.width; 95*b1cdbd2cSJim Jagielski height = [mpView bounds].size.height; 96*b1cdbd2cSJim Jagielski OSL_TRACE("Canvas::cairo::Surface(): BUG!! size is ZERO! fixing to %d x %d...", width, height); 97*b1cdbd2cSJim Jagielski } 98*b1cdbd2cSJim Jagielski 99*b1cdbd2cSJim Jagielski // create a generic surface, NSView/Window is ARGB32. 100*b1cdbd2cSJim Jagielski mpSurface.reset( 101*b1cdbd2cSJim Jagielski cairo_quartz_surface_create(CAIRO_FORMAT_ARGB32, width, height), 102*b1cdbd2cSJim Jagielski &cairo_surface_destroy); 103*b1cdbd2cSJim Jagielski 104*b1cdbd2cSJim Jagielski cairo_surface_set_device_offset( mpSurface.get(), x, y ); 105*b1cdbd2cSJim Jagielski } 106*b1cdbd2cSJim Jagielski 107*b1cdbd2cSJim Jagielski /** 108*b1cdbd2cSJim Jagielski * QuartzSurface::Surface: Create Canvas surface from CGContextRef. 109*b1cdbd2cSJim Jagielski * @param CGContext Native graphics context 110*b1cdbd2cSJim Jagielski * @param x horizontal location of the new surface 111*b1cdbd2cSJim Jagielski * @param y vertical location of the new surface 112*b1cdbd2cSJim Jagielski * @param width width of the new surface 113*b1cdbd2cSJim Jagielski * @param height height of the new surface 114*b1cdbd2cSJim Jagielski * 115*b1cdbd2cSJim Jagielski * Set the mpSurface to the new surface or NULL 116*b1cdbd2cSJim Jagielski **/ QuartzSurface(CGContextRef rContext,int x,int y,int width,int height)117*b1cdbd2cSJim Jagielski QuartzSurface::QuartzSurface( CGContextRef rContext, int x, int y, int width, int height ) : 118*b1cdbd2cSJim Jagielski mpView(NULL), 119*b1cdbd2cSJim Jagielski mpSurface() 120*b1cdbd2cSJim Jagielski { 121*b1cdbd2cSJim Jagielski OSL_TRACE("Canvas::cairo::Surface(CGContext:%p, x:%d, y:%d, w:%d, h:%d): New Surface.", rContext, x, y, width, height); 122*b1cdbd2cSJim Jagielski // create surface based on CGContext 123*b1cdbd2cSJim Jagielski 124*b1cdbd2cSJim Jagielski // ensure kCGBitmapByteOrder32Host flag, otherwise Cairo breaks (we are practically always using CGBitmapContext) 125*b1cdbd2cSJim Jagielski OSL_ASSERT ((CGBitmapContextGetBitsPerPixel(rContext) != 32) || 126*b1cdbd2cSJim Jagielski (CGBitmapContextGetBitmapInfo(rContext) & kCGBitmapByteOrderMask) == kCGBitmapByteOrder32Host); 127*b1cdbd2cSJim Jagielski 128*b1cdbd2cSJim Jagielski mpSurface.reset(cairo_quartz_surface_create_for_cg_context(rContext, width, height), 129*b1cdbd2cSJim Jagielski &cairo_surface_destroy); 130*b1cdbd2cSJim Jagielski 131*b1cdbd2cSJim Jagielski cairo_surface_set_device_offset( mpSurface.get(), x, y ); 132*b1cdbd2cSJim Jagielski 133*b1cdbd2cSJim Jagielski // Necessary, context is lost otherwise 134*b1cdbd2cSJim Jagielski CGContextRetain(rContext); 135*b1cdbd2cSJim Jagielski } 136*b1cdbd2cSJim Jagielski 137*b1cdbd2cSJim Jagielski 138*b1cdbd2cSJim Jagielski /** 139*b1cdbd2cSJim Jagielski * QuartzSurface::getCairo: Create Cairo (drawing object) for the Canvas surface 140*b1cdbd2cSJim Jagielski * 141*b1cdbd2cSJim Jagielski * @return new Cairo or NULL 142*b1cdbd2cSJim Jagielski **/ getCairo() const143*b1cdbd2cSJim Jagielski CairoSharedPtr QuartzSurface::getCairo() const 144*b1cdbd2cSJim Jagielski { 145*b1cdbd2cSJim Jagielski if (mpSurface.get()){ 146*b1cdbd2cSJim Jagielski return CairoSharedPtr( cairo_create(mpSurface.get()), 147*b1cdbd2cSJim Jagielski &cairo_destroy ); 148*b1cdbd2cSJim Jagielski } else { 149*b1cdbd2cSJim Jagielski return CairoSharedPtr(); 150*b1cdbd2cSJim Jagielski } 151*b1cdbd2cSJim Jagielski } 152*b1cdbd2cSJim Jagielski 153*b1cdbd2cSJim Jagielski /** 154*b1cdbd2cSJim Jagielski * QuartzSurface::getSimilar: Create new similar Canvas surface 155*b1cdbd2cSJim Jagielski * @param aContent format of the new surface (cairo_content_t from cairo/src/cairo.h) 156*b1cdbd2cSJim Jagielski * @param width width of the new surface 157*b1cdbd2cSJim Jagielski * @param height height of the new surface 158*b1cdbd2cSJim Jagielski * 159*b1cdbd2cSJim Jagielski * Creates a new Canvas surface. This normally creates platform native surface, even though 160*b1cdbd2cSJim Jagielski * generic function is used. 161*b1cdbd2cSJim Jagielski * 162*b1cdbd2cSJim Jagielski * Cairo surface from aContent (cairo_content_t) 163*b1cdbd2cSJim Jagielski * 164*b1cdbd2cSJim Jagielski * @return new surface or NULL 165*b1cdbd2cSJim Jagielski **/ getSimilar(Content aContent,int width,int height) const166*b1cdbd2cSJim Jagielski SurfaceSharedPtr QuartzSurface::getSimilar( Content aContent, int width, int height ) const 167*b1cdbd2cSJim Jagielski { 168*b1cdbd2cSJim Jagielski return SurfaceSharedPtr( 169*b1cdbd2cSJim Jagielski new QuartzSurface( 170*b1cdbd2cSJim Jagielski CairoSurfaceSharedPtr( 171*b1cdbd2cSJim Jagielski cairo_surface_create_similar( mpSurface.get(), aContent, width, height ), 172*b1cdbd2cSJim Jagielski &cairo_surface_destroy ))); 173*b1cdbd2cSJim Jagielski } 174*b1cdbd2cSJim Jagielski 175*b1cdbd2cSJim Jagielski /** 176*b1cdbd2cSJim Jagielski * QuartzSurface::Resize: Resizes the Canvas surface. 177*b1cdbd2cSJim Jagielski * @param width new width of the surface 178*b1cdbd2cSJim Jagielski * @param height new height of the surface 179*b1cdbd2cSJim Jagielski * 180*b1cdbd2cSJim Jagielski * Only used on X11. 181*b1cdbd2cSJim Jagielski * 182*b1cdbd2cSJim Jagielski * @return The new surface or NULL 183*b1cdbd2cSJim Jagielski **/ Resize(int width,int height)184*b1cdbd2cSJim Jagielski void QuartzSurface::Resize( int width, int height ) 185*b1cdbd2cSJim Jagielski { 186*b1cdbd2cSJim Jagielski OSL_ENSURE(false,"not supposed to be called!"); 187*b1cdbd2cSJim Jagielski } 188*b1cdbd2cSJim Jagielski 189*b1cdbd2cSJim Jagielski 190*b1cdbd2cSJim Jagielski /** 191*b1cdbd2cSJim Jagielski * QuartzSurface::flush: Draw the data to screen 192*b1cdbd2cSJim Jagielski **/ flush() const193*b1cdbd2cSJim Jagielski void QuartzSurface::flush() const 194*b1cdbd2cSJim Jagielski { 195*b1cdbd2cSJim Jagielski // can only flush surfaces with NSView 196*b1cdbd2cSJim Jagielski if( !mpView ) return; 197*b1cdbd2cSJim Jagielski 198*b1cdbd2cSJim Jagielski OSL_TRACE("Canvas::cairo::QuartzSurface::flush(): flush to NSView"); 199*b1cdbd2cSJim Jagielski 200*b1cdbd2cSJim Jagielski CGContextRef mrContext = getCGContext(); 201*b1cdbd2cSJim Jagielski 202*b1cdbd2cSJim Jagielski if (!mrContext) return; 203*b1cdbd2cSJim Jagielski 204*b1cdbd2cSJim Jagielski [mpView lockFocus]; 205*b1cdbd2cSJim Jagielski 206*b1cdbd2cSJim Jagielski /** 207*b1cdbd2cSJim Jagielski * This code is using same screen update code as in VCL (esp. AquaSalGraphics::UpdateWindow() ) 208*b1cdbd2cSJim Jagielski */ 209*b1cdbd2cSJim Jagielski CGContextRef rViewContext = reinterpret_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]); 210*b1cdbd2cSJim Jagielski CGImageRef xImage = CGBitmapContextCreateImage(mrContext); 211*b1cdbd2cSJim Jagielski CGContextDrawImage(rViewContext, 212*b1cdbd2cSJim Jagielski CGRectMake( 0, 0, 213*b1cdbd2cSJim Jagielski CGImageGetWidth(xImage), 214*b1cdbd2cSJim Jagielski CGImageGetHeight(xImage)), 215*b1cdbd2cSJim Jagielski xImage); 216*b1cdbd2cSJim Jagielski CGImageRelease( xImage ); 217*b1cdbd2cSJim Jagielski CGContextFlush( rViewContext ); 218*b1cdbd2cSJim Jagielski 219*b1cdbd2cSJim Jagielski [mpView unlockFocus]; 220*b1cdbd2cSJim Jagielski } 221*b1cdbd2cSJim Jagielski 222*b1cdbd2cSJim Jagielski /** 223*b1cdbd2cSJim Jagielski * QuartzSurface::getDepth: Get the color depth of the Canvas surface. 224*b1cdbd2cSJim Jagielski * 225*b1cdbd2cSJim Jagielski * @return color depth 226*b1cdbd2cSJim Jagielski **/ getDepth() const227*b1cdbd2cSJim Jagielski int QuartzSurface::getDepth() const 228*b1cdbd2cSJim Jagielski { 229*b1cdbd2cSJim Jagielski if (mpSurface.get()) { 230*b1cdbd2cSJim Jagielski switch (cairo_surface_get_content (mpSurface.get())) { 231*b1cdbd2cSJim Jagielski case CAIRO_CONTENT_ALPHA: return 8; break; 232*b1cdbd2cSJim Jagielski case CAIRO_CONTENT_COLOR: return 24; break; 233*b1cdbd2cSJim Jagielski case CAIRO_CONTENT_COLOR_ALPHA: return 32; break; 234*b1cdbd2cSJim Jagielski } 235*b1cdbd2cSJim Jagielski } 236*b1cdbd2cSJim Jagielski OSL_TRACE("Canvas::cairo::QuartzSurface::getDepth(): ERROR - depth unspecified!"); 237*b1cdbd2cSJim Jagielski 238*b1cdbd2cSJim Jagielski return -1; 239*b1cdbd2cSJim Jagielski } 240*b1cdbd2cSJim Jagielski 241*b1cdbd2cSJim Jagielski /** 242*b1cdbd2cSJim Jagielski * QuartzSurface::getCGContext: Get the native CGContextRef of the Canvas's cairo surface 243*b1cdbd2cSJim Jagielski * 244*b1cdbd2cSJim Jagielski * @return graphics context 245*b1cdbd2cSJim Jagielski **/ getCGContext() const246*b1cdbd2cSJim Jagielski CGContextRef QuartzSurface::getCGContext() const 247*b1cdbd2cSJim Jagielski { 248*b1cdbd2cSJim Jagielski if (mpSurface.get()) 249*b1cdbd2cSJim Jagielski return cairo_quartz_surface_get_cg_context(mpSurface.get()); 250*b1cdbd2cSJim Jagielski else 251*b1cdbd2cSJim Jagielski return NULL; 252*b1cdbd2cSJim Jagielski } 253*b1cdbd2cSJim Jagielski 254*b1cdbd2cSJim Jagielski /** 255*b1cdbd2cSJim Jagielski * cairo::createVirtualDevice: Create a VCL virtual device for the CGContext in the cairo Surface 256*b1cdbd2cSJim Jagielski * 257*b1cdbd2cSJim Jagielski * @return The new virtual device 258*b1cdbd2cSJim Jagielski **/ createVirtualDevice() const259*b1cdbd2cSJim Jagielski boost::shared_ptr<VirtualDevice> QuartzSurface::createVirtualDevice() const 260*b1cdbd2cSJim Jagielski { 261*b1cdbd2cSJim Jagielski SystemGraphicsData aSystemGraphicsData; 262*b1cdbd2cSJim Jagielski aSystemGraphicsData.nSize = sizeof(SystemGraphicsData); 263*b1cdbd2cSJim Jagielski aSystemGraphicsData.rCGContext = getCGContext(); 264*b1cdbd2cSJim Jagielski return boost::shared_ptr<VirtualDevice>( 265*b1cdbd2cSJim Jagielski new VirtualDevice( &aSystemGraphicsData, getDepth() )); 266*b1cdbd2cSJim Jagielski } 267*b1cdbd2cSJim Jagielski 268*b1cdbd2cSJim Jagielski /** 269*b1cdbd2cSJim Jagielski * cairo::createSurface: Create generic Canvas surface using given Cairo Surface 270*b1cdbd2cSJim Jagielski * 271*b1cdbd2cSJim Jagielski * @param rSurface Cairo Surface 272*b1cdbd2cSJim Jagielski * 273*b1cdbd2cSJim Jagielski * @return new Surface 274*b1cdbd2cSJim Jagielski */ createSurface(const CairoSurfaceSharedPtr & rSurface)275*b1cdbd2cSJim Jagielski SurfaceSharedPtr createSurface( const CairoSurfaceSharedPtr& rSurface ) 276*b1cdbd2cSJim Jagielski { 277*b1cdbd2cSJim Jagielski return SurfaceSharedPtr(new QuartzSurface(rSurface)); 278*b1cdbd2cSJim Jagielski } 279*b1cdbd2cSJim Jagielski 280*b1cdbd2cSJim Jagielski /** 281*b1cdbd2cSJim Jagielski * cairo::createSurface: Create Canvas surface using given VCL Window or Virtualdevice 282*b1cdbd2cSJim Jagielski * 283*b1cdbd2cSJim Jagielski * @param rSurface Cairo Surface 284*b1cdbd2cSJim Jagielski * 285*b1cdbd2cSJim Jagielski * For VCL Window, use platform native system environment data (struct SystemEnvData in vcl/inc/sysdata.hxx) 286*b1cdbd2cSJim Jagielski * For VCL Virtualdevice, use platform native system graphics data (struct SystemGraphicsData in vcl/inc/sysdata.hxx) 287*b1cdbd2cSJim Jagielski * 288*b1cdbd2cSJim Jagielski * @return new Surface 289*b1cdbd2cSJim Jagielski */ createSurface(const OutputDevice & rRefDevice,int x,int y,int width,int height)290*b1cdbd2cSJim Jagielski SurfaceSharedPtr createSurface( const OutputDevice& rRefDevice, 291*b1cdbd2cSJim Jagielski int x, int y, int width, int height ) 292*b1cdbd2cSJim Jagielski { 293*b1cdbd2cSJim Jagielski SurfaceSharedPtr surf; 294*b1cdbd2cSJim Jagielski 295*b1cdbd2cSJim Jagielski if( rRefDevice.GetOutDevType() == OUTDEV_WINDOW ) 296*b1cdbd2cSJim Jagielski { 297*b1cdbd2cSJim Jagielski const Window &rWindow = (const Window &) rRefDevice; 298*b1cdbd2cSJim Jagielski const SystemEnvData* pSysData = GetSysData(&rWindow); 299*b1cdbd2cSJim Jagielski if (pSysData) 300*b1cdbd2cSJim Jagielski surf = SurfaceSharedPtr(new QuartzSurface(pSysData->pView, x, y, width, height)); 301*b1cdbd2cSJim Jagielski } 302*b1cdbd2cSJim Jagielski else if( rRefDevice.GetOutDevType() == OUTDEV_VIRDEV ) 303*b1cdbd2cSJim Jagielski { 304*b1cdbd2cSJim Jagielski SystemGraphicsData aSysData = ((const VirtualDevice&) rRefDevice).GetSystemGfxData(); 305*b1cdbd2cSJim Jagielski 306*b1cdbd2cSJim Jagielski if (aSysData.rCGContext) 307*b1cdbd2cSJim Jagielski surf = SurfaceSharedPtr(new QuartzSurface(aSysData.rCGContext, x, y, width, height)); 308*b1cdbd2cSJim Jagielski } 309*b1cdbd2cSJim Jagielski return surf; 310*b1cdbd2cSJim Jagielski } 311*b1cdbd2cSJim Jagielski 312*b1cdbd2cSJim Jagielski /** 313*b1cdbd2cSJim Jagielski * cairo::createBitmapSurface: Create platfrom native Canvas surface from BitmapSystemData 314*b1cdbd2cSJim Jagielski * @param OutputDevice (not used) 315*b1cdbd2cSJim Jagielski * @param rData Platform native image data (struct BitmapSystemData in vcl/inc/bitmap.hxx) 316*b1cdbd2cSJim Jagielski * @param rSize width and height of the new surface 317*b1cdbd2cSJim Jagielski * 318*b1cdbd2cSJim Jagielski * Create a surface based on image data on rData 319*b1cdbd2cSJim Jagielski * 320*b1cdbd2cSJim Jagielski * @return new surface or empty surface 321*b1cdbd2cSJim Jagielski **/ createBitmapSurface(const OutputDevice &,const BitmapSystemData & rData,const Size & rSize)322*b1cdbd2cSJim Jagielski SurfaceSharedPtr createBitmapSurface( const OutputDevice& /* rRefDevice */, 323*b1cdbd2cSJim Jagielski const BitmapSystemData& rData, 324*b1cdbd2cSJim Jagielski const Size& rSize ) 325*b1cdbd2cSJim Jagielski { 326*b1cdbd2cSJim Jagielski OSL_TRACE( "requested size: %d x %d available size: %d x %d", 327*b1cdbd2cSJim Jagielski rSize.Width(), rSize.Height(), rData.mnWidth, rData.mnHeight ); 328*b1cdbd2cSJim Jagielski 329*b1cdbd2cSJim Jagielski if ( rData.mnWidth == rSize.Width() && rData.mnHeight == rSize.Height() ) 330*b1cdbd2cSJim Jagielski { 331*b1cdbd2cSJim Jagielski CGContextRef rContext = (CGContextRef)rData.rImageContext; 332*b1cdbd2cSJim Jagielski OSL_TRACE("Canvas::cairo::createBitmapSurface(): New native image surface, context = %p.", rData.rImageContext); 333*b1cdbd2cSJim Jagielski 334*b1cdbd2cSJim Jagielski return SurfaceSharedPtr(new QuartzSurface(rContext, 0, 0, rData.mnWidth, rData.mnHeight)); 335*b1cdbd2cSJim Jagielski } 336*b1cdbd2cSJim Jagielski return SurfaceSharedPtr(); 337*b1cdbd2cSJim Jagielski } 338*b1cdbd2cSJim Jagielski 339*b1cdbd2cSJim Jagielski } // namespace cairo 340*b1cdbd2cSJim Jagielski 341*b1cdbd2cSJim Jagielski #endif // CAIRO_HAS_QUARTZ_SURFACE 342*b1cdbd2cSJim Jagielski 343*b1cdbd2cSJim Jagielski #endif // QUARTZ 344