Esempio n. 1
0
already_AddRefed<layers::SharedSurfaceTextureClient>
SurfaceFactory::NewTexClient(const gfx::IntSize& size)
{
    while (!mRecycleFreePool.empty()) {
        RefPtr<layers::SharedSurfaceTextureClient> cur = mRecycleFreePool.front();
        mRecycleFreePool.pop();

        if (cur->Surf()->mSize == size) {
            return cur.forget();
        }

        StopRecycling(cur);
    }

    UniquePtr<SharedSurface> surf = Move(CreateShared(size));
    if (!surf)
        return nullptr;

    RefPtr<layers::SharedSurfaceTextureClient> ret;
    ret = new layers::SharedSurfaceTextureClient(mAllocator, mFlags, Move(surf), this);

    StartRecycling(ret);

    return ret.forget();
}
Esempio n. 2
0
UniquePtr<SharedSurface>
SurfaceFactory::NewSharedSurface(const gfx::IntSize& size)
{
    // Attempt to reuse an old surface.
    while (!mScraps.Empty()) {
        UniquePtr<SharedSurface> cur = mScraps.Pop();

        if (cur->mSize == size)
            return Move(cur);

        // Let `cur` be destroyed as it falls out of scope, if it wasn't
        // moved.
    }

    return CreateShared(size);
}
Esempio n. 3
0
SharedSurface*
SurfaceFactory::NewSharedSurface(const gfx::IntSize& size)
{
    // Attempt to reuse an old surface.
    while (!mScraps.empty()) {
        SharedSurface* cur = mScraps.front();
        mScraps.pop();
        if (cur->mSize == size)
            return cur;

        // Destroy old surfaces of the wrong size.
        delete cur;
    }

    SharedSurface* ret = CreateShared(size);

    return ret;
}
Esempio n. 4
0
File: device.c Progetto: DonCN/haiku
static status_t
OpenHook(const char *name, uint32 flags, void **cookie)
{
	status_t ret = B_OK;
	pci_info *pcii = &gPd->pcii;
	uint32 tmpUlong;

	TRACE("OpenHook (%s, %ld)\n", name, flags);
	ACQUIRE_BEN(gPd->kernel);

	if (gPd->isOpen)
		goto markAsOpen;

	/* Enable memory mapped IO and VGA I/O */
	tmpUlong = get_pci(PCI_command, 2);
	tmpUlong |= PCI_command_memory;
	tmpUlong |= PCI_command_io;
	set_pci(PCI_command, 2, tmpUlong);

	if ((ret = CreateShared()) != B_OK)
		goto done;
	if ((ret = CheckCapabilities()) != B_OK)
		goto freeShared;
	if ((ret = MapDevice()) != B_OK)
		goto freeShared;

markAsOpen:
	gPd->isOpen++;
	*cookie = gPd;
	goto done;

freeShared:
	FreeShared();

done:
	RELEASE_BEN(gPd->kernel);
	TRACE("OpenHook: %ld\n", ret);
	return ret;
}