aboutsummaryrefslogtreecommitdiff
path: root/helium/mask.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'helium/mask.cpp')
-rw-r--r--helium/mask.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/helium/mask.cpp b/helium/mask.cpp
new file mode 100644
index 0000000..86a33a8
--- /dev/null
+++ b/helium/mask.cpp
@@ -0,0 +1,39 @@
+// Copyright 2006 Google Inc.
+// All Rights Reserved.
+// Author: <renn@google.com> (Marius Renn)
+//
+#include "mask.h"
+
+using namespace helium;
+
+Mask::Mask() : Map<bool>() {
+}
+
+Mask::Mask(unsigned width, unsigned height) : Map<bool>(width, height) {
+}
+
+Mask::Mask(unsigned width, unsigned height, bool* data)
+ : Map<bool>(width, height, data) {
+}
+
+// Note on bit operations: We use the double boolean operators (i.e. '&&'),
+// thus potentially saving a pointer lookup for the second operand.
+void Mask::BitOr(const Mask& other) {
+ ASSERT((width() == other.width()) && (height() == other.height()));
+
+ bool* src_ptr = other.data();
+ for (bool* dest_ptr = data(); dest_ptr < DataEnd(); ++dest_ptr) {
+ *dest_ptr = (*dest_ptr) || (*src_ptr);
+ ++src_ptr;
+ }
+}
+
+void Mask::BitAnd(const Mask& other) {
+ ASSERT((width() == other.width()) && (height() == other.height()));
+
+ bool* src_ptr = other.data();
+ for (bool* dest_ptr = data(); dest_ptr < DataEnd(); ++dest_ptr) {
+ *dest_ptr = (*dest_ptr) && (*src_ptr);
+ ++src_ptr;
+ }
+}