optimization: cut off file dependencies.

we should avoid code insertion during file dependencies,
such as #include "xxx.h" which has implementations.

This could increase binary size, we can avoid it as possible.

Current patch improves binary size like this:

From: file(2059008) = text(120360) data(8096) bss(80) dec(128536)
To  : file(1921832) = text(118429) data(7872) bss(56) dec(126357)

More additional patches will come in to optmize binary size.
This commit is contained in:
Hermet Park 2020-09-23 20:51:40 +09:00 committed by Hermet Park
parent 145bafbec8
commit 6365d02a96
40 changed files with 60 additions and 34 deletions

View file

@ -23,6 +23,7 @@
#define _TVG_SW_COMMON_H_
#include "tvgCommon.h"
#include "tvgRender.h"
#ifdef THORVG_AVX_VECTOR_SUPPORT
#include <immintrin.h>

View file

@ -19,6 +19,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <float.h>
#include <math.h>
#include "tvgSwCommon.h"

View file

@ -20,6 +20,7 @@
* SOFTWARE.
*/
#include "tvgSwCommon.h"
#include "tvgRender.h"
/************************************************************************/
/* Internal Class Implementation */

View file

@ -20,6 +20,7 @@
* SOFTWARE.
*/
#include "tvgSwCommon.h"
#include "tvgTaskScheduler.h"
#include "tvgSwRenderer.h"
/************************************************************************/

View file

@ -22,6 +22,9 @@
#ifndef _TVG_SW_RENDERER_H_
#define _TVG_SW_RENDERER_H_
#include <vector>
#include "tvgRender.h"
struct SwSurface;
struct SwTask;

View file

@ -22,6 +22,7 @@
#include <setjmp.h>
#include <limits.h>
#include <memory.h>
#include "tvgSwCommon.h"
/************************************************************************/

View file

@ -19,7 +19,9 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <math.h>
#include "tvgSwCommon.h"
#include "tvgBezier.h"
/************************************************************************/
/* Internal Class Implementation */

View file

@ -19,6 +19,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <string.h>
#include <math.h>
#include "tvgSwCommon.h"

View file

@ -19,8 +19,9 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "tvgCommon.h"
#include <float.h>
#include <math.h>
#include "tvgBezier.h"
/************************************************************************/
/* Internal Class Implementation */

View file

@ -22,6 +22,8 @@
#ifndef _TVG_BEZIER_H_
#define _TVG_BEZIER_H_
#include "tvgCommon.h"
namespace tvg
{

View file

@ -19,7 +19,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "tvgCommon.h"
#include "tvgCanvasImpl.h"
/************************************************************************/

View file

@ -22,6 +22,7 @@
#ifndef _TVG_CANVAS_IMPL_H_
#define _TVG_CANVAS_IMPL_H_
#include <vector>
#include "tvgPaint.h"
/************************************************************************/

View file

@ -23,15 +23,6 @@
#define _TVG_COMMON_H_
#include "config.h"
#include <iostream>
#include <vector>
#include <math.h>
#include <float.h>
#include <string.h>
#include <memory>
#include <future>
#include "thorvg.h"
using namespace std;
@ -42,10 +33,4 @@ using namespace tvg;
#define TVG_UNUSED __attribute__ ((__unused__))
#include "tvgBezier.h"
#include "tvgLoader.h"
#include "tvgLoaderMgr.h"
#include "tvgRender.h"
#include "tvgTaskScheduler.h"
#endif //_TVG_COMMON_H_

View file

@ -22,6 +22,7 @@
#ifndef _TVG_FILL_H_
#define _TVG_FILL_H_
#include <string.h>
#include "tvgCommon.h"
template<typename T>

View file

@ -19,7 +19,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "tvgCommon.h"
#include "tvgCanvasImpl.h"
#ifdef THORVG_GL_RASTER_SUPPORT

View file

@ -20,6 +20,7 @@
* SOFTWARE.
*/
#include "tvgCommon.h"
#include "tvgTaskScheduler.h"
#include "tvgLoaderMgr.h"
#ifdef THORVG_SW_RASTER_SUPPORT

View file

@ -19,6 +19,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <float.h>
#include <math.h>
#include "tvgFill.h"
/************************************************************************/

View file

@ -22,6 +22,8 @@
#ifndef _TVG_LOADER_H_
#define _TVG_LOADER_H_
#include "tvgCommon.h"
namespace tvg
{

View file

@ -19,7 +19,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "tvgCommon.h"
#include "tvgLoaderMgr.h"
#ifdef THORVG_SVG_LOADER_SUPPORT
#include "tvgSvgLoader.h"

View file

@ -22,6 +22,8 @@
#ifndef _TVG_LOADER_MGR_H_
#define _TVG_LOADER_MGR_H_
#include "tvgLoader.h"
struct LoaderMgr
{
static bool init();

View file

@ -22,7 +22,9 @@
#ifndef _TVG_PAINT_H_
#define _TVG_PAINT_H_
#include "tvgCommon.h"
#include <float.h>
#include <math.h>
#include "tvgRender.h"
namespace tvg
{

View file

@ -23,6 +23,7 @@
#define _TVG_PICTURE_IMPL_H_
#include "tvgPaint.h"
#include "tvgLoaderMgr.h"
/************************************************************************/
/* Internal Class Implementation */

View file

@ -19,6 +19,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <float.h>
#include "tvgFill.h"
/************************************************************************/

View file

@ -19,7 +19,9 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "tvgCommon.h"
#include <float.h>
#include <math.h>
#include "tvgRender.h"
/************************************************************************/
/* Internal Class Implementation */

View file

@ -22,6 +22,8 @@
#ifndef _TVG_RENDER_H_
#define _TVG_RENDER_H_
#include "tvgCommon.h"
namespace tvg
{

View file

@ -22,6 +22,7 @@
#ifndef _TVG_SCENE_IMPL_H_
#define _TVG_SCENE_IMPL_H_
#include <vector>
#include "tvgPaint.h"
/************************************************************************/

View file

@ -20,7 +20,6 @@
* SOFTWARE.
*/
#include <limits>
#include "tvgShapeImpl.h"
/************************************************************************/

View file

@ -22,6 +22,7 @@
#ifndef _TVG_SHAPE_PATH_H_
#define _TVG_SHAPE_PATH_H_
#include <string.h>
#include "tvgCommon.h"
/************************************************************************/

View file

@ -19,7 +19,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "tvgCommon.h"
#include "tvgCanvasImpl.h"
#ifdef THORVG_SW_RASTER_SUPPORT

View file

@ -21,7 +21,8 @@
*/
#include <deque>
#include <thread>
#include "tvgCommon.h"
#include <vector>
#include "tvgTaskScheduler.h"
/************************************************************************/
/* Internal Class Implementation */

View file

@ -22,6 +22,7 @@
#ifndef _TVG_TASK_SCHEDULER_H_
#define _TVG_TASK_SCHEDULER_H_
#include <future>
#include "tvgCommon.h"
namespace tvg

View file

@ -20,6 +20,10 @@
* SOFTWARE.
*/
#include <ctype.h>
#include <cstring>
#include <alloca.h>
#include "tvgSimpleXmlParser.h"
static const char* _simpleXmlFindWhiteSpace(const char* itr, const char* itrEnd)

View file

@ -23,9 +23,7 @@
#ifndef _TVG_SIMPLE_XML_PARSER_H_
#define _TVG_SIMPLE_XML_PARSER_H_
#include <ctype.h>
#include <cstring>
#include <alloca.h>
#include "tvgSvgLoaderCommon.h"
enum class SimpleXMLType
{

View file

@ -21,9 +21,13 @@
*/
#include <stddef.h>
#include <fstream>
#include <string.h>
#include <float.h>
#include <math.h>
#include "tvgLoaderMgr.h"
#include "tvgSimpleXmlParser.h"
#include "tvgSvgLoader.h"
/************************************************************************/
/* Internal Class Implementation */
/************************************************************************/

View file

@ -22,7 +22,7 @@
#ifndef _TVG_SVG_LOADER_H_
#define _TVG_SVG_LOADER_H_
#include "tvgSvgLoaderCommon.h"
#include "tvgTaskScheduler.h"
#include "tvgSvgSceneBuilder.h"
class SvgLoader : public Loader, public Task

View file

@ -23,7 +23,6 @@
#define _TVG_SVG_LOADER_COMMON_H_
#include "tvgCommon.h"
#include "tvgSimpleXmlParser.h"
enum class SvgNodeType
{

View file

@ -19,9 +19,10 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <string.h>
#include <math.h>
#include "tvgSvgPath.h"
static char* _skipComma(const char* content)
{
while (*content && isspace(*content)) {

View file

@ -23,7 +23,8 @@
#ifndef _TVG_SVG_PATH_H_
#define _TVG_SVG_PATH_H_
#include "tvgCommon.h"
#include <vector>
#include "tvgSvgLoaderCommon.h"
tuple<vector<tvg::PathCommand>, vector<tvg::Point>> svgPathToTvgPath(const char* svg_path_data);

View file

@ -19,7 +19,9 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <math.h>
#include "tvgSvgSceneBuilder.h"
#include "tvgSvgPath.h"
unique_ptr<LinearGradient> _applyLinearGradientProperty(SvgStyleGradient* g, Shape* vg, float rx, float ry, float rw, float rh)
{

View file

@ -24,7 +24,6 @@
#define _TVG_SVG_SCENE_BUILDER_H_
#include "tvgSvgLoaderCommon.h"
#include "tvgSvgPath.h"
class SvgSceneBuilder
{