LibreOffice Module drawinglayer (master) 1
processor2dtools.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 */
20#include <vcl/gdimtf.hxx>
21#include <vcl/sysdata.hxx>
24#include <config_vclplug.h>
25
26#if defined(_WIN32)
28#elif USE_HEADLESS_CODE
30#endif
31
32using namespace com::sun::star;
33
35{
36std::unique_ptr<BaseProcessor2D> createPixelProcessor2DFromOutputDevice(
37 OutputDevice& rTargetOutDev,
38 const drawinglayer::geometry::ViewInformation2D& rViewInformation2D)
39{
40 static const bool bTestSystemPrimitiveRenderer(nullptr != std::getenv("TEST_SYSTEM_PRIMITIVE_RENDERER"));
41 if(bTestSystemPrimitiveRenderer)
42 {
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())
46 {
47 basegfx::B2DHomMatrix aTransform(aViewInformation2D.getViewTransformation());
48 aTransform.translate(rTargetOutDev.GetOutOffXPixel(), rTargetOutDev.GetOutOffYPixel());
49 aViewInformation2D.setViewTransformation(aTransform);
50 }
51#if defined(_WIN32)
53 std::unique_ptr<D2DPixelProcessor2D> aRetval(
54 std::make_unique<D2DPixelProcessor2D>(aViewInformation2D, aData.hDC));
55 if (aRetval->valid())
56 return aRetval;
57#elif USE_HEADLESS_CODE
59 std::unique_ptr<CairoPixelProcessor2D> aRetval(
60 std::make_unique<CairoPixelProcessor2D>(aViewInformation2D, static_cast<cairo_surface_t*>(aData.pSurface)));
61 if (aRetval->valid())
62 return aRetval;
63#endif
64 }
65
66 // create Pixel Vcl-Processor
67 return std::make_unique<VclPixelProcessor2D>(rViewInformation2D, rTargetOutDev);
68}
69
70std::unique_ptr<BaseProcessor2D> createProcessor2DFromOutputDevice(
71 OutputDevice& rTargetOutDev,
72 const drawinglayer::geometry::ViewInformation2D& rViewInformation2D)
73{
74 const GDIMetaFile* pMetaFile = rTargetOutDev.GetConnectMetaFile();
75 const bool bOutputToRecordingMetaFile(pMetaFile && pMetaFile->IsRecord()
76 && !pMetaFile->IsPause());
77
78 if (bOutputToRecordingMetaFile)
79 {
80 // create MetaFile Vcl-Processor and process
81 return std::make_unique<VclMetafileProcessor2D>(rViewInformation2D, rTargetOutDev);
82 }
83 else
84 {
85 // create Pixel Vcl-Processor
86 return createPixelProcessor2DFromOutputDevice(rTargetOutDev, rViewInformation2D);
87 }
88}
89
90} // end of namespace
91
92/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _cairo_surface cairo_surface_t
bool IsPause() const
bool IsRecord() const
GDIMetaFile * GetConnectMetaFile() const
tools::Long GetOutOffYPixel() const
SystemGraphicsData GetSystemGfxData() const
tools::Long GetOutOffXPixel() const
void translate(double fX, double fY)
void setViewTransformation(const basegfx::B2DHomMatrix &rNew)
const basegfx::B2DHomMatrix & getViewTransformation() const
constexpr OUStringLiteral aData
std::unique_ptr< BaseProcessor2D > createProcessor2DFromOutputDevice(OutputDevice &rTargetOutDev, const drawinglayer::geometry::ViewInformation2D &rViewInformation2D)
create a BaseProcessor2D dependent on some states of the given OutputDevice.
std::unique_ptr< BaseProcessor2D > createPixelProcessor2DFromOutputDevice(OutputDevice &rTargetOutDev, const drawinglayer::geometry::ViewInformation2D &rViewInformation2D)
create the best available pixel based BaseProcessor2D (which may be system-dependent)