summaryrefslogtreecommitdiff
path: root/print/XpsRasFilter/src/rasinterface.h
blob: 3fae74cfbedc408a38cdb489270273bdbe125177 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved
//
// File Name:
//
//    rasinterface.h
//
// Abstract:
//
//    Class to wrap rasterization-related calculations, interactions with
//    the Xps Rasterization Service, Xps Rasterization Service Callback,
//    and eventual raster output (i.e. TIFF encoding)
//

#pragma once

namespace xpsrasfilter
{

class RasterizationInterface
{
public:
    static
    RasterizationInterface_t
    CreateRasterizationInterface(
        const IPrintPipelinePropertyBag_t &pPropertyBag,
        const IPrintWriteStream_t &pStream
        );

    RasterizationInterface();

    void
    RasterizePage(
        const IXpsOMPage_t              &pPage,
        const ParametersFromPrintTicket &printTicketParams,
        const FilterLiveness_t          &pLiveness
        );

    void
    CancelRasterization();

    void
    FinishRasterization();

    //
    // Target band size; 16MB
    //
    const static LONG ms_targetBandSize = 1024 * 1024 * 16;

private:

    //
    // Constructor is private; use CreateRasterizationInterface
    // to create instances
    //
    RasterizationInterface(
        const IXpsRasterizationFactory_t    &pRasFactory,
        TiffStreamBitmapHandler_t           pBitmapHandler
        );

    //
    // prevent copy semantics
    //
    RasterizationInterface(const RasterizationInterface&);
    RasterizationInterface& operator=(const RasterizationInterface&);

    //
    // Internal data members
    //

    //
    // Xps Rasterization Service Factory
    //
    IXpsRasterizationFactory_t m_pXPSRasFactory;

    //
    // Bitmap Handler
    //
    TiffStreamBitmapHandler_t m_pBitmapHandler;
};

//
// Parameters that determine how a page is rasterized, in the
// units that the Rasterization Service expects
//
struct RasterizationParameters
{
    FLOAT       rasterizationDPI;       // dpi (scaling factor)
    INT         rasterHeight;           // total size of raster
    INT         rasterWidth;
    INT         originX;                // origin of the rasterization (translation)
    INT         originY;
    INT         bandHeight;             // height of individual bands

    RasterizationParameters(
        const ParametersFromPrintTicket &printTicketParams,
        const ParametersFromFixedPage   &fixedPageParams
        );
};

const FLOAT xpsDPI = 96.0f;

} // namespace xpsrasfilter