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 "SkPatchUtils.h" | 9 #include "SkPatchUtils.h" |
10 | 10 |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 } | 222 } |
223 | 223 |
224 void pushSaveBlock(const SkPaint* paint) { | 224 void pushSaveBlock(const SkPaint* paint) { |
225 // Starting a new Save block. Push a new entry to represent that. | 225 // Starting a new Save block. Push a new entry to represent that. |
226 SaveBounds sb = { 0, Bounds::MakeEmpty(), paint }; | 226 SaveBounds sb = { 0, Bounds::MakeEmpty(), paint }; |
227 fSaveStack.push(sb); | 227 fSaveStack.push(sb); |
228 this->pushControl(); | 228 this->pushControl(); |
229 } | 229 } |
230 | 230 |
231 static bool PaintMayAffectTransparentBlack(const SkPaint* paint) { | 231 static bool PaintMayAffectTransparentBlack(const SkPaint* paint) { |
232 // FIXME: this is very conservative | 232 if (paint) { |
233 return paint && (paint->getImageFilter() || paint->getColorFilter()); | 233 // FIXME: this is very conservative |
234 if (paint->getImageFilter() || paint->getColorFilter()) { | |
235 return true; | |
236 } | |
237 | |
238 // Unusual Xfermodes require us to process a saved layer | |
239 // even with operations outisde the clip. | |
240 // For example, DstIn is used by masking layers. | |
241 // https://code.google.com/p/skia/issues/detail?id=1291 | |
242 // https://crbug.com/401593 | |
243 SkXfermode* xfermode = paint->getXfermode(); | |
244 SkXfermode::Mode mode; | |
245 // SrcOver is ok, and is also the common case with a NULL xfermode. | |
246 // So we should make that the fast path and bypass the mode extracti on | |
247 // and test. | |
248 if (xfermode && xfermode->asMode(&mode)) { | |
249 switch (mode) { | |
250 case SkXfermode::kClear_Mode: | |
mtklein
2014/09/12 20:57:16
Might note something like,
// For each of these t
dneto
2014/09/15 15:48:48
Done.
| |
251 case SkXfermode::kSrc_Mode: | |
252 case SkXfermode::kSrcIn_Mode: | |
253 case SkXfermode::kDstIn_Mode: | |
254 case SkXfermode::kSrcOut_Mode: | |
255 case SkXfermode::kDstATop_Mode: | |
256 case SkXfermode::kModulate_Mode: | |
257 return true; | |
258 break; | |
259 default: | |
260 break; | |
261 } | |
262 } | |
263 } | |
264 return false; | |
234 } | 265 } |
235 | 266 |
236 Bounds popSaveBlock() { | 267 Bounds popSaveBlock() { |
237 // We're done the Save block. Apply the block's bounds to all control o ps inside it. | 268 // We're done the Save block. Apply the block's bounds to all control o ps inside it. |
238 SaveBounds sb; | 269 SaveBounds sb; |
239 fSaveStack.pop(&sb); | 270 fSaveStack.pop(&sb); |
240 | 271 |
241 // If the paint affects transparent black, we can't trust any of our cal culated bounds. | 272 // If the paint affects transparent black, we can't trust any of our cal culated bounds. |
242 const Bounds& bounds = | 273 const Bounds& bounds = |
243 PaintMayAffectTransparentBlack(sb.paint) ? fCurrentClipBounds : sb.b ounds; | 274 PaintMayAffectTransparentBlack(sb.paint) ? fCurrentClipBounds : sb.b ounds; |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
472 // Used to track the bounds of Save/Restore blocks and the control ops insid e them. | 503 // Used to track the bounds of Save/Restore blocks and the control ops insid e them. |
473 SkTDArray<SaveBounds> fSaveStack; | 504 SkTDArray<SaveBounds> fSaveStack; |
474 SkTDArray<unsigned> fControlIndices; | 505 SkTDArray<unsigned> fControlIndices; |
475 }; | 506 }; |
476 | 507 |
477 } // namespace SkRecords | 508 } // namespace SkRecords |
478 | 509 |
479 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { | 510 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { |
480 SkRecords::FillBounds(record, bbh); | 511 SkRecords::FillBounds(record, bbh); |
481 } | 512 } |
OLD | NEW |