aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/ScintillaDoc.html19
-rw-r--r--doc/ScintillaHistory.html5
-rw-r--r--include/Scintilla.h1
-rw-r--r--include/Scintilla.iface1
-rw-r--r--win32/ScintillaWin.cxx59
5 files changed, 65 insertions, 20 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html
index 068dbdf9d..8b9ecb1b2 100644
--- a/doc/ScintillaDoc.html
+++ b/doc/ScintillaDoc.html
@@ -82,7 +82,7 @@
<h1>Scintilla Documentation</h1>
- <p>Last edited 16 November 2014 NH</p>
+ <p>Last edited 24 November 2014 NH</p>
<p>There is <a class="jump" href="Design.html">an overview of the internal design of
Scintilla</a>.<br />
@@ -3270,16 +3270,20 @@ struct Sci_TextToFind {
<b id="SCI_GETTECHNOLOGY">SCI_GETTECHNOLOGY</b><br />
The technology property allows choosing between different drawing APIs and options.
On most platforms, the only choice is <code>SC_TECHNOLOGY_DEFAULT</code> (0).
- On Windows Vista or later, <code>SC_TECHNOLOGY_DIRECTWRITE</code> (1) or
- <code class="provisional">SC_TECHNOLOGY_DIRECTWRITERETAIN</code> (2)
+ On Windows Vista or later, <code>SC_TECHNOLOGY_DIRECTWRITE</code> (1),
+ <code class="provisional">SC_TECHNOLOGY_DIRECTWRITERETAIN</code> (2), or
+ <code class="provisional">SC_TECHNOLOGY_DIRECTWRITEDC</code> (3)
can be chosen to use the Direct2D and DirectWrite APIs for higher quality antialiased drawing.
<code class="provisional">SC_TECHNOLOGY_DIRECTWRITERETAIN</code> differs from
<code>SC_TECHNOLOGY_DIRECTWRITE</code> by requesting that the frame
is retained after being presented which may prevent drawing failures on some cards and drivers.
+ <code class="provisional">SC_TECHNOLOGY_DIRECTWRITEDC</code> differs from
+ <code>SC_TECHNOLOGY_DIRECTWRITE</code> by using DirectWrite to draw into a GDI DC.
Since Direct2D buffers drawing, Scintilla's buffering can be turned off with
<code>SCI_SETBUFFEREDDRAW(0)</code>.
- <span class="provisional">Since <code>SC_TECHNOLOGY_DIRECTWRITERETAIN</code>
- is provisional, it may be changed or removed in a future release if a better solution is found.</span></p>
+ <span class="provisional">Since <code>SC_TECHNOLOGY_DIRECTWRITERETAIN</code> and
+ <code>SC_TECHNOLOGY_DIRECTWRITEDC</code>
+ are provisional, they may be changed or removed in a future release if a better solution is found.</span></p>
<p><b id="SCI_SETFONTQUALITY">SCI_SETFONTQUALITY(int fontQuality)</b><br />
<b id="SCI_GETFONTQUALITY">SCI_GETFONTQUALITY</b><br />
@@ -7459,8 +7463,9 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next
<p>Provisional features are displayed in this document with <span class="provisional">a distinctive background colour</span>.</p>
<p>There are currently no provisional messages.
- The <code class="provisional">SC_TECHNOLOGY_DIRECTWRITERETAIN</code> value for
- <a class="message" href="#SCI_SETTECHNOLOGY">SCI_SETTECHNOLOGY</a> is provisional.</p>
+ The <code class="provisional">SC_TECHNOLOGY_DIRECTWRITERETAIN</code> and
+ <code class="provisional">SC_TECHNOLOGY_DIRECTWRITEDC</code> values for
+ <a class="message" href="#SCI_SETTECHNOLOGY">SCI_SETTECHNOLOGY</a> are provisional.</p>
<p>Using C++11 &lt;regex&gt; is provisional.</p>
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index ddd3c78a6..58c02178c 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -521,6 +521,11 @@
<a href="http://sourceforge.net/p/scintilla/bugs/1643/">Bug #1643</a>.
</li>
<li>
+ On Windows another DirectWrite mode SC_TECHNOLOGY_DIRECTWRITEDC added
+ which may avoid drawing failures in some circumstances by drawing into a GDI DC.
+ This feature is provisional and may be changed or removed if a better solution is found.
+ </li>
+ <li>
On Windows, avoid processing mouse move events where the mouse has not moved as these can
cause unexpected dwell start notifications.
<a href="http://sourceforge.net/p/scintilla/bugs/1670/">Bug #1670</a>.
diff --git a/include/Scintilla.h b/include/Scintilla.h
index 9779cfee6..deaede845 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -899,6 +899,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SC_TECHNOLOGY_DEFAULT 0
#define SC_TECHNOLOGY_DIRECTWRITE 1
#define SC_TECHNOLOGY_DIRECTWRITERETAIN 2
+#define SC_TECHNOLOGY_DIRECTWRITEDC 3
#define SCI_SETTECHNOLOGY 2630
#define SCI_GETTECHNOLOGY 2631
#define SCI_CREATELOADER 2632
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index e8c96591b..ca54c65ee 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -2366,6 +2366,7 @@ fun void ScrollToEnd=2629(,)
val SC_TECHNOLOGY_DEFAULT=0
val SC_TECHNOLOGY_DIRECTWRITE=1
val SC_TECHNOLOGY_DIRECTWRITERETAIN=2
+val SC_TECHNOLOGY_DIRECTWRITEDC=3
# Set the technology used.
set void SetTechnology=2630(int technology,)
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index 237f8e17a..bd205e370 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -210,7 +210,7 @@ class ScintillaWin :
static ATOM callClassAtom;
#if defined(USE_D2D)
- ID2D1HwndRenderTarget *pRenderTarget;
+ ID2D1RenderTarget *pRenderTarget;
bool renderTargetValid;
#endif
@@ -222,7 +222,7 @@ class ScintillaWin :
virtual void Initialise();
virtual void Finalise();
#if defined(USE_D2D)
- void EnsureRenderTarget();
+ void EnsureRenderTarget(HDC hdc);
void DropRenderTarget();
#endif
HWND MainHWND();
@@ -441,7 +441,7 @@ void ScintillaWin::Finalise() {
#if defined(USE_D2D)
-void ScintillaWin::EnsureRenderTarget() {
+void ScintillaWin::EnsureRenderTarget(HDC hdc) {
if (!renderTargetValid) {
DropRenderTarget();
renderTargetValid = true;
@@ -455,12 +455,6 @@ void ScintillaWin::EnsureRenderTarget() {
// Create a Direct2D render target.
#if 1
- D2D1_HWND_RENDER_TARGET_PROPERTIES dhrtp;
- dhrtp.hwnd = hw;
- dhrtp.pixelSize = size;
- dhrtp.presentOptions = (technology == SC_TECHNOLOGY_DIRECTWRITERETAIN) ?
- D2D1_PRESENT_OPTIONS_RETAIN_CONTENTS : D2D1_PRESENT_OPTIONS_NONE;
-
D2D1_RENDER_TARGET_PROPERTIES drtp;
drtp.type = D2D1_RENDER_TARGET_TYPE_DEFAULT;
drtp.pixelFormat.format = DXGI_FORMAT_UNKNOWN;
@@ -470,7 +464,32 @@ void ScintillaWin::EnsureRenderTarget() {
drtp.usage = D2D1_RENDER_TARGET_USAGE_NONE;
drtp.minLevel = D2D1_FEATURE_LEVEL_DEFAULT;
- pD2DFactory->CreateHwndRenderTarget(drtp, dhrtp, &pRenderTarget);
+ if (technology == SC_TECHNOLOGY_DIRECTWRITEDC) {
+ // Explicit pixel format needed.
+ drtp.pixelFormat = D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM,
+ D2D1_ALPHA_MODE_IGNORE);
+
+ ID2D1DCRenderTarget *pDCRT = NULL;
+ HRESULT hr = pD2DFactory->CreateDCRenderTarget(&drtp, &pDCRT);
+ if (FAILED(hr)) {
+ Platform::DebugPrintf("Failed CreateDCRenderTarget 0x%x\n", hr);
+ }
+ pRenderTarget = pDCRT;
+
+ } else {
+ D2D1_HWND_RENDER_TARGET_PROPERTIES dhrtp;
+ dhrtp.hwnd = hw;
+ dhrtp.pixelSize = size;
+ dhrtp.presentOptions = (technology == SC_TECHNOLOGY_DIRECTWRITERETAIN) ?
+ D2D1_PRESENT_OPTIONS_RETAIN_CONTENTS : D2D1_PRESENT_OPTIONS_NONE;
+
+ ID2D1HwndRenderTarget *pHwndRenderTarget = NULL;
+ HRESULT hr = pD2DFactory->CreateHwndRenderTarget(drtp, dhrtp, &pHwndRenderTarget);
+ if (FAILED(hr)) {
+ Platform::DebugPrintf("Failed CreateHwndRenderTarget 0x%x\n", hr);
+ }
+ pRenderTarget = pHwndRenderTarget;
+ }
#else
pD2DFactory->CreateHwndRenderTarget(
D2D1::RenderTargetProperties(
@@ -484,6 +503,16 @@ void ScintillaWin::EnsureRenderTarget() {
// need to be recreated.
DropGraphics(false);
}
+
+ if (technology == SC_TECHNOLOGY_DIRECTWRITEDC) {
+ RECT rcWindow;
+ GetClientRect(MainHWND(), &rcWindow);
+ HRESULT hr = static_cast<ID2D1DCRenderTarget*>(pRenderTarget)->BindDC(hdc, &rcWindow);
+ if (FAILED(hr)) {
+ Platform::DebugPrintf("BindDC failed 0x%x\n", hr);
+ DropRenderTarget();
+ }
+ }
}
void ScintillaWin::DropRenderTarget() {
@@ -638,7 +667,7 @@ LRESULT ScintillaWin::WndPaint(uptr_t wParam) {
}
} else {
#if defined(USE_D2D)
- EnsureRenderTarget();
+ EnsureRenderTarget(pps->hdc);
AutoSurface surfaceWindow(pRenderTarget, this);
if (surfaceWindow) {
pRenderTarget->BeginDraw();
@@ -1413,6 +1442,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
case SCI_SETTECHNOLOGY:
if ((wParam == SC_TECHNOLOGY_DEFAULT) ||
(wParam == SC_TECHNOLOGY_DIRECTWRITERETAIN) ||
+ (wParam == SC_TECHNOLOGY_DIRECTWRITEDC) ||
(wParam == SC_TECHNOLOGY_DIRECTWRITE)) {
if (technology != static_cast<int>(wParam)) {
if (static_cast<int>(wParam) > SC_TECHNOLOGY_DEFAULT) {
@@ -1424,6 +1454,9 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
return 0;
#endif
}
+#if defined(USE_D2D)
+ DropRenderTarget();
+#endif
technology = static_cast<int>(wParam);
// Invalidate all cached information including layout.
DropGraphics(true);
@@ -2549,7 +2582,7 @@ void ScintillaWin::HorizontalScrollMessage(WPARAM wParam) {
* This paint will not be abandoned.
*/
void ScintillaWin::FullPaint() {
- if (technology == SC_TECHNOLOGY_DEFAULT) {
+ if ((technology == SC_TECHNOLOGY_DEFAULT) || (technology == SC_TECHNOLOGY_DIRECTWRITEDC)) {
HDC hdc = ::GetDC(MainHWND());
FullPaintDC(hdc);
::ReleaseDC(MainHWND(), hdc);
@@ -2574,7 +2607,7 @@ void ScintillaWin::FullPaintDC(HDC hdc) {
}
} else {
#if defined(USE_D2D)
- EnsureRenderTarget();
+ EnsureRenderTarget(hdc);
AutoSurface surfaceWindow(pRenderTarget, this);
if (surfaceWindow) {
pRenderTarget->BeginDraw();