diff options
-rw-r--r-- | win32/PlatWin.cxx | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 38e19c6ac..bbf352ee6 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -1176,6 +1176,7 @@ class SurfaceD2D : public Surface { void Clear() noexcept; void SetFont(const Font &font_) noexcept; + HRESULT GetBitmap(ID2D1Bitmap **ppBitmap); public: SurfaceD2D() noexcept; @@ -1332,6 +1333,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); } @@ -1483,10 +1489,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 = @@ -1639,14 +1645,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, |