/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nullptr; c-basic-offset: 2 * -*- This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Enforce the pool size limit, removing least-recently-used entries as // necessary. while (mAvailableEntries.Length() > mPoolSizeLimit) {
mAvailableEntries.RemoveElementAt(0);
}
auto inUseEntryIter = mInUseEntries.find(aBuffer);
MOZ_RELEASE_ASSERT(inUseEntryIter != mInUseEntries.end());
SurfacePoolEntry& entry = inUseEntryIter->second; if (entry.mGLResources) { // We have an existing framebuffer.
MOZ_RELEASE_ASSERT(entry.mGLResources->mGL == aGL, "Recycled surface that still had GL resources from a " "different GL context. " "This shouldn't happen."); if (!aNeedsDepthBuffer || entry.mGLResources->mFramebuffer->HasDepth()) { return Some(entry.mGLResources->mFramebuffer->mFB);
}
}
// No usable existing framebuffer, we need to create one.
if (!aGL->MakeCurrent()) { // Context may have been destroyed. return {};
}
const GLuint tex = aBuffer->GetTexture(); auto fb = CreateFramebufferForTexture(lock, aGL, entry.mSize, tex,
aNeedsDepthBuffer); if (!fb) { // Framebuffer completeness check may have failed. return {};
}
UniquePtr<MozFramebuffer> SurfacePoolWayland::CreateFramebufferForTexture( const MutexAutoLock& aProofOfLock, GLContext* aGL, const IntSize& aSize,
GLuint aTexture, bool aNeedsDepthBuffer) { if (aNeedsDepthBuffer) { // Try to find an existing depth buffer of aSize in aGL and create a // framebuffer that shares it. if (auto buffer = GetDepthBufferForSharing(aProofOfLock, aGL, aSize)) { return MozFramebuffer::CreateForBackingWithSharedDepthAndStencil(
aSize, 0, LOCAL_GL_TEXTURE_2D, aTexture, buffer);
}
}
// No depth buffer needed or we didn't find one. Create a framebuffer with a // new depth buffer and store a weak pointer to the new depth buffer in // mDepthBuffers.
UniquePtr<MozFramebuffer> fb = MozFramebuffer::CreateForBacking(
aGL, aSize, 0, aNeedsDepthBuffer, LOCAL_GL_TEXTURE_2D, aTexture); if (fb && fb->GetDepthAndStencilBuffer()) {
mDepthBuffers.AppendElement(
DepthBufferEntry{aGL, aSize, fb->GetDepthAndStencilBuffer().get()});
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.