summaryrefslogtreecommitdiff
path: root/Development/Documentation/WrappingFunctions.mdwn
diff options
context:
space:
mode:
Diffstat (limited to 'Development/Documentation/WrappingFunctions.mdwn')
-rw-r--r--Development/Documentation/WrappingFunctions.mdwn38
1 files changed, 38 insertions, 0 deletions
diff --git a/Development/Documentation/WrappingFunctions.mdwn b/Development/Documentation/WrappingFunctions.mdwn
new file mode 100644
index 00000000..735e1898
--- /dev/null
+++ b/Development/Documentation/WrappingFunctions.mdwn
@@ -0,0 +1,38 @@
+
+# Moved from [[http://www.freedesktop.org/wiki/Software/WrappingFunctions|http://www.freedesktop.org/wiki/Software/WrappingFunctions]]
+
+
+## Wrapping Functions
+
+_XXX: Add some information about prologues/epilogues_
+
+Sometimes you want to override or hook into a certain function and have it do something else. For example, you might want to use an accelerated function for drawing triangles. This is done by replacing the function pointers in the data structures
+
+
+[[!format txt """
+/* Don't forget to save the original function */
+pMyScreenData->CreatePixmap = pSCreen->CreatePixmap;
+
+/* Replace the function */
+pScreen->CreatePixmap = MyCreatePixmap;
+"""]]
+Now the function `MyCreatePixmap` will be called instead of the regular `CreatePixmap` function. This is good if we're superstitious:
+[[!format txt """
+static PixmapPtr
+MyCreatePixmap (ScreenPtr pScreen, int w, int h, int depth)
+{
+ MyScreenDataPtr pMyScreenData = GET''MY''SCREEN_DATA (pScreen);
+
+ if (w == 13 && h == 13)
+ {
+ /* Refuse to create pixmaps with size 13x13 */
+ return NULL;
+ }
+
+ /* Call the original function */
+ return (* pMyScreenData->CreatePixmap) (pScreen, w, h, depth);
+}
+"""]]
+(See [[Development/Documentation/DevPrivates|Development/Documentation/DevPrivates]] for information on where the `MyScreenDataPtr` comes from)
+
+-- [[AndersCarlsson|AndersCarlsson]] - 23 Sep 2003