D3D9WPFRenderer::~D3D9WPFRenderer() { releaseSurface(); DestroyWindow(mHwnd); if ( mListener ) mListener->release(); mListener = NULL; if ( decrementClassReference() == 0 ) UnregisterClass(TEXT(APP_NAME), NULL); }
void D3D9target::unbind() { #if 0 if (m_isNullColor) { d3d9TargetManager->freeTarget(m_nullColor); } releaseSurface(); if (m_depthTarget) { m_depthTarget->releaseSurface(); } #endif }
bool D3D9WPFRenderer::checkResize( bool isDeviceLost ) { bool isDeviceReset = false; //resize the system if the desired width or height is more than we can support. if ( mDesiredWidth > m_displayWidth || mDesiredHeight > m_displayHeight || isDeviceLost ) { m_displayWidth = PxMax( mDesiredWidth, m_displayWidth ); m_displayHeight = PxMax( mDesiredHeight, m_displayHeight ); if ( isDeviceLost ) { physx::PxU64 res = m_d3dDevice->TestCooperativeLevel(); if(res == D3D_OK || res == D3DERR_DEVICENOTRESET) //if device is lost, device has to be ready for reset { isDeviceReset = true; onDeviceLost(); onDeviceReset(); } } else { releaseSurface(); releaseDepthStencilSurface(); allocateSurface(); buildDepthStencilSurface(); // set out initial states... m_d3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); m_d3dDevice->SetRenderState(D3DRS_LIGHTING, 0); m_d3dDevice->SetRenderState(D3DRS_ZENABLE, 1); } } //else just mess with the viewport so we only render pixel-by-pixel D3DVIEWPORT9 viewport = {0}; m_d3dDevice->GetViewport(&viewport); if ( viewport.Width != mDesiredWidth || viewport.Height != mDesiredHeight ) { viewport.X = 0; viewport.Y = 0; viewport.Width = (DWORD)mDesiredWidth; viewport.Height = (DWORD)mDesiredHeight; viewport.MinZ = 0.0f; viewport.MaxZ = 1.0f; m_d3dDevice->SetViewport(&viewport); } return isDeviceReset; }
int CDirectXRenderLayer::createSurfaceFromFile(char* fileName, unsigned int width, unsigned int height, TRect& srcRect, unsigned long flags, SURFACE_REF& surface) { if (createSurface(width, height, flags, surface)) { mRect[0].left = srcRect.mX0; mRect[0].top = srcRect.mY0; mRect[0].right = srcRect.mX1; mRect[0].bottom = srcRect.mY1; if (SUCCEEDED(D3DXLoadSurfaceFromFile(mSurface[surface].mD3DSurface, NULL, NULL, fileName, &mRect[0], D3DX_FILTER_NONE, 0, NULL))) { return E_SUCCESS; } else { releaseSurface(surface); } } return E_FAILED; }
void D3D9target::copyFramebuffer(const Rect& r) { getSurface(); IDirect3DSurface9* surface = 0; if (d3d9BoundTarget->isWindow()) { surface = ((D3D9window*)d3d9BoundTarget)->getSurface(); } else { surface = ((D3D9target*)d3d9BoundTarget)->getSurface(); } RECT d3drect; d3drect.left = 0; d3drect.top = 0; d3drect.right = r.width; d3drect.bottom = r.height; HRESULT hr; V(d3d9Device->StretchRect(surface, &d3drect, m_surface, &d3drect, D3DTEXF_NONE)); releaseSurface(); }
void QDirectFBWindowSurface::setGeometry(const QRect &rect) { const QRect oldRect = geometry(); if (oldRect == rect) return; IDirectFBSurface *oldSurface = dfbSurface; const bool sizeChanged = oldRect.size() != rect.size(); if (sizeChanged) { delete engine; engine = 0; releaseSurface(); Q_ASSERT(!dfbSurface); } if (rect.isNull()) { #ifndef QT_NO_DIRECTFB_WM if (dfbWindow) { if (window()) window()->setProperty("_q_DirectFBWindowID", QVariant()); dfbWindow->Release(dfbWindow); dfbWindow = 0; } #endif Q_ASSERT(!dfbSurface); #ifdef QT_DIRECTFB_SUBSURFACE Q_ASSERT(!subSurface); #endif } else { #ifdef QT_DIRECTFB_WM if (!dfbWindow) { createWindow(rect); } else { setWindowGeometry(dfbWindow, oldRect, rect); Q_ASSERT(!sizeChanged || !dfbSurface); if (sizeChanged) dfbWindow->GetSurface(dfbWindow, &dfbSurface); } #else IDirectFBSurface *primarySurface = screen->primarySurface(); DFBResult result = DFB_OK; if (mode == Primary) { Q_ASSERT(primarySurface); if (rect == screen->region().boundingRect()) { dfbSurface = primarySurface; } else { const DFBRectangle r = { rect.x(), rect.y(), rect.width(), rect.height() }; result = primarySurface->GetSubSurface(primarySurface, &r, &dfbSurface); } } else { // mode == Offscreen if (!dfbSurface) { dfbSurface = screen->createDFBSurface(rect.size(), surfaceFlags() & Opaque ? screen->pixelFormat() : screen->alphaPixmapFormat(), QDirectFBScreen::DontTrackSurface); } } if (result != DFB_OK) DirectFBErrorFatal("QDirectFBWindowSurface::setGeometry()", result); #endif } if (oldSurface != dfbSurface) { imageFormat = dfbSurface ? QDirectFBScreen::getImageFormat(dfbSurface) : QImage::Format_Invalid; } if (oldRect.size() != rect.size()) { QWSWindowSurface::setGeometry(rect); } else { QWindowSurface::setGeometry(rect); } }
QDirectFBWindowSurface::~QDirectFBWindowSurface() { releaseSurface(); // these are not tracked by QDirectFBScreen so we don't want QDirectFBPaintDevice to release it }
void D3D9WPFRenderer::onDeviceLost() { releaseSurface(); D3D9Renderer::onDeviceLost(); }