| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "SkPaint.h" | 9 #include "SkPaint.h" |
| 10 #include "SkAnnotation.h" | 10 #include "SkAnnotation.h" |
| (...skipping 2534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2545 case SkXfermode::kPlus_Mode: | 2545 case SkXfermode::kPlus_Mode: |
| 2546 return 0 == this->getAlpha(); | 2546 return 0 == this->getAlpha(); |
| 2547 case SkXfermode::kDst_Mode: | 2547 case SkXfermode::kDst_Mode: |
| 2548 return true; | 2548 return true; |
| 2549 default: | 2549 default: |
| 2550 break; | 2550 break; |
| 2551 } | 2551 } |
| 2552 } | 2552 } |
| 2553 return false; | 2553 return false; |
| 2554 } | 2554 } |
| 2555 | |
| 2556 | |
| 2557 //////////// Move these to their own file soon. | |
| 2558 | |
| 2559 SK_DEFINE_INST_COUNT(SkDrawLooper) | |
| 2560 | |
| 2561 bool SkDrawLooper::canComputeFastBounds(const SkPaint& paint) { | |
| 2562 SkCanvas canvas; | |
| 2563 | |
| 2564 this->init(&canvas); | |
| 2565 for (;;) { | |
| 2566 SkPaint p(paint); | |
| 2567 if (this->next(&canvas, &p)) { | |
| 2568 p.setLooper(NULL); | |
| 2569 if (!p.canComputeFastBounds()) { | |
| 2570 return false; | |
| 2571 } | |
| 2572 } else { | |
| 2573 break; | |
| 2574 } | |
| 2575 } | |
| 2576 return true; | |
| 2577 } | |
| 2578 | |
| 2579 void SkDrawLooper::computeFastBounds(const SkPaint& paint, const SkRect& src, | |
| 2580 SkRect* dst) { | |
| 2581 SkCanvas canvas; | |
| 2582 | |
| 2583 this->init(&canvas); | |
| 2584 for (bool firstTime = true;; firstTime = false) { | |
| 2585 SkPaint p(paint); | |
| 2586 if (this->next(&canvas, &p)) { | |
| 2587 SkRect r(src); | |
| 2588 | |
| 2589 p.setLooper(NULL); | |
| 2590 p.computeFastBounds(r, &r); | |
| 2591 canvas.getTotalMatrix().mapRect(&r); | |
| 2592 | |
| 2593 if (firstTime) { | |
| 2594 *dst = r; | |
| 2595 } else { | |
| 2596 dst->join(r); | |
| 2597 } | |
| 2598 } else { | |
| 2599 break; | |
| 2600 } | |
| 2601 } | |
| 2602 } | |
| OLD | NEW |