| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkRecordDraw.h" | 8 #include "SkRecordDraw.h" |
| 9 #include "SkTSort.h" | 9 #include "SkTSort.h" |
| 10 | 10 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 // TODO: remove this trivially-safe default when done bounding all ops | 182 // TODO: remove this trivially-safe default when done bounding all ops |
| 183 template <typename T> SkIRect bounds(const T&) { return SkIRect::MakeLargest
(); } | 183 template <typename T> SkIRect bounds(const T&) { return SkIRect::MakeLargest
(); } |
| 184 | 184 |
| 185 void pushSaveBlock() { | 185 void pushSaveBlock() { |
| 186 // Starting a new Save block. Push a new entry to represent that. | 186 // Starting a new Save block. Push a new entry to represent that. |
| 187 SaveBounds sb = { 0, SkIRect::MakeEmpty() }; | 187 SaveBounds sb = { 0, SkIRect::MakeEmpty() }; |
| 188 fSaveStack.push(sb); | 188 fSaveStack.push(sb); |
| 189 this->pushControl(); | 189 this->pushControl(); |
| 190 } | 190 } |
| 191 | 191 |
| 192 static bool PaintMayAffectTransparentBlack(const SkPaint* paint) { | |
| 193 // FIXME: this is very conservative | |
| 194 return paint && (paint->getImageFilter() || paint->getColorFilter()); | |
| 195 } | |
| 196 | |
| 197 SkIRect popSaveBlock() { | 192 SkIRect popSaveBlock() { |
| 198 // We're done the Save block. Apply the block's bounds to all control o
ps inside it. | 193 // We're done the Save block. Apply the block's bounds to all control o
ps inside it. |
| 199 SaveBounds sb; | 194 SaveBounds sb; |
| 200 fSaveStack.pop(&sb); | 195 fSaveStack.pop(&sb); |
| 201 | |
| 202 // If the paint affects transparent black, we can't trust any of our cal
culated bounds. | |
| 203 const SkIRect& bounds = | |
| 204 PaintMayAffectTransparentBlack(sb.paint) ? fCurrentClipBounds : sb.b
ounds; | |
| 205 | |
| 206 while (sb.controlOps --> 0) { | 196 while (sb.controlOps --> 0) { |
| 207 this->popControl(bounds); | 197 this->popControl(sb.bounds); |
| 208 } | 198 } |
| 209 | 199 |
| 210 // This whole Save block may be part another Save block. | 200 // This whole Save block may be part another Save block. |
| 211 this->updateSaveBounds(bounds); | 201 this->updateSaveBounds(sb.bounds); |
| 212 | 202 |
| 213 // If called from a real Restore (not a phony one for balance), it'll ne
ed the bounds. | 203 // If called from a real Restore (not a phony one for balance), it'll ne
ed the bounds. |
| 214 return bounds; | 204 return sb.bounds; |
| 215 } | 205 } |
| 216 | 206 |
| 217 void pushControl() { | 207 void pushControl() { |
| 218 fControlIndices.push(fCurrentOp); | 208 fControlIndices.push(fCurrentOp); |
| 219 if (!fSaveStack.isEmpty()) { | 209 if (!fSaveStack.isEmpty()) { |
| 220 fSaveStack.top().controlOps++; | 210 fSaveStack.top().controlOps++; |
| 221 } | 211 } |
| 222 } | 212 } |
| 223 | 213 |
| 224 void popControl(const SkIRect& bounds) { | 214 void popControl(const SkIRect& bounds) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 240 unsigned fCurrentOp; | 230 unsigned fCurrentOp; |
| 241 SkTDArray<SaveBounds> fSaveStack; | 231 SkTDArray<SaveBounds> fSaveStack; |
| 242 SkTDArray<unsigned> fControlIndices; | 232 SkTDArray<unsigned> fControlIndices; |
| 243 }; | 233 }; |
| 244 | 234 |
| 245 } // namespace SkRecords | 235 } // namespace SkRecords |
| 246 | 236 |
| 247 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { | 237 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { |
| 248 SkRecords::FillBounds(record, bbh); | 238 SkRecords::FillBounds(record, bbh); |
| 249 } | 239 } |
| OLD | NEW |