void SurfacePool::releaseBuffers() { if (!m_initialized || m_tilePool.isEmpty() || m_buffersSuspended) return; m_buffersSuspended = true; // Release the tile pool. for (size_t i = 0; i < m_tilePool.size(); ++i) { m_tilePool[i]->frontBuffer()->clearRenderedRegion(); // Clear the buffer to prevent accidental leakage of (possibly sensitive) pixel data. BlackBerry::Platform::Graphics::clearBuffer(m_tilePool[i]->frontBuffer()->nativeBuffer(), 0, 0, 0, 0); BlackBerry::Platform::Graphics::destroyPixmapBuffer(m_tilePool[i]->frontBuffer()->nativeBuffer()); } if (m_visibleTileBuffer) { m_visibleTileBuffer->frontBuffer()->clearRenderedRegion(); BlackBerry::Platform::Graphics::clearBuffer(m_visibleTileBuffer->frontBuffer()->nativeBuffer(), 0, 0, 0, 0); BlackBerry::Platform::Graphics::destroyPixmapBuffer(m_visibleTileBuffer->frontBuffer()->nativeBuffer()); } if (backBuffer()) { backBuffer()->clearRenderedRegion(); BlackBerry::Platform::Graphics::clearBuffer(backBuffer()->nativeBuffer(), 0, 0, 0, 0); BlackBerry::Platform::Graphics::destroyPixmapBuffer(backBuffer()->nativeBuffer()); } }
void SurfacePool::createBuffers() { if (!m_initialized || m_tilePool.isEmpty() || !m_buffersSuspended) return; // Create the tile pool. for (size_t i = 0; i < m_tilePool.size(); ++i) BlackBerry::Platform::Graphics::createPixmapBuffer(m_tilePool[i]->frontBuffer()->nativeBuffer()); if (m_visibleTileBuffer) BlackBerry::Platform::Graphics::createPixmapBuffer(m_visibleTileBuffer->frontBuffer()->nativeBuffer()); if (backBuffer()) BlackBerry::Platform::Graphics::createPixmapBuffer(backBuffer()->nativeBuffer()); m_buffersSuspended = false; }
ID3D11ShaderResourceView* SwapChain::GetResourceView() { ID3D11Texture2D *backBuffer(NULL); //获取后缓冲区地址 m_pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&backBuffer)); g_objDeviecManager.GetImmediateContext()->CopyResource(texEx, backBuffer); return mSRV; }
bool SwapChain::CreateWindowSizeDependentResources() { SAFE_RELEASE(m_depthStencilBuffer); SAFE_RELEASE(m_renderTargetView); SAFE_RELEASE(m_depthStencilView); HRESULT hr; m_pSwapChain->ResizeBuffers(1, m_nWidth, m_nHeight, DXGI_FORMAT_R8G8B8A8_UNORM, 0); // 3. 创建RenderTargetView,D3D11中创建视图需要对应的资源 ID3D11Texture2D *backBuffer(NULL); //获取后缓冲区地址 m_pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&backBuffer)); D3D11_TEXTURE2D_DESC textureDesc; backBuffer->GetDesc(&textureDesc); //创建视图 hr = m_pd3dDevice->CreateRenderTargetView(backBuffer, 0, &m_renderTargetView); if (FAILED(hr))return false; //释放后缓冲区引用 backBuffer->Release(); /************************************************************************/ /* 4. 创建深度、模板缓冲区及对应视图,创建缓冲区要即创建一个2维纹理 */ /************************************************************************/ D3D11_TEXTURE2D_DESC dsDesc; dsDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; dsDesc.Width = m_nWidth; dsDesc.Height = m_nHeight; dsDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL; dsDesc.MipLevels = 1; dsDesc.ArraySize = 1; dsDesc.CPUAccessFlags = 0; dsDesc.SampleDesc.Count = 1; dsDesc.SampleDesc.Quality = 0; dsDesc.MiscFlags = 0; dsDesc.Usage = D3D11_USAGE_DEFAULT; int w = m_nWidth; int h = m_nHeight; hr = m_pd3dDevice->CreateTexture2D(&dsDesc, nullptr, &m_depthStencilBuffer); //创建视图类型DepthStencilView // Not needed since this is a 2d texture hr = m_pd3dDevice->CreateDepthStencilView(m_depthStencilBuffer, 0, &m_depthStencilView); //创建完两个视图后当然就要绑定到渲染管线 // m_deviceContext->OMSetRenderTargets(1, &m_renderTargetView, m_depthStencilView); m_viewport.TopLeftX = 0.0f; m_viewport.TopLeftY = 0.0f; m_viewport.Width = (float)(m_nWidth); m_viewport.Height = (float)(m_nHeight); m_viewport.MinDepth = 0.0f; m_viewport.MaxDepth = 1.0f; SetMatrixPerspective(); return true; }
QImage Polygon::getImage(int width, int height) { this->width = width; this->height = height; lines.clear(); QImage backBuffer(width, height, QImage::Format_RGB888); backBuffer.fill(qRgb(255, 255, 255)); //drawBezier(&backBuffer, Qt::black); Bezier(&backBuffer, points[0].x(),points[0].y(), points[1].x(), points[1].y(), points[2].x(), points[2].y(), points[3].x(), points[3].y(), Qt::black); return backBuffer; }
void QDri2Context::resize(const QSize &size) { Q_D(QDri2Context); d->size= size; glBindFramebuffer(GL_FRAMEBUFFER,d->fbo); xcb_dri2_dri2_buffer_t *backBfr = backBuffer(); if (d->image) { qDebug() << "destroing image"; eglDestroyImageKHR(EGL_DISPLAY_FROM_XCB(d->qXcbWindow),d->image); } EGLint imgAttribs[] = { EGL_WIDTH, d->size.width(), EGL_HEIGHT, d->size.height(), EGL_DRM_BUFFER_STRIDE_MESA, backBfr->pitch /4, EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_FORMAT_ARGB32_MESA, EGL_NONE }; d->image = eglCreateImageKHR(EGL_DISPLAY_FROM_XCB(d->qXcbWindow), EGL_NO_CONTEXT, EGL_DRM_BUFFER_MESA, (EGLClientBuffer) backBfr->name, imgAttribs); glBindRenderbuffer(GL_RENDERBUFFER, d->rbo); glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER, d->image); glBindRenderbuffer(GL_RENDERBUFFER, d->depth); glRenderbufferStorage(GL_RENDERBUFFER,GL_DEPTH24_STENCIL8_OES,d->size.width(), d->size.height()); }
// This is the function that creates the screen presentation, by compositing the // top-level windows on the root window. void Workspace::repaint() { // If there's no damage, update the whole display if ( mDamage == None || mInitialRepaint ) { XRectangle r = { 0, 0, width(), height() }; XserverRegion region = XFixesCreateRegion( dpy, &r, 1 ); if ( mDamage ) XFixesDestroyRegion( dpy, mDamage ); mDamage = region; mInitialRepaint = false; } // Use the damage region as the clip region for the root window XFixesSetPictureClipRegion( dpy, frontBuffer(), 0, 0, mDamage ); // Client list for clients that are either translucent, or have a shadow ClientList translucents; // Draw each opaque window top to bottom, subtracting the bounding rect of // each drawn window from the clip region. ClientList::ConstIterator end = mList.constEnd(); for ( ClientList::ConstIterator it = mList.constBegin(); it != end; ++it ) { Client *client = *it; if ( !client->isVisible() || !client->isPainted() ) continue; // Update the region containing the area the window was last rendered at. client->updateOnScreenRegion(); // Only draw the window if it's opaque if ( client->isOpaque() ) { // Set the clip region for the backbuffer to the damage region, and // subtract the clients shape from the damage region XFixesSetPictureClipRegion( dpy, backBuffer(), 0, 0, mDamage ); XFixesSubtractRegion( dpy, mDamage, mDamage, client->shape() ); XRenderComposite( dpy, PictOpSrc, client->picture(), None, backBuffer(), 0, 0, 0, 0, client->x(), client->y(), client->width() + client->borderWidth() * 2, client->height() + client->borderWidth() * 2 ); } // Save the clip region before the next client shape is subtracted from it. // We need to restore it later when we're drawing the shadow. client->setShapeClip( mDamage ); translucents.prepend( client ); } // Draw any areas of the root window not covered by windows XFixesSetPictureClipRegion( dpy, backBuffer(), 0, 0, mDamage ); XRenderComposite( dpy, PictOpSrc, rootTile(), None, backBuffer(), 0, 0, 0, 0, 0, 0, width(), height() ); // Now walk the list backwards, drawing translucent windows and shadows. // That we draw bottom to top is important now since we're drawing translucent windows. end = translucents.constEnd(); for ( ClientList::ConstIterator it = translucents.constBegin(); it != end; ++it ) { Client *client = *it; // Restore the previously saved clip region XFixesSetPictureClipRegion( dpy, backBuffer(), 0, 0, client->shapeClip() ); // Only draw the window if it's translucent // (we drew the opaque ones in the previous loop) if ( !client->isOpaque() ) XRenderComposite( dpy, PictOpOver, client->picture(), client->alphaMask(), backBuffer(), 0, 0, 0, 0, client->x() + client->borderWidth(), client->y() + client->borderWidth(), client->width(), client->height() ); // We don't need the clip region anymore client->destroyShapeClip(); } translucents.clear(); // Destroy the damage region XFixesDestroyRegion( dpy, mDamage ); mDamage = None; // Copy the back buffer contents to the root window XFixesSetPictureClipRegion( dpy, backBuffer(), 0, 0, None ); XRenderComposite( dpy, PictOpSrc, backBuffer(), None, frontBuffer(), 0, 0, 0, 0, 0, 0, width(), height() ); }