revert 213 commits (to 56092) from the last month. 10 still need work to resolve...
[AROS.git] / workbench / libs / gallium / createpipe.c
blob73006b322d3df572e5eb0ce934f295f10263ae13
1 /*
2 Copyright © 2015-2018, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define DEBUG 1
7 #include <aros/debug.h>
9 #include <proto/utility.h>
10 #include <proto/intuition.h>
12 #include <hidd/gfx.h>
14 #include <stdio.h>
16 #include "gallium_intern.h"
18 #undef HiddGalliumAttrBase
19 #define HiddGalliumAttrBase GB(GalliumBase)->galliumAttrBase
21 /*****************************************************************************
23 NAME */
25 AROS_LH1(PipeHandle_t, CreatePipe,
27 /* SYNOPSIS */
28 AROS_LHA(struct TagItem *, tags, A0),
30 /* LOCATION */
31 struct Library *, GalliumBase, 5, Gallium)
33 /* FUNCTION
34 Instantiates a gallium pipe.
36 INPUTS
37 tags - a pointer to tags to be used during creation.
39 TAGS
40 CPS_PipeFriendBitmap - a bitmap our pipe screen will target.
41 CPS_PipeScreenDriver * - where to store the driver.
42 CPS_GalliumInterfaceVersion - Indicates a version of gallium interface
43 that a client is expected to receive. The client expected version
44 must ideally match with the version that the driver provides,
45 because gallium interface is not backwards compatible. This tag is
46 required. Unless otherwise needed, the value
47 GALLIUM_INTERFACE_VERSION should be passed.
48 See also CreatePipeV.
50 RESULT
51 A valid pipe instance or NULL if creation was not successful.
53 BUGS
55 INTERNALS
57 *****************************************************************************/
59 AROS_LIBFUNC_INIT
61 struct TagItem galliumTags[] =
63 { aHidd_Gallium_InterfaceVersion, 0 },
64 { TAG_DONE, 0 }
66 OOP_Object *_driver = NULL;
67 OOP_Object **driver;
68 struct BitMap *friendbm;
69 struct Screen *pubscreen = NULL;
71 galliumTags[0].ti_Data = GetTagData(CPS_GalliumInterfaceVersion, -1, tags);
72 friendbm = (struct BitMap *)GetTagData(CPS_PipeFriendBitMap, 0, tags);
73 driver = (OOP_Object **)GetTagData(CPS_PipeScreenDriver, (IPTR)&_driver, tags);
75 /* The tag is missing */
76 if (galliumTags[0].ti_Data == -1)
77 return NULL;
79 if (!friendbm)
81 if ((pubscreen = LockPubScreen(NULL)) != NULL)
82 friendbm = pubscreen->RastPort.BitMap;
85 D(bug("[Gallium] %s: friendbm @ 0x%p\n", __PRETTY_FUNCTION__, friendbm));
87 if (friendbm && IS_HIDD_BM(friendbm))
89 OOP_Object *bmObj = HIDD_BM_OBJ(friendbm);
90 if (bmObj)
92 OOP_Object *gfxhidd;
93 OOP_GetAttr(bmObj, aHidd_BitMap_GfxHidd, (IPTR *)&gfxhidd);
95 if (gfxhidd)
97 *driver = HIDD_Gfx_CreateObject(gfxhidd, GB(GalliumBase)->basegallium, galliumTags);
102 if (pubscreen)
103 UnlockPubScreen(NULL, pubscreen);
105 if (!*driver)
107 char tmpname[128];
108 if (!GB(GalliumBase)->fallbackmodule)
110 sprintf(tmpname, "%s.hidd", GB(GalliumBase)->fallback);
112 D(bug("[Gallium] %s: trying fallback '%s' ...\n", __PRETTY_FUNCTION__, tmpname));
114 GB(GalliumBase)->fallbackmodule = OpenLibrary(tmpname, 9);
116 D(bug("[Gallium] %s: '%s' @ 0x%p\n", __PRETTY_FUNCTION__, tmpname, GB(GalliumBase)->fallbackmodule));
119 if (GB(GalliumBase)->fallbackmodule)
121 sprintf(tmpname, "hidd.gallium.%s", GB(GalliumBase)->fallback);
123 *driver = OOP_NewObject(NULL, tmpname, galliumTags);
125 D(bug("[Gallium] %s: '%s' @ 0x%p\n", __PRETTY_FUNCTION__, tmpname, *driver));
129 return *driver;
131 AROS_LIBFUNC_EXIT