From 754a4aeaeaf8f93511913098c45e6457d9397503 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 e571507b..239a6562 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -1596,7 +1596,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. * @@ -1665,13 +1665,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 23f1c994..0f4404f4 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 e3716022..8ddb68a6 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 69de5127..06eabf42 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 dcb6d9bb..ab2147e9 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 ed2e4721..3360f489 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 270c1ea0..8a300636 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 463003ce..485f188c 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 4b235fc7..50b6d0d3 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 32cf0dd0..2c1a0a8b 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 5910d6ff..6b775227 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 7e6d134c..3a968bd7 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 db478c1a..d60d5660 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 348415a6..4b6e85f7 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 7b1c7e6a..a1b583db 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 6cf05412..12d58bcc 100644 --- a/src/examples/ImageScaleDown.cpp +++ b/src/examples/ImageScaleDown.cpp @@ -102,11 +102,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 880284c9..abd545b9 100644 --- a/src/examples/ImageScaleUp.cpp +++ b/src/examples/ImageScaleUp.cpp @@ -102,11 +102,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 8b3e4ed7..543dde62 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 bbc48d4e..b001d3d9 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 94bea1b8..1a0971e0 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 649e0c3a..fda47e99 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 48ade56e..83357a42 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 6ffc288b..c6a803af 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 57f368d2..ca61387f 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 6e56f4fb..5f55b3ea 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 9c58652c..532de445 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 3d8d98b6..aebed5cb 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 d9c673f7..3a6a8f2d 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 2596ef48..51e4ba63 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 fd6b1478..3228daf5 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 d0179d46..3821b0d3 100644 --- a/src/examples/Performance.cpp +++ b/src/examples/Performance.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); /* 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 74fe48b9..adcae521 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 aecbceb8..2d8160e8 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 54d79040..406320aa 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 ad2da55b..26c88e66 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 482058af..f69f2548 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 690dd919..1869f16e 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 19106f09..37bc201b 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 7be05bfb..9fe2fa65 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 0cc8ec1c..ec27125b 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 4b0853b9..0cbf7b45 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 951cba27..fb737d74 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 a952a1ff..929643c1 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 232e1aa2..14d1b1d3 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 3cc3348a..1fb3f64e 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 6acf6890..042c1868 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 92c02bec..5fa03c91 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 af064f71..12660af0 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 6b1af578..2574d7cf 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 54f7bf1f..4712d730 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 57c1f62e..50953c83 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 48f58b8d..29f5de59 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 a0774c8d..e4b56688 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 b2b3a24e..f1c62641 100644 --- a/src/renderer/gl_engine/tvgGlRenderer.cpp +++ b/src/renderer/gl_engine/tvgGlRenderer.cpp @@ -54,11 +54,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; @@ -67,10 +67,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 6507c8a4..d1b5ea30 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();