]> Dogcows Code - chaz/openbox/blobdiff - obrender/render.c
Adding RrButton to libobrender, ref counted appearances.
[chaz/openbox] / obrender / render.c
index 58bf12ec71a702499bfb3e78cd6a4850575f8741..7a3420429116fb808f6444333185b460ae353557 100644 (file)
@@ -170,6 +170,8 @@ Pixmap RrPaintPixmap(RrAppearance *a, gint w, gint h)
             }
             force_transfer = 1;
         break;
+        case RR_TEXTURE_NUM_TYPES:
+            g_assert_not_reached();
         }
     }
 
@@ -202,6 +204,7 @@ RrAppearance *RrAppearanceNew(const RrInstance *inst, gint numtex)
 
   out = g_slice_new0(RrAppearance);
   out->inst = inst;
+  out->ref = 1;
   out->textures = numtex;
   out->surface.bevel_light_adjust = 128;
   out->surface.bevel_dark_adjust = 64;
@@ -229,12 +232,22 @@ void RrAppearanceClearTextures(RrAppearance *a)
     memset(a->texture, 0, a->textures * sizeof(RrTexture));
 }
 
+/* shallow copy means up the ref count and return it */
+RrAppearance *RrAppearanceCopyShallow(RrAppearance *orig)
+{
+    orig->ref++;
+    return orig;
+}
+
+/* deep copy of orig, means reset ref to 1 on copy
+ * and copy each thing memwise. */
 RrAppearance *RrAppearanceCopy(RrAppearance *orig)
 {
     RrSurface *spo, *spc;
     RrAppearance *copy = g_slice_new(RrAppearance);
 
     copy->inst = orig->inst;
+    copy->ref = 1;
 
     spo = &(orig->surface);
     spc = &(copy->surface);
@@ -314,6 +327,7 @@ RrAppearance *RrAppearanceCopy(RrAppearance *orig)
     return copy;
 }
 
+/* now decrements ref counter, and frees only if ref <= 0 */
 void RrAppearanceFree(RrAppearance *a)
 {
     if (a) {
@@ -377,6 +391,8 @@ void RrMargins (RrAppearance *a, gint *l, gint *t, gint *r, gint *b)
             case RR_BEVEL_2:
                 *l = *t = *r = *b = 2;
                 break;
+            case RR_BEVEL_NUM_TYPES:
+                g_assert_not_reached();
             }
         } else if (a->surface.border) {
             *l = *t = *r = *b = 1;
@@ -426,6 +442,8 @@ gint RrMinWidth(RrAppearance *a)
             w = MAX(w, MAX(a->texture[i].data.lineart.x1 - l - r,
                            a->texture[i].data.lineart.x2 - l - r));
             break;
+        case RR_TEXTURE_NUM_TYPES:
+            g_assert_not_reached();
         }
     }
 
@@ -481,6 +499,8 @@ gint RrMinHeight(RrAppearance *a)
             h = MAX(h, MAX(a->texture[i].data.lineart.y1 - t - b,
                            a->texture[i].data.lineart.y2 - t - b));
             break;
+        case RR_TEXTURE_NUM_TYPES:
+            g_assert_not_reached();
         }
     }
 
This page took 0.026278 seconds and 4 git commands to generate.