mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
common: Clean up code
- Combine if condition with the same return value. - Remove empty space - Remove tab
This commit is contained in:
parent
6a4598f706
commit
c63f961b9c
6 changed files with 27 additions and 34 deletions
|
@ -24,10 +24,10 @@
|
|||
#include "tvgGlGpuBuffer.h"
|
||||
#include "tvgGlGeometry.h"
|
||||
|
||||
#define NORMALIZED_TOP_3D 1.0f
|
||||
#define NORMALIZED_BOTTOM_3D -1.0f
|
||||
#define NORMALIZED_LEFT_3D -1.0f
|
||||
#define NORMALIZED_RIGHT_3D 1.0f
|
||||
#define NORMALIZED_TOP_3D 1.0f
|
||||
#define NORMALIZED_BOTTOM_3D -1.0f
|
||||
#define NORMALIZED_LEFT_3D -1.0f
|
||||
#define NORMALIZED_RIGHT_3D 1.0f
|
||||
|
||||
uint32_t GlGeometry::getPrimitiveCount()
|
||||
{
|
||||
|
|
|
@ -38,32 +38,32 @@
|
|||
};
|
||||
|
||||
#define ROTATION_MATRIX(xPivot, yPivot) \
|
||||
auto radian = mTransform.angle / 180.0f * PI; \
|
||||
auto radian = mTransform.angle / 180.0f * PI; \
|
||||
auto cosVal = cosf(radian); \
|
||||
auto sinVal = sinf(radian); \
|
||||
float rotate[4*4] = { \
|
||||
cosVal, -sinVal, 0.0f, 0.0f, \
|
||||
sinVal, cosVal, 0.0f, 0.0f,\
|
||||
0.0f, 0.0f, 1.0f, 0.0f, \
|
||||
cosVal, -sinVal, 0.0f, 0.0f, \
|
||||
sinVal, cosVal, 0.0f, 0.0f, \
|
||||
0.0f, 0.0f, 1.0f, 0.0f, \
|
||||
(xPivot * (1.0f - cosVal)) - (yPivot * sinVal), (yPivot *(1.0f - cosVal)) + (xPivot * sinVal), 0.0f, 1.0f \
|
||||
};
|
||||
|
||||
#define MULTIPLY_MATRIX(A, B, transform) \
|
||||
for(auto i = 0; i < 4; ++i) \
|
||||
{ \
|
||||
{ \
|
||||
for(auto j = 0; j < 4; ++j) \
|
||||
{ \
|
||||
float sum = 0.0; \
|
||||
for (auto k = 0; k < 4; ++k) \
|
||||
{ \
|
||||
float sum = 0.0; \
|
||||
for (auto k = 0; k < 4; ++k) \
|
||||
sum += A[k*4+i] * B[j*4+k]; \
|
||||
transform[j*4+i] = sum; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define GET_TRANSFORMATION(xPivot, yPivot, transform) \
|
||||
MVP_MATRIX(); \
|
||||
ROTATION_MATRIX(xPivot, yPivot); \
|
||||
MULTIPLY_MATRIX(mvp, rotate, transform);
|
||||
#define GET_TRANSFORMATION(xPivot, yPivot, transform) \
|
||||
MVP_MATRIX(); \
|
||||
ROTATION_MATRIX(xPivot, yPivot); \
|
||||
MULTIPLY_MATRIX(mvp, rotate, transform);
|
||||
|
||||
class GlPoint
|
||||
{
|
||||
|
@ -225,7 +225,7 @@ struct GlTransform
|
|||
float angle = 0.0f;
|
||||
float scale = 1.0f;
|
||||
float w;
|
||||
float h;
|
||||
float h;
|
||||
float matrix[16];
|
||||
};
|
||||
|
||||
|
@ -261,7 +261,7 @@ private:
|
|||
|
||||
unique_ptr<GlGpuBuffer> mGpuBuffer;
|
||||
vector<GlPrimitive> mPrimitives;
|
||||
GlTransform mTransform;
|
||||
GlTransform mTransform;
|
||||
};
|
||||
|
||||
#endif /* _TVG_GL_GEOMETRY_H_ */
|
||||
|
|
|
@ -54,10 +54,8 @@ struct Canvas::Impl
|
|||
|
||||
Result clear(bool free)
|
||||
{
|
||||
if (!renderer) return Result::InsufficientCondition;
|
||||
|
||||
//Clear render target before drawing
|
||||
if (!renderer->clear()) return Result::InsufficientCondition;
|
||||
if (!renderer || !renderer->clear()) return Result::InsufficientCondition;
|
||||
|
||||
//free paints
|
||||
if (free) {
|
||||
|
@ -77,7 +75,7 @@ struct Canvas::Impl
|
|||
if (!renderer) return Result::InsufficientCondition;
|
||||
|
||||
Array<RenderData> clips;
|
||||
auto flag = force ? RenderUpdateFlag::All : RenderUpdateFlag::None;
|
||||
auto flag = force ? RenderUpdateFlag::All : RenderUpdateFlag::None;
|
||||
|
||||
//Update single paint node
|
||||
if (paint) {
|
||||
|
@ -93,9 +91,7 @@ struct Canvas::Impl
|
|||
|
||||
Result draw()
|
||||
{
|
||||
if (!renderer) return Result::InsufficientCondition;
|
||||
|
||||
if (!renderer->preRender()) return Result::InsufficientCondition;
|
||||
if (!renderer || !renderer->preRender()) return Result::InsufficientCondition;
|
||||
|
||||
for (auto paint = paints.data; paint < (paints.data + paints.count); ++paint) {
|
||||
if (!(*paint)->pImpl->render(*renderer)) return Result::InsufficientCondition;
|
||||
|
|
|
@ -220,8 +220,7 @@ namespace tvg
|
|||
|
||||
bool composite(Paint* target, CompositeMethod method)
|
||||
{
|
||||
if (!target && method != CompositeMethod::None) return false;
|
||||
if (target && method == CompositeMethod::None) return false;
|
||||
if ((!target && method != CompositeMethod::None) || (target && method == CompositeMethod::None)) return false;
|
||||
cmpTarget = target;
|
||||
cmpMethod = method;
|
||||
return true;
|
||||
|
|
|
@ -46,11 +46,11 @@ struct Picture::Impl
|
|||
|
||||
bool dispose(RenderMethod& renderer)
|
||||
{
|
||||
bool ret = true;
|
||||
bool ret = true;
|
||||
if (paint) {
|
||||
ret = paint->pImpl->dispose(renderer);
|
||||
delete(paint);
|
||||
paint = nullptr;
|
||||
paint = nullptr;
|
||||
}
|
||||
else if (pixels) {
|
||||
ret = renderer.dispose(rdata);
|
||||
|
|
|
@ -141,8 +141,7 @@ bool simpleXmlParseAttributes(const char* buf, unsigned bufLength, simpleXMLAttr
|
|||
const char *itr = buf, *itrEnd = buf + bufLength;
|
||||
char* tmpBuf = (char*)alloca(bufLength + 1);
|
||||
|
||||
if (!buf) return false;
|
||||
if (!func) return false;
|
||||
if (!buf || !func) return false;
|
||||
|
||||
while (itr < itrEnd) {
|
||||
const char* p = _simpleXmlSkipWhiteSpace(itr, itrEnd);
|
||||
|
@ -200,8 +199,7 @@ bool simpleXmlParse(const char* buf, unsigned bufLength, bool strip, simpleXMLCb
|
|||
{
|
||||
const char *itr = buf, *itrEnd = buf + bufLength;
|
||||
|
||||
if (!buf) return false;
|
||||
if (!func) return false;
|
||||
if (!buf || !func) return false;
|
||||
|
||||
#define CB(type, start, end) \
|
||||
do { \
|
||||
|
|
Loading…
Add table
Reference in a new issue