Commit Graph

84 Commits

Author SHA1 Message Date
Harley Acheson d5261e973b BLF: Do Not Preload Glyph Cache
This patch turns off the preloading of ascii glyphs and instead caches
each glyph the first time it is actually used.

See D12215 for much more detail.

Differential Revision: https://developer.blender.org/D12215

Reviewed by Campbell Barton
2021-08-14 13:50:51 -07:00
Harley Acheson 6a4533dd02 BLF Cleanup: Size Defines, Comments, etc
This patch makes some non-functional changes to BLF code. Some size
defines added, comments changed, simplification of macro
BLF_KERNING_VARS.

See D12200 for more details.

Differential Revision: https://developer.blender.org/D12200

Reviewed by Campbell Barton
2021-08-13 14:31:10 -07:00
Harley Acheson cd1bb63159 BLF: Do Not Cache Unused Rendered Glyphs
The loading of a font size or style renders bitmaps of the characters
0-255 and stores them in a cache. But glyphs 128-255 in this cache are
not accessible. What used to be ansi high-bit characters are now multi-
byte UTF-8 sequences.

Therefore this patch reduces the glyph_ascii_table size to 128 and
only caches characters 32-127, the visible portion of ASCII, which
greatly reduces the time to load a font.

See D12189 for more details.

Differential Revision: https://developer.blender.org/D12189

Reviewed by Campbell Barton
2021-08-11 13:55:58 -07:00
Jacques Lucke 91694b9b58 Code Style: use "#pragma once" in source directory
This replaces header include guards with `#pragma once`.
A couple of include guards are not removed yet (e.g. `__RNA_TYPES_H__`),
because they are used in other places.

This patch has been generated by P1561 followed by `make format`.

Differential Revision: https://developer.blender.org/D8466
2020-08-07 09:50:34 +02:00
Harley Acheson b74cc23dc4 UI: Ability to Print Bold and Italics
Adds the ability to print text in bold or italics style, synthesized from a single base UI font.

Differential Revision: https://developer.blender.org/D7893

Reviewed by Brecht Van Lommel
2020-06-05 15:39:17 -07:00
Campbell Barton ccaab72685 BLF: use 'int' for internal glyph x,y bearing
These were stored as float but were originally cast from an int
and were often cast back to int.

Also use int pairs for dimensions values.
2020-05-03 18:01:20 +10:00
Dalai Felinto 2d1cce8331 Cleanup: `make format` after SortedIncludes change 2020-03-19 09:33:58 +01:00
Germano Cavalcante 41dbb06b76 Fix T74228, T74246: Strange Characters
The glyph can come from a different cache.
2020-02-27 10:55:07 -03:00
Germano Cavalcante 001f7c92d1 BLF: Optimize text rendering and caching
The current code allocates and transfers a lot of memory to the GPU,
but only a small portion of this memory is actually used.
In addition, the code calls many costly gl operations during the
caching process.

This commit significantly reduce the amount of memory by allocating
and transferring a flat array without pads to the GPU.
It also calls as little as possible the gl operations during the cache.

This code also simulate a billinear filter `GL_LINEAR` using a 1D texture.

**Average drawing time:**
|before:|0.00003184 sec
|now:|0.00001943 sec
|fac:|1.6385156675048407

**5 worst times:**
|before:|[0.001075, 0.001433, 0.002143, 0.002915, 0.003242]
|now:|[0.00094, 0.000993, 0.001502, 0.002284, 0.002328]

Differential Revision: https://developer.blender.org/D6886
2020-02-24 08:01:22 -03:00
Campbell Barton 76e6d2f19d Cleanup: spelling
Also remove historic bftgl reference.
2019-10-17 12:40:36 +11:00
Richard Antalik a960dc4519 BLF: make library glyph cache handling thread-safe
Functions that utilize glyph cache should lock and unlock cache by
calling `blf_glyph_cache_acquire()` and `blf_glyph_cache_release()`.
Function `blf_glyph_cache_acquire()` will create glyph cache, if it doesn't exist.
Locking mutex is global and shared by all fonts.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5701
2019-09-13 17:24:42 -07:00
Campbell Barton e12c08e8d1 ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.

For details on usage and instructions for migrating branches
without conflicts, see:

https://wiki.blender.org/wiki/Tools/ClangFormat
2019-04-17 06:21:24 +02:00
Campbell Barton de13d0a80c doxygen: add newline after \file
While \file doesn't need an argument, it can't have another doxy
command after it.
2019-02-18 08:22:12 +11:00
Campbell Barton eef4077f18 Cleanup: remove redundant doxygen \file argument
Move \ingroup onto same line to be more compact and
make it clear the file is in the group.
2019-02-06 15:45:22 +11:00
Campbell Barton 65ec7ec524 Cleanup: remove redundant, invalid info from headers
BF-admins agree to remove header information that isn't useful,
to reduce noise.

- BEGIN/END license blocks

  Developers should add non license comments as separate comment blocks.
  No need for separator text.

- Contributors

  This is often invalid, outdated or misleading
  especially when splitting files.

  It's more useful to git-blame to find out who has developed the code.

See P901 for script to perform these edits.
2019-02-02 01:36:28 +11:00
Richard Antalik b3dbe17658 Add font selection to VSE text strips
Allows users to select a font for text strips in the video sequence editor.

Related: 3610f1fc43 Sequencer: refactor clipboard copy to no longer increase user count.

Reviewed by: Brecht

Differential Revision: https://developer.blender.org/D3621
2019-01-13 21:57:09 -08:00
Clément Foucault 8cd7828792 GWN: Port to GPU module: Replace GWN prefix by GPU 2018-07-18 11:49:15 +02:00
Clément Foucault 247ad2034d GWN: Port to GPU module: Move files to GPU
This does not include all the struct and type renaming. Only files were
renamed.

gwn_batch.c/h was fusioned with GPU_batch.c/h
gwn_immediate.c/h was fusioned with GPU_immediate.c/h
gwn_imm_util.c/h was fusioned with GPU_immediate_util.c/h
2018-07-18 00:17:57 +02:00
Campbell Barton c517778a8b Cleanup: style 2018-06-22 08:18:02 +02:00
Ray Molenkamp 84ae0fe3a5 GLRefactor: Refactor bf_blenfont to use GPUTexture instead of raw GL calls and types.
In an effort to centralize all opengl calls in the codebase, this patch replaces
the raw opengl calls in bf_blenfont with GPUTexture so it's no longer depended
on opengl headers.

reviewer: Brecht

Differential Revision: https://developer.blender.org/D3483
2018-06-21 18:36:05 -06:00
Campbell Barton 908b6960c0 Merge branch 'master' into blender2.8 2018-06-08 08:10:35 +02:00
Campbell Barton a25c11fd8d Cleanup: trailing space
Remove from blender/nodes, collada, blenfont & render.
2018-06-08 08:07:48 +02:00
Campbell Barton bfe1d0e0dc Merge branch 'master' into blender2.8 2018-06-01 18:26:42 +02:00
Campbell Barton 75fc1c3507 Cleanup: trailing whitespace (comment blocks)
Strip unindented comment blocks - mainly headers to avoid conflicts.
2018-06-01 18:19:39 +02:00
Campbell Barton 122d0d1504 Cleanup: style 2018-04-21 20:42:27 +02:00
Clément Foucault 0b5ebb3265 BLF: Fix problem with bound texture.
Previous code was assuming that the glyph texture would remain bound to
GL_TEXTURE0 until the cache would be drawn. This is not always the case,
so better save the texture and rebind it before drawing.
2018-04-08 01:14:43 +02:00
Campbell Barton b65ea517eb Merge branch 'master' into blender2.8
- Undo that changes modes currently asserts,
  since undo is now screen data.

  Most likely we will change how object mode and workspaces work
  since it's not practical/maintainable at the moment.

- Removed view_layer from particle settings
  (wasn't needed and complicated undo).
2018-04-01 11:03:25 +02:00
Clément Foucault f9691bae84 BLF: Perf: Add a kerning cache table for ascii chars.
This adds less than a megabyte of mem usage.
FT_Get_Kerning was the 2nd hotspot when profilling. This commit completly
remove this cost.

One concern though: I don't know if the kerning data is constant for every
sizes but it seems to be the case. I tested different fonts at different
dpi scalling and saw no differences.
2018-03-31 19:32:53 +02:00
Campbell Barton 22d40fdfd8 Cleanup: blf internal struct naming
- use x/y/width/height/max as a suffix.
- replace 'num' prefix /w 'len' suffix.
2018-03-31 13:40:23 +02:00
Campbell Barton 0ef38879b3 Cleanup: BLF batch drawing naming
- batching -> batch_draw.
- ct & size -> len.
- start/end -> begin/end (follow GL convention).
2018-03-31 13:11:38 +02:00
Clément Foucault 4241d6a9cc BFL: Fix broken vertical texts.
I've made a separate version of the geom shader that works with full
3D modelviewmat.

This commit also includes some fixup inside blf_batching_start().
2018-03-30 22:50:17 +02:00
Clément Foucault 963e48e1df BLF: Add Batching capabilities.
You can now use BLF_batching_start and BLF_batching_end to batch every
drawcall to BLF together minimizing the overhead introduced by BLF and the
opengl driver.

These calls cannot be nested (for now).

If the modelview matrix changes, previously batched calls are issued and a
the process resume with the new matrix.

However the projection matrix MUST not change and gl scissors as well.
2018-03-30 20:59:45 +02:00
Clément Foucault ab9adf9cdc BLF: Use Batch API instead of IMM.
This is not a perfect win just yet. It's now calling glBufferSubData for
every call (instead of using glMapBufferRange which is almost faster), but
with this system we will be able to batch drawcalls together.

See next commit.
2018-03-30 20:09:26 +02:00
Julian Eisel 69713aa2da Cleanup: Quiet warnings, use RAD2DEG macro 2016-10-16 17:28:12 +02:00
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