Update parseptblog.php for v3.0.11 and Matlab R2014a/b support.

Account for Psychtoolbox-3.0.11.
Account for Matlab R2014a and R2014b.
Cleanup useless info.

(cherry picked from commit 2d0253d018dbe12e28b9269849e14f86c15a5a6d)
Fix awful mess of white-space issues in PsychGraphicsHardwareHALSupport.c

Only a thousand more god awful ugly formatted files to go...

(cherry picked from commit 7484f6337572dc747e9c219706494cf1ebcd6bf0)
PsychSetBeamposCorrection: Fix wrong crtc offsets for debug readback on NV-d0

Offsets for diagnostic readback of vblstart, vblend, vactive was wrong,
copy & paste error from NV-50. This caused some misdiagnosis of nouveau
problems.

-> Fix it so it actually has some value.

(cherry picked from commit 6948e2e1872fcc9c4c2d4ba29785e37e98f61b43)
PerceptualVBLSyncTestFlipInfo.m: PerceptualVBLSyncTestFlipInfo, with extra diagnostic.

Uses the Linux-only Screen('GetFlipInfo') function for extra
diagnostics.

(cherry picked from commit b19e2535c26874c339864826bcde1838a4aff323)
HighColorPrecisionDrawingTest: Make robust against octave's new plotting backend.

Octave's fltk default plotting backend uses OpenGL and doesn't restore
context bindings after executing, neither do we, we are both lazy.

This means that a innocent plotting command can change the OpenGL
context on our main thread and thereby make us render into the
plot window, or vice versa, with "funny" results.

Work around this in HighColorPrecisionDrawingTest.m for now by
switching to good'ol gnuplot backend if we detect this.

The same problem may happen with future Matlab releases, so need
to implement proper protection inside Screen() soonish.

-> Fixes failure on Octave 3.8.x for now.

(cherry picked from commit 0c942829b78fb978b53853e5f3a9efa513e0fef3)
AdditiveBlendingForLinearSuperpositionTutorial: Fix cursor handling.

Use Show/HideCursor(screenNumber) instead of Show/HideCursor,
so it can address multiple screen's on Linux individually
to take advantage of its higher flexibility.

(cherry picked from commit 0184d1c563415b62b262ca70300bd2898e42dcbb)
PsychImaging: Simplify setup of Native10Bit mode.

Screen('GetWindowInfo')'s winfo.SpecialFlags setting
1024 clearly signals if our 10 bpc framebuffer hack
is in use (1024 present) or if the OS did the 10 bpc
setup (absent). Check for this value to find out if
we need to load and attach our custom GLSL ARGB2101010
formatting shader, or if we can skip this step.

-> Get rid of the tons of driver checks.

(cherry picked from commit 9151e74223ffcf80acb1ce6ecf8ef92d58a805eb)
FlipTimingWithRTBoxPhotoDiodeTest: Also report too early flips.

Like VBLSyncTest does.

(cherry picked from commit e40246b5485d654fc764381ede9d238d7fe2d403)
FlipTimingWithRTBoxPhotoDiodeTest: Improve plotting a tiny bit.

Use a different color for expected vs. real flip time delta.

(cherry picked from commit 6e33119244694b36daba93ab9a59095db4f11e21)
PerceptualVBLSyncTestFlipInfo - Abort on non-Linux, as this is Linux only.

(cherry picked from commit 43d01d978c850a10d67e04f2984d653947eab5b7)
GraphicsDisplaySyncAcrossDualHeadsTestLinux: Refine implementation a bit.

-> Use first two assigned display heads of x-screen, not always heads 0 and 1,
   as those might be the wrong ones on a multi x-screen setup.

-> Restore screentohead mapping after testing procedure.

-> Add support for fast AMD multi-display sync before test as syncmethod 1.
-> Move old broken driftsync to syncmethod 2 and warn about its brokeness.
-> Cleanup help texts and plotting code.

(cherry picked from commit 2fcb22a4ef05d98eb8f323018a389a4c191003cd)
Screen/Linux: Use old-style override-redirect even on KDE by default.

New-Style method for KDE doesn't play well with KDE multi-head setups,
and causes windows to be cut off, so only parts of the window show up
on dual-display presentation.

May need to rework this thoroughly but for now just disable it.
KDE's KWin works nicely with our fullscreen windows if the user
simply tells KWin once to unredirect fullscreen windows:

Go to: KDE System Settings -> Desktop Effects -> "Advanced" Tab ->
"Suspend desktop effects for fullscreen windows"
-> Check the checkbox, "Apply" -> Done.

Override redirect new-style can be forced on by
setenv("PSYCH_NEW_OVERRIDEREDIRECT", "1")
for experimentation.

-> Successfully tested to do the right thing(tm) on Ubuntu 14.04-LTS.

(cherry picked from commit c7feff6d695300a4d04f4f5fd6d484bbc675616c)
Screen/Linux: Restrict nouveau-kms pageflip workaround to Linux 3.13-3.15

The relevant bugs are fixed in Linux 3.16+, so are only present
in 3.13 - 3.15. Backports to 3.13-3.15 will likely happen, but
haven't happened yet, so leave workaround for those kernels active.

(cherry picked from commit ec06f88181e6ceefcd79ed722050a94ebbd8f9e3)
FlipTimingWithRTBoxPhotoDiodeTest: Make Flip vs. box reporting more intuitive.

Report difference between Screen('Flip') stimulus onset timestamp and
externally measured "ground truth" timestamps (e.g., Datapixx) as

delta = Flip - Measured, instead of delta = Measured - Flip.

This way, zero error means perfect agreement, a positive error
means that Flip reports a too late onset time (false deadline miss),
a negative error means Flip reports a too early onset.

Somehow this needs less brain cycles to attach meaning to than
the case with flipped signs. It is also consistent with the
quick and dirty VBLSyncTest + Datapixx output.

(cherry picked from commit 33db427228fc11aa9ecdb161e3b41a3f27f4a352)
PsychHIDTest: Disable most of test on Windows.

It doesn’t work there because Windows doesn’t allow low-level HID
keyboard and mouse access.

(cherry picked from commit 7baa3c7972166bed8b2e2deb622c09457005a693)
DrawFormattedText: Add new sx options 'wrapat' and 'justifytomax'

These options try to justify the width of text to both left- and right
border, so width of text appears roughly even. ‘wrapat’ justifies to a
fixed line width of ‘wrapat’ characters, whereas ‘justifytomax’
justifies to the width of the widest line of text in a given multi-line
text string.

This is achieved by changing the width of blanks in each line of text
to “rescale” the width of the line of text. If lines deviate more than
global ptb_drawformattedtext_padthresh
from the reference width, they are not stretched, to avoid ridiculous
looking results.
Default threshold is 33%.

This works ok’ish if the text is already separated via newline
characters into lines of roughly equal length.

DrawFormattedTextDemo updated to demonstrate this.

(cherry picked from commit ca4d745f80dcd2ff1f8b6d4820a1b2fb314aba88)
Screen/OSX: Warn about bad timing if display rotation is active.

Just as on Linux, warn about bad timing/timestamping if a display is
set to rotated mode (90, 180, 270 degree), as this will go through the
compositor.

(cherry picked from commit 28365002cf7759a72e8a79a0acce78a06dabfacc)
Screen/OSX: Prevent video mode switch from ruining the gamma table.

At least on OSX 10.9 with at least Nvidia gpu’s, prevent the latest
Apple brain damage from ruining some peoples day:
A modeset operation on at least 10.9 will, as a side effect, restore
the gnu gamma table to the session default about 1.6 - 1.8 seconds
after the video mode switch happened, thereby undoing the effect of any
Screen(‘LoadNormalizedGammatable’) or LoadIdentityClut() command
happening within a time interval of about less than 2 seconds within a
mode set aka Screen(‘Resolution’) or SetResolution(). Yay!

We prevent this by creating a backup copy of the gamma LUT, then
performing the mode set as usual, then waiting for 3 seconds, then
restoring the gamma LUT to pre-modeset state, so the screwup of the
gamma table has no user visible effect.

-> Reported by Michael Bannert and Andreas Schindler. Thanks.

(cherry picked from commit d66daa32334ab74d15544b04e60cfa0482a925ab)
Screen/OSX: Fix some debug output.

(cherry picked from commit 907c8bbdb43f5013a24b99b58a177fcc33ec6f23)
DrawFormattedText[Demo]: Refine justified text rendering a bit.

Draw text with y-position-is-baseline to avoid vertical jitter if
single words are rendered in separate DrawText invocations. Try to make
bounding box still roughly correct.

(cherry picked from commit 5a5b41cb9fc791b8b5baf2ae538af9c564dca811)