Cycles tonemapping

To revive this topic: @marcoG_ita asked me on IRC whether adding tonemapping in Viewport is possible, so I had a look.
It turns out that it works pretty well, but for a serious patch there are some considerations:

  • Adding TM to the display processing (where the curve, film etc. settings are) would be the best case, but it’s not posssible (as far as I see) because OpenColorIO uses fixed lookup-tables, while most tonemapping operators depend on the scene. This means that my solution would not work for BI, it’d be just an option for Cycles (somewhere in the Film tab, probably).
  • Since the Compositor already has tonemapping, I’d make it viewport-rendering-only.
  • As it then is a compositor replacement, it probably should sit in the color pipeline between render output and color processing, where compositing would be in a F12 render.

Which operators would you like? It should be also available in the compositor, since having perfectly balanced lighting in the viewport is no use if you can’t have the same result in an F12 render. My current code contains a LuxRender/Indigo-style Reinhard mapper, which however is not in the compositor. So, should I add this operator to the compositor as well, port the “Rh simple” from the compositor to Cycles, or use a completely different one?

So, I could use some feedback here. If there is interest, I could post a test build as well.