summaryrefslogtreecommitdiff
path: root/cogl/cogl-loose-region.h
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2011-09-27 15:32:58 +0100
committerNeil Roberts <neil@linux.intel.com>2011-09-27 16:08:42 +0100
commitc1602f4abcf9083fde25c8e576d019f30cf192fb (patch)
tree62296ff5b4538a79752a174599dc6d3624ed4262 /cogl/cogl-loose-region.h
parent7bd66f40ca3fa01ec49ebe2d87a76c26874bacd7 (diff)
downloadcogl-wip/journal-reorg.tar.gz
cogl-journal: Use a loose region instead of a bounding boxwip/journal-reorg
Instead of just recording the bounding box of a journal batch, it now uses a new data type called a loose region. A loose region keeps track of up to 4 separate bounding boxes to represent at least the region covered by the batch. If a new rectangle added to the region only increases the size of an existing bounding box to within a certain threshold then it will be added to that bounding box, otherwise it will start a new bounding box. This increases the chances that batches can be grouped together because it can represent sparse regions to a degree without as much of the complexity as totally accurately tracking the region.
Diffstat (limited to 'cogl/cogl-loose-region.h')
-rw-r--r--cogl/cogl-loose-region.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/cogl/cogl-loose-region.h b/cogl/cogl-loose-region.h
new file mode 100644
index 00000000..b7296d44
--- /dev/null
+++ b/cogl/cogl-loose-region.h
@@ -0,0 +1,64 @@
+/*
+ * Cogl
+ *
+ * An object oriented GL/GLES Abstraction/Utility Layer
+ *
+ * Copyright (C) 2011 Intel Corporation.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ *
+ * Authors:
+ * Neil Roberts <neil@linux.intel.com>
+ */
+
+/* CoglLooseRegion is a data structure that is a cross between a
+ simple bounding box and a region. Instead of keeping all of the
+ rectangles necessary to track an exact region, it only keeps around
+ a few bounding boxes. This can be checked for intersection much
+ more quickly than a complicated region but it will have some false
+ positives. */
+
+#ifndef __COGL_LOOSE_REGION_H__
+#define __COGL_LOOSE_REGION_H__
+
+#include <glib.h>
+
+#define COGL_LOOSE_REGION_N_RECTANGLES 4
+
+typedef struct _CoglLooseRegionRectangle
+{
+ float x_1, y_1;
+ float x_2, y_2;
+} CoglLooseRegionRectangle;
+
+typedef struct _CoglLooseRegion
+{
+ int n_rects;
+ CoglLooseRegionRectangle rects[COGL_LOOSE_REGION_N_RECTANGLES];
+} CoglLooseRegion;
+
+void
+_cogl_loose_region_init (CoglLooseRegion *region);
+
+void
+_cogl_loose_region_add_rectangle (CoglLooseRegion *region,
+ const CoglLooseRegionRectangle *rect);
+
+gboolean
+_cogl_loose_region_intersects (const CoglLooseRegion *region,
+ const CoglLooseRegionRectangle *rect);
+
+#endif /* __COGL_LOOSE_REGION_H__ */