mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-07 21:23:32 +00:00
api: revise the gl target() api.
API modification: - Result GlCanvas::target(int32_t id, uint32_t w, uint32_t h) -> Result GlCanvas::target(int32_t id, uint32_t w, uint32_t h, ColorSpace cs) - Tvg_Result tvg_glcanvas_set_target(Tvg_Canvas* canvas, int32_t id, uint32_t w, uint32_t h) -> Tvg_Result tvg_glcanvas_set_target(Tvg_Canvas* canvas, int32_t id, uint32_t w, uint32_t h, Tvg_Colorspace cs) issue: https://github.com/thorvg/thorvg/issues/1372
This commit is contained in:
parent
0b4f2a49fe
commit
96e8d3d7a2
6 changed files with 11 additions and 9 deletions
|
@ -344,7 +344,7 @@ struct GlWindow : Window
|
|||
void resize() override
|
||||
{
|
||||
//Set the canvas target and draw on it.
|
||||
verify(static_cast<tvg::GlCanvas*>(canvas)->target(0, width, height));
|
||||
verify(static_cast<tvg::GlCanvas*>(canvas)->target(0, width, height, tvg::ColorSpace::ABGR8888S));
|
||||
}
|
||||
|
||||
void refresh() override
|
||||
|
|
|
@ -218,7 +218,7 @@ void runGl()
|
|||
auto canvas = unique_ptr<tvg::GlCanvas>(tvg::GlCanvas::gen());
|
||||
|
||||
// Pass the framebuffer id to the GlCanvas
|
||||
tvgexam::verify(canvas->target(glFbo.fbo, SIZE, SIZE));
|
||||
tvgexam::verify(canvas->target(glFbo.fbo, SIZE, SIZE, tvg::ColorSpace::ABGR8888S));
|
||||
|
||||
content(canvas.get());
|
||||
if (tvgexam::verify(canvas->draw())) {
|
||||
|
|
|
@ -1732,6 +1732,7 @@ public:
|
|||
* @param[in] id The GL target ID, usually indicating the FBO ID. A value of @c 0 specifies the main surface.
|
||||
* @param[in] w The width (in pixels) of the raster image.
|
||||
* @param[in] h The height (in pixels) of the raster image.
|
||||
* @param[in] cs Specifies how the pixel values should be interpreted. Currently, it only allows @c ColorSpace::ABGR8888S as @c GL_RGBA8.
|
||||
*
|
||||
* @retval Result::InsufficientCondition if the canvas is performing rendering. Please ensure the canvas is synced.
|
||||
* @retval Result::NonSupport In case the gl engine is not supported.
|
||||
|
@ -1739,10 +1740,9 @@ public:
|
|||
* @see Canvas::viewport()
|
||||
* @see Canvas::sync()
|
||||
*
|
||||
* @note Currently, this only allows the GL_RGBA8 color space format.
|
||||
* @note Experimental API
|
||||
*/
|
||||
Result target(int32_t id, uint32_t w, uint32_t h) noexcept;
|
||||
Result target(int32_t id, uint32_t w, uint32_t h, ColorSpace cs) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Creates a new GlCanvas object.
|
||||
|
|
|
@ -522,15 +522,15 @@ TVG_API Tvg_Canvas* tvg_glcanvas_create(void);
|
|||
* \param[in] id The GL target ID, usually indicating the FBO ID. A value of @c 0 specifies the main surface.
|
||||
* \param[in] w The width (in pixels) of the raster image.
|
||||
* \param[in] h The height (in pixels) of the raster image.
|
||||
* \param[in] cs Specifies how the pixel values should be interpreted. Currently, it only allows @c TVG_COLORSPACE_ABGR8888S as @c GL_RGBA8.
|
||||
*
|
||||
* \return Tvg_Result enumeration.
|
||||
* \retval TVG_RESULT_INSUFFICIENT_CONDITION if the canvas is performing rendering. Please ensure the canvas is synced.
|
||||
* \retval TVG_RESULT_NOT_SUPPORTED In case the gl engine is not supported.
|
||||
*
|
||||
* \note Currently, this only allows the GL_RGBA8 color space format.
|
||||
* \note Experimental API
|
||||
*/
|
||||
TVG_API Tvg_Result tvg_glcanvas_set_target(Tvg_Canvas* canvas, int32_t id, uint32_t w, uint32_t h);
|
||||
TVG_API Tvg_Result tvg_glcanvas_set_target(Tvg_Canvas* canvas, int32_t id, uint32_t w, uint32_t h, Tvg_Colorspace cs);
|
||||
|
||||
/** \} */ // end defgroup ThorVGCapi_GlCanvas
|
||||
|
||||
|
|
|
@ -102,10 +102,10 @@ TVG_API Tvg_Result tvg_swcanvas_set_target(Tvg_Canvas* canvas, uint32_t* buffer,
|
|||
}
|
||||
|
||||
|
||||
TVG_API Tvg_Result tvg_glcanvas_set_target(Tvg_Canvas* canvas, int32_t id, uint32_t w, uint32_t h)
|
||||
TVG_API Tvg_Result tvg_glcanvas_set_target(Tvg_Canvas* canvas, int32_t id, uint32_t w, uint32_t h, Tvg_Colorspace cs)
|
||||
{
|
||||
if (!canvas) return TVG_RESULT_INVALID_ARGUMENT;
|
||||
return (Tvg_Result) reinterpret_cast<GlCanvas*>(canvas)->target(id, w, h);
|
||||
return (Tvg_Result) reinterpret_cast<GlCanvas*>(canvas)->target(id, w, h, static_cast<ColorSpace>(cs));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -59,9 +59,11 @@ GlCanvas::~GlCanvas()
|
|||
}
|
||||
|
||||
|
||||
Result GlCanvas::target(int32_t id, uint32_t w, uint32_t h) noexcept
|
||||
Result GlCanvas::target(int32_t id, uint32_t w, uint32_t h, ColorSpace cs) noexcept
|
||||
{
|
||||
#ifdef THORVG_GL_RASTER_SUPPORT
|
||||
if (cs != ColorSpace::ABGR8888S) return Result::NonSupport;
|
||||
|
||||
if (Canvas::pImpl->status != Status::Damaged && Canvas::pImpl->status != Status::Synced) {
|
||||
return Result::InsufficientCondition;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue