예제 #1
0
//------------------------------------------------------------------------
void HostProcessData::unprepare ()
{
	destroyBuffers (inputs, numInputs);
	destroyBuffers (outputs, numOutputs);

	channelBufferOwner = false;
}
예제 #2
0
/*
 * native_window_set_buffer_count(..., count)
 * Sets the number of buffers associated with this native window.
 */
int HWComposerNativeWindow::setBufferCount(int cnt)
{
    TRACE("cnt=%d", cnt);
    int err=NO_ERROR;
    pthread_mutex_lock(&_mutex);

    destroyBuffers();

    for(unsigned int i = 0; i < cnt; i++)
    {
        HWComposerNativeWindowBuffer *fbnb = new HWComposerNativeWindowBuffer(m_alloc,
                            m_width, m_height, m_bufFormat,
                            m_usage|GRALLOC_USAGE_HW_COMPOSER);

        fbnb->common.incRef(&fbnb->common);

        TRACE("buffer %i is at %p (native %p),err=%s, handle=%p stride=%i",
                i, fbnb, (ANativeWindowBuffer*)fbnb,
                strerror(-fbnb->status), fbnb->handle, fbnb->stride);

        if (fbnb->status)
        {
            fbnb->common.decRef(&fbnb->common);
            fprintf(stderr,"WARNING: %s: allocated only %d buffers out of %d\n", __PRETTY_FUNCTION__, m_freeBufs, cnt);
            break;
        }

        m_freeBufs++;
        m_bufList.push_back(fbnb);
    }
    pthread_mutex_unlock(&_mutex);

    return err;
}
예제 #3
0
void FbDevNativeWindow::reallocateBuffers()
{
    destroyBuffers();

    for(unsigned int i = 0; i < m_bufferCount; i++)
    {
        FbDevNativeWindowBuffer *fbnb = new FbDevNativeWindowBuffer(m_alloc,
                            m_fbDev->width, m_fbDev->height, m_fbDev->format,
                            m_usage|GRALLOC_USAGE_HW_FB );

        fbnb->common.incRef(&fbnb->common);

        TRACE("buffer %i is at %p (native %p) err=%s handle=%p stride=%i",
                i, fbnb, (ANativeWindowBuffer*)fbnb,
                strerror(-fbnb->status), fbnb->handle, fbnb->stride);

        if (fbnb->status)
        {
            fbnb->common.decRef(&fbnb->common);
            fprintf(stderr,"WARNING: %s: allocated only %d buffers out of %d\n", __PRETTY_FUNCTION__, m_freeBufs, m_bufferCount);
            break;
        }

        m_freeBufs++;
        m_bufList.push_back(fbnb);
    }

    m_allocateBuffers = false;
}
예제 #4
0
/*
 * native_window_set_buffer_count(..., count)
 * Sets the number of buffers associated with this native window.
 */
int HWComposerNativeWindow::setBufferCount(int count)
{
    TRACE("cnt=%d", count);
    if ((unsigned int) count != m_bufferCount)
        destroyBuffers();
    m_bufferCount = count;
    return NO_ERROR;
}
예제 #5
0
Framebuffer2D::~Framebuffer2D()
{
    if(glIsFramebuffer(fboHandle))
        glDeleteFramebuffers(1, &fboHandle);

    destroyBuffers( FBO_AUX0_BIT | FBO_AUX1_BIT | FBO_AUX2_BIT | FBO_AUX3_BIT |
                    FBO_DEPTH_BIT);
}
bool PluginViewPrivate::resizeBuffers(NPSurfaceFormat format, int width, int height)
{
    bool success = true;

    // If there is no buffer created, then try to create it.
    if (!m_pluginBufferSize.width() || !m_pluginBufferSize.height())
        return createBuffers(format, width, height);

    if (!width || !height)
        return destroyBuffers();

    PthreadMutexLocker backLock(&m_backBufferMutex);
    PthreadWriteLocker frontLock(&m_frontBufferRwLock);

    for (int i = 0; i < PLUGIN_BUFFERS && success; i++) {
        success &= BlackBerry::Platform::Graphics::reallocBuffer(m_pluginBuffers[i],
            BlackBerry::Platform::IntSize(width, height),
            toBufferType(format));
    }

    if (success) {
        m_pluginBufferSize = IntSize(width, height);
        m_pluginBufferType = toBufferType(format);
        return true;
    }

    // Attempt to undo if we failed to get the new size/format. We can't guarantee
    // we will get it back though.
    if (!m_pluginBufferSize.width() || !m_pluginBufferSize.height()) {
        destroyBuffers();
        return false;
    }

    bool undone = true;
    for (int i = 0; i < PLUGIN_BUFFERS; i++) {
        undone &= BlackBerry::Platform::Graphics::reallocBuffer(m_pluginBuffers[i],
            m_pluginBufferSize, m_pluginBufferType);
    }

    // If we fail to undo, delete the buffers altogether.
    if (!undone)
        destroyBuffers();

    return false;
}
예제 #7
0
NormalBlendedDecal::~NormalBlendedDecal()
{
    for (int idx = 0; idx < NUM_DECAL_BLENDS; ++idx) {
        glDeleteTextures(1, &mDecalNormals[idx]);
    }

    destroyShaders();
    destroyBuffers();
    LOGI("NormalBlendedDecal: destroyed\n");
}
예제 #8
0
/*
 * native_window_set_buffers_format(..., int format)
 * All buffers dequeued after this call will have the format specified.
 *
 * If the specified format is 0, the default buffer format will be used.
 */
int HWComposerNativeWindow::setBuffersFormat(int format)
{
    int need_realloc = ((unsigned int) format != m_bufFormat);
    TRACE("format=x%x realloc=%d", format, need_realloc);
    m_bufFormat = format;
    if (need_realloc)
        destroyBuffers();

    return NO_ERROR;
}
예제 #9
0
/*
 *  native_window_set_usage(..., usage)
 *  Sets the intended usage flags for the next buffers
 *  acquired with (*lockBuffer)() and on.
 *  By default (if this function is never called), a usage of
 *      GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE
 *  is assumed.
 *  Calling this function will usually cause following buffers to be
 *  reallocated.
 */
int HWComposerNativeWindow::setUsage(int usage)
{
    usage |= GRALLOC_USAGE_HW_COMPOSER|GRALLOC_USAGE_HW_FB;
    int need_realloc = (m_usage != (unsigned int) usage);
    TRACE("usage=x%x realloc=%d", usage, need_realloc);
    m_usage = usage;
    if (need_realloc)
        destroyBuffers();
    return NO_ERROR;
}
	Win32DirectSoundAudioDriver::~Win32DirectSoundAudioDriver()
	{
		mutex->Lock();
		TerminateThread(thread, 0);
		mutex->Unlock();
		delete mutex;

		destroyBuffers();

		device->Release();
	}
예제 #11
0
void NormalBlendedDecal::reshape(int32_t width, int32_t height)
{
    glViewport(0, 0, (GLint) width, (GLint) height);

    destroyBuffers();

    // Build buffers
    if ((width > 0) && (height > 0)) {
        glGenFramebuffers(1, &mGbufferFBO);

        glBindFramebuffer(GL_FRAMEBUFFER, mGbufferFBO);
        glGenTextures(NUM_GBUFFER_TEXTURES, mGbufferTextures);
        
        // uColorTex
        glBindTexture(GL_TEXTURE_2D, mGbufferTextures[COLOR_TEXTURE]);
        glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA16F, m_width, m_height);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

        // uNormalTex
        glBindTexture(GL_TEXTURE_2D, mGbufferTextures[NORMAL_TEXTURE]);
        glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA16F, m_width, m_height);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

        // uWorldPosTex
        glBindTexture(GL_TEXTURE_2D, mGbufferTextures[WORLDPOS_TEXTURE]);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, m_width, m_height, 0, GL_RGBA, GL_FLOAT, NULL);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

        // Depth texture
        glBindTexture(GL_TEXTURE_2D, mGbufferTextures[DEPTH_TEXTURE]);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, m_width, m_height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL);

        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mGbufferTextures[COLOR_TEXTURE], 0);
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, mGbufferTextures[NORMAL_TEXTURE], 0);
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, mGbufferTextures[WORLDPOS_TEXTURE], 0);
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, mGbufferTextures[DEPTH_TEXTURE], 0);

        glBindFramebuffer(GL_FRAMEBUFFER, 0);

        // Set GbufferDecalFBO
        glGenFramebuffers(1, &mGbufferDecalFBO);
        glBindFramebuffer(GL_FRAMEBUFFER, mGbufferDecalFBO);
        
        // Only color output
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mGbufferTextures[COLOR_TEXTURE], 0);
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, mGbufferTextures[DEPTH_TEXTURE], 0);

        glBindFramebuffer(GL_FRAMEBUFFER, 0);
    }
}
PluginViewPrivate::~PluginViewPrivate()
{
#if USE(ACCELERATED_COMPOSITING)
        if (m_platformLayer)
            static_cast<PluginLayerWebKitThread*>(m_platformLayer.get())->setPluginView(0);
#endif

    destroyBuffers();

    pthread_mutex_destroy(&m_backBufferMutex);
    pthread_rwlock_destroy(&m_frontBufferRwLock);
}
예제 #13
0
WaylandNativeWindow::~WaylandNativeWindow()
{
    std::list<WaylandNativeWindowBuffer *>::iterator it = m_bufList.begin();
    destroyBuffers();
    if (frame_callback)
        wl_callback_destroy(frame_callback);
    wl_event_queue_destroy(wl_queue);
   if (m_window) {
	    m_window->nativewindow = NULL;
	    m_window->resize_callback = NULL;
	    m_window->free_callback = NULL;
    }
}
예제 #14
0
	bool DX9Renderer::DX9PrepareBuffers(const Group& group)
	{
		if (!checkBuffers(group))
		{
			if (isBuffersCreationEnabled())
			{
				destroyBuffers(group);
				createBuffers(group);
				return true;
			}
			return false;
		}
		return true;
	}
예제 #15
0
bool Framebuffer2D::attachBuffer(   unsigned char buffer,
                                    GLint internalFormat, GLint format, GLint type,
                                    GLint textureMinFilter, GLint textureMagFilter,
                                    GLint textureWrapS, GLint textureWrapT, GLboolean mipMap)
{
    if(bufferIsValid(buffer))
    {
        unsigned int *textureHandle = getTextureHandle(buffer);
        GLenum attachment = getGLAttachment(buffer);

        if(buffer == FBO_DEPTH)
            destroyBuffers(RBO_DEPTH_BIT);

        if(glIsTexture(*textureHandle))
            glDeleteTextures(1, textureHandle);
        
        glGenTextures(1, textureHandle);

        glBindTexture(GL_TEXTURE_2D, *textureHandle);

        glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, textureMinFilter );
        glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, textureMagFilter );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, textureWrapS );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, textureWrapT );
        glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, type, NULL);

        if(mipMap)
            glGenerateMipmap(GL_TEXTURE_2D);

        glBindTexture(GL_TEXTURE_2D, 0);

        if(bufferIsAux(buffer))
             updateAuxBuffers();

        glBindFramebuffer(GL_FRAMEBUFFER, fboHandle);

        glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, *textureHandle, 0);
        
        glBindFramebuffer(GL_FRAMEBUFFER, 0);

        return true;
    }
    logError("passed buffer was not valid");

    return false;
}
bool PluginViewPrivate::createBuffers(NPSurfaceFormat format, int width, int height)
{
    bool success = true;

    PthreadMutexLocker backLock(&m_backBufferMutex);
    PthreadWriteLocker frontLock(&m_frontBufferRwLock);

    for (int i = 0; i < PLUGIN_BUFFERS; i++) {
        if (m_pluginBuffers[i]) {
            BlackBerry::Platform::Graphics::destroyBuffer(m_pluginBuffers[i]);
            m_pluginBuffers[i] = 0;
        }

        if (width <= 0 || height <= 0)
            success = true;
        else {
            m_pluginBuffers[i] = BlackBerry::Platform::Graphics::createBuffer(
                BlackBerry::Platform::IntSize(width, height),
                toBufferType(format));

            if (!m_pluginBuffers[i])
                success = false;
        }
    }

    if (success) {
        m_pluginBufferSize = IntSize(width, height);
        m_pluginBufferType = toBufferType(format);
    } else {
        m_pluginBufferSize = IntSize();
        m_pluginBufferType = BlackBerry::Platform::Graphics::PluginBufferWithAlpha;
        destroyBuffers();
    }

    return success;
}
예제 #17
0
	//------------------------------------------------------
	void DrawBuffer::buildBuffer() {
		// if size differs, we reallocate the buffers
		if (mQuadCount < mQuadList.size()) {
			// raise the buffer, with some padding to avoid frequent reallocations
			mQuadCount = mQuadList.size() * 2;
			destroyBuffers();
		}

		if (mQuadCount == 0)
			return;
		
		if (!mVertexData) {
			// no vertex data, let's reallocate some!
			mVertexData = new Ogre::VertexData();
			mVertexData->vertexStart = 0;
			mVertexData->vertexCount = mQuadCount * 4;

			Ogre::VertexDeclaration* decl = mVertexData->vertexDeclaration;
			Ogre::VertexBufferBinding* binding = mVertexData->vertexBufferBinding;

			size_t offset = 0;
			decl->addElement(0, offset, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
			offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
			decl->addElement(0, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES, 0);
			offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT2);
			decl->addElement(0, offset, Ogre::VET_COLOUR, Ogre::VES_DIFFUSE);

			mBuffer = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
					decl->getVertexSize(0), mVertexData->vertexCount, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE);

			binding->setBinding(0, mBuffer);
		}

		if (!mIndexData) {
			// no index data, so let's rebuilt it.
			mIndexData = new Ogre::IndexData();
			mIndexData->indexStart = 0;
			mIndexData->indexCount = mQuadCount * 6; // quad count, so we have a reserve

			// As canvas does it - build the IBO statically, we don't need no per-update updates
			mIndexData->indexBuffer = Ogre::HardwareBufferManager::getSingleton().createIndexBuffer(
					Ogre::HardwareIndexBuffer::IT_16BIT,
					mIndexData->indexCount,
					Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE, false);

			// now we'll fill the buffer with indices of triangles (0,2,1; 1,2,3)
			unsigned short* iData = reinterpret_cast<unsigned short*>(mIndexData->indexBuffer->lock(0, mIndexData->indexBuffer->getSizeInBytes(),
					Ogre::HardwareBuffer::HBL_DISCARD));

			// Inspired by Canvas. It's true we don't need to do this per frame,
			// we'll just set the mIndexData->indexCount to the proper value after building
			for (size_t iindex = 0, ivertex = 0, iquad = 0; iquad < mQuadCount; ++iquad, ivertex += 4) {
				iindex = iquad * 6;
				// tri 1
				iData[iindex++] = (unsigned short)(ivertex);
				iData[iindex++] = (unsigned short)(ivertex + 2);
				iData[iindex++] = (unsigned short)(ivertex + 1);
				// tri 2
				iData[iindex++] = (unsigned short)(ivertex + 1);
				iData[iindex++] = (unsigned short)(ivertex + 2);
				iData[iindex++] = (unsigned short)(ivertex + 3);
			}

			mIndexData->indexBuffer->unlock();
		};

		// now we'll build the vertex part - we are already sorted so we'll just need quad rewritten
		// to the vertex part
		float* buf = reinterpret_cast<float*>(mBuffer->lock(0, mQuadList.size() * mBuffer->getVertexSize() * 4, Ogre::HardwareBuffer::HBL_DISCARD));

		Ogre::RGBA* colptr;

		for (DrawQuadList::iterator it = mQuadList.begin(); it != mQuadList.end(); ++it) {
			// all the vertices
			const DrawQuad* dq = *it;

			/// Top Left corner
			*buf++ = dq->positions.left;
			*buf++ = dq->positions.top;
			*buf++ = dq->depth;

			*buf++ = dq->texCoords.left;
			*buf++ = dq->texCoords.top;

			colptr = reinterpret_cast<Ogre::RGBA*>(buf);
			Ogre::Root::getSingleton().convertColourValue(dq->color, colptr);
			colptr++;
			buf = reinterpret_cast<float*>(colptr);

			/// Top right corner
			*buf++ = dq->positions.right;
			*buf++ = dq->positions.top;
			*buf++ = dq->depth;

			*buf++ = dq->texCoords.right;
			*buf++ = dq->texCoords.top;

			colptr = reinterpret_cast<Ogre::RGBA*>(buf);
			Ogre::Root::getSingleton().convertColourValue(dq->color, colptr);
			colptr++;
			buf = reinterpret_cast<float*>(colptr);

			/// Bottom left corner
			*buf++ = dq->positions.left;
			*buf++ = dq->positions.bottom;
			*buf++ = dq->depth;

			*buf++ = dq->texCoords.left;
			*buf++ = dq->texCoords.bottom;

			colptr = reinterpret_cast<Ogre::RGBA*>(buf);
			Ogre::Root::getSingleton().convertColourValue(dq->color, colptr);
			colptr++;
			buf = reinterpret_cast<float*>(colptr);

			/// Bottom right corner
			*buf++ = dq->positions.right;
			*buf++ = dq->positions.bottom;
			*buf++ = dq->depth;

			*buf++ = dq->texCoords.right;
			*buf++ = dq->texCoords.bottom;

			colptr = reinterpret_cast<Ogre::RGBA*>(buf);
			Ogre::Root::getSingleton().convertColourValue(dq->color, colptr);
			colptr++;
			buf = reinterpret_cast<float*>(colptr);
		}

		// ibo length to the number of quads times six
		mIndexData->indexCount = mQuadList.size() * 6;

		mBuffer->unlock();
	};
예제 #18
0
FbDevNativeWindow::~FbDevNativeWindow()
{
    destroyBuffers();
}
예제 #19
0
PointSpritesGeometry::~PointSpritesGeometry() {
    destroyBuffers();
}
	void Win32DirectSoundAudioDriver::recreateBuffers()
	{
		destroyBuffers();
		createBuffers();
	}
예제 #21
0
HWComposerNativeWindow::~HWComposerNativeWindow()
{
    destroyBuffers();
}
예제 #22
0
	//------------------------------------------------------
	DrawBuffer::~DrawBuffer() {
		// destroy the material again
		// Ogre::MaterialManager::getSingleton().remove(mMaterial);
		destroyBuffers();
	};