thorvg/src/lib/sw_engine/tvgSwCommon.h
Hermet Park 682bc25298 common shape: revise scale/rotate approach.
Come to think of it, this optimized method is not so useful,
it could just bring the user misunderstanding and
not to efficient as I expected in the most cases.

So, changed policy for transformation behaviors.
it keeps the properties as others but leaves it to the backend implementation.

Plus, this change contains the correct RenderUpdateFlag.
You can refer the flag in the backend to figure out which kinds of properites has been updated

Change-Id: Ibe0494712598a8161950b9ae2e22ac45bed1c47b
2020-05-03 15:03:29 +09:00

104 lines
2.5 KiB
C++

/*
* Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef _TVG_SW_COMMON_H_
#define _TVG_SW_COMMON_H_
#include "tvgCommon.h"
using namespace tvg;
constexpr auto SW_CURVE_TYPE_POINT = 0;
constexpr auto SW_CURVE_TYPE_CUBIC = 1;
constexpr auto SW_OUTLINE_FILL_WINDING = 0;
constexpr auto SW_OUTLINE_FILL_EVEN_ODD = 1;
using SwCoord = signed long;
struct SwPoint
{
SwCoord x, y;
SwPoint operator+(const SwPoint& rhs) const {
return {x + rhs.x, y + rhs.y};
}
SwPoint operator-(const SwPoint& rhs) const {
return {x - rhs.x, y - rhs.y};
}
bool operator==(const SwPoint& rhs ) const {
return (x == rhs.x && y == rhs.y);
}
bool operator!=(const SwPoint& rhs) const {
return (x != rhs.x || y != rhs.y);
}
};
struct SwSize
{
SwCoord w, h;
};
struct SwOutline
{
size_t* cntrs; //the contour end points
size_t cntrsCnt; //number of contours in glyph
size_t reservedCntrsCnt;
SwPoint* pts; //the outline's points
size_t ptsCnt; //number of points in the glyph
size_t reservedPtsCnt;
uint8_t* types; //curve type
uint8_t fillMode; //outline fill mode
};
struct SwSpan
{
int16_t x, y;
uint16_t len;
uint8_t coverage;
};
struct SwRleData
{
SwSpan *spans;
size_t alloc;
size_t size;
};
struct SwBBox
{
SwPoint min, max;
};
struct SwShape
{
SwOutline* outline;
SwRleData* rle;
SwBBox bbox;
};
void shapeReset(SwShape& sdata);
bool shapeGenOutline(const Shape& shape, SwShape& sdata);
void shapeDelOutline(SwShape& sdata);
bool shapeGenRle(const Shape& shape, SwShape& sdata, const SwSize& clip);
bool shapeTransformOutline(const Shape& shape, SwShape& sdata);
SwRleData* rleRender(const SwShape& sdata, const SwSize& clip);
bool rasterShape(Surface& surface, SwShape& sdata, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
#endif /* _TVG_SW_COMMON_H_ */