summaryrefslogtreecommitdiff
path: root/Development/Documentation/WrappingFunctions.mdwn
diff options
context:
space:
mode:
authorJoe Rayhawk <jrayhawk@freedesktop.org>2013-07-08 07:19:58 +0000
committerJoe Rayhawk <jrayhawk@freedesktop.org>2013-07-08 07:19:58 +0000
commitf5c5b00ff9b2c7bb5f333aaaf5630d64170e632d (patch)
treea00c149e86ea358ba93c2461f30ab681e6f41964 /Development/Documentation/WrappingFunctions.mdwn
parent93f259e2a3511b0a4a68991e2b309865d91312ed (diff)
moin2mdwn: convert page Development/Documentation/WrappingFunctions
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