1 / 33

XPS Rasterization Service in Windows 7

XPS Rasterization Service in Windows 7. Georgi Chalakov Senior Software Development Engineer Microsoft Corporation georgi.chalakov@microsoft.com. Agenda. XPSDrv Print Driver Architecture XPS Rasterization Service ( XPSRas ) XPS Rasterizer Object Banding, Caches and Threads

bernad
Download Presentation

XPS Rasterization Service in Windows 7

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XPS Rasterization Service in Windows 7 Georgi Chalakov Senior Software Development Engineer Microsoft Corporation georgi.chalakov@microsoft.com

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

  3. XPSDrv Print Driver Architecture

  4. XPSDrv Print Driver Architecture Providedby: IHV ISV Microsoft Application Process GDI PrintApp XPS Print App Spooler Process Filter Pipeline Process Version 3 Driver Filter PipelineManager Config Module/Plug-in Filter 1 XPS Spool file ConversionRender Module Filter 2 PropertyBag FP ConfigXML Filter N

  5. Filter Pipeline Providedby: IHV ISV Microsoft Filter Pipeline Process Filter PipelineManager XPS Object Model Filter 1 Filter M FPConfigXML PropertyBag XPS Rasterization Service Filter N

  6. XPS Rasterization Service

  7. 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

  8. 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)

  9. XPS Rasterization Service Filter N XPS OM WIC Image Cancel/Continue XPS Rasterization Service

  10. 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.

  11. 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

  12. Code Sample HRESULT  IHV_CreateRasterizationFactory( __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 • IHV_CreateRasterizationFactory

  13. Code Sample //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) ); } if (SUCCEEDED(hr)) { // Give the caller our reference to the IXpsRasterizationFactory interface. *ppXPSRasFactory = pXPSRasFactory;¯ } VariantClear(&var); return hr; } • IHV_CreateRasterizationFactory

  14. XPS Rasterization Object

  15. 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.

  16. Code Sample HRESULT  IHV_CreateRasterizationObject ( __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; } • IHV_CreateRasterizationObject

  17. 3. Rasterizing Axis-Aligned Rectangle -x,-y Bleed Box • XPS Rasterization object can be called many times to rasterizedifferent 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 berasterized using a position outside the fixed page Bleed Box 0,0 Fixed Page width, height

  18. 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

  19. Code Sample 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; } • IHV_RasterizeRect

  20. 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.

  21. Banding, Caches and Threads

  22. 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.

  23. 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

  24. 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.

  25. XPS Rasterization API

  26. XPS Rasterization API 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 ); } • IXpsRasterizationFactory

  27. XPS Rasterization API 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 ); } • IXpsRasterizer

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

  29. 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.

  30. 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 Pipelinehttp://www.microsoft.com/whdc/device/print/XPSDrv_FilterPipe.mspx

  31. Additional Resources • Technical advice • XPSinfo@microsoft.com • XPS Portal on Microsoft Web site: http://www.microsoft.com/xps • Links to relevant blogs, white papers, specifications • XPS and Printing on the WHDC Web site: • Printing—Architecture and Driver Support • http://www.microsoft.com/whdc/device/print/default.mspx • Printing documentation on MSDN • XPS Printer Drivers in the WDKhttp://msdn.microsoft.com/en-us/library/aa907458.aspx

  32. Q&A

More Related