bool QDirectFBPixmapData::scroll(int dx, int dy, const QRect &rect) { if (!dfbSurface) { return false; } unlockSurface(); DFBResult result = dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX); if (result != DFB_OK) { DirectFBError("QDirectFBPixmapData::scroll", result); return false; } result = dfbSurface->SetPorterDuff(dfbSurface, DSPD_NONE); if (result != DFB_OK) { DirectFBError("QDirectFBPixmapData::scroll", result); return false; } const DFBRectangle source = { rect.x(), rect.y(), rect.width(), rect.height() }; result = dfbSurface->Blit(dfbSurface, dfbSurface, &source, source.x + dx, source.y + dy); if (result != DFB_OK) { DirectFBError("QDirectFBPixmapData::scroll", result); return false; } return true; }
QAndroidPlatformOpenGLWindow::~QAndroidPlatformOpenGLWindow() { m_surfaceWaitCondition.wakeOne(); lockSurface(); if (m_nativeSurfaceId != -1) QtAndroid::destroySurface(m_nativeSurfaceId); clearEgl(); unlockSurface(); }
void QDirectFBPaintDevice::releaseSubSurface() { Q_ASSERT(QDirectFBScreen::instance()); if (subSurface) { unlockSurface(); screen->releaseDFBSurface(subSurface); subSurface = 0; } }
QT_BEGIN_NAMESPACE QAndroidPlatformOpenGLWindow::QAndroidPlatformOpenGLWindow(QWindow *window, EGLDisplay display) :QAndroidPlatformWindow(window), m_eglDisplay(display) { lockSurface(); m_nativeSurfaceId = QtAndroid::createSurface(this, geometry(), bool(window->flags() & Qt::WindowStaysOnTopHint), 32); m_surfaceWaitCondition.wait(&m_surfaceMutex); unlockSurface(); }
void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect) { if (data->classId() != DirectFBClass) { QPixmapData::copy(data, rect); return; } const QDirectFBPixmapData *otherData = static_cast<const QDirectFBPixmapData*>(data); #ifdef QT_NO_DIRECTFB_SUBSURFACE if (otherData->lockFlags()) { const_cast<QDirectFBPixmapData*>(otherData)->unlockSurface(); } #endif IDirectFBSurface *src = otherData->directFBSurface(); alpha = data->hasAlphaChannel(); imageFormat = (alpha ? QDirectFBScreen::instance()->alphaPixmapFormat() : QDirectFBScreen::instance()->pixelFormat()); dfbSurface = screen->createDFBSurface(rect.size(), imageFormat, QDirectFBScreen::TrackSurface); if (!dfbSurface) { qWarning("QDirectFBPixmapData::copy()"); invalidate(); return; } if (alpha) { dfbSurface->Clear(dfbSurface, 0, 0, 0, 0); dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_BLEND_ALPHACHANNEL); } else { dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX); } const DFBRectangle blitRect = { rect.x(), rect.y(), rect.width(), rect.height() }; w = rect.width(); h = rect.height(); d = otherData->d; is_null = (w <= 0 || h <= 0); unlockSurface(); DFBResult result = dfbSurface->Blit(dfbSurface, src, &blitRect, 0, 0); #if (Q_DIRECTFB_VERSION >= 0x010000) dfbSurface->ReleaseSource(dfbSurface); #endif if (result != DFB_OK) { DirectFBError("QDirectFBPixmapData::copy()", result); invalidate(); return; } setSerialNumber(++global_ser_no); }
QDirectFBPaintDevice::~QDirectFBPaintDevice() { if (QDirectFBScreen::instance()) { unlockSurface(); #ifdef QT_DIRECTFB_SUBSURFACE releaseSubSurface(); #endif if (dfbSurface) { screen->releaseDFBSurface(dfbSurface); } } delete engine; }
void QAndroidPlatformOpenGLWindow::surfaceChanged(JNIEnv *jniEnv, jobject surface, int w, int h) { Q_UNUSED(jniEnv); Q_UNUSED(w); Q_UNUSED(h); lockSurface(); m_androidSurfaceObject = surface; m_surfaceWaitCondition.wakeOne(); unlockSurface(); // repaint the window QWindowSystemInterface::handleExposeEvent(window(), QRegion(geometry())); }
void QAndroidPlatformOpenGLWindow::surfaceChanged(JNIEnv *jniEnv, jobject surface, int w, int h) { Q_UNUSED(jniEnv); Q_UNUSED(w); Q_UNUSED(h); lockSurface(); m_androidSurfaceObject = surface; m_surfaceWaitCondition.wakeOne(); unlockSurface(); // repaint the window QRect availableGeometry = screen()->availableGeometry(); if (geometry().width() > 0 && geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0) QWindowSystemInterface::handleExposeEvent(window(), QRegion(geometry())); }
// // ISDL12Window::setPalette // // Saves the given palette and updates it during refresh. // void ISDL12Window::setPalette(const argb_t* palette_colors) { lockSurface(); I_SetSDL12Palette(SDL_GetVideoSurface(), palette_colors); // if (mSDLSoftwareSurface) // I_SetSDL12Palette(mSDLSoftwareSurface, palette_colors); getPrimarySurface()->setPalette(palette_colors); mNeedPaletteRefresh = true; unlockSurface(); }
void QDirectFBWindowSurface::releaseSurface() { if (dfbSurface) { #ifdef QT_DIRECTFB_SUBSURFACE releaseSubSurface(); #else unlockSurface(); #endif #ifdef QT_NO_DIRECTFB_WM Q_ASSERT(screen->primarySurface()); if (dfbSurface != screen->primarySurface()) #endif dfbSurface->Release(dfbSurface); dfbSurface = 0; } }
bool QDirectFBPaintDevice::lockSurface(DFBSurfaceLockFlags lockFlags) { if (lockFlgs && (lockFlags & ~lockFlgs)) unlockSurface(); if (!mem) { Q_ASSERT(dfbSurface); #ifdef QT_DIRECTFB_SUBSURFACE if (!subSurface) { DFBResult result; subSurface = screen->getSubSurface(dfbSurface, QRect(), QDirectFBScreen::TrackSurface, &result); if (result != DFB_OK || !subSurface) { DirectFBError("Couldn't create sub surface", result); return false; } } IDirectFBSurface *surface = subSurface; #else IDirectFBSurface *surface = dfbSurface; #endif Q_ASSERT(surface); mem = QDirectFBScreen::lockSurface(surface, lockFlags, &bpl); lockFlgs = lockFlags; Q_ASSERT(mem); Q_ASSERT(bpl > 0); const QSize s = size(); lockedImage = QImage(mem, s.width(), s.height(), bpl, QDirectFBScreen::getImageFormat(dfbSurface)); return true; } #ifdef QT_DIRECTFB_SUBSURFACE if (syncPending) { syncPending = false; screen->waitIdle(); } #endif return false; }
void QDirectFBWindowSurface::endPaint(const QRegion &) { #ifdef QT_NO_DIRECTFB_SUBSURFACE unlockSurface(); #endif }
/** * Copys an area from one GfxSurface to another */ void GfxSurface::copyFrom(GfxSurface &src, Rect srcBounds, Rect destBounds, Region *priorityRegion) { GfxSurface srcImage; if (srcBounds.isEmpty()) return; if (srcBounds == src.getBounds()) srcImage = src; else { // Set the source image to be the subset specified by the source bounds Graphics::Surface srcSurface = src.lockSurface(); srcImage.create(srcBounds.width(), srcBounds.height()); Graphics::Surface destSurface = srcImage.lockSurface(); const byte *srcP = (const byte *)srcSurface.getBasePtr(srcBounds.left, srcBounds.top); byte *destP = (byte *)destSurface.pixels; for (int yp = srcBounds.top; yp < srcBounds.bottom; ++yp, srcP += srcSurface.pitch, destP += destSurface.pitch) { Common::copy(srcP, srcP + srcBounds.width(), destP); } srcImage.unlockSurface(); src.unlockSurface(); } if ((destBounds.width() != srcBounds.width()) || (destBounds.height() != srcBounds.height())) srcImage = ResizeSurface(srcImage, destBounds.width(), destBounds.height(), src._transColor); Graphics::Surface srcSurface = srcImage.lockSurface(); Graphics::Surface destSurface = lockSurface(); // Adjust bounds to ensure destination will be on-screen int srcX = 0, srcY = 0; if (destBounds.left < 0) { srcX = -destBounds.left; destBounds.left = 0; } if (destBounds.top < 0) { srcY = -destBounds.top; destBounds.top = 0; } if (destBounds.right > destSurface.w) destBounds.right = destSurface.w; if (destBounds.bottom > destSurface.h) destBounds.bottom = destSurface.h; if (destBounds.isValidRect()) { const byte *pSrc = (const byte *)srcSurface.getBasePtr(srcX, srcY); byte *pDest = (byte *)destSurface.getBasePtr(destBounds.left, destBounds.top); for (int y = 0; y < destBounds.height(); ++y, pSrc += srcSurface.pitch, pDest += destSurface.pitch) { if (!priorityRegion && (src._transColor == -1)) Common::copy(pSrc, pSrc + destBounds.width(), pDest); else { const byte *tempSrc = pSrc; byte *tempDest = pDest; int xp = destBounds.left; while (tempSrc < (pSrc + destBounds.width())) { if (!priorityRegion || !priorityRegion->contains(Common::Point( xp + _globals->_sceneManager._scene->_sceneBounds.left, destBounds.top + y + _globals->_sceneManager._scene->_sceneBounds.top))) { if (*tempSrc != src._transColor) *tempDest = *tempSrc; } ++tempSrc; ++tempDest; ++xp; } } } } unlockSurface(); srcImage.unlockSurface(); }
/** * Fills a specified rectangle on the surface with the specified color * * @bounds Area to fill * @color Color to use */ void GfxSurface::fillRect(const Rect &bounds, int color) { Graphics::Surface surface = lockSurface(); surface.fillRect(bounds, color); unlockSurface(); }