1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #include <drawinglayer/processor2d/processor2dtools.hxx>
20 #include <vcl/gdimtf.hxx>
21 #include <vcl/sysdata.hxx>
22 #include "vclpixelprocessor2d.hxx"
23 #include "vclmetafileprocessor2d.hxx"
24 #include <config_vclplug.h>
27 #include <drawinglayer/processor2d/d2dpixelprocessor2d.hxx>
28 #elif USE_HEADLESS_CODE
29 #include <drawinglayer/processor2d/cairopixelprocessor2d.hxx>
32 using namespace com::sun::star
;
34 namespace drawinglayer::processor2d
36 std::unique_ptr
<BaseProcessor2D
> createPixelProcessor2DFromOutputDevice(
37 OutputDevice
& rTargetOutDev
,
38 const drawinglayer::geometry::ViewInformation2D
& rViewInformation2D
)
40 static const bool bTestSystemPrimitiveRenderer(nullptr != std::getenv("TEST_SYSTEM_PRIMITIVE_RENDERER"));
41 if(bTestSystemPrimitiveRenderer
)
43 drawinglayer::geometry::ViewInformation2D
aViewInformation2D(rViewInformation2D
);
44 // if mnOutOffX/mnOutOffY is set (a 'hack' to get a cheap additional offset), apply it additionally
45 if(0 != rTargetOutDev
.GetOutOffXPixel() || 0 != rTargetOutDev
.GetOutOffYPixel())
47 basegfx::B2DHomMatrix
aTransform(aViewInformation2D
.getViewTransformation());
48 aTransform
.translate(rTargetOutDev
.GetOutOffXPixel(), rTargetOutDev
.GetOutOffYPixel());
49 aViewInformation2D
.setViewTransformation(aTransform
);
52 SystemGraphicsData
aData(rTargetOutDev
.GetSystemGfxData());
53 std::unique_ptr
<D2DPixelProcessor2D
> aRetval(
54 std::make_unique
<D2DPixelProcessor2D
>(aViewInformation2D
, aData
.hDC
));
57 #elif USE_HEADLESS_CODE
58 SystemGraphicsData
aData(rTargetOutDev
.GetSystemGfxData());
59 std::unique_ptr
<CairoPixelProcessor2D
> aRetval(
60 std::make_unique
<CairoPixelProcessor2D
>(aViewInformation2D
, static_cast<cairo_surface_t
*>(aData
.pSurface
)));
66 // create Pixel Vcl-Processor
67 return std::make_unique
<VclPixelProcessor2D
>(rViewInformation2D
, rTargetOutDev
);
70 std::unique_ptr
<BaseProcessor2D
> createProcessor2DFromOutputDevice(
71 OutputDevice
& rTargetOutDev
,
72 const drawinglayer::geometry::ViewInformation2D
& rViewInformation2D
)
74 const GDIMetaFile
* pMetaFile
= rTargetOutDev
.GetConnectMetaFile();
75 const bool bOutputToRecordingMetaFile(pMetaFile
&& pMetaFile
->IsRecord()
76 && !pMetaFile
->IsPause());
78 if (bOutputToRecordingMetaFile
)
80 // create MetaFile Vcl-Processor and process
81 return std::make_unique
<VclMetafileProcessor2D
>(rViewInformation2D
, rTargetOutDev
);
85 // create Pixel Vcl-Processor
86 return createPixelProcessor2DFromOutputDevice(rTargetOutDev
, rViewInformation2D
);
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */