Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#1398 D2D issues

Bug
open
Neil Hodgson
Scintilla (788)
3
2012-08-25
2012-08-24
No

here is a collection of some problems and crashes of Scintilla when
used with D2D, SC_TECHNOLOGY_DIRECTWRITE, Call(SCI_SETBUFFEREDDRAW, 0)
and Call(SCI_SETFONTQUALITY, SC_EFF_QUALITY_LCD_OPTIMIZED).

Hopefully it helps, you can fix it and/or give some advises.

Problems:
* Text Box Blinks Its Background (http://code.google.com/p/tortoisegit/issues/detail?id=1227; we applied the following patch: http://code.google.com/p/tortoisegit/source/browse/ext/scintilla/backgroundcolors.patch\)
* Redraw issues in mstsc Remote Desktop session (http://code.google.com/p/tortoisegit/issues/detail?id=1322)
* And maybe: Text cursor is often invisible (http://code.google.com/p/tortoisegit/issues/detail?id=1326)

Crashes (login as guest):
https://www.crash-server.com/Problem.aspx?ClientID=TortoiseGit&ProblemID=2326
https://www.crash-server.com/Problem.aspx?ClientID=TortoiseGit&ProblemID=2563
https://www.crash-server.com/Problem.aspx?ClientID=TortoiseGit&ProblemID=2717
https://www.crash-server.com/Problem.aspx?ClientID=TortoiseGit&ProblemID=2774
https://www.crash-server.com/Problem.aspx?ClientID=TortoiseGit&ProblemID=2561

Discussion

  • Stefan Kueng
    Stefan Kueng
    2012-08-24

    Reading through the google groups post, I searched for LockRenderTarget and UnlockRenderTarget: those functions are not available in MFC pre VS2012. But they are present in the MFC that ships with VS2012. The functions are this:

    CHwndRenderTarget* CWnd::LockRenderTarget()
    {
    CHwndRenderTarget* pRenderTarget = NULL;

    g\_RenderTargetCriticalSection.Lock\(\);
    BOOL bRes = g\_RenderTargets.Lookup\(this, pRenderTarget\);
    
    if \(bRes\)
    \{
        ASSERT\_VALID\(pRenderTarget\);
        return pRenderTarget;
    \}
    
    return NULL;
    

    }

    void CWnd::UnlockRenderTarget()
    {
    g_RenderTargetCriticalSection.Unlock();
    }

    And DoD2DPaint() starts like this:
    BOOL CWnd::DoD2DPaint()
    {
    CHwndRenderTarget* pRenderTarget = LockRenderTarget();
    if (pRenderTarget == NULL)
    {
    UnlockRenderTarget();
    return FALSE;
    }

    ASSERT\_VALID\(pRenderTarget\);
    
    if \(\!pRenderTarget->IsValid\(\)\)
    \{
        pRenderTarget->Create\(GetSafeHwnd\(\)\);
    \}
    

    ...

     
  • Neil Hodgson
    Neil Hodgson
    2012-08-25

    Scintilla only uses render targets from one thread, the GUI thread, so a critical section is not needed to protect access. The code does not appear to be avoiding reentrance which could be an issue with Scintilla.

     
  • Neil Hodgson
    Neil Hodgson
    2012-08-25

    • assigned_to: nobody --> nyamatongwe
     
  • Neil Hodgson
    Neil Hodgson
    2012-08-25

    There are multiple issues included in this report which makes it less likely that anyone will work on it.

    The SCN_GETBKCOLOR patch is a bad idea on several fronts: it allows application code to perturb the state of Scintilla deep within drawing which would then have to be protected from such changes. Including a system-mediated callback in such a heavily executed position will be slow. Therefore I am rejecting SCN_GETBKCOLOR.

     
  • Neil Hodgson
    Neil Hodgson
    2012-08-25

    • priority: 5 --> 3
     
  • Greg Smith
    Greg Smith
    2012-08-29

    The LockRenderTarget stuff was what Pat Brenner told me to use, but at the time, it was only available inside MS. We did fix some re-entrancy problems at the time I was agitating about these issues, but this did not fix the problems I had when dragging a Scintilla window in an MFC view over another Scintilla window (looking similar to your drawing problem). I regret that I am deep in other projects at the moment or I would experiment with the Lock and Unlock code you have unearthed.