Anteckning
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Creates Direct2D resources.
Inheritance
The ID2D1Factory interface inherits from the IUnknown interface. ID2D1Factory also has these types of members:
Methods
The ID2D1Factory interface has these methods.
| ID2D1Factory::CreateDCRenderTarget  Creates a render target that draws to a Windows Graphics Device Interface (GDI) device context.  | 
| ID2D1Factory::CreateDrawingStateBlock  Creates an ID2D1DrawingStateBlock that can be used with the SaveDrawingState and RestoreDrawingState methods of a render target. (overload 1/3)  | 
| ID2D1Factory::CreateDrawingStateBlock  Creates an ID2D1DrawingStateBlock that can be used with the SaveDrawingState and RestoreDrawingState methods of a render target. (overload 2/3)  | 
| ID2D1Factory::CreateDrawingStateBlock  Creates an ID2D1DrawingStateBlock that can be used with the SaveDrawingState and RestoreDrawingState methods of a render target. (overload 3/3)  | 
| ID2D1Factory::CreateDxgiSurfaceRenderTarget  Creates a render target that draws to a DirectX Graphics Infrastructure (DXGI) surface. (overload 1/2)  | 
| ID2D1Factory::CreateDxgiSurfaceRenderTarget  Creates a render target that draws to a DirectX Graphics Infrastructure (DXGI) surface. (overload 2/2)  | 
| ID2D1Factory::CreateEllipseGeometry  Creates an ID2D1EllipseGeometry. (overload 2/2)  | 
| ID2D1Factory::CreateEllipseGeometry  Creates an ID2D1EllipseGeometry. (overload 1/2)  | 
| ID2D1Factory::CreateGeometryGroup  Creates an ID2D1GeometryGroup, which is an object that holds other geometries.  | 
| ID2D1Factory::CreateHwndRenderTarget  Creates an ID2D1HwndRenderTarget, a render target that renders to a window. (overload 2/2)  | 
| ID2D1Factory::CreateHwndRenderTarget  Creates an ID2D1HwndRenderTarget, a render target that renders to a window. (overload 1/2)  | 
| ID2D1Factory::CreatePathGeometry  Creates an empty ID2D1PathGeometry.  | 
| ID2D1Factory::CreateRectangleGeometry  Creates an ID2D1RectangleGeometry. (overload 2/2)  | 
| ID2D1Factory::CreateRectangleGeometry  Creates an ID2D1RectangleGeometry. (overload 1/2)  | 
| ID2D1Factory::CreateRoundedRectangleGeometry  Creates an ID2D1RoundedRectangleGeometry. (overload 2/2)  | 
| ID2D1Factory::CreateRoundedRectangleGeometry  Creates an ID2D1RoundedRectangleGeometry. (overload 1/2)  | 
| ID2D1Factory::CreateStrokeStyle  Creates an ID2D1StrokeStyle that describes start cap, dash pattern, and other features of a stroke. (overload 2/2)  | 
| ID2D1Factory::CreateStrokeStyle  Creates an ID2D1StrokeStyle that describes start cap, dash pattern, and other features of a stroke. (overload 1/2)  | 
| ID2D1Factory::CreateTransformedGeometry  Transforms the specified geometry and stores the result as an ID2D1TransformedGeometry object. (overload 2/2)  | 
| ID2D1Factory::CreateTransformedGeometry  Transforms the specified geometry and stores the result as an ID2D1TransformedGeometry object. (overload 1/2)  | 
| ID2D1Factory::CreateWicBitmapRenderTarget  Creates a render target that renders to a Microsoft Windows Imaging Component (WIC) bitmap. (overload 2/2)  | 
| ID2D1Factory::CreateWicBitmapRenderTarget  Creates a render target that renders to a Microsoft Windows Imaging Component (WIC) bitmap. (overload 1/2)  | 
| ID2D1Factory::GetDesktopDpi  Retrieves the current desktop dots per inch (DPI). To refresh this value, call ReloadSystemMetrics.  | 
| ID2D1Factory::ReloadSystemMetrics  Forces the factory to refresh any system defaults that it might have changed since factory creation.  | 
Remarks
The ID2D1Factory interface is the starting point for using Direct2D; it's what you use to create other Direct2D resources that you can use to draw or describe shapes.
A factory defines a set of CreateResource methods that can produce the following drawing resources:
- Render targets: objects that render drawing commands.
 - Drawing state blocks: objects that store drawing state information, such as the current transformation and antialiasing mode.
 - Geometries: objects that represent simple and potentially complex shapes.
 
To create an ID2D1Factory, you use one of the CreateFactory methods. You should retain the ID2D1Factory instance for as long as you use Direct2D resources; in general, you shouldn't need to recreate it when the application is running. For more information about Direct2D resources, see the Resources Overview.
Singlethreaded and Multithreaded Factories
When you create a factory, you can specify whether it is multithreaded or singlethreaded. A singlethreaded factory provides no serialization against any other single threaded instance within Direct2D, so, this mechanism provides a very large degree of scaling on the CPU.You can also create a multithreaded factory instance. In this case, the factory and all derived objects can be used from any thread and each render target can be rendered to independently. Direct2D serializes calls to these objects, so a single multithreaded Direct2D instance won't scale as well on the CPU as many single threaded instances. However, the resources can be shared within the multithreaded instance.
Note that the qualifier "On the CPU": GPUs generally take advantage of fine-grained parallelism more so than CPUs. For example, multithreaded calls from the CPU might still end up being serialized when being sent to the GPU, however, a whole bank of pixel and vertex shaders will run in parallel to perform the rendering.
See Multithreaded Direct2D Apps for more info.
Examples
The following code fragments declare a factory pointer, create a singlethreaded factory instance, and use the factory to create a render target.
ID2D1Factory* m_pDirect2dFactory;
    // Create a Direct2D factory.
    hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &m_pDirect2dFactory);
        // Create a Direct2D render target.
        hr = m_pDirect2dFactory->CreateHwndRenderTarget(
            D2D1::RenderTargetProperties(),
            D2D1::HwndRenderTargetProperties(m_hwnd, size),
            &m_pRenderTarget
            );
Requirements
| Requirement | Value | 
|---|---|
| Minimum supported client | Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | UWP apps] | 
| Minimum supported server | Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | UWP apps] | 
| Target Platform | Windows | 
| Header | d2d1.h |