aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2020-07-27 13:58:17 +1000
committerNeil <nyamatongwe@gmail.com>2020-07-27 13:58:17 +1000
commitba6c4fd91318ea24c1f9491a0a09c69b74a10ad3 (patch)
tree813a2bbb9bfc2c69d495619f3a1839104920d9d3
parent8fb21d5471a9c50151a4c7c7fde35edf922e4daf (diff)
downloadscintilla-mirror-ba6c4fd91318ea24c1f9491a0a09c69b74a10ad3.tar.gz
Backport: Add private SurfaceD2D::GetBitmap to better encapsulate the bitmap render target
and simplify callers. Backport of changeset 8460:6e7bbeda1f5a.
-rw-r--r--win32/PlatWin.cxx19
1 files changed, 11 insertions, 8 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 560fa3435..dcc92baa3 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -1170,6 +1170,7 @@ class SurfaceD2D : public Surface {
void Clear() noexcept;
void SetFont(const Font &font_) noexcept;
+ HRESULT GetBitmap(ID2D1Bitmap **ppBitmap);
public:
SurfaceD2D() noexcept;
@@ -1323,6 +1324,11 @@ void SurfaceD2D::InitPixMap(int width, int height, Surface *surface_, WindowID w
SetDBCSMode(psurfOther->codePage);
}
+HRESULT SurfaceD2D::GetBitmap(ID2D1Bitmap **ppBitmap) {
+ PLATFORM_ASSERT(pBitmapRenderTarget);
+ return pBitmapRenderTarget->GetBitmap(ppBitmap);
+}
+
void SurfaceD2D::PenColour(ColourDesired fore) {
D2DPenColour(fore);
}
@@ -1474,10 +1480,10 @@ void SurfaceD2D::FillRectangle(PRectangle rc, ColourDesired back) {
void SurfaceD2D::FillRectangle(PRectangle rc, Surface &surfacePattern) {
SurfaceD2D *psurfOther = dynamic_cast<SurfaceD2D *>(&surfacePattern);
- PLATFORM_ASSERT(psurfOther && psurfOther->pBitmapRenderTarget);
+ PLATFORM_ASSERT(psurfOther);
psurfOther->FlushDrawing();
ID2D1Bitmap *pBitmap = nullptr;
- HRESULT hr = psurfOther->pBitmapRenderTarget->GetBitmap(&pBitmap);
+ HRESULT hr = psurfOther->GetBitmap(&pBitmap);
if (SUCCEEDED(hr) && pBitmap) {
ID2D1BitmapBrush *pBitmapBrush = nullptr;
const D2D1_BITMAP_BRUSH_PROPERTIES brushProperties =
@@ -1630,14 +1636,11 @@ void SurfaceD2D::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back)
}
void SurfaceD2D::Copy(PRectangle rc, Point from, Surface &surfaceSource) {
- SurfaceD2D &surfOther = static_cast<SurfaceD2D &>(surfaceSource);
+ SurfaceD2D &surfOther = dynamic_cast<SurfaceD2D &>(surfaceSource);
surfOther.FlushDrawing();
- ID2D1BitmapRenderTarget *pCompatibleRenderTarget = reinterpret_cast<ID2D1BitmapRenderTarget *>(
- surfOther.pRenderTarget);
- PLATFORM_ASSERT(pCompatibleRenderTarget);
ID2D1Bitmap *pBitmap = nullptr;
- HRESULT hr = pCompatibleRenderTarget->GetBitmap(&pBitmap);
- if (SUCCEEDED(hr)) {
+ HRESULT hr = surfOther.GetBitmap(&pBitmap);
+ if (SUCCEEDED(hr) && pBitmap) {
const D2D1_RECT_F rcDestination = RectangleFromPRectangle(rc);
D2D1_RECT_F rcSource = {from.x, from.y, from.x + rc.Width(), from.y + rc.Height()};
pRenderTarget->DrawBitmap(pBitmap, rcDestination, 1.0f,