From 4b3b7bce4c15ad9806ae12b1fd6442348f2c7397 Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Fri, 19 Feb 2021 15:22:17 +0900 Subject: [PATCH] common: Functions that can declare const are refactored to use const Member functions that don't mutate their objects should be declared "const" --- src/lib/sw_engine/tvgSwCommon.h | 4 ++-- src/lib/sw_engine/tvgSwRenderer.cpp | 2 +- src/lib/tvgPictureImpl.h | 4 ++-- src/lib/tvgSceneImpl.h | 4 ++-- src/lib/tvgShapeImpl.h | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib/sw_engine/tvgSwCommon.h b/src/lib/sw_engine/tvgSwCommon.h index e06d378..82a6023 100644 --- a/src/lib/sw_engine/tvgSwCommon.h +++ b/src/lib/sw_engine/tvgSwCommon.h @@ -75,13 +75,13 @@ struct SwPoint return (x != rhs.x || y != rhs.y); } - bool zero() + bool zero() const { if (x == 0 && y == 0) return true; else return false; } - bool small() + bool small() const { //2 is epsilon... if (abs(x) < 2 && abs(y) < 2) return true; diff --git a/src/lib/sw_engine/tvgSwRenderer.cpp b/src/lib/sw_engine/tvgSwRenderer.cpp index f5cab79..09b199b 100644 --- a/src/lib/sw_engine/tvgSwRenderer.cpp +++ b/src/lib/sw_engine/tvgSwRenderer.cpp @@ -40,7 +40,7 @@ struct SwTask : Task uint32_t opacity; SwBBox bbox = {{0, 0}, {0, 0}}; //Whole Rendering Region - void bounds(uint32_t* x, uint32_t* y, uint32_t* w, uint32_t* h) + void bounds(uint32_t* x, uint32_t* y, uint32_t* w, uint32_t* h) const { //Range over? auto xx = bbox.min.x > 0 ? bbox.min.x : 0; diff --git a/src/lib/tvgPictureImpl.h b/src/lib/tvgPictureImpl.h index d39809d..e3b0c5d 100644 --- a/src/lib/tvgPictureImpl.h +++ b/src/lib/tvgPictureImpl.h @@ -130,7 +130,7 @@ struct Picture::Impl return false; } - bool viewbox(float* x, float* y, float* w, float* h) + bool viewbox(float* x, float* y, float* w, float* h) const { if (!loader) return false; if (x) *x = loader->vx; @@ -148,7 +148,7 @@ struct Picture::Impl return true; } - bool bounds(float* x, float* y, float* w, float* h) + bool bounds(float* x, float* y, float* w, float* h) const { if (!paint) return false; return paint->pImpl->bounds(x, y, w, h); diff --git a/src/lib/tvgSceneImpl.h b/src/lib/tvgSceneImpl.h index 5494565..4745da7 100644 --- a/src/lib/tvgSceneImpl.h +++ b/src/lib/tvgSceneImpl.h @@ -81,7 +81,7 @@ struct Scene::Impl return true; } - bool bounds(RenderMethod& renderer, uint32_t* px, uint32_t* py, uint32_t* pw, uint32_t* ph) + bool bounds(RenderMethod& renderer, uint32_t* px, uint32_t* py, uint32_t* pw, uint32_t* ph) const { if (paints.count == 0) return false; @@ -113,7 +113,7 @@ struct Scene::Impl return true; } - bool bounds(float* px, float* py, float* pw, float* ph) + bool bounds(float* px, float* py, float* pw, float* ph) const { if (paints.count == 0) return false; diff --git a/src/lib/tvgShapeImpl.h b/src/lib/tvgShapeImpl.h index 14f911e..c50f938 100644 --- a/src/lib/tvgShapeImpl.h +++ b/src/lib/tvgShapeImpl.h @@ -168,7 +168,7 @@ struct ShapePath cmds[cmdCnt++] = PathCommand::Close; } - bool bounds(float* x, float* y, float* w, float* h) + bool bounds(float* x, float* y, float* w, float* h) const { if (ptsCnt == 0) return false; -- 2.7.4