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