Rename glu libtess symbols. When enabled in WebKit, the internal_glu libtess

symbols in skia will collide with the same internal_ implementation in WebKit.
Rename the glu entry points with an Sk_ prefix instead.  Also, unfork the
changes to the libtess source as much as possible (the same as was done in
http://trac.webkit.org/changeset/87178).

Review URL:  http://codereview.appspot.com/4536080/



git-svn-id: http://skia.googlecode.com/svn/trunk@1419 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
senorblanco@chromium.org 2011-05-25 14:46:17 +00:00
parent 8887ede824
commit 1fa803d6b4
16 changed files with 89 additions and 81 deletions

View File

@ -21,7 +21,7 @@
#include "GrPoint.h"
#include "GrTDArray.h"
#include <internal_glu.h>
#include <sk_glu.h>
struct PolygonData {
PolygonData(GrTDArray<GrPoint>* vertices, GrTDArray<short>* indices)
@ -289,34 +289,34 @@ FINISHED:
inVertices[i * 3 + 2] = 1.0;
}
GLUtesselator* tess = internal_gluNewTess();
GLUtesselator* tess = Sk_gluNewTess();
unsigned windingRule = fill_type_to_glu_winding_rule(fill);
internal_gluTessProperty(tess, GLU_TESS_WINDING_RULE, windingRule);
internal_gluTessCallback(tess, GLU_TESS_BEGIN_DATA, (TESSCB) &beginData);
internal_gluTessCallback(tess, GLU_TESS_VERTEX_DATA, (TESSCB) &vertexData);
internal_gluTessCallback(tess, GLU_TESS_END_DATA, (TESSCB) &endData);
internal_gluTessCallback(tess, GLU_TESS_EDGE_FLAG_DATA, (TESSCB) &edgeFlagData);
internal_gluTessCallback(tess, GLU_TESS_COMBINE_DATA, (TESSCB) &combineData);
Sk_gluTessProperty(tess, GLU_TESS_WINDING_RULE, windingRule);
Sk_gluTessCallback(tess, GLU_TESS_BEGIN_DATA, (TESSCB) &beginData);
Sk_gluTessCallback(tess, GLU_TESS_VERTEX_DATA, (TESSCB) &vertexData);
Sk_gluTessCallback(tess, GLU_TESS_END_DATA, (TESSCB) &endData);
Sk_gluTessCallback(tess, GLU_TESS_EDGE_FLAG_DATA, (TESSCB) &edgeFlagData);
Sk_gluTessCallback(tess, GLU_TESS_COMBINE_DATA, (TESSCB) &combineData);
GrTDArray<short> indices;
GrTDArray<GrPoint> vertices;
PolygonData data(&vertices, &indices);
internal_gluTessBeginPolygon(tess, &data);
Sk_gluTessBeginPolygon(tess, &data);
size_t i = 0;
for (int sp = 0; sp < subpathCnt; ++sp) {
internal_gluTessBeginContour(tess);
Sk_gluTessBeginContour(tess);
int start = i;
size_t end = start + subpathVertCount[sp];
for (; i < end; ++i) {
double* inVertex = &inVertices[i * 3];
*vertices.append() = GrPoint::Make(inVertex[0], inVertex[1]);
internal_gluTessVertex(tess, inVertex, reinterpret_cast<void*>(i));
Sk_gluTessVertex(tess, inVertex, reinterpret_cast<void*>(i));
}
internal_gluTessEndContour(tess);
Sk_gluTessEndContour(tess);
}
internal_gluTessEndPolygon(tess);
internal_gluDeleteTess(tess);
Sk_gluTessEndPolygon(tess);
Sk_gluDeleteTess(tess);
if (indices.count() > 0) {
target->setVertexSourceToArray(layout, vertices.begin(), vertices.count());

View File

@ -8,13 +8,12 @@ LICENSE.txt in this directory.
The following changes were made in order to incorporate this code:
- The addition of a simplified gluos.h to eliminate operating system
dependencies.
dependencies. The entry points to the tessellator were prefixed with
Sk_ to avoid symbol collisions with any host OS version of GLU via
#defines in gluos.h.
- The removal of inclusion of GL/glu.h and replacement with an
include of internal_glu.h.
- The entry points to the tessellator were prefixed with internal_
to avoid symbol collisions with any host OS version of GLU.
include of sk_glu.h.
- In tess.c, the obsolete entry points gluBeginPolygon,
gluNextContour and gluEndPolygon in tess.c were #if 0'd out.

View File

@ -42,6 +42,18 @@ typedef unsigned int GLenum;
typedef float GLfloat;
typedef void GLvoid;
#define gluNewTess Sk_gluNewTess
#define gluDeleteTess Sk_gluDeleteTess
#define gluTessProperty Sk_gluTessProperty
#define gluGetTessProperty Sk_gluGetTessProperty
#define gluTessNormal Sk_gluTessNormal
#define gluTessCallback Sk_gluTessCallback
#define gluTessVertex Sk_gluTessVertex
#define gluTessBeginPolygon Sk_gluTessBeginPolygon
#define gluTessBeginContour Sk_gluTessBeginContour
#define gluTessEndContour Sk_gluTessEndContour
#define gluTessEndPolygon Sk_gluTessEndPolygon
#undef MIN
#undef MAX

View File

@ -39,8 +39,8 @@
** $Header: //depot/main/gfx/lib/glu/libtess/geom.c#5 $
*/
#include "gluos.h"
#include <assert.h>
#include <gluos.h>
#include "mesh.h"
#include "geom.h"

View File

@ -39,8 +39,8 @@
** $Header: //depot/main/gfx/lib/glu/libtess/memalloc.c#5 $
*/
#include "string.h"
#include "memalloc.h"
#include "string.h"
int __gl_memInit( size_t maxFast )
{

View File

@ -39,11 +39,11 @@
** $Header: //depot/main/gfx/lib/glu/libtess/mesh.c#6 $
*/
#include <assert.h>
#include "gluos.h"
#include <stddef.h>
#include <gluos.h>
#include "memalloc.h"
#include <assert.h>
#include "mesh.h"
#include "memalloc.h"
#define TRUE 1
#define FALSE 0

View File

@ -42,7 +42,7 @@
#ifndef __mesh_h_
#define __mesh_h_
#include <internal_glu.h>
#include <sk_glu.h>
typedef struct GLUmesh GLUmesh;

View File

@ -39,12 +39,12 @@
** $Header: //depot/main/gfx/lib/glu/libtess/normal.c#5 $
*/
#include <assert.h>
#include <math.h>
#include <gluos.h>
#include "gluos.h"
#include "mesh.h"
#include "normal.h"
#include "tess.h"
#include "normal.h"
#include <math.h>
#include <assert.h>
#define TRUE 1
#define FALSE 0

View File

@ -39,11 +39,11 @@
** $Header: //depot/main/gfx/lib/glu/libtess/priorityq-heap.c#5 $
*/
#include <stddef.h>
#include <assert.h>
#include <limits.h>
#include <stddef.h>
#include "memalloc.h"
#include "priorityq-heap.h"
#include "memalloc.h"
#define INIT_SIZE 32

View File

@ -39,10 +39,10 @@
** $Header: //depot/main/gfx/lib/glu/libtess/priorityq.c#5 $
*/
#include "gluos.h"
#include <stddef.h>
#include <assert.h>
#include <limits.h> /* LONG_MAX */
#include <stddef.h>
#include <gluos.h>
#include "memalloc.h"
/* Include all the code for the regular heap-based queue here. */

View File

@ -39,12 +39,12 @@
** $Header: //depot/main/gfx/lib/glu/libtess/render.c#5 $
*/
#include "gluos.h"
#include <assert.h>
#include <stddef.h>
#include <gluos.h>
#include "mesh.h"
#include "render.h"
#include "tess.h"
#include "render.h"
#define TRUE 1
#define FALSE 0

View File

@ -39,19 +39,19 @@
** $Header: //depot/main/gfx/lib/glu/libtess/sweep.c#5 $
*/
#include "gluos.h"
#include <assert.h>
#include <stddef.h>
#include <setjmp.h> /* longjmp */
#include <limits.h> /* LONG_MAX */
#include <stddef.h>
#include <gluos.h>
#include "dict.h"
#include "geom.h"
#include "memalloc.h"
#include "mesh.h"
#include "priorityq.h"
#include "sweep.h"
#include "geom.h"
#include "tess.h"
#include "dict.h"
#include "priorityq.h"
#include "memalloc.h"
#include "sweep.h"
#define TRUE 1
#define FALSE 0

View File

@ -39,18 +39,17 @@
** $Header: //depot/main/gfx/lib/glu/libtess/tess.c#7 $
*/
#include "gluos.h"
#include <stddef.h>
#include <assert.h>
#include <setjmp.h>
#include <stddef.h>
#include <gluos.h>
#include "memalloc.h"
#include "tess.h"
#include "mesh.h"
#include "normal.h"
#include "render.h"
#include "sweep.h"
#include "tess.h"
#include "tessmono.h"
#include "render.h"
#define GLU_TESS_DEFAULT_TOLERANCE 0.0
#define GLU_TESS_MESH 100112 /* void (*)(GLUmesh *mesh) */
@ -92,7 +91,7 @@ typedef struct { GLUhalfEdge e, eSym; } EdgePair;
GLUtesselator * GLAPIENTRY
internal_gluNewTess( void )
gluNewTess( void )
{
GLUtesselator *tess;
@ -164,11 +163,11 @@ static void GotoState( GLUtesselator *tess, enum TessState newState )
switch( tess->state ) {
case T_DORMANT:
CALL_ERROR_OR_ERROR_DATA( GLU_TESS_MISSING_BEGIN_POLYGON );
internal_gluTessBeginPolygon( tess, NULL );
gluTessBeginPolygon( tess, NULL );
break;
case T_IN_POLYGON:
CALL_ERROR_OR_ERROR_DATA( GLU_TESS_MISSING_BEGIN_CONTOUR );
internal_gluTessBeginContour( tess );
gluTessBeginContour( tess );
break;
default:
assert(0);
@ -178,7 +177,7 @@ static void GotoState( GLUtesselator *tess, enum TessState newState )
switch( tess->state ) {
case T_IN_CONTOUR:
CALL_ERROR_OR_ERROR_DATA( GLU_TESS_MISSING_END_CONTOUR );
internal_gluTessEndContour( tess );
gluTessEndContour( tess );
break;
case T_IN_POLYGON:
CALL_ERROR_OR_ERROR_DATA( GLU_TESS_MISSING_END_POLYGON );
@ -195,7 +194,7 @@ static void GotoState( GLUtesselator *tess, enum TessState newState )
void GLAPIENTRY
internal_gluDeleteTess( GLUtesselator *tess )
gluDeleteTess( GLUtesselator *tess )
{
RequireState( tess, T_DORMANT );
memFree( tess );
@ -203,7 +202,7 @@ internal_gluDeleteTess( GLUtesselator *tess )
void GLAPIENTRY
internal_gluTessProperty( GLUtesselator *tess, GLenum which, GLdouble value )
gluTessProperty( GLUtesselator *tess, GLenum which, GLdouble value )
{
GLenum windingRule;
@ -242,7 +241,7 @@ internal_gluTessProperty( GLUtesselator *tess, GLenum which, GLdouble value )
/* Returns tessellator property */
void GLAPIENTRY
internal_gluGetTessProperty( GLUtesselator *tess, GLenum which, GLdouble *value )
gluGetTessProperty( GLUtesselator *tess, GLenum which, GLdouble *value )
{
switch (which) {
case GLU_TESS_TOLERANCE:
@ -270,7 +269,7 @@ internal_gluGetTessProperty( GLUtesselator *tess, GLenum which, GLdouble *value
} /* gluGetTessProperty() */
void GLAPIENTRY
internal_gluTessNormal( GLUtesselator *tess, GLdouble x, GLdouble y, GLdouble z )
gluTessNormal( GLUtesselator *tess, GLdouble x, GLdouble y, GLdouble z )
{
tess->normal[0] = x;
tess->normal[1] = y;
@ -278,7 +277,7 @@ internal_gluTessNormal( GLUtesselator *tess, GLdouble x, GLdouble y, GLdouble z
}
void GLAPIENTRY
internal_gluTessCallback( GLUtesselator *tess, GLenum which, void (GLAPIENTRY *fn)())
gluTessCallback( GLUtesselator *tess, GLenum which, void (GLAPIENTRY *fn)())
{
switch( which ) {
case GLU_TESS_BEGIN:
@ -417,7 +416,7 @@ static int EmptyCache( GLUtesselator *tess )
void GLAPIENTRY
internal_gluTessVertex( GLUtesselator *tess, GLdouble coords[3], void *data )
gluTessVertex( GLUtesselator *tess, GLdouble coords[3], void *data )
{
int i, tooLarge = FALSE;
GLdouble x, clamped[3];
@ -464,7 +463,7 @@ internal_gluTessVertex( GLUtesselator *tess, GLdouble coords[3], void *data )
void GLAPIENTRY
internal_gluTessBeginPolygon( GLUtesselator *tess, void *data )
gluTessBeginPolygon( GLUtesselator *tess, void *data )
{
RequireState( tess, T_DORMANT );
@ -478,7 +477,7 @@ internal_gluTessBeginPolygon( GLUtesselator *tess, void *data )
void GLAPIENTRY
internal_gluTessBeginContour( GLUtesselator *tess )
gluTessBeginContour( GLUtesselator *tess )
{
RequireState( tess, T_IN_POLYGON );
@ -495,14 +494,14 @@ internal_gluTessBeginContour( GLUtesselator *tess )
void GLAPIENTRY
internal_gluTessEndContour( GLUtesselator *tess )
gluTessEndContour( GLUtesselator *tess )
{
RequireState( tess, T_IN_CONTOUR );
tess->state = T_IN_POLYGON;
}
void GLAPIENTRY
internal_gluTessEndPolygon( GLUtesselator *tess )
gluTessEndPolygon( GLUtesselator *tess )
{
GLUmesh *mesh;

View File

@ -42,11 +42,10 @@
#ifndef __tess_h_
#define __tess_h_
#include <sk_glu.h>
#include <setjmp.h>
#include <internal_glu.h>
#include "dict.h"
#include "mesh.h"
#include "dict.h"
#include "priorityq.h"
/* The begin/end calls must be properly nested. We keep track of

View File

@ -39,13 +39,12 @@
** $Header: //depot/main/gfx/lib/glu/libtess/tessmono.c#5 $
*/
#include <assert.h>
#include "gluos.h"
#include <stdlib.h>
#include <gluos.h>
#include "geom.h"
#include "mesh.h"
#include "tessmono.h"
#include <assert.h>
#define AddWinding(eDst,eSrc) (eDst->winding += eSrc->winding, \
eDst->Sym->winding += eSrc->Sym->winding)

View File

@ -33,8 +33,8 @@
// only the definitions, constants and function declarations necessary
// to compile the GLU tessellator.
#ifndef INTERNAL_GLU_H_
#define INTERNAL_GLU_H_
#ifndef SK_GLU_H_
#define SK_GLU_H_
#include "gluos.h"
@ -110,32 +110,32 @@ typedef struct GLUtesselator GLUtesselator;
extern "C" {
#endif
extern GLUtesselator * GLAPIENTRY internal_gluNewTess(void);
extern void GLAPIENTRY internal_gluDeleteTess(GLUtesselator *tess);
extern void GLAPIENTRY internal_gluTessProperty(GLUtesselator *tess,
extern GLUtesselator * GLAPIENTRY Sk_gluNewTess(void);
extern void GLAPIENTRY Sk_gluDeleteTess(GLUtesselator *tess);
extern void GLAPIENTRY Sk_gluTessProperty(GLUtesselator *tess,
GLenum which,
GLdouble value);
extern void GLAPIENTRY internal_gluGetTessProperty(GLUtesselator *tess,
extern void GLAPIENTRY Sk_gluGetTessProperty(GLUtesselator *tess,
GLenum which,
GLdouble *value);
extern void GLAPIENTRY internal_gluTessNormal(GLUtesselator *tess,
extern void GLAPIENTRY Sk_gluTessNormal(GLUtesselator *tess,
GLdouble x,
GLdouble y,
GLdouble z);
extern void GLAPIENTRY internal_gluTessCallback(GLUtesselator *tess,
extern void GLAPIENTRY Sk_gluTessCallback(GLUtesselator *tess,
GLenum which,
void (GLAPIENTRY *fn)());
extern void GLAPIENTRY internal_gluTessVertex(GLUtesselator *tess,
extern void GLAPIENTRY Sk_gluTessVertex(GLUtesselator *tess,
GLdouble coords[3],
void *data);
extern void GLAPIENTRY internal_gluTessBeginPolygon(GLUtesselator *tess,
extern void GLAPIENTRY Sk_gluTessBeginPolygon(GLUtesselator *tess,
void *data);
extern void GLAPIENTRY internal_gluTessBeginContour(GLUtesselator *tess);
extern void GLAPIENTRY internal_gluTessEndContour(GLUtesselator *tess);
extern void GLAPIENTRY internal_gluTessEndPolygon(GLUtesselator *tess);
extern void GLAPIENTRY Sk_gluTessBeginContour(GLUtesselator *tess);
extern void GLAPIENTRY Sk_gluTessEndContour(GLUtesselator *tess);
extern void GLAPIENTRY Sk_gluTessEndPolygon(GLUtesselator *tess);
#ifdef __cplusplus
}
#endif
#endif // INTERNAL_GLU_H_
#endif // SK_GLU_H_