| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 The Android Open Source Project |
| 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkCanvasPriv.h" | 9 #include "SkCanvasPriv.h" |
| 10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
| (...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 #ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG | 826 #ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG |
| 827 return (flags & SkCanvas::kClipToLayer_SaveFlag) != 0; | 827 return (flags & SkCanvas::kClipToLayer_SaveFlag) != 0; |
| 828 #else | 828 #else |
| 829 return true; | 829 return true; |
| 830 #endif | 830 #endif |
| 831 } | 831 } |
| 832 | 832 |
| 833 bool SkCanvas::clipRectBounds(const SkRect* bounds, SaveFlags flags, | 833 bool SkCanvas::clipRectBounds(const SkRect* bounds, SaveFlags flags, |
| 834 SkIRect* intersection, const SkImageFilter* image
Filter) { | 834 SkIRect* intersection, const SkImageFilter* image
Filter) { |
| 835 SkIRect clipBounds; | 835 SkIRect clipBounds; |
| 836 SkRegion::Op op = SkRegion::kIntersect_Op; |
| 836 if (!this->getClipDeviceBounds(&clipBounds)) { | 837 if (!this->getClipDeviceBounds(&clipBounds)) { |
| 837 return false; | 838 return false; |
| 838 } | 839 } |
| 839 | 840 |
| 840 const SkMatrix& ctm = fMCRec->fMatrix; // this->getTotalMatrix() | 841 const SkMatrix& ctm = fMCRec->fMatrix; // this->getTotalMatrix() |
| 841 | 842 |
| 842 if (imageFilter) { | 843 if (imageFilter) { |
| 843 imageFilter->filterBounds(clipBounds, ctm, &clipBounds); | 844 imageFilter->filterBounds(clipBounds, ctm, &clipBounds); |
| 845 // Filters may grow the bounds beyond the device bounds. |
| 846 op = SkRegion::kReplace_Op; |
| 844 } | 847 } |
| 845 SkIRect ir; | 848 SkIRect ir; |
| 846 if (bounds) { | 849 if (bounds) { |
| 847 SkRect r; | 850 SkRect r; |
| 848 | 851 |
| 849 ctm.mapRect(&r, *bounds); | 852 ctm.mapRect(&r, *bounds); |
| 850 r.roundOut(&ir); | 853 r.roundOut(&ir); |
| 851 // early exit if the layer's bounds are clipped out | 854 // early exit if the layer's bounds are clipped out |
| 852 if (!ir.intersect(clipBounds)) { | 855 if (!ir.intersect(clipBounds)) { |
| 853 if (bounds_affects_clip(flags)) { | 856 if (bounds_affects_clip(flags)) { |
| 854 fMCRec->fRasterClip.setEmpty(); | 857 fMCRec->fRasterClip.setEmpty(); |
| 855 } | 858 } |
| 856 return false; | 859 return false; |
| 857 } | 860 } |
| 858 } else { // no user bounds, so just use the clip | 861 } else { // no user bounds, so just use the clip |
| 859 ir = clipBounds; | 862 ir = clipBounds; |
| 860 } | 863 } |
| 861 | 864 |
| 862 if (bounds_affects_clip(flags)) { | 865 if (bounds_affects_clip(flags)) { |
| 863 // Simplify the current clips since they will be applied properly during
restore() | 866 fClipStack->clipDevRect(ir, op); |
| 864 fClipStack->clipDevRect(ir, SkRegion::kReplace_Op); | |
| 865 // early exit if the clip is now empty | 867 // early exit if the clip is now empty |
| 866 if (!fMCRec->fRasterClip.op(ir, SkRegion::kReplace_Op)) { | 868 if (!fMCRec->fRasterClip.op(ir, op)) { |
| 867 return false; | 869 return false; |
| 868 } | 870 } |
| 869 } | 871 } |
| 870 | 872 |
| 871 if (intersection) { | 873 if (intersection) { |
| 872 *intersection = ir; | 874 *intersection = ir; |
| 873 } | 875 } |
| 874 return true; | 876 return true; |
| 875 } | 877 } |
| 876 | 878 |
| (...skipping 1645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2522 } | 2524 } |
| 2523 | 2525 |
| 2524 if (matrix) { | 2526 if (matrix) { |
| 2525 canvas->concat(*matrix); | 2527 canvas->concat(*matrix); |
| 2526 } | 2528 } |
| 2527 } | 2529 } |
| 2528 | 2530 |
| 2529 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 2531 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
| 2530 fCanvas->restoreToCount(fSaveCount); | 2532 fCanvas->restoreToCount(fSaveCount); |
| 2531 } | 2533 } |
| OLD | NEW |