Struct piet_direct2d::d2d::DeviceContext
source · pub struct DeviceContext(_);
Expand description
The main context that takes drawing operations.
This type is a thin wrapper for ID2D1DeviceContext.
This struct is public only to use for system integration in piet_common and druid-shell. It is not intended that end-users directly use this struct.
Implementations§
source§impl DeviceContext
impl DeviceContext
sourcepub unsafe fn new(ptr: ComPtr<ID2D1DeviceContext>) -> DeviceContext
pub unsafe fn new(ptr: ComPtr<ID2D1DeviceContext>) -> DeviceContext
Create a new device context from an existing COM object.
Marked as unsafe because the device must be in a good state. This might be overly conservative.
Safety
TODO
sourcepub fn get_raw(&self) -> *mut ID2D1DeviceContext
pub fn get_raw(&self) -> *mut ID2D1DeviceContext
Get the raw pointer
sourcepub fn get_comptr(&self) -> &ComPtr<ID2D1DeviceContext>
pub fn get_comptr(&self) -> &ComPtr<ID2D1DeviceContext>
Get the Com ptr
TODO rename to inner
, like for D3D11Device?
sourcepub unsafe fn create_bitmap_from_dxgi(
&self,
dxgi: &ComPtr<IDXGISurface>,
dpi_scale: f32
) -> Result<Bitmap, Error>
pub unsafe fn create_bitmap_from_dxgi(
&self,
dxgi: &ComPtr<IDXGISurface>,
dpi_scale: f32
) -> Result<Bitmap, Error>
Create a bitmap from a DXGI surface.
Most often, this bitmap will be used to set the target of a DeviceContext.
Assumes RGBA8 format and premultiplied alpha.
The unsafe
might be conservative, but we assume the dxgi
argument is in good shape to be a target.
Safety
TODO
sourcepub fn set_target(&mut self, target: &Bitmap)
pub fn set_target(&mut self, target: &Bitmap)
Set the target for the device context.
Useful for rendering into bitmaps.
sourcepub fn set_dpi_scale(&mut self, dpi_scale: f32)
pub fn set_dpi_scale(&mut self, dpi_scale: f32)
Set the dpi scale.
Mostly useful when rendering into bitmaps.
pub fn get_dpi_scale(&self) -> (f32, f32)
sourcepub fn begin_draw(&mut self)
pub fn begin_draw(&mut self)
Begin drawing.
This must be done before any piet drawing operations.
There may be safety concerns (not clear what happens if the sequence is not followed).
Trait Implementations§
source§impl Clone for DeviceContext
impl Clone for DeviceContext
source§fn clone(&self) -> DeviceContext
fn clone(&self) -> DeviceContext
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more