move more stuff that should be private out from GrGLConfig.h
Review URL: http://codereview.appspot.com/6202053/ git-svn-id: http://skia.googlecode.com/svn/trunk@3856 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
92fde90d9b
commit
2717d56b22
@ -181,89 +181,4 @@
|
||||
#error "Cannot combine GR_GL_NO_CONSTANT_ATTRIBUTES and GR_GL_ATTRIBUTE_MATRICES"
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if GR_SCALAR_IS_FIXED
|
||||
#define GrGLType GL_FIXED
|
||||
#elif GR_SCALAR_IS_FLOAT
|
||||
#define GrGLType GR_GL_FLOAT
|
||||
#else
|
||||
#error "unknown GR_SCALAR type"
|
||||
#endif
|
||||
|
||||
#if GR_TEXT_SCALAR_IS_USHORT
|
||||
#define GrGLTextType GR_GL_UNSIGNED_SHORT
|
||||
#define GR_GL_TEXT_TEXTURE_NORMALIZED 1
|
||||
#elif GR_TEXT_SCALAR_IS_FLOAT
|
||||
#define GrGLTextType GR_GL_FLOAT
|
||||
#define GR_GL_TEXT_TEXTURE_NORMALIZED 0
|
||||
#elif GR_TEXT_SCALAR_IS_FIXED
|
||||
#define GrGLTextType GR_GL_FIXED
|
||||
#define GR_GL_TEXT_TEXTURE_NORMALIZED 0
|
||||
#else
|
||||
#error "unknown GR_TEXT_SCALAR type"
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct GrGLInterface;
|
||||
|
||||
extern void GrGLCheckErr(const GrGLInterface* gl,
|
||||
const char* location,
|
||||
const char* call);
|
||||
|
||||
extern void GrGLClearErr(const GrGLInterface* gl);
|
||||
|
||||
#if GR_GL_CHECK_ERROR
|
||||
extern bool gCheckErrorGL;
|
||||
#define GR_GL_CHECK_ERROR_IMPL(IFACE, X) \
|
||||
if (gCheckErrorGL) \
|
||||
GrGLCheckErr(IFACE, GR_FILE_AND_LINE_STR, #X)
|
||||
#else
|
||||
#define GR_GL_CHECK_ERROR_IMPL(IFACE, X)
|
||||
#endif
|
||||
|
||||
#if GR_GL_LOG_CALLS
|
||||
extern bool gLogCallsGL;
|
||||
#define GR_GL_LOG_CALLS_IMPL(X) \
|
||||
if (gLogCallsGL) \
|
||||
GrPrintf(GR_FILE_AND_LINE_STR "GL: " #X "\n")
|
||||
#else
|
||||
#define GR_GL_LOG_CALLS_IMPL(X)
|
||||
#endif
|
||||
|
||||
#if GR_GL_PER_GL_FUNC_CALLBACK
|
||||
#define GR_GL_CALLBACK_IMPL(IFACE) (IFACE)->fCallback(IFACE)
|
||||
#else
|
||||
#define GR_GL_CALLBACK_IMPL(IFACE)
|
||||
#endif
|
||||
|
||||
#define GR_GL_CALL(IFACE, X) \
|
||||
do { \
|
||||
GR_GL_CALL_NOERRCHECK(IFACE, X); \
|
||||
GR_GL_CHECK_ERROR_IMPL(IFACE, X); \
|
||||
} while (false)
|
||||
|
||||
#define GR_GL_CALL_NOERRCHECK(IFACE, X) \
|
||||
do { \
|
||||
GR_GL_CALLBACK_IMPL(IFACE); \
|
||||
(IFACE)->f##X; \
|
||||
GR_GL_LOG_CALLS_IMPL(X); \
|
||||
} while (false)
|
||||
|
||||
#define GR_GL_CALL_RET(IFACE, RET, X) \
|
||||
do { \
|
||||
GR_GL_CALL_RET_NOERRCHECK(IFACE, RET, X); \
|
||||
GR_GL_CHECK_ERROR_IMPL(IFACE, X); \
|
||||
} while (false)
|
||||
|
||||
#define GR_GL_CALL_RET_NOERRCHECK(IFACE, RET, X) \
|
||||
do { \
|
||||
GR_GL_CALLBACK_IMPL(IFACE); \
|
||||
(RET) = (IFACE)->f##X; \
|
||||
GR_GL_LOG_CALLS_IMPL(X); \
|
||||
} while (false)
|
||||
|
||||
#define GR_GL_GET_ERROR(IFACE) (IFACE)->fGetError()
|
||||
|
||||
#endif
|
||||
|
@ -13,10 +13,6 @@
|
||||
#include "GrGLConfig.h"
|
||||
#include "GrRefCnt.h"
|
||||
|
||||
#if !defined(GR_GL_FUNCTION_TYPE)
|
||||
#define GR_GL_FUNCTION_TYPE
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
|
@ -253,7 +253,7 @@ HAS_ATLAS:
|
||||
GrFixed tx = GrIntToFixed(glyph->fAtlasLocation.fX);
|
||||
GrFixed ty = GrIntToFixed(glyph->fAtlasLocation.fY);
|
||||
|
||||
#if GR_GL_TEXT_TEXTURE_NORMALIZED
|
||||
#if GR_TEXT_SCALAR_IS_USHORT
|
||||
int x = vx >> 16;
|
||||
int y = vy >> 16;
|
||||
int w = width >> 16;
|
||||
|
@ -72,10 +72,79 @@ GrGLSLVersion GrGLGetGLSLVersion(const GrGLInterface*);
|
||||
* Helpers for glGetError()
|
||||
*/
|
||||
|
||||
extern void GrGLCheckErr(const GrGLInterface* gl,
|
||||
const char* location,
|
||||
const char* call);
|
||||
void GrGLCheckErr(const GrGLInterface* gl,
|
||||
const char* location,
|
||||
const char* call);
|
||||
|
||||
extern void GrGLClearErr(const GrGLInterface* gl);
|
||||
void GrGLClearErr(const GrGLInterface* gl);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Macros for using GrGLInterface to make GL calls
|
||||
*/
|
||||
|
||||
// internal macro to conditionally call glGetError based on compile-time and
|
||||
// run-time flags.
|
||||
#if GR_GL_CHECK_ERROR
|
||||
extern bool gCheckErrorGL;
|
||||
#define GR_GL_CHECK_ERROR_IMPL(IFACE, X) \
|
||||
if (gCheckErrorGL) \
|
||||
GrGLCheckErr(IFACE, GR_FILE_AND_LINE_STR, #X)
|
||||
#else
|
||||
#define GR_GL_CHECK_ERROR_IMPL(IFACE, X)
|
||||
#endif
|
||||
|
||||
// internal macro to conditionally log the gl call using GrPrintf based on
|
||||
// compile-time and run-time flags.
|
||||
#if GR_GL_LOG_CALLS
|
||||
extern bool gLogCallsGL;
|
||||
#define GR_GL_LOG_CALLS_IMPL(X) \
|
||||
if (gLogCallsGL) \
|
||||
GrPrintf(GR_FILE_AND_LINE_STR "GL: " #X "\n")
|
||||
#else
|
||||
#define GR_GL_LOG_CALLS_IMPL(X)
|
||||
#endif
|
||||
|
||||
// internal macro that does the per-GL-call callback (if necessary)
|
||||
#if GR_GL_PER_GL_FUNC_CALLBACK
|
||||
#define GR_GL_CALLBACK_IMPL(IFACE) (IFACE)->fCallback(IFACE)
|
||||
#else
|
||||
#define GR_GL_CALLBACK_IMPL(IFACE)
|
||||
#endif
|
||||
|
||||
// makes a GL call on the interface and does any error checking and logging
|
||||
#define GR_GL_CALL(IFACE, X) \
|
||||
do { \
|
||||
GR_GL_CALL_NOERRCHECK(IFACE, X); \
|
||||
GR_GL_CHECK_ERROR_IMPL(IFACE, X); \
|
||||
} while (false)
|
||||
|
||||
// Variant of above that always skips the error check. This is useful when
|
||||
// the caller wants to do its own glGetError() call and examine the error value.
|
||||
#define GR_GL_CALL_NOERRCHECK(IFACE, X) \
|
||||
do { \
|
||||
GR_GL_CALLBACK_IMPL(IFACE); \
|
||||
(IFACE)->f##X; \
|
||||
GR_GL_LOG_CALLS_IMPL(X); \
|
||||
} while (false)
|
||||
|
||||
// same as GR_GL_CALL but stores the return value of the gl call in RET
|
||||
#define GR_GL_CALL_RET(IFACE, RET, X) \
|
||||
do { \
|
||||
GR_GL_CALL_RET_NOERRCHECK(IFACE, RET, X); \
|
||||
GR_GL_CHECK_ERROR_IMPL(IFACE, X); \
|
||||
} while (false)
|
||||
|
||||
// same as GR_GL_CALL_RET but always skips the error check.
|
||||
#define GR_GL_CALL_RET_NOERRCHECK(IFACE, RET, X) \
|
||||
do { \
|
||||
GR_GL_CALLBACK_IMPL(IFACE); \
|
||||
(RET) = (IFACE)->f##X; \
|
||||
GR_GL_LOG_CALLS_IMPL(X); \
|
||||
} while (false)
|
||||
|
||||
// call glGetError without doing a redundant error check or logging.
|
||||
#define GR_GL_GET_ERROR(IFACE) (IFACE)->fGetError()
|
||||
|
||||
#endif
|
||||
|
@ -843,6 +843,19 @@ bool GrGpuGLShaders::flushGraphicsState(GrPrimitiveType type) {
|
||||
void GrGpuGLShaders::postDraw() {
|
||||
}
|
||||
|
||||
#if GR_TEXT_SCALAR_IS_USHORT
|
||||
#define TEXT_COORDS_GL_TYPE GR_GL_UNSIGNED_SHORT
|
||||
#define TEXT_COORDS_ARE_NORMALIZED 1
|
||||
#elif GR_TEXT_SCALAR_IS_FLOAT
|
||||
#define TEXT_COORDS_GL_TYPE GR_GL_FLOAT
|
||||
#define TEXT_COORDS_ARE_NORMALIZED 0
|
||||
#elif GR_TEXT_SCALAR_IS_FIXED
|
||||
#define TEXT_COORDS_GL_TYPE GR_GL_FIXED
|
||||
#define TEXT_COORDS_ARE_NORMALIZED 0
|
||||
#else
|
||||
#error "unknown GR_TEXT_SCALAR type"
|
||||
#endif
|
||||
|
||||
void GrGpuGLShaders::setupGeometry(int* startVertex,
|
||||
int* startIndex,
|
||||
int vertexCount,
|
||||
@ -881,10 +894,11 @@ void GrGpuGLShaders::setupGeometry(int* startVertex,
|
||||
GrGLenum scalarType;
|
||||
bool texCoordNorm;
|
||||
if (currLayout & kTextFormat_VertexLayoutBit) {
|
||||
scalarType = GrGLTextType;
|
||||
texCoordNorm = GR_GL_TEXT_TEXTURE_NORMALIZED;
|
||||
scalarType = TEXT_COORDS_GL_TYPE;
|
||||
texCoordNorm = SkToBool(TEXT_COORDS_ARE_NORMALIZED);
|
||||
} else {
|
||||
scalarType = GrGLType;
|
||||
GR_STATIC_ASSERT(GR_SCALAR_IS_FLOAT);
|
||||
scalarType = GR_GL_FLOAT;
|
||||
texCoordNorm = false;
|
||||
}
|
||||
|
||||
@ -902,7 +916,7 @@ void GrGpuGLShaders::setupGeometry(int* startVertex,
|
||||
// position and tex coord offsets change if above conditions are true
|
||||
// or the type/normalization changed based on text vs nontext type coords.
|
||||
bool posAndTexChange = allOffsetsChange ||
|
||||
(((GrGLTextType != GrGLType) || GR_GL_TEXT_TEXTURE_NORMALIZED) &&
|
||||
(((TEXT_COORDS_GL_TYPE != GR_GL_FLOAT) || TEXT_COORDS_ARE_NORMALIZED) &&
|
||||
(kTextFormat_VertexLayoutBit &
|
||||
(fHWGeometryState.fVertexLayout ^ currLayout)));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user