Abstraction for rendering into an RImage.
More...
#include <RSurface.h>
|
| std::shared_ptr< RPass > | beginPass (CZBitset< RPassCap > caps=RPassCap_Painter|RPassCap_SkCanvas, RDevice *device=nullptr) const noexcept |
| | Begins a rendering pass.
|
| |
| std::shared_ptr< RImage > | image () const noexcept |
| | Returns the backing image used by the surface.
|
| |
| bool | setGeometry (const RSurfaceGeometry &geometry) noexcept |
| | Updates the viewport -> (transform) -> dst mapping.
|
| |
| const RSurfaceGeometry & | geometry () const noexcept |
| | Returns the current viewport -> (transform) -> dst mapping.
|
| |
| bool | resize (SkISize size, SkScalar scale, bool shrink=false) noexcept |
| | Resizes the surface and optionally shrinks the backing image to fit the new destination size.
|
| |
| | ~RSurface () noexcept |
| | Destructor.
|
| |
| | RObject ()=default |
| | Constructs a default RObject.
|
| |
|
| static std::shared_ptr< RSurface > | Make (SkISize size, SkScalar scale, bool alpha) noexcept |
| | Creates a new surface with an internal image.
|
| |
| static std::shared_ptr< RSurface > | WrapImage (std::shared_ptr< RImage > image) noexcept |
| | Creates a surface from an existing RImage.
|
| |
Abstraction for rendering into an RImage.
RSurface wraps an RImage and provides convenience APIs to render using either RPainter or Skia SkCanvas. It maintains a virtual viewport and pixel destination rectangle to control coordinate mapping.
◆ ~RSurface()
◆ Make()
| static std::shared_ptr< RSurface > Make |
( |
SkISize |
size, |
|
|
SkScalar |
scale, |
|
|
bool |
alpha |
|
) |
| |
|
staticnoexcept |
Creates a new surface with an internal image.
The created image will have at least the following caps for the main device:
- RImageCap_Src
- RImageCap_Dst
- RImageCap_SkImage
- RImageCap_SkSurface
- Parameters
-
| size | Viewport size (unscaled). |
| scale | Scale factor. |
| alpha | Whether the RImage format has alpha. |
- Returns
- A shared pointer to the new RSurface, or nullptr on failure.
- Note
- If additional caps are needed, create an RImage manually and use WrapImage().
◆ WrapImage()
| static std::shared_ptr< RSurface > WrapImage |
( |
std::shared_ptr< RImage > |
image | ) |
|
|
staticnoexcept |
Creates a surface from an existing RImage.
Wraps an existing image without copying it.
- Note
- The alphaType() of the backing storage/destination image is ignored and always considered premultiplied alpha.
- Parameters
-
| image | An existing image with suitable caps. |
- Returns
- A new surface wrapping the image, or nullptr on failure.
◆ beginPass()
| std::shared_ptr< RPass > beginPass |
( |
CZBitset< RPassCap > |
caps = RPassCap_Painter|RPassCap_SkCanvas, |
|
|
RDevice * |
device = nullptr |
|
) |
| const |
|
noexcept |
Begins a rendering pass.
- Parameters
-
| device | Optional device to use. If nullptr, the main device is used. |
- Returns
- A valid RPass object on success, or an invalid RPass on failure.
◆ image()
| std::shared_ptr< RImage > image |
( |
| ) |
const |
|
inlinenoexcept |
Returns the backing image used by the surface.
- Returns
- Shared pointer to the underlying RImage. Always valid.
◆ setGeometry()
Updates the viewport -> (transform) -> dst mapping.
Unlike resize(), it never allocates a new image, even if the destination exceeds image bounds.
- Parameters
-
| viewport | Portion of the world to capture. |
| dst | Pixel area within the image to render into. |
| transform | Optional transform to apply (defaults to CZTransform::Normal). |
- Returns
- true if geometry was successfully set, false if invalid.
◆ geometry()
Returns the current viewport -> (transform) -> dst mapping.
◆ resize()
| bool resize |
( |
SkISize |
size, |
|
|
SkScalar |
scale, |
|
|
bool |
shrink = false |
|
) |
| |
|
noexcept |
Resizes the surface and optionally shrinks the backing image to fit the new destination size.
- Parameters
-
| size | Unscaled image size (viewport size). |
| scale | Scale factor. |
| shrink | If true, a new image will be allocated if the new dst size is different than the current image. If false, the existing image is reused as long as it is large enough. |
- Returns
- true if a new image was allocated, false if the current image was reused.