LibreOffice Module vcl (master)  1
outdev.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <sal/config.h>
21 #include <sal/log.hxx>
22 
23 #include <tools/debug.hxx>
24 #include <vcl/gdimtf.hxx>
25 #include <vcl/graph.hxx>
26 #include <vcl/metaact.hxx>
27 #include <vcl/virdev.hxx>
28 #include <vcl/outdev.hxx>
29 #include <vcl/toolkit/unowrap.hxx>
30 #include <vcl/svapp.hxx>
31 #include <vcl/sysdata.hxx>
32 #include <vcl/lazydelete.hxx>
34 
35 #include <ImplOutDevData.hxx>
37 #include <salgdi.hxx>
38 #include <window.h>
39 
40 #include <com/sun/star/awt/DeviceCapability.hpp>
41 #include <com/sun/star/awt/XWindow.hpp>
42 #include <com/sun/star/rendering/CanvasFactory.hpp>
43 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
44 
45 #ifdef DISABLE_DYNLOADING
46 // Linking all needed LO code into one .so/executable, these already
47 // exist in the tools library, so put them in the anonymous namespace
48 // here to avoid clash...
49 namespace {
50 #endif
51 #ifdef DISABLE_DYNLOADING
52 }
53 #endif
54 
55 using namespace ::com::sun::star::uno;
56 
57 // Begin initializer and accessor public functions
58 
60  meOutDevType(eOutDevType),
61  maRegion(true),
63  maTextLineColor( COL_TRANSPARENT ),
64  mxSettings( new AllSettings(Application::GetSettings()) )
65 {
66  mpGraphics = nullptr;
67  mpUnoGraphicsList = nullptr;
68  mpPrevGraphics = nullptr;
69  mpNextGraphics = nullptr;
70  mpMetaFile = nullptr;
71  mpFontInstance = nullptr;
72  mpFontFaceCollection = nullptr;
73  mpAlphaVDev = nullptr;
74  mpExtOutDevData = nullptr;
75  mnOutOffX = 0;
76  mnOutOffY = 0;
77  mnOutWidth = 0;
78  mnOutHeight = 0;
79  mnDPIX = 0;
80  mnDPIY = 0;
82  mnTextOffX = 0;
83  mnTextOffY = 0;
84  mnOutOffOrigX = 0;
85  mnOutOffLogicX = 0;
86  mnOutOffOrigY = 0;
87  mnOutOffLogicY = 0;
88  mnEmphasisAscent = 0;
92 
93  if( AllSettings::GetLayoutRTL() ) //#i84553# tip BiDi preference to RTL
95 
97  mbMap = false;
98  mbClipRegion = false;
99  mbBackground = false;
100  mbOutput = true;
101  mbDevOutput = false;
102  mbOutputClipped = false;
107  meTextLanguage = LANGUAGE_SYSTEM; // TODO: get default from configuration?
109  mbLineColor = true;
110  mbFillColor = true;
111  mbInitLineColor = true;
112  mbInitFillColor = true;
113  mbInitFont = true;
114  mbInitTextColor = true;
115  mbInitClipRegion = true;
116  mbClipRegionSet = false;
117  mbNewFont = true;
118  mbTextLines = false;
119  mbTextSpecial = false;
120  mbRefPoint = false;
121  mbEnableRTL = false; // mirroring must be explicitly allowed (typically for windows only)
122 
123  // struct ImplMapRes
124  maMapRes.mnMapOfsX = 0;
125  maMapRes.mnMapOfsY = 0;
126  maMapRes.mnMapScNumX = 1;
127  maMapRes.mnMapScNumY = 1;
130 
131  // struct ImplOutDevData- see #i82615#
132  mpOutDevData.reset(new ImplOutDevData);
133  mpOutDevData->mpRotateDev = nullptr;
134  mpOutDevData->mpRecordLayout = nullptr;
135 
136  // #i75163#
137  mpOutDevData->mpViewTransform = nullptr;
138  mpOutDevData->mpInverseViewTransform = nullptr;
139 }
140 
142 {
143  disposeOnce();
144 }
145 
147 {
148  if ( GetUnoGraphicsList() )
149  {
150  UnoWrapperBase* pWrapper = UnoWrapperBase::GetUnoWrapper( false );
151  if ( pWrapper )
152  pWrapper->ReleaseAllGraphics( this );
153  delete mpUnoGraphicsList;
154  mpUnoGraphicsList = nullptr;
155  }
156 
157  mpOutDevData->mpRotateDev.disposeAndClear();
158 
159  // #i75163#
161 
162  mpOutDevData.reset();
163 
164  // for some reason, we haven't removed state from the stack properly
165  if ( !maOutDevStateStack.empty() )
166  SAL_WARN( "vcl.gdi", "OutputDevice::~OutputDevice(): OutputDevice::Push() calls != OutputDevice::Pop() calls" );
167  maOutDevStateStack.clear();
168 
169  // release the active font instance
170  mpFontInstance.clear();
171 
172  // remove cached results of GetDevFontList/GetDevSizeList
173  mpFontFaceCollection.reset();
174 
175  // release ImplFontCache specific to this OutputDevice
176  mxFontCache.reset();
177 
178  // release ImplFontList specific to this OutputDevice
179  mxFontCollection.reset();
180 
185 }
186 
188 {
189  return false;
190 }
191 
193 {
195 
196  if (!mpGraphics && !AcquireGraphics())
197  SAL_WARN("vcl.gdi", "No mpGraphics set");
198 
199  return mpGraphics;
200 }
201 
203 {
205 
206  if (!mpGraphics && !AcquireGraphics())
207  SAL_WARN("vcl.gdi", "No mpGraphics set");
208 
209  return mpGraphics;
210 }
211 
213 {
214  mpMetaFile = pMtf;
215 }
216 
217 void OutputDevice::SetSettings( const AllSettings& rSettings )
218 {
219  *mxSettings = rSettings;
220 
221  if( mpAlphaVDev )
222  mpAlphaVDev->SetSettings( rSettings );
223 }
224 
226 {
227  if (!mpGraphics && !AcquireGraphics())
228  return SystemGraphicsData();
229  assert(mpGraphics);
230 
231  return mpGraphics->GetGraphicsData();
232 }
233 
235 {
236  if (!mpGraphics && !AcquireGraphics())
237  return {};
238  assert(mpGraphics);
239 
241 }
242 
243 #if ENABLE_CAIRO_CANVAS
244 
245 bool OutputDevice::SupportsCairo() const
246 {
247  if (!mpGraphics && !AcquireGraphics())
248  return false;
249  assert(mpGraphics);
250 
251  return mpGraphics->SupportsCairo();
252 }
253 
255 {
256  if (!mpGraphics && !AcquireGraphics())
257  return cairo::SurfaceSharedPtr();
258  assert(mpGraphics);
259  return mpGraphics->CreateSurface(rSurface);
260 }
261 
262 cairo::SurfaceSharedPtr OutputDevice::CreateSurface(int x, int y, int width, int height) const
263 {
264  if (!mpGraphics && !AcquireGraphics())
265  return cairo::SurfaceSharedPtr();
266  assert(mpGraphics);
267  return mpGraphics->CreateSurface(*this, x, y, width, height);
268 }
269 
271 {
272  if (!mpGraphics && !AcquireGraphics())
273  return cairo::SurfaceSharedPtr();
274  assert(mpGraphics);
275  return mpGraphics->CreateBitmapSurface(*this, rData, rSize);
276 }
277 
278 css::uno::Any OutputDevice::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize) const
279 {
280  if (!mpGraphics && !AcquireGraphics())
281  return css::uno::Any();
282  assert(mpGraphics);
283  return mpGraphics->GetNativeSurfaceHandle(rSurface, rSize);
284 }
285 
286 #endif // ENABLE_CAIRO_CANVAS
287 
289 {
290  const SystemGraphicsData aSysData = GetSystemGfxData();
291  css::uno::Sequence< sal_Int8 > aSeq( reinterpret_cast<sal_Int8 const *>(&aSysData),
292  aSysData.nSize );
293 
294  return css::uno::Any(aSeq);
295 }
296 
298 {
299  if ( mpMetaFile )
300  mpMetaFile->AddAction( new MetaRefPointAction( Point(), false ) );
301 
302  mbRefPoint = false;
303  maRefPoint.setX(0);
304  maRefPoint.setY(0);
305 
306  if( mpAlphaVDev )
308 }
309 
310 void OutputDevice::SetRefPoint( const Point& rRefPoint )
311 {
312  if ( mpMetaFile )
313  mpMetaFile->AddAction( new MetaRefPointAction( rRefPoint, true ) );
314 
315  mbRefPoint = true;
316  maRefPoint = rRefPoint;
317 
318  if( mpAlphaVDev )
319  mpAlphaVDev->SetRefPoint( rRefPoint );
320 }
321 
323 {
324  if ( mpMetaFile )
325  mpMetaFile->AddAction( new MetaRasterOpAction( eRasterOp ) );
326 
327  if ( meRasterOp != eRasterOp )
328  {
329  meRasterOp = eRasterOp;
331 
332  if( mpGraphics || AcquireGraphics() )
333  {
334  assert(mpGraphics);
336  }
337  }
338 
339  if( mpAlphaVDev )
340  mpAlphaVDev->SetRasterOp( eRasterOp );
341 }
342 
343 void OutputDevice::EnableOutput( bool bEnable )
344 {
345  mbOutput = bEnable;
346 
347  if( mpAlphaVDev )
348  mpAlphaVDev->EnableOutput( bEnable );
349 }
350 
352 {
353  if ( mnAntialiasing != nMode )
354  {
355  mnAntialiasing = nMode;
356  mbInitFont = true;
357 
358  if (mpGraphics)
360  }
361 
362  if( mpAlphaVDev )
363  mpAlphaVDev->SetAntialiasing( nMode );
364 }
365 
367 {
369  {
371 
372  if (mpGraphics)
374  }
375 
376  if (mpAlphaVDev)
378 }
379 
381 {
382  mnDrawMode = nDrawMode;
383 
384  if (mpAlphaVDev)
385  mpAlphaVDev->SetDrawMode(nDrawMode);
386 }
387 
388 sal_uInt16 OutputDevice::GetBitCount() const
389 {
390  // we need a graphics instance
391  if ( !mpGraphics && !AcquireGraphics() )
392  return 0;
393  assert(mpGraphics);
394 
395  return mpGraphics->GetBitCount();
396 }
397 
399 {
400  mnOutOffX = nOutOffX;
401 }
402 
404 {
405  mnOutOffY = nOutOffY;
406 }
407 
408 css::uno::Reference< css::awt::XGraphics > OutputDevice::CreateUnoGraphics()
409 {
411  return pWrapper ? pWrapper->CreateGraphics( this ) : css::uno::Reference< css::awt::XGraphics >();
412 }
413 
414 std::vector< VCLXGraphics* > *OutputDevice::CreateUnoGraphicsList()
415 {
416  mpUnoGraphicsList = new std::vector< VCLXGraphics* >;
417  return mpUnoGraphicsList;
418 }
419 
420 // Helper public function
421 
423 {
424  if( !mpGraphics && !AcquireGraphics() )
425  return false;
426  assert(mpGraphics);
427  const bool bHasSupport = mpGraphics->supportsOperation( eType );
428  return bHasSupport;
429 }
430 
431 // Direct OutputDevice drawing public functions
432 
433 void OutputDevice::DrawOutDev( const Point& rDestPt, const Size& rDestSize,
434  const Point& rSrcPt, const Size& rSrcSize )
435 {
436  if( ImplIsRecordLayout() )
437  return;
438 
439  if ( RasterOp::Invert == meRasterOp )
440  {
441  DrawRect( tools::Rectangle( rDestPt, rDestSize ) );
442  return;
443  }
444 
445  if ( mpMetaFile )
446  {
447  const Bitmap aBmp( GetBitmap( rSrcPt, rSrcSize ) );
448  mpMetaFile->AddAction( new MetaBmpScaleAction( rDestPt, rDestSize, aBmp ) );
449  }
450 
451  if ( !IsDeviceOutputNecessary() )
452  return;
453 
454  if ( !mpGraphics && !AcquireGraphics() )
455  return;
456  assert(mpGraphics);
457 
458  if ( mbInitClipRegion )
459  InitClipRegion();
460 
461  if ( mbOutputClipped )
462  return;
463 
464  tools::Long nSrcWidth = ImplLogicWidthToDevicePixel( rSrcSize.Width() );
465  tools::Long nSrcHeight = ImplLogicHeightToDevicePixel( rSrcSize.Height() );
466  tools::Long nDestWidth = ImplLogicWidthToDevicePixel( rDestSize.Width() );
467  tools::Long nDestHeight = ImplLogicHeightToDevicePixel( rDestSize.Height() );
468 
469  if (nSrcWidth && nSrcHeight && nDestWidth && nDestHeight)
470  {
471  SalTwoRect aPosAry(ImplLogicXToDevicePixel(rSrcPt.X()), ImplLogicYToDevicePixel(rSrcPt.Y()),
472  nSrcWidth, nSrcHeight,
473  ImplLogicXToDevicePixel(rDestPt.X()), ImplLogicYToDevicePixel(rDestPt.Y()),
474  nDestWidth, nDestHeight);
475 
476  AdjustTwoRect( aPosAry, GetOutputRectPixel() );
477 
478  if ( aPosAry.mnSrcWidth && aPosAry.mnSrcHeight && aPosAry.mnDestWidth && aPosAry.mnDestHeight )
479  mpGraphics->CopyBits(aPosAry, *this);
480  }
481 
482  if( mpAlphaVDev )
483  mpAlphaVDev->DrawOutDev( rDestPt, rDestSize, rSrcPt, rSrcSize );
484 }
485 
486 void OutputDevice::DrawOutDev( const Point& rDestPt, const Size& rDestSize,
487  const Point& rSrcPt, const Size& rSrcSize,
488  const OutputDevice& rOutDev )
489 {
490  if ( ImplIsRecordLayout() )
491  return;
492 
493  if ( RasterOp::Invert == meRasterOp )
494  {
495  DrawRect( tools::Rectangle( rDestPt, rDestSize ) );
496  return;
497  }
498 
499  if ( mpMetaFile )
500  {
501  if (rOutDev.mpAlphaVDev)
502  {
503  const BitmapEx aBmpEx(rOutDev.GetBitmapEx(rSrcPt, rSrcSize));
504  mpMetaFile->AddAction(new MetaBmpExScaleAction(rDestPt, rDestSize, aBmpEx));
505  }
506  else
507  {
508  const Bitmap aBmp(rOutDev.GetBitmap(rSrcPt, rSrcSize));
509  mpMetaFile->AddAction(new MetaBmpScaleAction(rDestPt, rDestSize, aBmp));
510  }
511  }
512 
513  if ( !IsDeviceOutputNecessary() )
514  return;
515 
516  if ( !mpGraphics && !AcquireGraphics() )
517  return;
518  assert(mpGraphics);
519 
520  if ( mbInitClipRegion )
521  InitClipRegion();
522 
523  if ( mbOutputClipped )
524  return;
525 
526  if (rOutDev.mpAlphaVDev)
527  {
528  // alpha-blend source over destination
529  DrawBitmapEx(rDestPt, rDestSize, rOutDev.GetBitmapEx(rSrcPt, rSrcSize));
530  }
531  else
532  {
533  SalTwoRect aPosAry(rOutDev.ImplLogicXToDevicePixel(rSrcPt.X()),
534  rOutDev.ImplLogicYToDevicePixel(rSrcPt.Y()),
535  rOutDev.ImplLogicWidthToDevicePixel(rSrcSize.Width()),
536  rOutDev.ImplLogicHeightToDevicePixel(rSrcSize.Height()),
537  ImplLogicXToDevicePixel(rDestPt.X()),
538  ImplLogicYToDevicePixel(rDestPt.Y()),
539  ImplLogicWidthToDevicePixel(rDestSize.Width()),
540  ImplLogicHeightToDevicePixel(rDestSize.Height()));
541 
542  drawOutDevDirect(rOutDev, aPosAry);
543 
544  // #i32109#: make destination rectangle opaque - source has no alpha
545  if (mpAlphaVDev)
547  }
548 }
549 
550 void OutputDevice::CopyArea( const Point& rDestPt,
551  const Point& rSrcPt, const Size& rSrcSize,
552  bool bWindowInvalidate )
553 {
554  if ( ImplIsRecordLayout() )
555  return;
556 
557  RasterOp eOldRop = GetRasterOp();
559 
560  if ( !IsDeviceOutputNecessary() )
561  return;
562 
563  if ( !mpGraphics && !AcquireGraphics() )
564  return;
565  assert(mpGraphics);
566 
567  if ( mbInitClipRegion )
568  InitClipRegion();
569 
570  if ( mbOutputClipped )
571  return;
572 
573  tools::Long nSrcWidth = ImplLogicWidthToDevicePixel( rSrcSize.Width() );
574  tools::Long nSrcHeight = ImplLogicHeightToDevicePixel( rSrcSize.Height() );
575  if (nSrcWidth && nSrcHeight)
576  {
577  SalTwoRect aPosAry(ImplLogicXToDevicePixel(rSrcPt.X()), ImplLogicYToDevicePixel(rSrcPt.Y()),
578  nSrcWidth, nSrcHeight,
579  ImplLogicXToDevicePixel(rDestPt.X()), ImplLogicYToDevicePixel(rDestPt.Y()),
580  nSrcWidth, nSrcHeight);
581 
582  AdjustTwoRect( aPosAry, GetOutputRectPixel() );
583 
584  CopyDeviceArea( aPosAry, bWindowInvalidate );
585  }
586 
587  SetRasterOp( eOldRop );
588 
589  if( mpAlphaVDev )
590  mpAlphaVDev->CopyArea( rDestPt, rSrcPt, rSrcSize, bWindowInvalidate );
591 }
592 
593 // Direct OutputDevice drawing protected function
594 
595 void OutputDevice::CopyDeviceArea( SalTwoRect& aPosAry, bool /*bWindowInvalidate*/)
596 {
597  if (aPosAry.mnSrcWidth == 0 || aPosAry.mnSrcHeight == 0 || aPosAry.mnDestWidth == 0 || aPosAry.mnDestHeight == 0)
598  return;
599 
600  aPosAry.mnDestWidth = aPosAry.mnSrcWidth;
601  aPosAry.mnDestHeight = aPosAry.mnSrcHeight;
602  mpGraphics->CopyBits(aPosAry, *this);
603 }
604 
605 // Direct OutputDevice drawing private function
607 {
608  SalGraphics* pSrcGraphics;
609  if (const OutputDevice* pCheckedSrc = DrawOutDevDirectCheck(rSrcDev))
610  {
611  if (!pCheckedSrc->mpGraphics && !pCheckedSrc->AcquireGraphics())
612  return;
613  pSrcGraphics = pCheckedSrc->mpGraphics;
614  }
615  else
616  pSrcGraphics = nullptr;
617 
618  if (!mpGraphics && !AcquireGraphics())
619  return;
620  assert(mpGraphics);
621 
622  // #102532# Offset only has to be pseudo window offset
623 
624  AdjustTwoRect( rPosAry, rSrcDev.GetOutputRectPixel() );
625 
626  if ( rPosAry.mnSrcWidth && rPosAry.mnSrcHeight && rPosAry.mnDestWidth && rPosAry.mnDestHeight )
627  {
628  // if this is no window, but rSrcDev is a window
629  // mirroring may be required
630  // because only windows have a SalGraphicsLayout
631  // mirroring is performed here
632  DrawOutDevDirectProcess(rSrcDev, rPosAry, pSrcGraphics);
633  }
634 }
635 
637 {
638  return this == &rSrcDev ? nullptr : &rSrcDev;
639 }
640 
641 void OutputDevice::DrawOutDevDirectProcess(const OutputDevice& rSrcDev, SalTwoRect& rPosAry, SalGraphics* pSrcGraphics)
642 {
643  if( pSrcGraphics && (pSrcGraphics->GetLayout() & SalLayoutFlags::BiDiRtl) )
644  {
645  SalTwoRect aPosAry2 = rPosAry;
646  pSrcGraphics->mirror( aPosAry2.mnSrcX, aPosAry2.mnSrcWidth, rSrcDev );
647  mpGraphics->CopyBits( aPosAry2, *pSrcGraphics, *this, rSrcDev );
648  return;
649  }
650  if (pSrcGraphics)
651  mpGraphics->CopyBits( rPosAry, *pSrcGraphics, *this, rSrcDev );
652  else
653  mpGraphics->CopyBits( rPosAry, *this );
654 }
655 
657 {
658  return tools::Rectangle( Point( 0, 0 ), GetOutputSizePixel() );
659 }
660 
661 // Layout public functions
662 
663 void OutputDevice::EnableRTL( bool bEnable )
664 {
665  mbEnableRTL = bEnable;
666 
667  if( mpAlphaVDev )
668  mpAlphaVDev->EnableRTL( bEnable );
669 }
670 
672 {
673  bool bRet = false;
674  if( AcquireGraphics() )
675  {
678  {
679  bRet = true;
680  }
681  }
682  return bRet;
683 }
684 
685 // note: the coordinates to be remirrored are in frame coordinates !
686 
687 void OutputDevice::ReMirror( Point &rPoint ) const
688 {
689  rPoint.setX( mnOutOffX + mnOutWidth - 1 - rPoint.X() + mnOutOffX );
690 }
692 {
693  tools::Long nWidth = rRect.Right() - rRect.Left();
694 
695  //long lc_x = rRect.nLeft - mnOutOffX; // normalize
696  //lc_x = mnOutWidth - nWidth - 1 - lc_x; // mirror
697  //rRect.nLeft = lc_x + mnOutOffX; // re-normalize
698 
699  rRect.SetLeft( mnOutOffX + mnOutWidth - nWidth - 1 - rRect.Left() + mnOutOffX );
700  rRect.SetRight( rRect.Left() + nWidth );
701 }
702 
703 void OutputDevice::ReMirror( vcl::Region &rRegion ) const
704 {
705  RectangleVector aRectangles;
706  rRegion.GetRegionRectangles(aRectangles);
707  vcl::Region aMirroredRegion;
708 
709  for (auto & rectangle : aRectangles)
710  {
712  aMirroredRegion.Union(rectangle);
713  }
714 
715  rRegion = aMirroredRegion;
716 
717 }
718 
720 {
722 }
723 
725 {
726  if (!mpOutDevData)
727  return false;
728 
729  return mpOutDevData->mpRecordLayout;
730 }
731 
732 css::awt::DeviceInfo OutputDevice::GetCommonDeviceInfo(Size const& rDevSz) const
733 {
734  css::awt::DeviceInfo aInfo;
735 
736  aInfo.Width = rDevSz.Width();
737  aInfo.Height = rDevSz.Height();
738 
739  Size aTmpSz = LogicToPixel(Size(1000, 1000), MapMode(MapUnit::MapCM));
740  aInfo.PixelPerMeterX = aTmpSz.Width() / 10;
741  aInfo.PixelPerMeterY = aTmpSz.Height() / 10;
742  aInfo.BitsPerPixel = GetBitCount();
743 
744  aInfo.Capabilities = css::awt::DeviceCapability::RASTEROPERATIONS |
745  css::awt::DeviceCapability::GETBITS;
746 
747  return aInfo;
748 }
749 
750 css::awt::DeviceInfo OutputDevice::GetDeviceInfo() const
751 {
752  css::awt::DeviceInfo aInfo = GetCommonDeviceInfo(GetOutputSizePixel());
753 
754  aInfo.LeftInset = 0;
755  aInfo.TopInset = 0;
756  aInfo.RightInset = 0;
757  aInfo.BottomInset = 0;
758 
759  return aInfo;
760 }
761 
762 Reference< css::rendering::XCanvas > OutputDevice::GetCanvas() const
763 {
764  // try to retrieve hard reference from weak member
765  Reference< css::rendering::XCanvas > xCanvas( mxCanvas );
766  // canvas still valid? Then we're done.
767  if( xCanvas.is() )
768  return xCanvas;
769  xCanvas = ImplGetCanvas( false );
770  mxCanvas = xCanvas;
771  return xCanvas;
772 }
773 
774 Reference< css::rendering::XSpriteCanvas > OutputDevice::GetSpriteCanvas() const
775 {
776  Reference< css::rendering::XCanvas > xCanvas( mxCanvas );
777  Reference< css::rendering::XSpriteCanvas > xSpriteCanvas( xCanvas, UNO_QUERY );
778  if( xSpriteCanvas.is() )
779  return xSpriteCanvas;
780  xCanvas = ImplGetCanvas( true );
781  mxCanvas = xCanvas;
782  return Reference< css::rendering::XSpriteCanvas >( xCanvas, UNO_QUERY );
783 }
784 
785 // Generic implementation, Window will override.
787 {
788  /* Arguments:
789  0: ptr to creating instance (Window or VirtualDevice)
790  1: current bounds of creating instance
791  2: bool, denoting always on top state for Window (always false for VirtualDevice)
792  3: XWindow for creating Window (or empty for VirtualDevice)
793  4: SystemGraphicsData as a streamed Any
794  */
795  Sequence< Any > aArg{
796  Any(reinterpret_cast<sal_Int64>(this)),
797  Any(css::awt::Rectangle( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight )),
798  Any(false),
799  Any(Reference< css::awt::XWindow >()),
801  };
802 
804 
806  css::rendering::CanvasFactory::create( xContext ) );
807  Reference<css::lang::XMultiComponentFactory> xCanvasFactory(xStaticCanvasFactory.get());
808  Reference< css::rendering::XCanvas > xCanvas;
809 
810  if(xCanvasFactory.is())
811  {
812  xCanvas.set( xCanvasFactory->createInstanceWithArgumentsAndContext(
813  bSpriteCanvas ?
814  OUString( "com.sun.star.rendering.SpriteCanvas" ) :
815  OUString( "com.sun.star.rendering.Canvas" ),
816  aArg,
817  xContext ),
818  UNO_QUERY );
819  }
820 
821  // no factory??? Empty reference, then.
822  return xCanvas;
823 }
824 
826 {
827  css::uno::Reference< css::rendering::XCanvas > xCanvas( mxCanvas );
828  if( xCanvas.is() )
829  {
830  css::uno::Reference< css::lang::XComponent > xCanvasComponent( xCanvas, css::uno::UNO_QUERY );
831  if( xCanvasComponent.is() )
832  xCanvasComponent->dispose();
833  }
834 }
835 
836 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
void EnableOutput(bool bEnable=true)
Definition: outdev.cxx:343
sal_Int32 mnDPIScalePercentage
For HiDPI displays, we want to draw elements for a percentage larger.
Definition: outdev.hxx:220
Similar to DeleteOnDeinit, the DeleteUnoReferenceOnDeinit template class makes sure that a static UNO...
Definition: lazydelete.hxx:112
VclPtr< OutputDevice > mpNextGraphics
Next output device in list.
Definition: outdev.hxx:190
virtual OUString getRenderBackendName() const
virtual css::uno::Reference< css::rendering::XCanvas > ImplGetCanvas(bool bSpriteCanvas) const
Definition: outdev.cxx:786
tools::Long mnTextOffX
font specific text alignment offsets in pixel units
Definition: outdev.hxx:222
tools::Long mnOutOffLogicX
Additional output offset in logical coordinates, applied in PixelToLogic (used by SetPixelOffset/GetP...
Definition: outdev.hxx:207
SAL_DLLPRIVATE bool ImplIsRecordLayout() const
Definition: outdev.cxx:724
void SetAntialiasing(AntialiasingFlags nMode)
Definition: outdev.cxx:351
tools::Long mnOutOffOrigY
Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset) ...
Definition: outdev.hxx:209
AntialiasingFlags
OutputDevice(const OutputDevice &)=delete
bool mbOutput
Definition: outdev.hxx:250
virtual bool IsVirtual() const
Definition: outdev.cxx:187
Color maTextColor
Definition: outdev.hxx:235
bool SupportsCairo() const
virtual ~OutputDevice() override
Definition: outdev.cxx:141
constexpr tools::Long Left() const
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
Definition: bitmapex.cxx:33
virtual bool supportsOperation(OutDevSupportType) const =0
void Union(const tools::Rectangle &rRegion)
Definition: region.cxx:506
bool mbTextSpecial
Definition: outdev.hxx:263
DrawModeFlags mnDrawMode
Definition: outdev.hxx:226
void setTextRenderModeForResolutionIndependentLayout(bool bNew)
Definition: salgdi.hxx:99
long Long
constexpr::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
void disposeAndClear()
Definition: vclptr.hxx:200
BmpMirrorFlags AdjustTwoRect(SalTwoRect &rTwoRect, const Size &rSizePix)
Definition: rect.cxx:341
css::uno::Reference< I > get()
Definition: lazydelete.hxx:120
SAL_DLLPRIVATE void ImplDisposeCanvas()
Definition: outdev.cxx:825
bool mbOutputClipped
Definition: outdev.hxx:252
void CopyBits(const SalTwoRect &rPosAry, const OutputDevice &rOutDev)
tools::Long mnOutOffY
Output offset for device output in pixel (pseudo window offset within window system's frames) ...
Definition: outdev.hxx:215
cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr &rSurface) const
Create Surface from given cairo surface.
sal_Int32 mnDPIY
Definition: outdev.hxx:219
tools::Long mnSrcHeight
Definition: salgtype.hxx:43
std::vector< VCLXGraphics * > * mpUnoGraphicsList
Definition: outdev.hxx:196
std::shared_ptr< vcl::font::PhysicalFontCollection > mxFontCollection
Definition: outdev.hxx:268
tools::Long mnSrcWidth
Definition: salgtype.hxx:42
cairo::SurfaceSharedPtr CreateBitmapSurface(const BitmapSystemData &rData, const Size &rSize) const
Create Surface for given bitmap data.
sal_Int32 mnDPIX
Definition: outdev.hxx:218
virtual void SetSettings(const AllSettings &rSettings)
Definition: outdev.cxx:217
bool SupportsOperation(OutDevSupportType) const
Query an OutputDevice to see whether it supports a specific operation.
Definition: outdev.cxx:422
bool mbMap
Definition: outdev.hxx:247
std::vector< VCLXGraphics * > * CreateUnoGraphicsList()
Definition: outdev.cxx:414
virtual void DrawOutDevDirectProcess(const OutputDevice &rSrcDev, SalTwoRect &rPosAry, SalGraphics *pSrcGraphics)
Definition: outdev.cxx:641
tools::Long mnMapScDenomX
Scaling factor - denominator in X direction.
Definition: ImplMapRes.hxx:32
bool mbEnableRTL
Definition: outdev.hxx:265
tools::Long mnEmphasisDescent
Definition: outdev.hxx:225
tools::Long mnOutOffOrigX
Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset) ...
Definition: outdev.hxx:205
OutDevSupportType
Definition: vclenum.hxx:195
tools::Long mnDestWidth
Definition: salgtype.hxx:46
std::vector< tools::Rectangle > RectangleVector
Definition: region.hxx:34
void SetDrawMode(DrawModeFlags nDrawMode)
Definition: outdev.cxx:380
std::unique_ptr< vcl::font::PhysicalFontFaceCollection > mpFontFaceCollection
Definition: outdev.hxx:193
constexpr tools::Long Width() const
Color maOverlineColor
Definition: outdev.hxx:237
void SetOutOffYPixel(tools::Long nOutOffY)
Definition: outdev.cxx:403
SAL_DLLPRIVATE void ReMirror(Point &rPoint) const
Definition: outdev.cxx:687
virtual void ReleaseAllGraphics(OutputDevice *pOutDev)=0
SAL_DLLPRIVATE tools::Long ImplLogicXToDevicePixel(tools::Long nX) const
Convert a logical X coordinate to a device pixel's X coordinate.
Definition: map.cxx:306
sal_uInt32 nSize
Definition: sysdata.hxx:143
OutDevViewType meOutDevViewType
Definition: outdev.hxx:230
vcl::text::ComplexTextLayoutFlags mnTextLayoutMode
Definition: outdev.hxx:227
AntialiasingFlags mnAntialiasing
Definition: outdev.hxx:243
bool mbBackground
Definition: outdev.hxx:249
virtual Bitmap GetBitmap(const Point &rSrcPt, const Size &rSize) const
tools::Long mnMapScDenomY
Scaling factor - denominator in Y direction.
Definition: ImplMapRes.hxx:33
virtual void EnableRTL(bool bEnable=true)
Definition: outdev.cxx:663
bool mbClipRegionSet
Definition: outdev.hxx:260
SystemGraphicsData GetSystemGfxData() const
Definition: outdev.cxx:225
virtual void CopyDeviceArea(SalTwoRect &aPosAry, bool bWindowInvalidate)
Definition: outdev.cxx:595
void DrawRect(const tools::Rectangle &rRect)
Definition: rect.cxx:51
std::unique_ptr< AllSettings > mxSettings
Definition: outdev.hxx:240
constexpr void SetLeft(tools::Long v)
std::vector< vcl::State > maOutDevStateStack
Definition: outdev.hxx:194
SalGraphics * mpGraphics
Graphics context to draw on.
Definition: outdev.hxx:188
std::shared_ptr< Surface > SurfaceSharedPtr
Definition: cairo.hxx:36
virtual void CopyArea(const Point &rDestPt, const Point &rSrcPt, const Size &rSrcSize, bool bWindowInvalidate=false)
Definition: outdev.cxx:550
SAL_DLLPRIVATE void ImplInvalidateViewTransform()
Invalidate the view transformation.
Definition: map.cxx:226
tools::Long mnDestHeight
Definition: salgtype.hxx:47
void SetRefPoint()
Definition: outdev.cxx:297
void clear()
Definition: vclptr.hxx:190
void SetConnectMetaFile(GDIMetaFile *pMtf)
Definition: outdev.cxx:212
bool IsRTLEnabled() const
Definition: outdev.hxx:1284
virtual tools::Rectangle GetBackgroundComponentBounds() const
Definition: outdev.cxx:656
css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr &rSurface, const basegfx::B2ISize &rSize) const
Return native handle for underlying surface.
OutDevType
Definition: outdev.hxx:149
virtual void dispose() override
Definition: outdev.cxx:146
bool mbTextRenderModeForResolutionIndependentLayout
Definition: outdev.hxx:245
#define LANGUAGE_SYSTEM
virtual const OutputDevice * DrawOutDevDirectCheck(const OutputDevice &rSrcDev) const
Definition: outdev.cxx:636
virtual bool AcquireGraphics() const =0
Acquire a graphics device that the output device uses to draw on.
virtual void EnableRTL(bool bEnable=true) override
Definition: virdev.cxx:395
SAL_DLLPRIVATE bool ImplIsAntiparallel() const
Definition: outdev.cxx:671
virtual bool HasMirroredGraphics() const
Definition: outdev.cxx:719
bool mbInitLineColor
Definition: outdev.hxx:255
constexpr tools::Long Right() const
tools::Long mnOutHeight
Definition: outdev.hxx:217
bool mbNewFont
Definition: outdev.hxx:261
SAL_DLLPRIVATE void drawOutDevDirect(const OutputDevice &rSrcDev, SalTwoRect &rPosAry)
Definition: outdev.cxx:606
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:175
SAL_DLLPRIVATE tools::Long ImplLogicWidthToDevicePixel(tools::Long nWidth) const
Convert a logical width to a width in units of device pixels.
Definition: map.cxx:324
SAL_DLLPRIVATE void ImplFillOpaqueRectangle(const tools::Rectangle &rRect)
Used for alpha VDev, to set areas to opaque.
Definition: virdev.cxx:344
bool mbTextLines
Definition: outdev.hxx:262
static bool GetLayoutRTL()
css::uno::WeakReference< css::rendering::XCanvas > mxCanvas
Definition: outdev.hxx:199
bool mbLineColor
Definition: outdev.hxx:253
std::shared_ptr< cairo_surface_t > CairoSurfaceSharedPtr
Definition: cairo.hxx:34
constexpr void SetRight(tools::Long v)
tools::Long mnMapOfsX
Offset in X direction.
Definition: ImplMapRes.hxx:28
RasterOp meRasterOp
Definition: outdev.hxx:238
css::uno::Reference< css::rendering::XCanvas > GetCanvas() const
request XCanvas render interface
Definition: outdev.cxx:762
Size GetOutputSizePixel() const
Definition: outdev.hxx:321
bool mbInitTextColor
Definition: outdev.hxx:258
Base class used mainly for the LibreOffice Desktop class.
Definition: svapp.hxx:233
css::uno::Any GetSystemGfxDataAny() const
Definition: outdev.cxx:288
virtual SystemGraphicsData GetGraphicsData() const =0
void mirror(tools::Long &nX, const OutputDevice &rOutDev) const
virtual sal_uInt16 GetBitCount() const
Definition: outdev.cxx:388
RasterOp
Definition: RasterOp.hxx:22
tools::Long mnMapOfsY
Offset in Y direction.
Definition: ImplMapRes.hxx:29
tools::Long mnEmphasisAscent
Definition: outdev.hxx:224
tools::Long mnSrcX
Definition: salgtype.hxx:40
bool mbRefPoint
Definition: outdev.hxx:264
virtual void dispose()
std::vector< VCLXGraphics * > * GetUnoGraphicsList() const
Definition: outdev.hxx:339
virtual css::uno::Reference< css::awt::XGraphics > CreateGraphics(OutputDevice *pOutDev)=0
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:933
uno::Sequence< double > maFillColor
virtual void SetXORMode(bool bSet, bool bInvertOnly)=0
VclPtr< OutputDevice > mpPrevGraphics
Previous output device in list.
Definition: outdev.hxx:189
virtual sal_uInt16 GetBitCount() const =0
void setAntiAlias(bool bNew)
Definition: salgdi.hxx:85
bool mbFillColor
Definition: outdev.hxx:254
VclPtr< VirtualDevice > mpAlphaVDev
Definition: outdev.hxx:202
def rectangle(l)
ImplMapRes maMapRes
Definition: outdev.hxx:228
bool mbClipRegion
Definition: outdev.hxx:248
tools::Long mnMapScNumY
Scaling factor - numerator in Y direction.
Definition: ImplMapRes.hxx:31
css::awt::DeviceInfo GetCommonDeviceInfo(Size const &aDevSize) const
Definition: outdev.cxx:732
constexpr tools::Long Height() const
SalLayoutFlags GetLayout() const
Definition: salgdi.hxx:222
void AddAction(const rtl::Reference< MetaAction > &pAction)
Definition: gdimtf.cxx:581
tools::Rectangle GetOutputRectPixel() const
Definition: outdev.hxx:331
tools::Long mnMapScNumX
Scaling factor - numerator in X direction.
Definition: ImplMapRes.hxx:30
bool mbInitClipRegion
Definition: outdev.hxx:259
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
void GetRegionRectangles(RectangleVector &rTarget) const
Definition: region.cxx:1673
void SetRasterOp(RasterOp eRasterOp)
Definition: outdev.cxx:322
void SetOutOffXPixel(tools::Long nOutOffX)
Definition: outdev.cxx:398
SalGraphics const * GetGraphics() const
Get the graphic context that the output device uses to draw on.
Definition: outdev.cxx:202
css::uno::Reference< css::awt::XGraphics > CreateUnoGraphics()
Definition: outdev.cxx:408
virtual void InitClipRegion()
void SetTextRenderModeForResolutionIndependentLayout(bool bMode)
Definition: outdev.cxx:366
Reference< XComponentContext > getProcessComponentContext()
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
Sequence< sal_Int8 > aSeq
bool mbInitFont
Definition: outdev.hxx:257
RasterOp GetRasterOp() const
Definition: outdev.hxx:507
virtual void DrawOutDev(const Point &rDestPt, const Size &rDestSize, const Point &rSrcPt, const Size &rSrcSize)
Definition: outdev.cxx:433
rtl::Reference< LogicalFontInstance > mpFontInstance
Definition: outdev.hxx:192
bool mbInitFillColor
Definition: outdev.hxx:256
OUString GetRenderBackendName() const
Definition: outdev.cxx:234
tools::Long mnOutWidth
Definition: outdev.hxx:216
bool mbDevOutput
Definition: outdev.hxx:251
BitmapEx GetBitmapEx(const Point &rSrcPt, const Size &rSize) const
Query extended bitmap (with alpha channel, if available).
Definition: bitmapex.cxx:149
std::shared_ptr< ImplFontCache > mxFontCache
Definition: outdev.hxx:269
tools::Long mnOutOffX
Output offset for device output in pixel (pseudo window offset within window system's frames) ...
Definition: outdev.hxx:213
#define SAL_WARN(area, stream)
std::unique_ptr< ImplOutDevData > mpOutDevData
Definition: outdev.hxx:195
SAL_DLLPRIVATE tools::Long ImplLogicYToDevicePixel(tools::Long nY) const
Convert a logical Y coordinate to a device pixel's Y coordinate.
Definition: map.cxx:315
vcl::ExtOutDevData * mpExtOutDevData
Definition: outdev.hxx:197
#define DBG_TESTSOLARMUTEX()
static UnoWrapperBase * GetUnoWrapper(bool bCreateIfNotExists=true)
Get the application's UNO wrapper object.
Definition: svapp.cxx:1590
tools::Long mnOutOffLogicY
Additional output offset in logical coordinates, applied in PixelToLogic (used by SetPixelOffset/GetP...
Definition: outdev.hxx:211
css::uno::Reference< css::rendering::XSpriteCanvas > GetSpriteCanvas() const
request XSpriteCanvas render interface
Definition: outdev.cxx:774
bool IsDeviceOutputNecessary() const
Definition: outdev.hxx:488
Point maRefPoint
Definition: outdev.hxx:242
SAL_DLLPRIVATE tools::Long ImplLogicHeightToDevicePixel(tools::Long nHeight) const
Convert a logical height to a height in units of device pixels.
Definition: map.cxx:332
tools::Long mnTextOffY
Definition: outdev.hxx:223
DrawModeFlags
virtual css::awt::DeviceInfo GetDeviceInfo() const
Definition: outdev.cxx:750
GDIMetaFile * mpMetaFile
Definition: outdev.hxx:191
LanguageType meTextLanguage
Definition: outdev.hxx:244