Commit Graph

50 Commits

Author SHA1 Message Date
Mike Erwin 1deab69e0a BLF/OpenGL: more text drawing optimization
Make color values compact. Set color once per primitive. Use new immSkipAttrib to avoid useless color copies.

All of this should make text drawing less CPU hungry.
2016-10-16 02:08:16 -04:00
Mike Erwin a8dc3f4596 BLF: make blurry text an optional (disabled) feature
While trying to simplify text drawing, noticed no Blender code uses the blur feature. Hopefully scripts don't use it!
2016-10-15 19:40:41 -04:00
Mike Erwin 87fac9a816 use float (not double) for font matrix
Following up on recent double --> float commits in the game engine.
2015-12-14 22:28:12 -05:00
Campbell Barton f2341f8296 BLF: initial word-wrap support
- Adds support for word wrapping to Blender's BLF font library.
- Splits lines when width limit is reached or on explicit \n newlines.

Details:

- Word wrapping is used when `BLF_WORD_WRAP` flag is enabled.
- There is a single loop to handle line wrapping,
  this runs callback, passing in a substring,
  this way we can avoid code-duplication for all word-wrapped
  versions of functions... OR... avoid having to add support
  for word-wrapping directly into each function.
- The `ResultBLF` struct was added to be able to get the number
  of wrapped lines, when calling otherwise unrelated functions
  such as `BLF_draw/BLF_width/BLF_boundbox`,
  which can be passed as the last argument to `BLF_*_ex()` functions.
- The `ResultBLF` struct is used to store the result of drawing
  (currently only the number of lines wrapped, and the width).
2015-09-18 20:43:52 +10:00
Campbell Barton c56c493cf4 BLF: use regular unsigned int's
So GL isnt needed to include BLF types.
2015-04-08 10:30:18 +10:00
Campbell Barton 1ae11f71ff BLF: avoid float/int conversion drawing glyphs
also use UNLIKELY for error cases
2014-07-16 11:12:19 +10:00
Campbell Barton 2924a02a35 move strict compiler checks into a header so its easier to manage in one place (pragmas were copied around).
also enable more strict warnings for BLF (which had some incorrect casts).
2013-09-01 00:46:04 +00:00
Brecht Van Lommel 0d7dbbb6e1 Fix #35884: crash opening .blend with generated color grid image and preview render.
Printing text on the color grid image would initialize font glyphs from a thread at
the same time as the UI, causing conflicts. The freetype glyph renderer needs to be
mutex locked because it uses a shared buffer internally even when rendering for
different fonts. Also needed to change the image generate function to use the render
monospace font to avoid conflicts in blenfont.

What's still weak in the blenfont API is that there is no distinction between a font
and a thread using that font to render with some particular size, style, etc.
2013-06-28 13:05:15 +00:00
Campbell Barton 0d36225dd1 quiet sign conversion warnings and reduce sign conversion for BLI_string, and BLF. 2013-05-12 06:33:21 +00:00
Campbell Barton 60c1a7898a use radians for BLF_rotation 2013-02-21 17:15:19 +00:00
Sergey Sharybin a73dd3476e Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.

This introduces two configurable color spaces:

- Input color space for images and movie clips. This space is used to convert
  images/movies from color space in which file is saved to Blender's linear
  space (for float images, byte images are not internally converted, only input
  space is stored for such images and used later).

  This setting could be found in image/clip data block settings.

- Display color space which defines space in which particular display is working.

  This settings could be found in scene's Color Management panel.

When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.

This conversions are:

- View, which defines tone curve applying before display transformation.
  These are different ways to view the image on the same display device.
  For example it could be used to emulate film view on sRGB display.

- Exposure affects on image exposure before tone map is applied.

- Gamma is post-display gamma correction, could be used to match particular
  display gamma.

- RGB curves are user-defined curves which are applying before display
  transformation, could be used for different purposes.

All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.

This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).

Some technical notes:

- Image buffer's float buffer is now always in linear space, even if it was
  created from 16bit byte images.

- Space of byte buffer is stored in image buffer's rect_colorspace property.

- Profile of image buffer was removed since it's not longer meaningful.

- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
  to support other spaces, but it's quite large project which isn't so
  much important.

- Legacy Color Management option disabled is emulated by using None display.
  It could have some regressions, but there's no clear way to avoid them.

- If OpenColorIO is disabled on build time, it should make blender behaving
  in the same way as previous release with color management enabled.

More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management

--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
Campbell Barton 10f631094c fix [#32126] STAMP: Setting a background color causes color flicker
when rendering the sequencer can output float or char buffers which stamp wasn't accounting for.
2012-08-12 22:50:21 +00:00
Campbell Barton 866f986898 fix for stamp text drawing into a color buffer not taking color management into account. 2012-08-12 22:18:20 +00:00
Jason Wilkins a0ce240de9 Renamed "fake" OpenGL identifiers.
Any identifier that looks like an OpenGL identifier, but isn't, causes a false alarm by the glreport.py tool.  Most of these were in comments so I just rephrased the comments.  There were a couple of static functions/macros that were easy enough to rename.  Only the glTexco and glIndex fields of the DMVertexAttribs struct was public and had non-local uses.
2012-05-04 11:50:11 +00:00
Campbell Barton 2b7ca2304a unify include guard defines, __$FILENAME__
without the underscores these clogged up the namespace for autocompleation which was annoying.
2012-02-17 18:59:41 +00:00
Campbell Barton 4a04f72069 remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
Campbell Barton 100313db6e Speedup for font drawing, every letter was character was calling:
glGetIntegerv(GL_TEXTURE_2D_BINDING_EXT, &cur_tex);

... with shadow enabled glGetFloatv(GL_CURRENT_COLOR, color) was called twice per character as well.


Now only call glGetFloatv(GL_CURRENT_COLOR, ...) once per string and only when drawing with shadow or blur, texture bind is stored in the font.

Gives 8% overall FPS speedup when displaying heavy UI in my test.
2011-09-17 10:45:20 +00:00
Campbell Barton 156e96762b fix for changing font sizes with recent utf8 speedup 2011-09-12 09:12:34 +00:00
Campbell Barton 03c362f1ab fix [#27221] stamp text bug in lower lines 2011-04-30 08:54:06 +00:00
Nathan Letwory b9e70c743b doxygen: blender/blenfont tagged. 2011-02-27 20:42:42 +00:00
Nathan Letwory 5b607701a7 doxygen: prevent GPL license block from being parsed as doxygen comment. 2011-02-23 10:52:22 +00:00
Diego Borghetti 65ce537c6c Rename global_ft_lib and make it static.
Remove the XXX code from blf_glyph.c and use the pointer
inside the FontBLF struct.

If still have problem, let me know.
2011-02-19 13:43:22 +00:00
Diego Borghetti 545cc4803e Change the BLF_aspect function to handle 3d text.
This is need to properly handle 3d text (dalai work on GE), before
the BLF_aspect only take one argument, and the result was a call to:
	glScalef(aspect, aspect, 1.0)

Now the three value are store in the font (x, y and z) and also
need to be enable using BLF_enable(BLF_ASPECT).

By default all the code that don't have BLF_ASPECT enable work with
a scale of 1.0 (so nothing change to the current UI).

I also remove all the call of BLF_aspect(fontid, 1.0) found in
the editors, because is disable by default, so no need any more.

Campbell the only thing to check is the python api, right now
I modify the api to from:
	BLF_aspect(fontid, aspect)
to:
	BLF_aspect(fontid, aspect, aspect, 1.0)

This is to avoid break the api, but now you need add the BLF_ASPECT
option to the function py_blf_enable and in some point change
py_blf_aspect to take 3 arguments.
2010-12-09 22:27:55 +00:00
Diego Borghetti b25c32393d Add the possibility to set a 4x4 matrix to be used on blf.
This option allow the user to set a 4x4 matrix to be
multiplied before draw the text, for example:

	double *m;

	/* Get the matrix or build it! */

	BLF_matrix(m);
	BLF_enable(BLF_MATRIX);

	/* set color, size, etc and draw! */

	BLF_disable(BLF_MATRIX);

You don't need the last line (disable), but remember
that if you use the font to draw in any other place,
the matrix will be used!.

The GL code is:

	glPushMatrix();
	glMultMatrixd(m);
	glTranslatef();
	glScalef();
	glRotatef();

	glPopMatrix();

Let's Dalai test this!!! :D
2010-12-09 04:36:58 +00:00
Campbell Barton b349f7c99d Minor speedups for 3D view text drawing ~10-15% improved frame-rate with particle display.
- ascii text drawing functions, slightly faster since they dont have to do hash lookups & utf8 conversions for each char.
- used ascii drawing functions for the view3d's number display.
- each text item was using fixed 128 chars, now only allocate the string length needed.
2010-10-30 23:02:38 +00:00
Campbell Barton 081c1205a3 correct fsf address 2010-02-12 13:34:04 +00:00
Diego Borghetti 7d812822bd Stamp info back only for float buffer. (next commit add unsigned char).
A couple of new functions:
	BLF_width_and_height	- Merge of BLF_width and BLF_height in one call to avoid freetype2 stuff.
	BLF_buffer		- Set the buffer, size and number of channel.
	BLF_buffer_col		- Set the text color (the alpha is not used right now).
	BLF_draw_buffer		- Draw the text in the current buffer.

Also tweak a little the boundbox and draw function to avoid access the freetype2 and use the cache info.
By default the font size is 12, the UI still need work to allow change the font and size.
2009-08-18 19:26:53 +00:00
Diego Borghetti d5f51f5019 Cleanup a little to add "draw to buffer" (and bring back stamp). 2009-08-06 20:51:41 +00:00
Diego Borghetti 74b3681532 Remove bitmap mode from blenfont, only draw with textures.
As Joe point on a previous mail, glBitmap don't work nice
on all cards and also some of the things that we can do
with texture are hard (or need that blender check the font mode)
to implement.
2009-08-06 20:06:02 +00:00
Diego Borghetti ad59d04c77 Yes!! a nice font again!!
Matt, I found the problem in one of my previous commit, so I revert
all my changes and now the font look good again.

Also remove all the options (kerning, overlap and user kerning), I want
to make this a little better.
2009-07-10 20:18:19 +00:00
Diego Borghetti cb59bf722e Move shadow option (for text) from editor/interface to blenfont.
Two new function:
 BLF_shadow: set the level (for blur) and the shadow color.
 BLF_shadow_offset: set the x and y offset for shadow.
		 (this is the current position plus offset)

By default shadow is not enable in the font, so before draw the
text you need call BLF_enable(BLF_SHADOW), also remember disable
the option in the end.
2009-06-23 16:27:35 +00:00
Diego Borghetti 845e9a0e25 Made the kerning a float, this give a little more of tweak.
0.5 is the default value now, the range are from -5.0 to 5.0.
Note that we allow negative value, but the current draw code
always check for overlap characters.
2009-06-12 17:18:59 +00:00
Diego Borghetti ec8b2593ec Smal tweak to allow the user set a kerning value.
This commit add two option to the blenfont library:

1) BLF_FONT_KERNING

 This enable the kerning information that come with the
font, by default this option is disable and still don't
have a UI for change.

2) BLF USER_KERNING
 This allow the user set a kerning value to by apply for
every character, by default this option is enable but all
the font have a kerning value of zero.

Ton I add this option to the style with a default value of 1.

Access from:
 Outliner -> User Preferences -> Style -> FontStyle -> Kerning
2009-06-11 21:43:59 +00:00
Diego Borghetti 749a908331 Cleanup blendfont.
Now that we only work with Freetype2, I don't see any point to keep
wrapping the functions.

Also remove the reference code, it's something that we don't go to used.
2009-05-08 19:47:40 +00:00
Diego Borghetti 405cf80eb8 Big, big commit!!
1) Remove WITH_FREETYPE2 from code, so now blender always need freetype2
2) Remove the old bmfont
3) Remove ftfont and bFTGL library
4) Implement a new BLF_draw_default function for place that still need/use
   the old BMF api.

I try to update both, scons and cmake, but I only can test with make, so
hope all work fine.

MSVC is broken, but I don't have Windows, things to search and fix are
any reference to WITH_FREETYPE2, FTGL and BMFONT (take in care that
blenkernel also have a BKE_bmfont.h, this don't have anything to do with bmfont).
        Always have to link/include the freetype2 library
        Remove any reference to libbmfont
        Remove any reference to libftfont
        Remove any reference to libbftgl (or libbFTGL)
2009-05-05 23:10:32 +00:00
Diego Borghetti efd1a69d6c Move texture draw to blf_util.c, now both font used it.
A little cleanup on the internal font, it's possible load the old
bmfont with: BLF_load_mem(name, NULL, 0) where name can be: helv,
helvb or scr.

Note that the internal font also support both draw, texture and bitmap,
by default always used texture.

Remove some old lang function that I left there and don't exist any more
because the locale are now in the RNA.

Small changes to Style's, so if we build without freetype2 by default
go back to the internal font, this is a little ugly (and have the old
problem of scale) but now blender always show text (need work a little
more there).
2009-04-23 21:57:41 +00:00
Ton Roosendaal 6124933781 2.5
Nicer implementation of blurred font draw, moved to blenfont
module. Set it with BLF_blur(value). Current kernels implemented
are 3 and 5 only. Blenfont module can extend this once.
2009-04-10 14:27:29 +00:00
Diego Borghetti 59190778a8 New Bitmap draw mode for Freetype2 fonts.
The library can load any font supported by the Freetype2 library or
used the internal bitmap font.

With both types it's possible draw the text as texture or bitmap,
and using texture it's possible rotate, scale and clipping text.

Still have things to fix/add, but I think it's ready to move-on
and start droping the old api, most of (if it's not all) the
editors/interface/text.c will be remove, but some things still
has to be define, like:

 * Where is store the fonts ? (default font, panel font, filesel font, etc)
   I mean, every space have own fonts ? or we keep it on the context ?
   It's not a really problem from the blenfont side, because every font
   have reference number, so it's load only the first time.

 * What we do about gettext ?
   Keep the old system that call gettext inside the blenfont or replace
   it for _() in the Blender source ?
   Also things like pupmen has to be take care, if we want translate the menu.

Ok, time to sleep, back tomorrow to start moving the things :)
2009-04-07 08:42:28 +00:00
Diego Borghetti e430816cde Add back bitmap draw mode, right now only internal font, tomorrow
freetype2.
2009-04-06 04:12:31 +00:00
Diego Borghetti 4861ddf350 Small cleanup, all this options are now in the User Preferences, RNA. 2009-03-31 21:19:23 +00:00
Diego Borghetti 22fec544c8 Add blender internal font.
This is the old bmfont library but using textures.

I made small test in the space Info and work fine,
commit now to finish tomorrow from work.
2009-03-30 05:32:46 +00:00
Diego Borghetti 63b4879c9e And another commit to cleanup a little, this is the last,
next commit add internal font and we can go ahead and remove
ftfont and bmfont.
2009-03-02 21:02:39 +00:00
Diego Borghetti acc8d06b77 Cleanup a little before add internal font (bmfont). 2009-03-02 05:20:48 +00:00
Diego Borghetti 8145489a7d Add clipping text option to blenfont also add an enable/disable
function for aspect and rotation (and the new clipping).

Update source/Makefile to point to the new libed_sculpt_paint.
2009-02-20 05:42:44 +00:00
Diego Borghetti 6bf9f383dc 4 new function, boundbox, width, height and rotation.
The rotation is through glRotatef and as you can see it's ugly,
the freetype2 allow apply a transformation (2x2 mat) to the glyph
before load, so I want to try using that.
Another thing to add is the 4x4 mat to get the scale and size from
there.. but I need commit this now to continue from my home.
2009-02-19 16:39:36 +00:00
Diego Borghetti 16a61743e1 Making the things compiled!!
I change the #if 0 with #if WITH_FREETYPE2, also fix a lot of typos, etc.
This is the basic but now it draw text!!, I am using the "User Preference"
space to test the library, nobody is working on that and the option are
in the outliner now so...

TODO-next: using the 4x4 mat, string size, bounding box, aspect and rotate.

Notes: I update the Makefile, missing some include and other things so
maybe scons, cmake and msvc also need update ?
2009-02-17 16:56:29 +00:00
Diego Borghetti a150242f8e Commit to continue tomorrow from work. 2009-02-12 05:02:42 +00:00
Diego Borghetti 2c82163d5b commit to continue in my home.
Also I remove some of the #if 0.
2009-02-10 21:41:14 +00:00
Diego Borghetti b9063b27a9 Just commit so I can continue tomorrow from work.
All the code have #if 0 / #endif so nothing to worry about.
2009-02-09 07:15:22 +00:00
Diego Borghetti 6e08a165bb Moving Language code from interface/text.c to blenfont library.
I go to start commit the new code here and then replace one
by one bmfont and ftfont, this do nothing right now, but it's
more easy keep the files here to work from the studio and my home.

I only update the Makefile and SConscript (but JesterKing a double
check never is bad), so please check the msvc and cmake files.

The new library is libblenfont.a
2009-01-29 05:19:27 +00:00