Skip to content

Commit c784ed7

Browse files
committed
renderer/canvas: tweak the viewport behavior.
reset the viewport context when target buffer is reset.
1 parent c261cc5 commit c784ed7

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

inc/thorvg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ class TVG_API Canvas
642642
*
643643
* @warning It's not allowed to change the viewport during Canvas::push() - Canvas::sync() or Canvas::update() - Canvas::sync().
644644
*
645-
* @note The specified viewport region will be intersected with the target region.
645+
* @note When resetting the target, the viewport will also be reset to the target size.
646646
* @note Experimental API
647647
*/
648648
virtual Result viewport(int32_t x, int32_t y, int32_t w, int32_t h) noexcept;

src/bindings/capi/thorvg_capi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ TVG_API Tvg_Result tvg_canvas_sync(Tvg_Canvas* canvas);
760760
*
761761
* \warning It's not allowed to change the viewport during tvg_canvas_update() - tvg_canvas_sync() or tvg_canvas_push() - tvg_canvas_sync().
762762
*
763-
* \note The specified viewport region will be intersected with the target region.
763+
* \note When resetting the target, the viewport will also be reset to the target size.
764764
* \note Experimental API
765765
* \see tvg_swcanvas_set_target()
766766
*/

src/renderer/tvgGlCanvas.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Result GlCanvas::target(int32_t id, uint32_t w, uint32_t h) noexcept
6868
if (!renderer) return Result::MemoryCorruption;
6969

7070
if (!renderer->target(id, w, h)) return Result::Unknown;
71-
Canvas::pImpl->vport.intersect({0, 0, (int32_t)w, (int32_t)h});
71+
Canvas::pImpl->vport = {0, 0, (int32_t)w, (int32_t)h};
7272
renderer->viewport(Canvas::pImpl->vport);
7373

7474
//Paints must be updated again with this new target.

src/renderer/tvgSwCanvas.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Result SwCanvas::target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t
8787
if (!renderer) return Result::MemoryCorruption;
8888

8989
if (!renderer->target(buffer, stride, w, h, static_cast<ColorSpace>(cs))) return Result::InvalidArguments;
90-
Canvas::pImpl->vport.intersect({0, 0, (int32_t)w, (int32_t)h});
90+
Canvas::pImpl->vport = {0, 0, (int32_t)w, (int32_t)h};
9191
renderer->viewport(Canvas::pImpl->vport);
9292

9393
//Paints must be updated again with this new target.

src/renderer/tvgWgCanvas.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Result WgCanvas::target(void* window, uint32_t w, uint32_t h) noexcept
6363
if (!renderer) return Result::MemoryCorruption;
6464

6565
if (!renderer->target(window, w, h)) return Result::Unknown;
66-
Canvas::pImpl->vport.intersect({0, 0, (int32_t)w, (int32_t)h});
66+
Canvas::pImpl->vport = {0, 0, (int32_t)w, (int32_t)h};
6767
renderer->viewport(Canvas::pImpl->vport);
6868

6969
//Paints must be updated again with this new target.

0 commit comments

Comments
 (0)