1 /* 2 * Copyright 2009, 2011 Henri Verbeet for CodeWeavers 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 17 * 18 */ 19 20 #include "wined3d_private.h" 21 22 WINE_DEFAULT_DEBUG_CHANNEL(d3d); 23 24 ULONG CDECL wined3d_rendertarget_view_incref(struct wined3d_rendertarget_view *view) 25 { 26 ULONG refcount = InterlockedIncrement(&view->refcount); 27 28 TRACE("%p increasing refcount to %u.\n", view, refcount); 29 30 return refcount; 31 } 32 33 ULONG CDECL wined3d_rendertarget_view_decref(struct wined3d_rendertarget_view *view) 34 { 35 ULONG refcount = InterlockedDecrement(&view->refcount); 36 37 TRACE("%p decreasing refcount to %u.\n", view, refcount); 38 39 if (!refcount) 40 HeapFree(GetProcessHeap(), 0, view); 41 42 return refcount; 43 } 44 45 void * CDECL wined3d_rendertarget_view_get_parent(const struct wined3d_rendertarget_view *view) 46 { 47 TRACE("view %p.\n", view); 48 49 return view->parent; 50 } 51 52 struct wined3d_resource * CDECL wined3d_rendertarget_view_get_resource(const struct wined3d_rendertarget_view *view) 53 { 54 TRACE("view %p.\n", view); 55 56 return view->resource; 57 } 58 59 static void wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *view, 60 struct wined3d_resource *resource, void *parent) 61 { 62 view->refcount = 1; 63 view->resource = resource; 64 view->parent = parent; 65 } 66 67 HRESULT CDECL wined3d_rendertarget_view_create(struct wined3d_resource *resource, 68 void *parent, struct wined3d_rendertarget_view **rendertarget_view) 69 { 70 struct wined3d_rendertarget_view *object; 71 72 TRACE("resource %p, parent %p, rendertarget_view %p.\n", 73 resource, parent, rendertarget_view); 74 75 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); 76 if (!object) 77 return E_OUTOFMEMORY; 78 79 wined3d_rendertarget_view_init(object, resource, parent); 80 81 TRACE("Created render target view %p.\n", object); 82 *rendertarget_view = object; 83 84 return WINED3D_OK; 85 } 86