From 5d10e514d7c528efe2f02a41f3f4686a6a5542c4 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Wed, 13 Mar 2024 00:29:29 +0900 Subject: [PATCH] renderer/gl_engine: Refine GlCanvas Interface Refactor the GlCanvas::target() interface to allow passing the drawing target ID from the user side. Previously, it performed the drawing on the currently set FBO target. Beta API change: Result GlCanvas::target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h) -> Result GlCanvas::target(int32_t id, uint32_t w, uint32_t h) --- inc/thorvg.h | 18 +++++++++++++----- src/examples/Accessor.cpp | 10 +++++++--- src/examples/AnimateMasking.cpp | 10 +++++++--- src/examples/Animation.cpp | 10 +++++++--- src/examples/Arc.cpp | 10 +++++++--- src/examples/Blending.cpp | 10 +++++++--- src/examples/ClipPath.cpp | 10 +++++++--- src/examples/CustomTransform.cpp | 10 +++++++--- src/examples/DataLoad.cpp | 10 +++++++--- src/examples/DirectUpdate.cpp | 10 +++++++--- src/examples/Duplicate.cpp | 10 +++++++--- src/examples/FillRule.cpp | 10 +++++++--- src/examples/GradientMasking.cpp | 10 +++++++--- src/examples/GradientStroke.cpp | 10 +++++++--- src/examples/GradientTransform.cpp | 10 +++++++--- src/examples/ImageScaleDown.cpp | 10 +++++++--- src/examples/ImageScaleUp.cpp | 10 +++++++--- src/examples/InvLumaMasking.cpp | 10 +++++++--- src/examples/InvMasking.cpp | 10 +++++++--- src/examples/LinearGradient.cpp | 10 +++++++--- src/examples/Lottie.cpp | 10 +++++++--- src/examples/LottieExtension.cpp | 10 +++++++--- src/examples/LumaMasking.cpp | 10 +++++++--- src/examples/Masking.cpp | 10 +++++++--- src/examples/MaskingMethods.cpp | 10 +++++++--- src/examples/MultiCanvas.cpp | 10 +++++++--- src/examples/MultiShapes.cpp | 10 +++++++--- src/examples/Opacity.cpp | 10 +++++++--- src/examples/Path.cpp | 10 +++++++--- src/examples/PathCopy.cpp | 10 +++++++--- src/examples/Performance.cpp | 10 +++++++--- src/examples/PictureJpg.cpp | 10 +++++++--- src/examples/PicturePng.cpp | 10 +++++++--- src/examples/PictureRaw.cpp | 10 +++++++--- src/examples/PictureSvg.cpp | 10 +++++++--- src/examples/PictureTvg.cpp | 10 +++++++--- src/examples/PictureWebp.cpp | 10 +++++++--- src/examples/RadialGradient.cpp | 10 +++++++--- src/examples/Retaining.cpp | 10 +++++++--- src/examples/Scene.cpp | 10 +++++++--- src/examples/SceneBlending.cpp | 10 +++++++--- src/examples/SceneClipper.cpp | 10 +++++++--- src/examples/SceneTransform.cpp | 10 +++++++--- src/examples/Shape.cpp | 10 +++++++--- src/examples/Stroke.cpp | 10 +++++++--- src/examples/StrokeLine.cpp | 10 +++++++--- src/examples/StrokeMiterlimit.cpp | 10 +++++++--- src/examples/Svg.cpp | 10 +++++++--- src/examples/Texmap.cpp | 10 +++++++--- src/examples/Text.cpp | 10 +++++++--- src/examples/Transform.cpp | 10 +++++++--- src/examples/Tvg.cpp | 10 +++++++--- src/examples/Update.cpp | 10 +++++++--- src/renderer/gl_engine/tvgGlRenderer.cpp | 9 +++------ src/renderer/gl_engine/tvgGlRenderer.h | 2 +- src/renderer/tvgGlCanvas.cpp | 4 ++-- 56 files changed, 383 insertions(+), 170 deletions(-) diff --git a/inc/thorvg.h b/inc/thorvg.h index d4fa5c87..8e5a7d89 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -1645,7 +1645,7 @@ public: }; /** - * @brief Sets the target buffer for the rasterization. + * @brief Sets the drawing target for the rasterization. * * The buffer of a desirable size should be allocated and owned by the caller. * @@ -1714,13 +1714,21 @@ public: ~GlCanvas(); /** - * @brief Sets the target buffer for the rasterization. + * @brief Sets the drawing target for rasterization. * - * @warning Please do not use it, this API is not official one. It could be modified in the next version. + * This function specifies the drawing target where the rasterization will occur. It can target + * a specific framebuffer object (FBO) or the main surface. * + * @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. + * + * @warning This API is experimental and not officially supported. It may be modified or removed in future versions. + * + * @note Currently, this only allows the GL_RGBA8 color space format. * @note Experimental API - */ - Result target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h) noexcept; + */ + Result target(int32_t id, uint32_t w, uint32_t h) noexcept; /** * @brief Creates a new GlCanvas object. diff --git a/src/examples/Accessor.cpp b/src/examples/Accessor.cpp index d90f3972..4ffaf279 100644 --- a/src/examples/Accessor.cpp +++ b/src/examples/Accessor.cpp @@ -97,11 +97,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/AnimateMasking.cpp b/src/examples/AnimateMasking.cpp index c97519cd..5e7b6721 100644 --- a/src/examples/AnimateMasking.cpp +++ b/src/examples/AnimateMasking.cpp @@ -133,11 +133,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/Animation.cpp b/src/examples/Animation.cpp index c5f67be5..4b4ca8a6 100644 --- a/src/examples/Animation.cpp +++ b/src/examples/Animation.cpp @@ -130,11 +130,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); tvgDrawCmds(glCanvas.get()); } diff --git a/src/examples/Arc.cpp b/src/examples/Arc.cpp index a7d2ea21..c4c8468d 100644 --- a/src/examples/Arc.cpp +++ b/src/examples/Arc.cpp @@ -126,11 +126,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/Blending.cpp b/src/examples/Blending.cpp index d3918224..a3831d02 100644 --- a/src/examples/Blending.cpp +++ b/src/examples/Blending.cpp @@ -207,11 +207,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/ClipPath.cpp b/src/examples/ClipPath.cpp index f8a77178..53ff5bc7 100644 --- a/src/examples/ClipPath.cpp +++ b/src/examples/ClipPath.cpp @@ -188,11 +188,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/CustomTransform.cpp b/src/examples/CustomTransform.cpp index 07253649..da3f82b2 100644 --- a/src/examples/CustomTransform.cpp +++ b/src/examples/CustomTransform.cpp @@ -135,11 +135,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/DataLoad.cpp b/src/examples/DataLoad.cpp index 4fd02ab9..2666ef17 100644 --- a/src/examples/DataLoad.cpp +++ b/src/examples/DataLoad.cpp @@ -84,11 +84,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/DirectUpdate.cpp b/src/examples/DirectUpdate.cpp index 0dca0fb3..a456e4b0 100644 --- a/src/examples/DirectUpdate.cpp +++ b/src/examples/DirectUpdate.cpp @@ -127,11 +127,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/Duplicate.cpp b/src/examples/Duplicate.cpp index b2387e80..27d01c93 100644 --- a/src/examples/Duplicate.cpp +++ b/src/examples/Duplicate.cpp @@ -191,11 +191,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/FillRule.cpp b/src/examples/FillRule.cpp index 61a8d691..16f850ef 100644 --- a/src/examples/FillRule.cpp +++ b/src/examples/FillRule.cpp @@ -92,11 +92,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/GradientMasking.cpp b/src/examples/GradientMasking.cpp index cbd0829c..cc084e77 100644 --- a/src/examples/GradientMasking.cpp +++ b/src/examples/GradientMasking.cpp @@ -175,11 +175,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/GradientStroke.cpp b/src/examples/GradientStroke.cpp index 8ae709f8..c8ef435e 100644 --- a/src/examples/GradientStroke.cpp +++ b/src/examples/GradientStroke.cpp @@ -159,11 +159,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/GradientTransform.cpp b/src/examples/GradientTransform.cpp index 076a121b..0d7e7bfc 100644 --- a/src/examples/GradientTransform.cpp +++ b/src/examples/GradientTransform.cpp @@ -156,11 +156,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/ImageScaleDown.cpp b/src/examples/ImageScaleDown.cpp index 8c98a779..ca157b95 100644 --- a/src/examples/ImageScaleDown.cpp +++ b/src/examples/ImageScaleDown.cpp @@ -100,11 +100,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/ImageScaleUp.cpp b/src/examples/ImageScaleUp.cpp index 468d0480..63e50c32 100644 --- a/src/examples/ImageScaleUp.cpp +++ b/src/examples/ImageScaleUp.cpp @@ -100,11 +100,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/InvLumaMasking.cpp b/src/examples/InvLumaMasking.cpp index 69990ffb..42289154 100644 --- a/src/examples/InvLumaMasking.cpp +++ b/src/examples/InvLumaMasking.cpp @@ -152,11 +152,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/InvMasking.cpp b/src/examples/InvMasking.cpp index 2fe53eb2..0224f180 100644 --- a/src/examples/InvMasking.cpp +++ b/src/examples/InvMasking.cpp @@ -157,11 +157,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/LinearGradient.cpp b/src/examples/LinearGradient.cpp index f163b48a..0bae6e28 100644 --- a/src/examples/LinearGradient.cpp +++ b/src/examples/LinearGradient.cpp @@ -125,11 +125,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/Lottie.cpp b/src/examples/Lottie.cpp index e9cbc5e4..5b08b812 100644 --- a/src/examples/Lottie.cpp +++ b/src/examples/Lottie.cpp @@ -194,11 +194,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); tvgDrawCmds(glCanvas.get()); diff --git a/src/examples/LottieExtension.cpp b/src/examples/LottieExtension.cpp index 0905c72a..8e30090a 100644 --- a/src/examples/LottieExtension.cpp +++ b/src/examples/LottieExtension.cpp @@ -137,11 +137,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); tvgDrawCmds(glCanvas.get()); } diff --git a/src/examples/LumaMasking.cpp b/src/examples/LumaMasking.cpp index cca34993..40c3c442 100644 --- a/src/examples/LumaMasking.cpp +++ b/src/examples/LumaMasking.cpp @@ -152,11 +152,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/Masking.cpp b/src/examples/Masking.cpp index afbf9b19..8579920b 100644 --- a/src/examples/Masking.cpp +++ b/src/examples/Masking.cpp @@ -159,11 +159,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/MaskingMethods.cpp b/src/examples/MaskingMethods.cpp index 7e15dc15..10ae0b99 100644 --- a/src/examples/MaskingMethods.cpp +++ b/src/examples/MaskingMethods.cpp @@ -424,11 +424,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/MultiCanvas.cpp b/src/examples/MultiCanvas.cpp index a9e23bda..f58a00ca 100644 --- a/src/examples/MultiCanvas.cpp +++ b/src/examples/MultiCanvas.cpp @@ -156,11 +156,15 @@ void initGLview(Evas_Object *obj) auto objData = reinterpret_cast(evas_object_data_get(obj, "objdata")); objData->idx = counter; - static constexpr auto BPP = 4; - //Create a Canvas auto canvas = tvg::GlCanvas::gen(); - canvas->target(nullptr, SIZE * BPP, SIZE, SIZE); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + canvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/MultiShapes.cpp b/src/examples/MultiShapes.cpp index a36d45c6..1e473469 100644 --- a/src/examples/MultiShapes.cpp +++ b/src/examples/MultiShapes.cpp @@ -85,11 +85,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/Opacity.cpp b/src/examples/Opacity.cpp index de1fe1e8..22b49fd9 100644 --- a/src/examples/Opacity.cpp +++ b/src/examples/Opacity.cpp @@ -141,11 +141,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/Path.cpp b/src/examples/Path.cpp index dd1f8f58..bc04f34d 100644 --- a/src/examples/Path.cpp +++ b/src/examples/Path.cpp @@ -104,11 +104,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/PathCopy.cpp b/src/examples/PathCopy.cpp index 1882fa23..76532c69 100644 --- a/src/examples/PathCopy.cpp +++ b/src/examples/PathCopy.cpp @@ -141,11 +141,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/Performance.cpp b/src/examples/Performance.cpp index 8fcf6cfa..2373cf0b 100644 --- a/src/examples/Performance.cpp +++ b/src/examples/Performance.cpp @@ -128,11 +128,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/PictureJpg.cpp b/src/examples/PictureJpg.cpp index 5adc6b8a..b88c46c9 100644 --- a/src/examples/PictureJpg.cpp +++ b/src/examples/PictureJpg.cpp @@ -107,11 +107,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/PicturePng.cpp b/src/examples/PicturePng.cpp index 41766611..76bdc87a 100644 --- a/src/examples/PicturePng.cpp +++ b/src/examples/PicturePng.cpp @@ -113,11 +113,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/PictureRaw.cpp b/src/examples/PictureRaw.cpp index 59fbe846..131defc7 100644 --- a/src/examples/PictureRaw.cpp +++ b/src/examples/PictureRaw.cpp @@ -105,11 +105,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/PictureSvg.cpp b/src/examples/PictureSvg.cpp index 771a1e95..a51b0a29 100644 --- a/src/examples/PictureSvg.cpp +++ b/src/examples/PictureSvg.cpp @@ -104,11 +104,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/PictureTvg.cpp b/src/examples/PictureTvg.cpp index 35f24f95..65695039 100644 --- a/src/examples/PictureTvg.cpp +++ b/src/examples/PictureTvg.cpp @@ -84,11 +84,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/PictureWebp.cpp b/src/examples/PictureWebp.cpp index b5b2c50d..fd227fd6 100644 --- a/src/examples/PictureWebp.cpp +++ b/src/examples/PictureWebp.cpp @@ -113,11 +113,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/RadialGradient.cpp b/src/examples/RadialGradient.cpp index 035cfcde..b12c0c57 100644 --- a/src/examples/RadialGradient.cpp +++ b/src/examples/RadialGradient.cpp @@ -125,11 +125,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/Retaining.cpp b/src/examples/Retaining.cpp index d4bac2f5..0c12eedf 100644 --- a/src/examples/Retaining.cpp +++ b/src/examples/Retaining.cpp @@ -128,11 +128,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/Scene.cpp b/src/examples/Scene.cpp index c6e94e3c..d13397e0 100644 --- a/src/examples/Scene.cpp +++ b/src/examples/Scene.cpp @@ -132,11 +132,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/SceneBlending.cpp b/src/examples/SceneBlending.cpp index 5e579ea0..1ede0388 100644 --- a/src/examples/SceneBlending.cpp +++ b/src/examples/SceneBlending.cpp @@ -147,11 +147,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/SceneClipper.cpp b/src/examples/SceneClipper.cpp index 668bcd02..13e8907b 100644 --- a/src/examples/SceneClipper.cpp +++ b/src/examples/SceneClipper.cpp @@ -110,11 +110,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/SceneTransform.cpp b/src/examples/SceneTransform.cpp index 062be5f3..5f7705b2 100644 --- a/src/examples/SceneTransform.cpp +++ b/src/examples/SceneTransform.cpp @@ -156,11 +156,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/Shape.cpp b/src/examples/Shape.cpp index 0300f29b..489ab82f 100644 --- a/src/examples/Shape.cpp +++ b/src/examples/Shape.cpp @@ -77,11 +77,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/Stroke.cpp b/src/examples/Stroke.cpp index 3bc114cd..cf5c9ffd 100644 --- a/src/examples/Stroke.cpp +++ b/src/examples/Stroke.cpp @@ -163,11 +163,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/StrokeLine.cpp b/src/examples/StrokeLine.cpp index c44e2645..450f63a6 100644 --- a/src/examples/StrokeLine.cpp +++ b/src/examples/StrokeLine.cpp @@ -209,11 +209,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/StrokeMiterlimit.cpp b/src/examples/StrokeMiterlimit.cpp index 62cc8cfd..9c234fbe 100644 --- a/src/examples/StrokeMiterlimit.cpp +++ b/src/examples/StrokeMiterlimit.cpp @@ -198,11 +198,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/Svg.cpp b/src/examples/Svg.cpp index 21b06c77..5ae21f4a 100644 --- a/src/examples/Svg.cpp +++ b/src/examples/Svg.cpp @@ -134,11 +134,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/Texmap.cpp b/src/examples/Texmap.cpp index e7d1d850..1f2d34c5 100644 --- a/src/examples/Texmap.cpp +++ b/src/examples/Texmap.cpp @@ -124,11 +124,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/Text.cpp b/src/examples/Text.cpp index aa6a19ba..99dbfac6 100644 --- a/src/examples/Text.cpp +++ b/src/examples/Text.cpp @@ -208,11 +208,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/Transform.cpp b/src/examples/Transform.cpp index 9b326588..c1fc99dc 100644 --- a/src/examples/Transform.cpp +++ b/src/examples/Transform.cpp @@ -113,11 +113,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/Tvg.cpp b/src/examples/Tvg.cpp index 43105b30..aef9ce35 100644 --- a/src/examples/Tvg.cpp +++ b/src/examples/Tvg.cpp @@ -120,11 +120,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/examples/Update.cpp b/src/examples/Update.cpp index 32325eb5..2f173b5a 100644 --- a/src/examples/Update.cpp +++ b/src/examples/Update.cpp @@ -101,11 +101,15 @@ static unique_ptr glCanvas; void initGLview(Evas_Object *obj) { - static constexpr auto BPP = 4; - //Create a Canvas glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); + + //Get the drawing target id + int32_t targetId; + auto gl = elm_glview_gl_api_get(obj); + gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &targetId); + + glCanvas->target(targetId, WIDTH, HEIGHT); /* Push the shape into the Canvas drawing list When this shape is into the canvas list, the shape could update & prepare diff --git a/src/renderer/gl_engine/tvgGlRenderer.cpp b/src/renderer/gl_engine/tvgGlRenderer.cpp index 3eb27619..9583acad 100644 --- a/src/renderer/gl_engine/tvgGlRenderer.cpp +++ b/src/renderer/gl_engine/tvgGlRenderer.cpp @@ -55,11 +55,11 @@ bool GlRenderer::clear() } -bool GlRenderer::target(TVG_UNUSED uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h) +bool GlRenderer::target(int32_t id, uint32_t w, uint32_t h) { assert(w > 0 && h > 0); - surface.stride = stride; + surface.stride = w; surface.w = w; surface.h = h; @@ -68,10 +68,7 @@ bool GlRenderer::target(TVG_UNUSED uint32_t* buffer, uint32_t stride, uint32_t w mViewport.w = surface.w; mViewport.h = surface.h; - // get current binded framebuffer id - // EFL seems has a seperate framebuffer for evagl view - //TODO: introduce a new api to specify which fbo this canvas is binded - GL_CHECK(glGetIntegerv(GL_FRAMEBUFFER_BINDING, &mTargetFboId)); + mTargetFboId = static_cast(id); mRootTarget = make_unique(surface.w, surface.h); mRootTarget->init(mTargetFboId); diff --git a/src/renderer/gl_engine/tvgGlRenderer.h b/src/renderer/gl_engine/tvgGlRenderer.h index 818d3559..52dccd75 100644 --- a/src/renderer/gl_engine/tvgGlRenderer.h +++ b/src/renderer/gl_engine/tvgGlRenderer.h @@ -67,7 +67,7 @@ public: bool blend(BlendMethod method) override; ColorSpace colorSpace() override; - bool target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h); + bool target(int32_t id, uint32_t w, uint32_t h); bool sync() override; bool clear() override; diff --git a/src/renderer/tvgGlCanvas.cpp b/src/renderer/tvgGlCanvas.cpp index f6f0d354..940e6682 100644 --- a/src/renderer/tvgGlCanvas.cpp +++ b/src/renderer/tvgGlCanvas.cpp @@ -60,14 +60,14 @@ GlCanvas::~GlCanvas() } -Result GlCanvas::target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h) noexcept +Result GlCanvas::target(int32_t id, uint32_t w, uint32_t h) noexcept { #ifdef THORVG_GL_RASTER_SUPPORT //We know renderer type, avoid dynamic_cast for performance. auto renderer = static_cast(Canvas::pImpl->renderer); if (!renderer) return Result::MemoryCorruption; - if (!renderer->target(buffer, stride, w, h)) return Result::Unknown; + if (!renderer->target(id, w, h)) return Result::Unknown; //Paints must be updated again with this new target. Canvas::pImpl->needRefresh();