Commit Graph

1257 Commits

Author SHA1 Message Date
D G Turner
ac4087856f ALL: Remove optimization unstable code on checking for null after new.
These issues were identified by the STACK tool.

By default, the C++ new operator will throw an exception on allocation
failure, rather than returning a null pointer.

The result is that testing the returned pointer for null is redundant
and _may_ be removed by the compiler. This is thus optimization
unstable and may result in incorrect behaviour at runtime.

However, we do not use exceptions as they are not supported by all
compilers and may be disabled.

To make this stable without removing the null check, you could qualify
the new operator call with std::nothrow to indicate that this should
return a null, rather than throwing an exception.

However, using (std::nothrow) was not desirable due to the Symbian
toolchain lacking a <new> header.
A global solution to this was also not easy by redefining "new" as "new
(std::nothrow)" due to custom constructors in NDS toolchain and various
common classes.

Also, this would then need explicit checks for OOM adding to all new
usages as per C malloc which is untidy.

For now to remove this optimisation unstable code is best as it is
likely to not be present anyway, and OOM will cause a system library
exception instead, even without exceptions enabled in the application
code.
2014-01-15 02:36:19 +00:00
Marcus Comstedt
4b81b1299d GRAPHICS: Fix dest alpha formula in blendPixelPtr
The original alpha computation formula had a problem:  If something was
drawn on top of a pixel that was already fully opaque, there would be
an overflow in the computed alpha, and the destination alpha would be
truncated to 0 (fully transparent).

In commit 264ba4a9 this formula was replaced with another one, which
did not have overflows but also was not correct.

This commits introduces a new formula, where the rounding errors have
been turned in another direction; drawing a fully opaque pixel on top
of a transparent one would result in a pixel which is almost, but not
fully, opaque.  However, this is no problem in practice, since drawing
fully opaque pixels can be achieved with much less code as a special
case, so add that (also improves rendering speed).
2014-01-10 20:04:10 +01:00
Marcus Comstedt
51d7405a7b GRAPHICS: Fix computation of addA in darkenFill()
The old computation had rounding issues, causing alpha to leak into
the red (usually) component.  There's a much easier way to compute it
that does not lead to such problems:  What should really happen is that
the two top bits of the A component should be set to 1 (thus adding
75% alpha).  So compute it that way for speed and precision.
2014-01-10 15:56:53 +01:00
D G Turner
094c378217 GRAPHICS: Minor readability fixes to drawBevelSquareAlg method.
No functional change.
2013-12-13 23:41:24 +00:00
Johannes Schickel
b6f32028e1 GRAPHICS: Document loadTTFFont a bit. 2013-12-08 20:11:59 +01:00
Eugene Sandulenko
3e85976877 GRAPHICS: Initialize variable. CID 1133708 2013-12-01 00:51:09 +02:00
Johannes Schickel
14d328faca GRAPHICS: Fix SharedPtrSurfaceDeleter for nullptr inputs. 2013-11-27 19:44:54 +01:00
Johannes Schickel
9da09f5846 GRAPHICS: Allow Font to accept U32String as strings. 2013-11-23 21:34:54 +01:00
Johannes Schickel
09c634dd55 GRAPHICS: Allow TTFFont to cache glyphs when required.
This should allow TTFFont to display UTF-32 characters from fonts.
2013-11-23 21:34:54 +01:00
Johannes Schickel
13d470dc61 GRAPHICS: Get rid of _glyphSlots in TTFFont. 2013-11-23 21:34:54 +01:00
Johannes Schickel
afa3f50b8a GRAPHICS: Let Font take uint32 as character codes.
This is required to support UTF-32 strings but does not make them work
automatically!
2013-11-23 21:34:54 +01:00
Alyssa Milburn
575f81da5f GRAPHICS: Set PNG alpha bits to 0 if there's no alpha present.
This fixes the color-keying checks in Wintermute for PNG images.
2013-11-12 10:57:25 +01:00
Matthew Hoops
aea224e260 ALL: Mark off common code used by ZVision 2013-10-26 10:39:36 -04:00
peres
070558c4c4 GRAPHICS: do not reset the extra parameters of IFFDecoder on destroy().
The two properties that control pixel packing and the size of the
surface need to be preserved for loadStream() to work correctly.
They are now under complete responsibility of the client.
2013-10-26 23:26:22 +09:00
peres
69be9adf52 Revert "GRAPHICS: do not clear the internal state of IFFDecoder on loadStream()."
This reverts commit 92c1ff31d6.
2013-10-26 23:26:22 +09:00
Matthew Hoops
091bcbf313 GRAPHICS: Have TGA's loadStream() call destroy() 2013-10-26 10:21:08 -04:00
Matthew Hoops
1b3eee6d78 GRAPHICS: Clarify implicit destroy() usage 2013-10-26 10:21:03 -04:00
peres
92c1ff31d6 GRAPHICS: do not clear the internal state of IFFDecoder on loadStream().
This decoder needs to keep track of client parameters that control
how the pixels are going to be packaged, so the responsibility for
clearing the state has been moved on the client (using the destroy()
method on ImageDecoder).

As no client uses the IFFDecoder for more than one image at a time,
this change does not require updates to the engines. The only effect
is on Parallaction (BRA-Amiga), which can now control the way pixels
are packaged in mask and path bitmaps.
2013-10-26 22:24:16 +09:00
Willem Jan Palenstijn
a532c7729f Merge branch 'zvision'
This merges pull request 395 for the ZVision engine developed during
GSoC2013.
2013-10-17 23:00:00 +02:00
D G Turner
480a059f83 GRAPHICS: Fix uninitialised field in PNG decoder. CID 1002280. 2013-09-30 05:01:41 +01:00
D G Turner
b6fbc3f4c6 GRAPHICS: Fix uninitialized cursor visibility variable. CID 1002283.
The default at cursor construction has been set to not visible.
This now requires an explicit call to setVisible(true) to show the
cursor, but a basic test shows that this seems to be OK and engines
which fail to do this would have been intermittently broken before.
2013-09-30 04:47:11 +01:00
RichieSams
49d67caa31 Merge branch 'master' into zvision 2013-09-29 18:04:53 -05:00
RichieSams
701250efb5 GRAPHICS: Remove variable shadowing 2013-09-22 15:54:06 -05:00
Johannes Schickel
46a69c89f4 Merge pull request #376 from lordhoto/libjpeg
GRAPHICS: Implement JPEGDecoder based on libjpeg.
2013-09-16 17:10:57 -07:00
Johannes Schickel
4063de4070 GRAPHICS: Add some paranoia asserts in JPEGDecoder. 2013-09-16 19:54:19 +02:00
Johannes Schickel
4809294b43 GRAPHICS: Make JPEGDecoder request RGB output from libjpeg by default.
This fixes loading of JPEG files which contain RGB color space instead of YUV.
It is a pretty odd extension of JPEG files by Adobe which is indicated by this:
http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/JPEG.html#Adobe

To still support Groovie's need for YUV data I added some possibility to
request direct YUV output.
2013-09-16 19:54:19 +02:00
Johannes Schickel
ac66cc9219 GRAPHICS: Implement JPEGDecoder based on libjpeg. 2013-09-16 15:55:36 +02:00
RichieSams
6f4e80e36e ZVISION: Add wrapper function for copyRectToSurface
Also rename some arguments to make them more clear
2013-09-12 14:07:42 -05:00
Willem Jan Palenstijn
6417192584 Merge branch 'master' into zvision
Conflicts:
	video/avi_decoder.cpp
2013-09-24 13:55:54 +02:00
Eugene Sandulenko
8a340007ea Merge pull request #361 from rundfunk47/guiimprovements
GUI: Various GUI Improvements
2013-08-22 05:31:23 -07:00
Johannes Schickel
a2fabef87c GRAPHICS: Increase robustness of VectorRendererSpec::drawString. 2013-08-22 11:46:50 +02:00
Johannes Schickel
af13b74d02 GRAPHICS: Unify drawing paths in VectorRendererSpec::drawString.
Formerly, the behavior between when a drawable area was specified and when not
was different in a sense which is not expected. For example, when an empty
textDrawableArea was passed and the text could be drawn outside the 'area'
specified. While when a textDrawableArea covering the whole screen was passed
the text was clipped inside 'area'. Now, the code does follow the latter logic
in both cases.

I am not sure whether this will cause any issues, but a quick check of the
launcher and options menu didn't reveal anything...
2013-08-22 11:46:49 +02:00
Johannes Schickel
81ae06cae3 GRAPHICS: Simplify VectorRendererSpec::drawString.
This removes the two additional copy steps for rendering when a drawable text
area is specified. Instead it uses Surface::getSubArea to draw directly onto
_activeSurface.
2013-08-22 11:46:48 +02:00
Torbjörn Andersson
8c2bbb09a8 GRAPHICS: Add missing "break"s in switch, CID 1063214
This won't actually make any difference, since the fall through
would do nothing and then reach the break in the default case. But
I think it's less error-prone this way if the code is ever modified.
2013-08-19 19:34:41 +02:00
Narek Mailian
6fa3c7751f GRAPHICS: Gradient blending on borders of rounded squares 2013-08-16 20:54:10 +02:00
Narek Mailian
52ee92625f GRAPHICS: Change soft-shadow calculation to not use doubles 2013-08-16 20:54:09 +02:00
Narek Mailian
b91e10f931 GRAPHICS: Shadows on tabs 2013-08-16 20:54:09 +02:00
Narek Mailian
5c00dbbd2a GRAPHICS: Add support for Soft Shadows with rounded squares 2013-08-16 20:54:08 +02:00
Narek Mailian
887a99e211 GRAPHICS: Added changes and improved code from inisider/scummvm (partial text)
Includes code from https://github.com/inisider/scummvm/ , which has been
squashed and bugfixed
2013-08-16 20:54:08 +02:00
richiesams
7e8e9bf3d1 GRAPHICS: Create copyRectToSurface member function 2013-08-15 14:31:21 -05:00
Johannes Schickel
a2a5d42a58 GRAPHICS: Fix warnings about mismatching format arguments. 2013-08-12 16:43:35 +02:00
Narek Mailian
1f1d35bd3d GRAPHICS: Allow VectorRenderer and ThemeEngine to init with 4BPP 2013-08-08 08:35:08 +02:00
Narek Mailian
f545a2f08f GUI: Change name of GUI-renderers to remove "16-bit" 2013-08-08 08:35:08 +02:00
Narek Mailian
ece8b7fb65 GRAPHICS: Fix fonts/bdf.cpp to allow for 32bpp to be used 2013-08-08 08:27:11 +02:00
Narek Mailian
1d40dca7a0 GRAPHICS: Add error-checking in blendPixelPtr for invalid BPPs 2013-08-08 08:27:11 +02:00
Johannes Schickel
0f59009e6e GRAPHICS: Fix VectorRendererSpec for RGBA8888.
Formerly values in the gradient and blending code overflowed and thus caused
incorrect colors. Now there's some special case for 32bpp modes, which needs
slightly more operations but assures a correct output.
2013-08-08 08:27:11 +02:00
Torbjörn Andersson
b8850522b6 GRAPHICS: Fix incorrect parameter order for getBasePtr.
This caused createThumbnail() to crash, e.g. when saving in the
Kyrandia engine. Probably other engines as well.
2013-08-08 06:55:17 +02:00
Johannes Schickel
7f8308e0eb Merge pull request #365 from lordhoto/protected-pixels
Make Graphics::Surface::pixels protected.
2013-08-07 12:24:59 -07:00
Johannes Schickel
363a5a95cf GRAPHICS: Make Surface::pixels protected. 2013-08-06 03:51:49 +02:00
Johannes Schickel
604e1b0070 GRAPHICS: Fix typo. 2013-08-04 01:01:15 +02:00