2009-02-24 07:43:02 +01:00
|
|
|
/*
|
2011-04-05 19:01:32 +02:00
|
|
|
* Copyright 2009, 2011 Henri Verbeet for CodeWeavers
|
2009-02-24 07:43:02 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
|
|
|
#include "wined3d_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
|
|
|
|
|
2011-04-05 19:01:32 +02:00
|
|
|
ULONG CDECL wined3d_rendertarget_view_incref(struct wined3d_rendertarget_view *view)
|
2009-02-24 07:43:02 +01:00
|
|
|
{
|
2011-04-05 19:01:32 +02:00
|
|
|
ULONG refcount = InterlockedIncrement(&view->refcount);
|
2009-02-24 07:43:02 +01:00
|
|
|
|
2011-04-05 19:01:32 +02:00
|
|
|
TRACE("%p increasing refcount to %u.\n", view, refcount);
|
2009-02-24 07:43:02 +01:00
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2011-04-05 19:01:32 +02:00
|
|
|
ULONG CDECL wined3d_rendertarget_view_decref(struct wined3d_rendertarget_view *view)
|
2009-02-24 07:43:02 +01:00
|
|
|
{
|
2011-04-05 19:01:32 +02:00
|
|
|
ULONG refcount = InterlockedDecrement(&view->refcount);
|
2009-02-24 07:43:02 +01:00
|
|
|
|
2011-04-05 19:01:32 +02:00
|
|
|
TRACE("%p decreasing refcount to %u.\n", view, refcount);
|
2009-02-24 07:43:02 +01:00
|
|
|
|
|
|
|
if (!refcount)
|
2011-04-05 19:01:32 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, view);
|
2009-02-24 07:43:02 +01:00
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2011-04-05 19:01:32 +02:00
|
|
|
void * CDECL wined3d_rendertarget_view_get_parent(const struct wined3d_rendertarget_view *view)
|
2009-02-24 07:43:02 +01:00
|
|
|
{
|
2011-04-05 19:01:32 +02:00
|
|
|
TRACE("view %p.\n", view);
|
2009-02-24 07:43:02 +01:00
|
|
|
|
2011-04-05 19:01:32 +02:00
|
|
|
return view->parent;
|
2009-02-24 07:43:02 +01:00
|
|
|
}
|
|
|
|
|
2011-04-05 19:01:32 +02:00
|
|
|
struct wined3d_resource * CDECL wined3d_rendertarget_view_get_resource(const struct wined3d_rendertarget_view *view)
|
2009-02-24 07:43:02 +01:00
|
|
|
{
|
2011-04-05 19:01:32 +02:00
|
|
|
TRACE("view %p.\n", view);
|
2009-02-24 07:43:02 +01:00
|
|
|
|
2011-04-05 19:01:32 +02:00
|
|
|
return view->resource;
|
2009-02-24 07:43:02 +01:00
|
|
|
}
|
|
|
|
|
2011-05-10 21:18:47 +02:00
|
|
|
static void wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *view,
|
2011-03-01 09:47:56 +01:00
|
|
|
struct wined3d_resource *resource, void *parent)
|
2010-04-13 20:46:24 +02:00
|
|
|
{
|
|
|
|
view->refcount = 1;
|
2011-01-17 18:49:30 +01:00
|
|
|
view->resource = resource;
|
2010-04-13 20:46:24 +02:00
|
|
|
view->parent = parent;
|
|
|
|
}
|
2011-05-10 21:18:47 +02:00
|
|
|
|
|
|
|
HRESULT CDECL wined3d_rendertarget_view_create(struct wined3d_resource *resource,
|
|
|
|
void *parent, struct wined3d_rendertarget_view **rendertarget_view)
|
|
|
|
{
|
|
|
|
struct wined3d_rendertarget_view *object;
|
|
|
|
|
|
|
|
TRACE("resource %p, parent %p, rendertarget_view %p.\n",
|
|
|
|
resource, parent, rendertarget_view);
|
|
|
|
|
|
|
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate memory\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
wined3d_rendertarget_view_init(object, resource, parent);
|
|
|
|
|
|
|
|
TRACE("Created render target view %p.\n", object);
|
|
|
|
*rendertarget_view = object;
|
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|