The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #define LOG_TAG "Region" |
| 18 | |
Mathias Agopian | 72b0ffe | 2009-07-06 18:07:26 -0700 | [diff] [blame] | 19 | #include <limits.h> |
| 20 | |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 21 | #include <utils/Log.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | #include <utils/String8.h> |
Mathias Agopian | 068d47f | 2012-09-11 18:56:23 -0700 | [diff] [blame] | 23 | #include <utils/CallStack.h> |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 24 | |
| 25 | #include <ui/Rect.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | #include <ui/Region.h> |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 27 | #include <ui/Point.h> |
| 28 | |
| 29 | #include <private/ui/RegionHelper.h> |
| 30 | |
| 31 | // ---------------------------------------------------------------------------- |
| 32 | #define VALIDATE_REGIONS (false) |
| 33 | #define VALIDATE_WITH_CORECG (false) |
| 34 | // ---------------------------------------------------------------------------- |
| 35 | |
| 36 | #if VALIDATE_WITH_CORECG |
| 37 | #include <core/SkRegion.h> |
| 38 | #endif |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | |
| 40 | namespace android { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 41 | // ---------------------------------------------------------------------------- |
| 42 | |
| 43 | enum { |
| 44 | op_nand = region_operator<Rect>::op_nand, |
| 45 | op_and = region_operator<Rect>::op_and, |
| 46 | op_or = region_operator<Rect>::op_or, |
| 47 | op_xor = region_operator<Rect>::op_xor |
| 48 | }; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 49 | |
| 50 | // ---------------------------------------------------------------------------- |
| 51 | |
Mathias Agopian | 3ab6855 | 2012-08-31 14:31:40 -0700 | [diff] [blame] | 52 | Region::Region() { |
| 53 | mStorage.add(Rect(0,0)); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | Region::Region(const Region& rhs) |
Mathias Agopian | 3ab6855 | 2012-08-31 14:31:40 -0700 | [diff] [blame] | 57 | : mStorage(rhs.mStorage) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 58 | { |
Mathias Agopian | d0b55c0 | 2011-03-16 23:18:07 -0700 | [diff] [blame] | 59 | #if VALIDATE_REGIONS |
| 60 | validate(rhs, "rhs copy-ctor"); |
| 61 | #endif |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 62 | } |
| 63 | |
Mathias Agopian | 3ab6855 | 2012-08-31 14:31:40 -0700 | [diff] [blame] | 64 | Region::Region(const Rect& rhs) { |
| 65 | mStorage.add(rhs); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | Region::~Region() |
| 69 | { |
| 70 | } |
| 71 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 72 | Region& Region::operator = (const Region& rhs) |
| 73 | { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 74 | #if VALIDATE_REGIONS |
Mathias Agopian | d0b55c0 | 2011-03-16 23:18:07 -0700 | [diff] [blame] | 75 | validate(*this, "this->operator="); |
| 76 | validate(rhs, "rhs.operator="); |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 77 | #endif |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 78 | mStorage = rhs.mStorage; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 79 | return *this; |
| 80 | } |
| 81 | |
Mathias Agopian | 9f96145 | 2009-06-29 18:46:37 -0700 | [diff] [blame] | 82 | Region& Region::makeBoundsSelf() |
| 83 | { |
Mathias Agopian | 3ab6855 | 2012-08-31 14:31:40 -0700 | [diff] [blame] | 84 | if (mStorage.size() >= 2) { |
| 85 | const Rect bounds(getBounds()); |
| 86 | mStorage.clear(); |
| 87 | mStorage.add(bounds); |
| 88 | } |
Mathias Agopian | 9f96145 | 2009-06-29 18:46:37 -0700 | [diff] [blame] | 89 | return *this; |
| 90 | } |
| 91 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 92 | void Region::clear() |
| 93 | { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 94 | mStorage.clear(); |
Mathias Agopian | 3ab6855 | 2012-08-31 14:31:40 -0700 | [diff] [blame] | 95 | mStorage.add(Rect(0,0)); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | void Region::set(const Rect& r) |
| 99 | { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 100 | mStorage.clear(); |
Mathias Agopian | 3ab6855 | 2012-08-31 14:31:40 -0700 | [diff] [blame] | 101 | mStorage.add(r); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 102 | } |
| 103 | |
Mathias Agopian | 0926f50 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 104 | void Region::set(uint32_t w, uint32_t h) |
| 105 | { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 106 | mStorage.clear(); |
Mathias Agopian | 3ab6855 | 2012-08-31 14:31:40 -0700 | [diff] [blame] | 107 | mStorage.add(Rect(w,h)); |
Mathias Agopian | 0926f50 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 108 | } |
| 109 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 110 | // ---------------------------------------------------------------------------- |
| 111 | |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 112 | void Region::addRectUnchecked(int l, int t, int r, int b) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 113 | { |
Mathias Agopian | 3ab6855 | 2012-08-31 14:31:40 -0700 | [diff] [blame] | 114 | Rect rect(l,t,r,b); |
| 115 | size_t where = mStorage.size() - 1; |
| 116 | mStorage.insertAt(rect, where, 1); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 117 | } |
| 118 | |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 119 | // ---------------------------------------------------------------------------- |
| 120 | |
| 121 | Region& Region::orSelf(const Rect& r) { |
| 122 | return operationSelf(r, op_or); |
| 123 | } |
Romain Guy | b8a2e98 | 2012-02-07 17:04:34 -0800 | [diff] [blame] | 124 | Region& Region::xorSelf(const Rect& r) { |
| 125 | return operationSelf(r, op_xor); |
| 126 | } |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 127 | Region& Region::andSelf(const Rect& r) { |
| 128 | return operationSelf(r, op_and); |
| 129 | } |
| 130 | Region& Region::subtractSelf(const Rect& r) { |
| 131 | return operationSelf(r, op_nand); |
| 132 | } |
| 133 | Region& Region::operationSelf(const Rect& r, int op) { |
| 134 | Region lhs(*this); |
| 135 | boolean_operation(op, *this, lhs, r); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 136 | return *this; |
| 137 | } |
| 138 | |
| 139 | // ---------------------------------------------------------------------------- |
| 140 | |
| 141 | Region& Region::orSelf(const Region& rhs) { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 142 | return operationSelf(rhs, op_or); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 143 | } |
Romain Guy | b8a2e98 | 2012-02-07 17:04:34 -0800 | [diff] [blame] | 144 | Region& Region::xorSelf(const Region& rhs) { |
| 145 | return operationSelf(rhs, op_xor); |
| 146 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 147 | Region& Region::andSelf(const Region& rhs) { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 148 | return operationSelf(rhs, op_and); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 149 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 150 | Region& Region::subtractSelf(const Region& rhs) { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 151 | return operationSelf(rhs, op_nand); |
| 152 | } |
| 153 | Region& Region::operationSelf(const Region& rhs, int op) { |
| 154 | Region lhs(*this); |
| 155 | boolean_operation(op, *this, lhs, rhs); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 156 | return *this; |
| 157 | } |
| 158 | |
| 159 | Region& Region::translateSelf(int x, int y) { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 160 | if (x|y) translate(*this, x, y); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 161 | return *this; |
| 162 | } |
| 163 | |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 164 | // ---------------------------------------------------------------------------- |
| 165 | |
Mathias Agopian | bed9dd1 | 2009-05-27 17:01:58 -0700 | [diff] [blame] | 166 | const Region Region::merge(const Rect& rhs) const { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 167 | return operation(rhs, op_or); |
| 168 | } |
Romain Guy | b8a2e98 | 2012-02-07 17:04:34 -0800 | [diff] [blame] | 169 | const Region Region::mergeExclusive(const Rect& rhs) const { |
| 170 | return operation(rhs, op_xor); |
| 171 | } |
Mathias Agopian | bed9dd1 | 2009-05-27 17:01:58 -0700 | [diff] [blame] | 172 | const Region Region::intersect(const Rect& rhs) const { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 173 | return operation(rhs, op_and); |
| 174 | } |
Mathias Agopian | bed9dd1 | 2009-05-27 17:01:58 -0700 | [diff] [blame] | 175 | const Region Region::subtract(const Rect& rhs) const { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 176 | return operation(rhs, op_nand); |
| 177 | } |
Mathias Agopian | bed9dd1 | 2009-05-27 17:01:58 -0700 | [diff] [blame] | 178 | const Region Region::operation(const Rect& rhs, int op) const { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 179 | Region result; |
| 180 | boolean_operation(op, result, *this, rhs); |
| 181 | return result; |
| 182 | } |
| 183 | |
| 184 | // ---------------------------------------------------------------------------- |
| 185 | |
Mathias Agopian | bed9dd1 | 2009-05-27 17:01:58 -0700 | [diff] [blame] | 186 | const Region Region::merge(const Region& rhs) const { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 187 | return operation(rhs, op_or); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 188 | } |
Romain Guy | b8a2e98 | 2012-02-07 17:04:34 -0800 | [diff] [blame] | 189 | const Region Region::mergeExclusive(const Region& rhs) const { |
| 190 | return operation(rhs, op_xor); |
| 191 | } |
Mathias Agopian | bed9dd1 | 2009-05-27 17:01:58 -0700 | [diff] [blame] | 192 | const Region Region::intersect(const Region& rhs) const { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 193 | return operation(rhs, op_and); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 194 | } |
Mathias Agopian | bed9dd1 | 2009-05-27 17:01:58 -0700 | [diff] [blame] | 195 | const Region Region::subtract(const Region& rhs) const { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 196 | return operation(rhs, op_nand); |
| 197 | } |
Mathias Agopian | bed9dd1 | 2009-05-27 17:01:58 -0700 | [diff] [blame] | 198 | const Region Region::operation(const Region& rhs, int op) const { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 199 | Region result; |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 200 | boolean_operation(op, result, *this, rhs); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 201 | return result; |
| 202 | } |
| 203 | |
Mathias Agopian | bed9dd1 | 2009-05-27 17:01:58 -0700 | [diff] [blame] | 204 | const Region Region::translate(int x, int y) const { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 205 | Region result; |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 206 | translate(result, *this, x, y); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 207 | return result; |
| 208 | } |
| 209 | |
| 210 | // ---------------------------------------------------------------------------- |
| 211 | |
| 212 | Region& Region::orSelf(const Region& rhs, int dx, int dy) { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 213 | return operationSelf(rhs, dx, dy, op_or); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 214 | } |
Romain Guy | b8a2e98 | 2012-02-07 17:04:34 -0800 | [diff] [blame] | 215 | Region& Region::xorSelf(const Region& rhs, int dx, int dy) { |
| 216 | return operationSelf(rhs, dx, dy, op_xor); |
| 217 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 218 | Region& Region::andSelf(const Region& rhs, int dx, int dy) { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 219 | return operationSelf(rhs, dx, dy, op_and); |
| 220 | } |
| 221 | Region& Region::subtractSelf(const Region& rhs, int dx, int dy) { |
| 222 | return operationSelf(rhs, dx, dy, op_nand); |
| 223 | } |
| 224 | Region& Region::operationSelf(const Region& rhs, int dx, int dy, int op) { |
| 225 | Region lhs(*this); |
| 226 | boolean_operation(op, *this, lhs, rhs, dx, dy); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 227 | return *this; |
| 228 | } |
| 229 | |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 230 | // ---------------------------------------------------------------------------- |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 231 | |
Mathias Agopian | bed9dd1 | 2009-05-27 17:01:58 -0700 | [diff] [blame] | 232 | const Region Region::merge(const Region& rhs, int dx, int dy) const { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 233 | return operation(rhs, dx, dy, op_or); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 234 | } |
Romain Guy | b8a2e98 | 2012-02-07 17:04:34 -0800 | [diff] [blame] | 235 | const Region Region::mergeExclusive(const Region& rhs, int dx, int dy) const { |
| 236 | return operation(rhs, dx, dy, op_xor); |
| 237 | } |
Mathias Agopian | bed9dd1 | 2009-05-27 17:01:58 -0700 | [diff] [blame] | 238 | const Region Region::intersect(const Region& rhs, int dx, int dy) const { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 239 | return operation(rhs, dx, dy, op_and); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 240 | } |
Mathias Agopian | bed9dd1 | 2009-05-27 17:01:58 -0700 | [diff] [blame] | 241 | const Region Region::subtract(const Region& rhs, int dx, int dy) const { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 242 | return operation(rhs, dx, dy, op_nand); |
| 243 | } |
Mathias Agopian | bed9dd1 | 2009-05-27 17:01:58 -0700 | [diff] [blame] | 244 | const Region Region::operation(const Region& rhs, int dx, int dy, int op) const { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 245 | Region result; |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 246 | boolean_operation(op, result, *this, rhs, dx, dy); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 247 | return result; |
| 248 | } |
| 249 | |
| 250 | // ---------------------------------------------------------------------------- |
| 251 | |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 252 | // This is our region rasterizer, which merges rects and spans together |
| 253 | // to obtain an optimal region. |
| 254 | class Region::rasterizer : public region_operator<Rect>::region_rasterizer |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 255 | { |
Mathias Agopian | 3ab6855 | 2012-08-31 14:31:40 -0700 | [diff] [blame] | 256 | Rect bounds; |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 257 | Vector<Rect>& storage; |
| 258 | Rect* head; |
| 259 | Rect* tail; |
| 260 | Vector<Rect> span; |
| 261 | Rect* cur; |
| 262 | public: |
| 263 | rasterizer(Region& reg) |
Mathias Agopian | 3ab6855 | 2012-08-31 14:31:40 -0700 | [diff] [blame] | 264 | : bounds(INT_MAX, 0, INT_MIN, 0), storage(reg.mStorage), head(), tail(), cur() { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 265 | storage.clear(); |
| 266 | } |
| 267 | |
| 268 | ~rasterizer() { |
| 269 | if (span.size()) { |
| 270 | flushSpan(); |
| 271 | } |
| 272 | if (storage.size()) { |
| 273 | bounds.top = storage.itemAt(0).top; |
| 274 | bounds.bottom = storage.top().bottom; |
| 275 | if (storage.size() == 1) { |
| 276 | storage.clear(); |
| 277 | } |
| 278 | } else { |
| 279 | bounds.left = 0; |
| 280 | bounds.right = 0; |
| 281 | } |
Mathias Agopian | 3ab6855 | 2012-08-31 14:31:40 -0700 | [diff] [blame] | 282 | storage.add(bounds); |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | virtual void operator()(const Rect& rect) { |
Steve Block | 9d45368 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 286 | //ALOGD(">>> %3d, %3d, %3d, %3d", |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 287 | // rect.left, rect.top, rect.right, rect.bottom); |
| 288 | if (span.size()) { |
| 289 | if (cur->top != rect.top) { |
| 290 | flushSpan(); |
| 291 | } else if (cur->right == rect.left) { |
| 292 | cur->right = rect.right; |
| 293 | return; |
| 294 | } |
| 295 | } |
| 296 | span.add(rect); |
| 297 | cur = span.editArray() + (span.size() - 1); |
| 298 | } |
| 299 | private: |
| 300 | template<typename T> |
| 301 | static inline T min(T rhs, T lhs) { return rhs < lhs ? rhs : lhs; } |
| 302 | template<typename T> |
| 303 | static inline T max(T rhs, T lhs) { return rhs > lhs ? rhs : lhs; } |
| 304 | void flushSpan() { |
| 305 | bool merge = false; |
| 306 | if (tail-head == ssize_t(span.size())) { |
Romain Guy | b801624 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 307 | Rect const* p = span.editArray(); |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 308 | Rect const* q = head; |
| 309 | if (p->top == q->bottom) { |
| 310 | merge = true; |
| 311 | while (q != tail) { |
| 312 | if ((p->left != q->left) || (p->right != q->right)) { |
| 313 | merge = false; |
| 314 | break; |
| 315 | } |
| 316 | p++, q++; |
| 317 | } |
| 318 | } |
| 319 | } |
| 320 | if (merge) { |
| 321 | const int bottom = span[0].bottom; |
| 322 | Rect* r = head; |
| 323 | while (r != tail) { |
| 324 | r->bottom = bottom; |
| 325 | r++; |
| 326 | } |
| 327 | } else { |
| 328 | bounds.left = min(span.itemAt(0).left, bounds.left); |
| 329 | bounds.right = max(span.top().right, bounds.right); |
| 330 | storage.appendVector(span); |
| 331 | tail = storage.editArray() + storage.size(); |
| 332 | head = tail - span.size(); |
| 333 | } |
| 334 | span.clear(); |
| 335 | } |
| 336 | }; |
| 337 | |
Mathias Agopian | 068d47f | 2012-09-11 18:56:23 -0700 | [diff] [blame] | 338 | bool Region::validate(const Region& reg, const char* name, bool silent) |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 339 | { |
| 340 | bool result = true; |
| 341 | const_iterator cur = reg.begin(); |
| 342 | const_iterator const tail = reg.end(); |
Mathias Agopian | 068d47f | 2012-09-11 18:56:23 -0700 | [diff] [blame] | 343 | const_iterator prev = cur; |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 344 | Rect b(*prev); |
| 345 | while (cur != tail) { |
Mathias Agopian | 068d47f | 2012-09-11 18:56:23 -0700 | [diff] [blame] | 346 | if (cur->isValid() == false) { |
| 347 | ALOGE_IF(!silent, "%s: region contains an invalid Rect", name); |
| 348 | result = false; |
| 349 | } |
| 350 | if (cur->right > region_operator<Rect>::max_value) { |
| 351 | ALOGE_IF(!silent, "%s: rect->right > max_value", name); |
| 352 | result = false; |
| 353 | } |
| 354 | if (cur->bottom > region_operator<Rect>::max_value) { |
| 355 | ALOGE_IF(!silent, "%s: rect->right > max_value", name); |
| 356 | result = false; |
| 357 | } |
| 358 | if (prev != cur) { |
| 359 | b.left = b.left < cur->left ? b.left : cur->left; |
| 360 | b.top = b.top < cur->top ? b.top : cur->top; |
| 361 | b.right = b.right > cur->right ? b.right : cur->right; |
| 362 | b.bottom = b.bottom > cur->bottom ? b.bottom : cur->bottom; |
| 363 | if ((*prev < *cur) == false) { |
| 364 | ALOGE_IF(!silent, "%s: region's Rects not sorted", name); |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 365 | result = false; |
Mathias Agopian | 068d47f | 2012-09-11 18:56:23 -0700 | [diff] [blame] | 366 | } |
| 367 | if (cur->top == prev->top) { |
| 368 | if (cur->bottom != prev->bottom) { |
| 369 | ALOGE_IF(!silent, "%s: invalid span %p", name, cur); |
| 370 | result = false; |
| 371 | } else if (cur->left < prev->right) { |
| 372 | ALOGE_IF(!silent, |
| 373 | "%s: spans overlap horizontally prev=%p, cur=%p", |
| 374 | name, prev, cur); |
| 375 | result = false; |
| 376 | } |
| 377 | } else if (cur->top < prev->bottom) { |
| 378 | ALOGE_IF(!silent, |
| 379 | "%s: spans overlap vertically prev=%p, cur=%p", |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 380 | name, prev, cur); |
| 381 | result = false; |
| 382 | } |
Mathias Agopian | 068d47f | 2012-09-11 18:56:23 -0700 | [diff] [blame] | 383 | prev = cur; |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 384 | } |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 385 | cur++; |
| 386 | } |
| 387 | if (b != reg.getBounds()) { |
| 388 | result = false; |
Mathias Agopian | 068d47f | 2012-09-11 18:56:23 -0700 | [diff] [blame] | 389 | ALOGE_IF(!silent, |
| 390 | "%s: invalid bounds [%d,%d,%d,%d] vs. [%d,%d,%d,%d]", name, |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 391 | b.left, b.top, b.right, b.bottom, |
| 392 | reg.getBounds().left, reg.getBounds().top, |
| 393 | reg.getBounds().right, reg.getBounds().bottom); |
| 394 | } |
Mathias Agopian | 3ab6855 | 2012-08-31 14:31:40 -0700 | [diff] [blame] | 395 | if (reg.mStorage.size() == 2) { |
Mathias Agopian | 068d47f | 2012-09-11 18:56:23 -0700 | [diff] [blame] | 396 | result = false; |
| 397 | ALOGE_IF(!silent, "%s: mStorage size is 2, which is never valid", name); |
Mathias Agopian | 3ab6855 | 2012-08-31 14:31:40 -0700 | [diff] [blame] | 398 | } |
Mathias Agopian | 068d47f | 2012-09-11 18:56:23 -0700 | [diff] [blame] | 399 | if (result == false && !silent) { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 400 | reg.dump(name); |
Mathias Agopian | 068d47f | 2012-09-11 18:56:23 -0700 | [diff] [blame] | 401 | CallStack stack; |
| 402 | stack.update(); |
| 403 | stack.dump(""); |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 404 | } |
| 405 | return result; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 406 | } |
| 407 | |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 408 | void Region::boolean_operation(int op, Region& dst, |
| 409 | const Region& lhs, |
| 410 | const Region& rhs, int dx, int dy) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 411 | { |
Mathias Agopian | d0b55c0 | 2011-03-16 23:18:07 -0700 | [diff] [blame] | 412 | #if VALIDATE_REGIONS |
| 413 | validate(lhs, "boolean_operation (before): lhs"); |
| 414 | validate(rhs, "boolean_operation (before): rhs"); |
| 415 | validate(dst, "boolean_operation (before): dst"); |
| 416 | #endif |
| 417 | |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 418 | size_t lhs_count; |
| 419 | Rect const * const lhs_rects = lhs.getArray(&lhs_count); |
| 420 | |
| 421 | size_t rhs_count; |
| 422 | Rect const * const rhs_rects = rhs.getArray(&rhs_count); |
| 423 | |
| 424 | region_operator<Rect>::region lhs_region(lhs_rects, lhs_count); |
| 425 | region_operator<Rect>::region rhs_region(rhs_rects, rhs_count, dx, dy); |
| 426 | region_operator<Rect> operation(op, lhs_region, rhs_region); |
| 427 | { // scope for rasterizer (dtor has side effects) |
| 428 | rasterizer r(dst); |
| 429 | operation(r); |
| 430 | } |
| 431 | |
| 432 | #if VALIDATE_REGIONS |
| 433 | validate(lhs, "boolean_operation: lhs"); |
| 434 | validate(rhs, "boolean_operation: rhs"); |
| 435 | validate(dst, "boolean_operation: dst"); |
| 436 | #endif |
| 437 | |
| 438 | #if VALIDATE_WITH_CORECG |
| 439 | SkRegion sk_lhs; |
| 440 | SkRegion sk_rhs; |
| 441 | SkRegion sk_dst; |
| 442 | |
| 443 | for (size_t i=0 ; i<lhs_count ; i++) |
| 444 | sk_lhs.op( |
| 445 | lhs_rects[i].left + dx, |
| 446 | lhs_rects[i].top + dy, |
| 447 | lhs_rects[i].right + dx, |
| 448 | lhs_rects[i].bottom + dy, |
| 449 | SkRegion::kUnion_Op); |
| 450 | |
| 451 | for (size_t i=0 ; i<rhs_count ; i++) |
| 452 | sk_rhs.op( |
| 453 | rhs_rects[i].left + dx, |
| 454 | rhs_rects[i].top + dy, |
| 455 | rhs_rects[i].right + dx, |
| 456 | rhs_rects[i].bottom + dy, |
| 457 | SkRegion::kUnion_Op); |
| 458 | |
| 459 | const char* name = "---"; |
| 460 | SkRegion::Op sk_op; |
| 461 | switch (op) { |
| 462 | case op_or: sk_op = SkRegion::kUnion_Op; name="OR"; break; |
Romain Guy | b8a2e98 | 2012-02-07 17:04:34 -0800 | [diff] [blame] | 463 | case op_xor: sk_op = SkRegion::kUnion_XOR; name="XOR"; break; |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 464 | case op_and: sk_op = SkRegion::kIntersect_Op; name="AND"; break; |
| 465 | case op_nand: sk_op = SkRegion::kDifference_Op; name="NAND"; break; |
| 466 | } |
| 467 | sk_dst.op(sk_lhs, sk_rhs, sk_op); |
| 468 | |
| 469 | if (sk_dst.isEmpty() && dst.isEmpty()) |
| 470 | return; |
| 471 | |
| 472 | bool same = true; |
| 473 | Region::const_iterator head = dst.begin(); |
| 474 | Region::const_iterator const tail = dst.end(); |
| 475 | SkRegion::Iterator it(sk_dst); |
| 476 | while (!it.done()) { |
| 477 | if (head != tail) { |
| 478 | if ( |
| 479 | head->left != it.rect().fLeft || |
| 480 | head->top != it.rect().fTop || |
| 481 | head->right != it.rect().fRight || |
| 482 | head->bottom != it.rect().fBottom |
| 483 | ) { |
| 484 | same = false; |
| 485 | break; |
| 486 | } |
| 487 | } else { |
| 488 | same = false; |
| 489 | break; |
| 490 | } |
| 491 | head++; |
| 492 | it.next(); |
| 493 | } |
| 494 | |
| 495 | if (head != tail) { |
| 496 | same = false; |
| 497 | } |
| 498 | |
| 499 | if(!same) { |
Steve Block | 9d45368 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 500 | ALOGD("---\nregion boolean %s failed", name); |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 501 | lhs.dump("lhs"); |
| 502 | rhs.dump("rhs"); |
| 503 | dst.dump("dst"); |
Steve Block | 9d45368 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 504 | ALOGD("should be"); |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 505 | SkRegion::Iterator it(sk_dst); |
| 506 | while (!it.done()) { |
Steve Block | 9d45368 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 507 | ALOGD(" [%3d, %3d, %3d, %3d]", |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 508 | it.rect().fLeft, |
| 509 | it.rect().fTop, |
| 510 | it.rect().fRight, |
| 511 | it.rect().fBottom); |
| 512 | it.next(); |
| 513 | } |
| 514 | } |
| 515 | #endif |
| 516 | } |
| 517 | |
| 518 | void Region::boolean_operation(int op, Region& dst, |
| 519 | const Region& lhs, |
| 520 | const Rect& rhs, int dx, int dy) |
| 521 | { |
Mathias Agopian | 0450452 | 2011-09-19 16:12:08 -0700 | [diff] [blame] | 522 | if (!rhs.isValid()) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 523 | ALOGE("Region::boolean_operation(op=%d) invalid Rect={%d,%d,%d,%d}", |
Mathias Agopian | 0450452 | 2011-09-19 16:12:08 -0700 | [diff] [blame] | 524 | op, rhs.left, rhs.top, rhs.right, rhs.bottom); |
Mathias Agopian | 0857c8f | 2011-09-26 15:58:20 -0700 | [diff] [blame] | 525 | return; |
Mathias Agopian | 0450452 | 2011-09-19 16:12:08 -0700 | [diff] [blame] | 526 | } |
| 527 | |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 528 | #if VALIDATE_WITH_CORECG || VALIDATE_REGIONS |
| 529 | boolean_operation(op, dst, lhs, Region(rhs), dx, dy); |
| 530 | #else |
| 531 | size_t lhs_count; |
| 532 | Rect const * const lhs_rects = lhs.getArray(&lhs_count); |
| 533 | |
| 534 | region_operator<Rect>::region lhs_region(lhs_rects, lhs_count); |
| 535 | region_operator<Rect>::region rhs_region(&rhs, 1, dx, dy); |
| 536 | region_operator<Rect> operation(op, lhs_region, rhs_region); |
| 537 | { // scope for rasterizer (dtor has side effects) |
| 538 | rasterizer r(dst); |
| 539 | operation(r); |
| 540 | } |
| 541 | |
| 542 | #endif |
| 543 | } |
| 544 | |
| 545 | void Region::boolean_operation(int op, Region& dst, |
| 546 | const Region& lhs, const Region& rhs) |
| 547 | { |
| 548 | boolean_operation(op, dst, lhs, rhs, 0, 0); |
| 549 | } |
| 550 | |
| 551 | void Region::boolean_operation(int op, Region& dst, |
| 552 | const Region& lhs, const Rect& rhs) |
| 553 | { |
| 554 | boolean_operation(op, dst, lhs, rhs, 0, 0); |
| 555 | } |
| 556 | |
| 557 | void Region::translate(Region& reg, int dx, int dy) |
| 558 | { |
Mathias Agopian | 4c0a170 | 2012-08-31 12:45:33 -0700 | [diff] [blame] | 559 | if ((dx || dy) && !reg.isEmpty()) { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 560 | #if VALIDATE_REGIONS |
| 561 | validate(reg, "translate (before)"); |
| 562 | #endif |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 563 | size_t count = reg.mStorage.size(); |
| 564 | Rect* rects = reg.mStorage.editArray(); |
| 565 | while (count) { |
| 566 | rects->translate(dx, dy); |
| 567 | rects++; |
| 568 | count--; |
| 569 | } |
| 570 | #if VALIDATE_REGIONS |
| 571 | validate(reg, "translate (after)"); |
| 572 | #endif |
| 573 | } |
| 574 | } |
| 575 | |
| 576 | void Region::translate(Region& dst, const Region& reg, int dx, int dy) |
| 577 | { |
| 578 | dst = reg; |
| 579 | translate(dst, dx, dy); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 580 | } |
| 581 | |
| 582 | // ---------------------------------------------------------------------------- |
| 583 | |
Mathias Agopian | 8683fca | 2012-08-12 19:37:16 -0700 | [diff] [blame] | 584 | size_t Region::getSize() const { |
Mathias Agopian | 3ab6855 | 2012-08-31 14:31:40 -0700 | [diff] [blame] | 585 | return mStorage.size() * sizeof(Rect); |
Mathias Agopian | 8683fca | 2012-08-12 19:37:16 -0700 | [diff] [blame] | 586 | } |
| 587 | |
| 588 | status_t Region::flatten(void* buffer) const { |
Mathias Agopian | 068d47f | 2012-09-11 18:56:23 -0700 | [diff] [blame] | 589 | #if VALIDATE_REGIONS |
| 590 | validate(*this, "Region::flatten"); |
| 591 | #endif |
Mathias Agopian | 8683fca | 2012-08-12 19:37:16 -0700 | [diff] [blame] | 592 | Rect* rects = reinterpret_cast<Rect*>(buffer); |
Mathias Agopian | 8683fca | 2012-08-12 19:37:16 -0700 | [diff] [blame] | 593 | memcpy(rects, mStorage.array(), mStorage.size() * sizeof(Rect)); |
| 594 | return NO_ERROR; |
| 595 | } |
| 596 | |
| 597 | status_t Region::unflatten(void const* buffer, size_t size) { |
Mathias Agopian | 068d47f | 2012-09-11 18:56:23 -0700 | [diff] [blame] | 598 | Region result; |
Mathias Agopian | 8683fca | 2012-08-12 19:37:16 -0700 | [diff] [blame] | 599 | if (size >= sizeof(Rect)) { |
| 600 | Rect const* rects = reinterpret_cast<Rect const*>(buffer); |
Mathias Agopian | 8683fca | 2012-08-12 19:37:16 -0700 | [diff] [blame] | 601 | size_t count = size / sizeof(Rect); |
| 602 | if (count > 0) { |
Mathias Agopian | 068d47f | 2012-09-11 18:56:23 -0700 | [diff] [blame] | 603 | result.mStorage.clear(); |
| 604 | ssize_t err = result.mStorage.insertAt(0, count); |
Mathias Agopian | 8683fca | 2012-08-12 19:37:16 -0700 | [diff] [blame] | 605 | if (err < 0) { |
| 606 | return status_t(err); |
| 607 | } |
Mathias Agopian | 068d47f | 2012-09-11 18:56:23 -0700 | [diff] [blame] | 608 | memcpy(result.mStorage.editArray(), rects, count*sizeof(Rect)); |
Mathias Agopian | b612142 | 2010-02-17 20:22:26 -0800 | [diff] [blame] | 609 | } |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 610 | } |
Mathias Agopian | 3ab6855 | 2012-08-31 14:31:40 -0700 | [diff] [blame] | 611 | #if VALIDATE_REGIONS |
Mathias Agopian | 068d47f | 2012-09-11 18:56:23 -0700 | [diff] [blame] | 612 | validate(result, "Region::unflatten"); |
Mathias Agopian | 3ab6855 | 2012-08-31 14:31:40 -0700 | [diff] [blame] | 613 | #endif |
Mathias Agopian | 068d47f | 2012-09-11 18:56:23 -0700 | [diff] [blame] | 614 | |
| 615 | if (!result.validate(result, "Region::unflatten", true)) { |
| 616 | ALOGE("Region::unflatten() failed, invalid region"); |
| 617 | return BAD_VALUE; |
| 618 | } |
| 619 | mStorage = result.mStorage; |
Mathias Agopian | 8683fca | 2012-08-12 19:37:16 -0700 | [diff] [blame] | 620 | return NO_ERROR; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 621 | } |
| 622 | |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 623 | // ---------------------------------------------------------------------------- |
| 624 | |
| 625 | Region::const_iterator Region::begin() const { |
Mathias Agopian | 3ab6855 | 2012-08-31 14:31:40 -0700 | [diff] [blame] | 626 | return mStorage.array(); |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 627 | } |
| 628 | |
| 629 | Region::const_iterator Region::end() const { |
Mathias Agopian | 3ab6855 | 2012-08-31 14:31:40 -0700 | [diff] [blame] | 630 | size_t numRects = isRect() ? 1 : mStorage.size() - 1; |
| 631 | return mStorage.array() + numRects; |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 632 | } |
| 633 | |
| 634 | Rect const* Region::getArray(size_t* count) const { |
| 635 | const_iterator const b(begin()); |
| 636 | const_iterator const e(end()); |
| 637 | if (count) *count = e-b; |
| 638 | return b; |
| 639 | } |
| 640 | |
Mathias Agopian | 2401ead | 2012-08-31 15:41:24 -0700 | [diff] [blame] | 641 | SharedBuffer const* Region::getSharedBuffer(size_t* count) const { |
| 642 | // We can get to the SharedBuffer of a Vector<Rect> because Rect has |
| 643 | // a trivial destructor. |
| 644 | SharedBuffer const* sb = SharedBuffer::bufferFromData(mStorage.array()); |
| 645 | if (count) { |
| 646 | size_t numRects = isRect() ? 1 : mStorage.size() - 1; |
| 647 | count[0] = numRects; |
| 648 | } |
| 649 | sb->acquire(); |
| 650 | return sb; |
| 651 | } |
| 652 | |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 653 | // ---------------------------------------------------------------------------- |
| 654 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 655 | void Region::dump(String8& out, const char* what, uint32_t flags) const |
| 656 | { |
| 657 | (void)flags; |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 658 | const_iterator head = begin(); |
| 659 | const_iterator const tail = end(); |
| 660 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 661 | size_t SIZE = 256; |
| 662 | char buffer[SIZE]; |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 663 | |
| 664 | snprintf(buffer, SIZE, " Region %s (this=%p, count=%d)\n", |
| 665 | what, this, tail-head); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 666 | out.append(buffer); |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 667 | while (head != tail) { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 668 | snprintf(buffer, SIZE, " [%3d, %3d, %3d, %3d]\n", |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 669 | head->left, head->top, head->right, head->bottom); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 670 | out.append(buffer); |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 671 | head++; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 672 | } |
| 673 | } |
| 674 | |
| 675 | void Region::dump(const char* what, uint32_t flags) const |
| 676 | { |
| 677 | (void)flags; |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 678 | const_iterator head = begin(); |
| 679 | const_iterator const tail = end(); |
Steve Block | 9d45368 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 680 | ALOGD(" Region %s (this=%p, count=%d)\n", what, this, tail-head); |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 681 | while (head != tail) { |
Steve Block | 9d45368 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 682 | ALOGD(" [%3d, %3d, %3d, %3d]\n", |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 683 | head->left, head->top, head->right, head->bottom); |
| 684 | head++; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 685 | } |
| 686 | } |
| 687 | |
| 688 | // ---------------------------------------------------------------------------- |
| 689 | |
| 690 | }; // namespace android |