| 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* imageF
ilter) { | 834 SkIRect* intersection, const SkImageFilter* imageF
ilter) { |
| 835 SkIRect clipBounds; | 835 SkIRect clipBounds; |
| 836 SkRegion::Op op = SkRegion::kIntersect_Op; | |
| 837 if (!this->getClipDeviceBounds(&clipBounds)) { | 836 if (!this->getClipDeviceBounds(&clipBounds)) { |
| 838 return false; | 837 return false; |
| 839 } | 838 } |
| 840 | 839 |
| 841 const SkMatrix& ctm = fMCRec->fMatrix; // this->getTotalMatrix() | 840 const SkMatrix& ctm = fMCRec->fMatrix; // this->getTotalMatrix() |
| 842 | 841 |
| 843 if (imageFilter) { | 842 if (imageFilter) { |
| 844 imageFilter->filterBounds(clipBounds, ctm, &clipBounds); | 843 imageFilter->filterBounds(clipBounds, ctm, &clipBounds); |
| 845 // Filters may grow the bounds beyond the device bounds. | |
| 846 op = SkRegion::kReplace_Op; | |
| 847 } | 844 } |
| 848 SkIRect ir; | 845 SkIRect ir; |
| 849 if (bounds) { | 846 if (bounds) { |
| 850 SkRect r; | 847 SkRect r; |
| 851 | 848 |
| 852 ctm.mapRect(&r, *bounds); | 849 ctm.mapRect(&r, *bounds); |
| 853 r.roundOut(&ir); | 850 r.roundOut(&ir); |
| 854 // early exit if the layer's bounds are clipped out | 851 // early exit if the layer's bounds are clipped out |
| 855 if (!ir.intersect(clipBounds)) { | 852 if (!ir.intersect(clipBounds)) { |
| 856 if (bounds_affects_clip(flags)) { | 853 if (bounds_affects_clip(flags)) { |
| 857 fCachedLocalClipBoundsDirty = true; | 854 fCachedLocalClipBoundsDirty = true; |
| 858 fMCRec->fRasterClip.setEmpty(); | 855 fMCRec->fRasterClip.setEmpty(); |
| 859 } | 856 } |
| 860 return false; | 857 return false; |
| 861 } | 858 } |
| 862 } else { // no user bounds, so just use the clip | 859 } else { // no user bounds, so just use the clip |
| 863 ir = clipBounds; | 860 ir = clipBounds; |
| 864 } | 861 } |
| 862 SkASSERT(!ir.isEmpty()); |
| 865 | 863 |
| 866 if (bounds_affects_clip(flags)) { | 864 if (bounds_affects_clip(flags)) { |
| 865 // Simplify the current clips since they will be applied properly during
restore() |
| 867 fCachedLocalClipBoundsDirty = true; | 866 fCachedLocalClipBoundsDirty = true; |
| 868 fClipStack->clipDevRect(ir, op); | 867 fClipStack->clipDevRect(ir, SkRegion::kReplace_Op); |
| 869 // early exit if the clip is now empty | 868 fMCRec->fRasterClip.setRect(ir); |
| 870 if (!fMCRec->fRasterClip.op(ir, op)) { | |
| 871 return false; | |
| 872 } | |
| 873 } | 869 } |
| 874 | 870 |
| 875 if (intersection) { | 871 if (intersection) { |
| 876 *intersection = ir; | 872 *intersection = ir; |
| 877 } | 873 } |
| 878 return true; | 874 return true; |
| 879 } | 875 } |
| 880 | 876 |
| 881 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint) { | 877 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint) { |
| 882 if (gIgnoreSaveLayerBounds) { | 878 if (gIgnoreSaveLayerBounds) { |
| (...skipping 1643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2526 } | 2522 } |
| 2527 | 2523 |
| 2528 if (matrix) { | 2524 if (matrix) { |
| 2529 canvas->concat(*matrix); | 2525 canvas->concat(*matrix); |
| 2530 } | 2526 } |
| 2531 } | 2527 } |
| 2532 | 2528 |
| 2533 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 2529 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
| 2534 fCanvas->restoreToCount(fSaveCount); | 2530 fCanvas->restoreToCount(fSaveCount); |
| 2535 } | 2531 } |
| OLD | NEW |