Chromium Code Reviews| 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; | |
| 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 fMCRec->fRasterClip.setEmpty(); | 854 fMCRec->fRasterClip.setEmpty(); |
| 858 } | 855 } |
| 859 return false; | 856 return false; |
| 860 } | 857 } |
| 861 } else { // no user bounds, so just use the clip | 858 } else { // no user bounds, so just use the clip |
| 862 ir = clipBounds; | 859 ir = clipBounds; |
| 863 } | 860 } |
| 864 | 861 |
| 865 if (bounds_affects_clip(flags)) { | 862 if (bounds_affects_clip(flags)) { |
| 866 fClipStack->clipDevRect(ir, op); | 863 // Simplify the current clips since they will be applied properly during restore() |
| 864 fClipStack->clipDevRect(ir, SkRegion::kReplace_Op); | |
|
robertphillips
2015/03/11 16:06:38
I don't think ir can be empty - remove this code?
reed1
2015/03/11 17:02:52
I'll make a new CL that asserts that it is non-emp
| |
| 867 // early exit if the clip is now empty | 865 // early exit if the clip is now empty |
| 868 if (!fMCRec->fRasterClip.op(ir, op)) { | 866 if (!fMCRec->fRasterClip.op(ir, SkRegion::kReplace_Op)) { |
| 869 return false; | 867 return false; |
| 870 } | 868 } |
| 871 } | 869 } |
| 872 | 870 |
| 873 if (intersection) { | 871 if (intersection) { |
| 874 *intersection = ir; | 872 *intersection = ir; |
| 875 } | 873 } |
| 876 return true; | 874 return true; |
| 877 } | 875 } |
| 878 | 876 |
| (...skipping 1645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2524 } | 2522 } |
| 2525 | 2523 |
| 2526 if (matrix) { | 2524 if (matrix) { |
| 2527 canvas->concat(*matrix); | 2525 canvas->concat(*matrix); |
| 2528 } | 2526 } |
| 2529 } | 2527 } |
| 2530 | 2528 |
| 2531 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 2529 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
| 2532 fCanvas->restoreToCount(fSaveCount); | 2530 fCanvas->restoreToCount(fSaveCount); |
| 2533 } | 2531 } |
| OLD | NEW |