sampler.c revision a956c473406f6ddd9799f7deeba54d3dc684b1db
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync/*
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync * Copyright 2012 Henri Verbeet for CodeWeavers
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync *
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync * This library is free software; you can redistribute it and/or
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync * modify it under the terms of the GNU Lesser General Public
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync * License as published by the Free Software Foundation; either
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync * version 2.1 of the License, or (at your option) any later version.
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync *
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync * This library is distributed in the hope that it will be useful,
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync * but WITHOUT ANY WARRANTY; without even the implied warranty of
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync * Lesser General Public License for more details.
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync *
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync * You should have received a copy of the GNU Lesser General Public
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync * License along with this library; if not, write to the Free Software
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync *
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync */
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync#include "config.h"
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync#include "wine/port.h"
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync#include "wined3d_private.h"
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync
91b827c98a305956e75cb1618af6ae17e450fb88vboxsyncWINE_DEFAULT_DEBUG_CHANNEL(d3d);
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsyncULONG CDECL wined3d_sampler_incref(struct wined3d_sampler *sampler)
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync{
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync ULONG refcount = InterlockedIncrement(&sampler->refcount);
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync TRACE("%p increasing refcount to %u.\n", sampler, refcount);
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync return refcount;
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync}
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsyncULONG CDECL wined3d_sampler_decref(struct wined3d_sampler *sampler)
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync{
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync ULONG refcount = InterlockedDecrement(&sampler->refcount);
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync TRACE("%p decreasing refcount to %u.\n", sampler, refcount);
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync if (!refcount)
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync HeapFree(GetProcessHeap(), 0, sampler);
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync return refcount;
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync}
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsyncvoid * CDECL wined3d_sampler_get_parent(const struct wined3d_sampler *sampler)
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync{
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync TRACE("sampler %p.\n", sampler);
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync return sampler->parent;
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync}
91b827c98a305956e75cb1618af6ae17e450fb88vboxsync
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsyncstatic void wined3d_sampler_init(struct wined3d_sampler *sampler, void *parent)
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync{
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync sampler->refcount = 1;
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync sampler->parent = parent;
91b827c98a305956e75cb1618af6ae17e450fb88vboxsync}
91b827c98a305956e75cb1618af6ae17e450fb88vboxsync
91b827c98a305956e75cb1618af6ae17e450fb88vboxsyncHRESULT CDECL wined3d_sampler_create(void *parent, struct wined3d_sampler **sampler)
91b827c98a305956e75cb1618af6ae17e450fb88vboxsync{
91b827c98a305956e75cb1618af6ae17e450fb88vboxsync struct wined3d_sampler *object;
91b827c98a305956e75cb1618af6ae17e450fb88vboxsync
91b827c98a305956e75cb1618af6ae17e450fb88vboxsync TRACE("parent %p, sampler %p.\n", parent, sampler);
91b827c98a305956e75cb1618af6ae17e450fb88vboxsync
91b827c98a305956e75cb1618af6ae17e450fb88vboxsync if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
91b827c98a305956e75cb1618af6ae17e450fb88vboxsync return E_OUTOFMEMORY;
91b827c98a305956e75cb1618af6ae17e450fb88vboxsync
91b827c98a305956e75cb1618af6ae17e450fb88vboxsync wined3d_sampler_init(object, parent);
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync TRACE("Created sampler %p.\n", object);
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync *sampler = object;
b6013430932520fe58eba109db1dfce66a7cad88vboxsync
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync return WINED3D_OK;
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync}
b56ca3f25c9c141f3c0855b656f8f64bbfa19496vboxsync