[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47588] branches/soc-2012-swiss_cheese/ source/blender: For some reason BLF_draw_font is very sensitive to every little change I make .
Jason Wilkins
Jason.A.Wilkins at gmail.com
Thu Jun 7 22:10:04 CEST 2012
Revision: 47588
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47588
Author: jwilkins
Date: 2012-06-07 20:09:55 +0000 (Thu, 07 Jun 2012)
Log Message:
-----------
For some reason BLF_draw_font is very sensitive to every little change I make.
Modified Paths:
--------------
branches/soc-2012-swiss_cheese/source/blender/blenfont/intern/blf.c
branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate.c
branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_primitives.c
Modified: branches/soc-2012-swiss_cheese/source/blender/blenfont/intern/blf.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/blenfont/intern/blf.c 2012-06-07 19:56:38 UTC (rev 47587)
+++ branches/soc-2012-swiss_cheese/source/blender/blenfont/intern/blf.c 2012-06-07 20:09:55 UTC (rev 47588)
@@ -459,7 +459,7 @@
void BLF_draw_default_unlock(void)
{
if (get_default()) {
- BLF_draw_unlock();
+ BLF_draw_unlock(global_font_default);
}
}
@@ -492,52 +492,73 @@
static void draw_lock(FontBLF *font)
{
- /* one time GL setup */
- if (gpuImmediateLockCount() == 0) {
- glEnable(GL_TEXTURE_2D);
+ if (!font) {
+ return;
+ }
+ if (font->locked == 0) {
if (font->shadow || font->blur) {
gpuImmediateFormat_T2_C4_V2(); // DOODLE: blurred and/or shadowed text
}
else {
- gpuImmediateFormat_T2_V2(); // DOODLE: normal text
+ gpuImmediateFormat_T2_V2(); // DOODLE: normal text
}
+
+ /* one-time GL setup */
+ glEnable(GL_TEXTURE_2D);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
+ font->locked++;
}
-void BLF_draw_lock(int fontid)
+static void draw_unlock(FontBLF *font)
{
- FontBLF *font = BLF_get(fontid);
+ if (!font) {
+ return;
+ }
- if (font) {
- draw_lock(font);
+ GPU_ASSERT(font->locked > 0);
+
+ font->locked--;
+
+ if (font->locked == 0) {
+ glDisable(GL_BLEND);
+ glDisable(GL_TEXTURE_2D);
+
+ gpuImmediateUnformat();
}
}
-void BLF_draw_unlock(void)
+void BLF_draw_lock(int fontid)
{
- glDisable(GL_BLEND);
- glDisable(GL_TEXTURE_2D);
+ draw_lock(BLF_get(fontid));
+}
- if (gpuImmediateLockCount() == 1) {
- gpuImmediateUnformat();
- }
+void BLF_draw_unlock(int fontid)
+{
+ draw_unlock(BLF_get(fontid));
}
-static void blf_draw__start(FontBLF *font, GLint *mode, GLint *param)
+static void blf_draw__start(FontBLF *font)
{
- /*
- * The pixmap alignment hack is handle
- * in BLF_position (old ui_rasterpos_safe).
- */
+ /* The pixmap alignment hack is handled
+ in BLF_position (old ui_rasterpos_safe). */
- /* Save the current matrix mode. */
- glGetIntegerv(GL_MATRIX_MODE, mode);
+#if GPU_SAFETY
+ {
+ GLenum mode;
+ GLenum param;
+ glGetIntegerv(GL_MATRIX_MODE, &mode);
+ GPU_ASSERT(mode == GL_MODELVIEW);
+
+ glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, ¶m);
+ GPU_ASSERT(param == GL_MODULATE);
+ }
+#endif
+
glMatrixMode(GL_TEXTURE);
glPushMatrix();
glLoadIdentity();
@@ -545,8 +566,9 @@
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
- if (font->flags & BLF_MATRIX)
+ if (font->flags & BLF_MATRIX) {
glMultMatrixd((GLdouble *)&font->m);
+ }
glTranslatef(font->pos[0], font->pos[1], font->pos[2]);
@@ -565,42 +587,29 @@
/* always bind the texture for the first glyph */
font->tex_bind_state = -1;
- /* Save the current parameter to restore it later. */
- glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, param);
- if (*param != GL_MODULATE)
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
draw_lock(font);
}
-static void blf_draw__end(GLint mode, GLint param)
+static void blf_draw__end(FontBLF *font)
{
- BLF_draw_unlock();
+ draw_unlock(font);
- /* and restore the original value. */
- if (param != GL_MODULATE)
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, param);
-
glMatrixMode(GL_TEXTURE);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
-
- if (mode != GL_MODELVIEW)
- glMatrixMode(mode);
}
void BLF_draw(int fontid, const char *str, size_t len)
{
if (len > 0 && str[0]) {
FontBLF *font = BLF_get(fontid);
- GLint mode, param;
if (font && font->glyph_cache) {
- blf_draw__start(font, &mode, ¶m);
+ blf_draw__start(font);
blf_font_draw(font, str, len);
- blf_draw__end(mode, param);
+ blf_draw__end(font);
}
}
}
@@ -609,12 +618,11 @@
{
if (len > 0 && str[0]) {
FontBLF *font = BLF_get(fontid);
- GLint mode, param;
if (font && font->glyph_cache) {
- blf_draw__start(font, &mode, ¶m);
+ blf_draw__start(font);
blf_font_draw_ascii(font, str, len);
- blf_draw__end(mode, param);
+ blf_draw__end(font);
}
}
}
Modified: branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate.c 2012-06-07 19:56:38 UTC (rev 47587)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate.c 2012-06-07 20:09:55 UTC (rev 47588)
@@ -531,7 +531,7 @@
#endif
if (gpuImmediateLockCount() == 0) {
- gpuImmediateElementSizes(2, 0, 4);
+ gpuImmediateElementSizes(2, 0, 4); //-V112
}
gpuImmediateLock();
@@ -692,7 +692,7 @@
GLint texCoordSizes[1] = { 3 };
GLenum texUnitMap[1] = { GL_TEXTURE0 };
- gpuImmediateElementSizes(3, 0, 4); //V-112
+ gpuImmediateElementSizes(3, 0, 4); //-V112
gpuImmediateTextureUnitCount(1);
gpuImmediateTexCoordSizes(texCoordSizes);
gpuImmediateTextureUnitMap(texUnitMap);
@@ -845,7 +845,7 @@
void gpuGetCurrentColor4fv(GLfloat *restrict color)
{
- GLubyte v[4];
+ GLubyte v[4]; //-V112
GPU_CHECK_CAN_CURRENT();
Modified: branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_primitives.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_primitives.c 2012-06-07 19:56:38 UTC (rev 47587)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_primitives.c 2012-06-07 20:09:55 UTC (rev 47588)
@@ -551,8 +551,8 @@
pointhack = floor(size[0] + 0.5f);
- if (pointhack > 4) {
- pointhack = 4;
+ if (pointhack > 4) { //-V112
+ pointhack = 4; //-V112
}
}
else {
More information about the Bf-blender-cvs
mailing list