Presentation is loading. Please wait.

Presentation is loading. Please wait.

XPS Rasterization Service in Windows 7

Similar presentations


Presentation on theme: "XPS Rasterization Service in Windows 7"— Presentation transcript:

1

2 XPS Rasterization Service in Windows 7
Georgi Chalakov Senior Software Development Engineer Microsoft Corporation

3 Agenda XPSDrv Print Driver Architecture
XPS Rasterization Service (XPSRas) XPS Rasterizer Object Banding, Caches and Threads XPSRas API Q & A

4 XPSDrv Print Driver Architecture

5 XPSDrv Print Driver Architecture
WinHEC 2006 XPSDrv Print Driver Architecture Application Process GDI Print App XPS Print App Spooler Process Filter Pipeline Process Version 3 Driver Filter Pipeline Manager Config Module/ Plug-in Filter 1 XPS Spool file Conversion Render Module Filter 2 Property Bag FP Config XML Filter N Provided by: ISV IHV Microsoft © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

6 Filter Pipeline Manager
WinHEC 2006 Filter Pipeline Filter Pipeline Process Filter Pipeline Manager XPS Object Model Filter 1 Filter M FP Config XML Property Bag XPS Rasterization Service Filter N Provided by: ISV IHV Microsoft © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

7 XPS Rasterization Service

8 XPS Rasterization Service
In-box component in Windows 7 Converts XPS Object Model (XPSOM) to WIC images Simplifies the design of an XPSDrv filter High printing fidelity Fast rasterization - uses next generation 2D rasterizers in Windows 7 Access to the service is through Print Filter Pipeline only

9 XPS Rasterization Service
XPS Rasterization Service (XPSRas) Next Gen Rasterization Next Gen Font Management XPS Object Model (XPSOM) Windows Imaging Component (WIC) XPS OPC Service Windows Color Management System (WCMS)

10 XPS Rasterization Service
Filter N XPS OM WIC Image Cancel/Continue XPS Rasterization Service

11 XPS Rasterization Step by Step
Obtain XPS Rasterization Factory from the Property Bag. Create XPS Rasterization Object for an XPS OM Fixed Page. Rasterize a rectangle from the page. Rasterize next rectangle from the page Rasterize the last rectangle from the page. Release XPS Rasterization Object.

12 1. Obtaining the XPS Rasterization Factory
The Print Filter Pipeline Manager calls the filter and passes the property bag as an input parameter. The call sequence: The pipeline manager calls IPrintPipelineFilter::InitializeFilter The filter calls IPrintPipelinePropertyBag::GetProperty MS_IXpsRasterizationService The filter calls IUnknown::QueryInterface for IXpsRasterizationFactory

13 Code Sample IHV_CreateRasterizationFactory HRESULT
__in IPrintPipelinePropertyBag  *pPropertyBag, __out IXpsRasterizationFactory  **ppXPSRasFactory ) { HRESULT hr; // Retrieve the factory object from the property bag. VARIANT var; VariantInit(&var); hr = pPropertyBag->GetProperty( L"MS_IXpsRasterizationFactory“, &var ); //continued on the next slide

14 Code Sample IHV_CreateRasterizationFactory
//continued from the previous slide IXpsRasterizationFactory *pXPSRasFactory; if (SUCCEEDED(hr)) { // Get the factory object's IXpsRasterizationFactory interface. IUnknown *pUnknown = var.punkVal; hr = pUnknown->QueryInterface( __uuidof(IXpsRasterizationFactory), reinterpret_cast<void**>(&pXPSRasFactory) ); } // Give the caller our reference to the IXpsRasterizationFactory interface. *ppXPSRasFactory = pXPSRasFactory;¯ VariantClear(&var); return hr;

15 XPS Rasterization Object

16 2. Create XPS Rasterization Object
XPS Rasterization object is created with following parameters: XPS OM Fixed Page Rasterization DPI (dots per inch) Glyphs rendering mode – aliased/anti-aliased. Non glyphs rendering mode – aliased/anti-aliased. XPS Rasterization object is bound to the XPS OM Fixed Page and it cannot be reused across pages. XPS Rasterization can be called many times to rasterize axis-aligned rectangles from the page.

17 Code Sample IHV_CreateRasterizationObject HRESULT
__in IXpsRasterizationFactory  *pXPSRasFactory, __in IXpsOMPage *pXPSOMPage, __out IXpsRasterizer **ppXPSRasObject ) { HRESULT hr; hr =  pXPSRasFactory->CreateRasterizer( pXPSOMPage, // XPS OM Fixed Page 600.0f, // DPI XPSRAS_RENDERING_MODE_ALIASED, // non text rendering mode XPSRAS_RENDERING_MODE_ANTIALIASED, // text rendering mode &ppXPSRasObject // the rasterization object ); return hr; }

18 3. Rasterizing Axis-Aligned Rectangle
-x,-y Bleed Box XPS Rasterization object can be called many times to rasterize different axis-aligned rectangles from the page The rectangle is represented with integer numbers and it is in device coordinate space The content on the bleed box can be rasterized using a position outside the fixed page Bleed Box 0,0 Fixed Page width, height

19 3. Rasterizing Axis-Aligned Rectangle
The result is a new Windows Image Component (WIC) bitmap The image is initially cleared with white full transparent color clear color: R=1, G=1, B=1, A=0 The image format is GUID_WICPixelFormat32bppPBGRA Pre-multiplied alpha 32bpp - 8 red, 8 green, 8 blue, 8 alpha

20 Code Sample IHV_RasterizeRect HRESULT IHV_RasterizeRect(
IXpsRasterizer *pXPSRasObject, RECT const &rect, IWICBitmap **ppBitmap ) { HRESULT  hr; hr =  pXPSRasObject->RasterizeRect ( rect.left,, // x rect.top, // y rect.right-rect.left, // width rect.bottom-rect.top, // height NULL, // cancel interface &ppBitmap // result ); return hr; }

21 Rasterization Cancel Interface
interface IXpsRasterizerNotificationCallback : IUnknown { HRESULT Continue(); } It is called quite often. It is called from the same thread where RasterizeRect is called If the client returns a failure HRESULT, the rasterization is canceled and RasterizeRect returns the same HRESULT. After rasterization is canceled, the rasterization object is still valid.

22 Banding, Caches and Threads

23 Banding and Caches Banding is the main scenario and the service is optimized for calling RasterizeRect for a sequence of bands. Anything that doesn’t intersect with the requested axis-aligned rectangles is skipped early in the process of the rasterization. Any resource—font/image/brush—most likely will be cached for a while between rasterizing calls. First rasterization call is more expensive than the following rasterization calls on the same fixed page.

24 Rendering Transformations on the Fixed Page
Scaling is supported per page by providing a DPI Translation is supported per rasterizing call by positioning the rasterized rectangle. For an arbitrary transformation, the XPS object model can be modified before the rasterization object is created. Any transformation can be applied to the XPS OM page by wrapping the page in a canvas

25 Thread Safety Calling the same XPS Rasterization object concurrently from different threads is not supported. Rasterizing the same page from the different XPS Rasterization object is supported—you can create more than one object per XPS OM fixed page. Canceling is immediate. There is no synchronization and there is no separate thread. XPS Rasterization Service calls the cancel interface from the same thread that calls RasterizeRect.

26 XPS Rasterization API

27 XPS Rasterization API IXpsRasterizationFactory
interface IXpsRasterizationFactory : IUnknown { [helpstring("Create a new instance of IXpsRasterizer.")] HRESULT CreateRasterizer( [in] IXpsOMPage *xpsPage, [in] FLOAT DPI, [in] XPSRAS_RENDERING_MODE nonTextRenderingMode, [in] XPSRAS_RENDERING_MODE textRenderingMode, [out] IXpsRasterizer **ppIXPSRasterizer ); }

28 XPS Rasterization API IXpsRasterizer
interface IXpsRasterizer : IUnknown { [helpstring("Rasterize axis aligned rectangle to a WIC bitmap.")] HRESULT RasterizeRect( [in] INT x, [in] INT y, [in] INT width, [in] INT height, [in] IXpsRasterizerNotificationCallback *notificationCallback, [out]IWICBitmap **bitmap ); }

29 XPS Rasterization API IXpsRasterizerNotificationCallback
interface IXpsRasterizerNotificationCallback : IUnknown { [helpstring("Client callback function called during rasterization to allow client to cancel.")] HRESULT Continue(); }

30 Summary XPS Rasterization Service is Windows 7 in-box component.
The access to the XPS Rasterization Service is through Filter Pipeline Property bag therefore it is for filters from XPSDrv Filter Pipeline only. XPS Rasterization object is bound to an XPS Fixed Page and once it is created, the page must not be modified. Any content that intersects with an axis-aligned rectangle is rasterized to a 32bpp WIC bitmap. The service is optimized for banding. The rasterization object caches some of the resources for the next call. There is an optional Cancel interface for aborting the rasterization process.

31 Call To Action Look for the XPS Rasterization Filter sample in Windows 7 WDK A sample XPSDrv filter Conversion to XPSOM model Rasterizing the whole page as series of bands Read the white paper on WHDC XPSDrv Filter Pipeline

32 WHDC PowerPoint Template Notes & Handouts
Additional Resources Technical advice XPS Portal on Microsoft Web site: Links to relevant blogs, white papers, specifications XPS and Printing on the WHDC Web site: Printing—Architecture and Driver Support Printing documentation on MSDN XPS Printer Drivers in the WDK

33 Q&A


Download ppt "XPS Rasterization Service in Windows 7"

Similar presentations


Ads by Google