| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 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 | 9 |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 fClipStack.save(); | 827 fClipStack.save(); |
| 828 } | 828 } |
| 829 | 829 |
| 830 return saveCount; | 830 return saveCount; |
| 831 } | 831 } |
| 832 | 832 |
| 833 void SkCanvas::willSave(SaveFlags) { | 833 void SkCanvas::willSave(SaveFlags) { |
| 834 // Do nothing. Subclasses may do something. | 834 // Do nothing. Subclasses may do something. |
| 835 } | 835 } |
| 836 | 836 |
| 837 #ifdef SK_SUPPORT_LEGACY_SAVEFLAGS |
| 837 int SkCanvas::save(SaveFlags flags) { | 838 int SkCanvas::save(SaveFlags flags) { |
| 839 #else |
| 840 int SkCanvas::save() { |
| 841 SaveFlags flags = kMatrixClip_SaveFlag; |
| 842 #endif |
| 843 |
| 838 this->willSave(flags); | 844 this->willSave(flags); |
| 839 // call shared impl | 845 // call shared impl |
| 840 return this->internalSave(flags); | 846 return this->internalSave(flags); |
| 841 } | 847 } |
| 842 | 848 |
| 843 static bool bounds_affects_clip(SkCanvas::SaveFlags flags) { | 849 bool SkCanvas::bounds_affects_clip(SkCanvas::SaveFlags flags) { |
| 844 #ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG | 850 #ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG |
| 845 return (flags & SkCanvas::kClipToLayer_SaveFlag) != 0; | 851 return (flags & SkCanvas::kClipToLayer_SaveFlag) != 0; |
| 846 #else | 852 #else |
| 847 return true; | 853 return true; |
| 848 #endif | 854 #endif |
| 849 } | 855 } |
| 850 | 856 |
| 851 bool SkCanvas::clipRectBounds(const SkRect* bounds, SaveFlags flags, | 857 bool SkCanvas::clipRectBounds(const SkRect* bounds, SaveFlags flags, |
| 852 SkIRect* intersection, const SkImageFilter* image
Filter) { | 858 SkIRect* intersection, const SkImageFilter* image
Filter) { |
| 853 SkIRect clipBounds; | 859 SkIRect clipBounds; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 } | 897 } |
| 892 return true; | 898 return true; |
| 893 } | 899 } |
| 894 | 900 |
| 895 SkCanvas::SaveLayerStrategy SkCanvas::willSaveLayer(const SkRect*, const SkPaint
*, SaveFlags) { | 901 SkCanvas::SaveLayerStrategy SkCanvas::willSaveLayer(const SkRect*, const SkPaint
*, SaveFlags) { |
| 896 | 902 |
| 897 // Do nothing. Subclasses may do something. | 903 // Do nothing. Subclasses may do something. |
| 898 return kFullLayer_SaveLayerStrategy; | 904 return kFullLayer_SaveLayerStrategy; |
| 899 } | 905 } |
| 900 | 906 |
| 907 #ifdef SK_SUPPORT_LEGACY_SAVEFLAGS |
| 901 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint, | 908 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint, |
| 902 SaveFlags flags) { | 909 SaveFlags flags) { |
| 910 #else |
| 911 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint) { |
| 912 SaveFlags flags = kARGB_ClipLayer_SaveFlag; |
| 913 #endif |
| 914 |
| 903 // Overriding classes may return false to signal that we don't need to creat
e a layer. | 915 // Overriding classes may return false to signal that we don't need to creat
e a layer. |
| 904 SaveLayerStrategy strategy = this->willSaveLayer(bounds, paint, flags); | 916 SaveLayerStrategy strategy = this->willSaveLayer(bounds, paint, flags); |
| 905 return this->internalSaveLayer(bounds, paint, flags, false, strategy); | 917 return this->internalSaveLayer(bounds, paint, flags, false, strategy); |
| 906 } | 918 } |
| 907 | 919 |
| 908 static SkBaseDevice* create_compatible_device(SkCanvas* canvas, | 920 static SkBaseDevice* create_compatible_device(SkCanvas* canvas, |
| 909 const SkImageInfo& info) { | 921 const SkImageInfo& info) { |
| 910 SkBaseDevice* device = canvas->getDevice(); | 922 SkBaseDevice* device = canvas->getDevice(); |
| 911 return device ? device->createCompatibleDevice(info) : NULL; | 923 return device ? device->createCompatibleDevice(info) : NULL; |
| 912 } | 924 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 device->unref(); | 980 device->unref(); |
| 969 | 981 |
| 970 layer->fNext = fMCRec->fTopLayer; | 982 layer->fNext = fMCRec->fTopLayer; |
| 971 fMCRec->fLayer = layer; | 983 fMCRec->fLayer = layer; |
| 972 fMCRec->fTopLayer = layer; // this field is NOT an owner of layer | 984 fMCRec->fTopLayer = layer; // this field is NOT an owner of layer |
| 973 | 985 |
| 974 fSaveLayerCount += 1; | 986 fSaveLayerCount += 1; |
| 975 return count; | 987 return count; |
| 976 } | 988 } |
| 977 | 989 |
| 990 |
| 991 #ifdef SK_SUPPORT_LEGACY_SAVEFLAGS |
| 978 int SkCanvas::saveLayerAlpha(const SkRect* bounds, U8CPU alpha, | 992 int SkCanvas::saveLayerAlpha(const SkRect* bounds, U8CPU alpha, |
| 979 SaveFlags flags) { | 993 SaveFlags flags) { |
| 994 #else |
| 995 int SkCanvas::saveLayerAlpha(const SkRect* bounds, U8CPU alpha) { |
| 996 #endif |
| 997 |
| 980 if (0xFF == alpha) { | 998 if (0xFF == alpha) { |
| 981 return this->saveLayer(bounds, NULL, flags); | 999 return this->saveLayer(bounds, NULL |
| 1000 #ifdef SK_SUPPORT_LEGACY_SAVEFLAGS |
| 1001 , flags |
| 1002 #endif |
| 1003 ); |
| 982 } else { | 1004 } else { |
| 983 SkPaint tmpPaint; | 1005 SkPaint tmpPaint; |
| 984 tmpPaint.setAlpha(alpha); | 1006 tmpPaint.setAlpha(alpha); |
| 985 return this->saveLayer(bounds, &tmpPaint, flags); | 1007 return this->saveLayer(bounds, &tmpPaint |
| 1008 #ifdef SK_SUPPORT_LEGACY_SAVEFLAGS |
| 1009 , flags |
| 1010 #endif |
| 1011 ); |
| 986 } | 1012 } |
| 987 } | 1013 } |
| 988 | 1014 |
| 989 void SkCanvas::willRestore() { | 1015 void SkCanvas::willRestore() { |
| 990 // Do nothing. Subclasses may do something. | 1016 // Do nothing. Subclasses may do something. |
| 991 } | 1017 } |
| 992 | 1018 |
| 993 void SkCanvas::restore() { | 1019 void SkCanvas::restore() { |
| 994 // check for underflow | 1020 // check for underflow |
| 995 if (fMCStack.count() > 1) { | 1021 if (fMCStack.count() > 1) { |
| (...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2637 if (!supported_for_raster_canvas(info)) { | 2663 if (!supported_for_raster_canvas(info)) { |
| 2638 return NULL; | 2664 return NULL; |
| 2639 } | 2665 } |
| 2640 | 2666 |
| 2641 SkBitmap bitmap; | 2667 SkBitmap bitmap; |
| 2642 if (!bitmap.installPixels(info, pixels, rowBytes)) { | 2668 if (!bitmap.installPixels(info, pixels, rowBytes)) { |
| 2643 return NULL; | 2669 return NULL; |
| 2644 } | 2670 } |
| 2645 return SkNEW_ARGS(SkCanvas, (bitmap)); | 2671 return SkNEW_ARGS(SkCanvas, (bitmap)); |
| 2646 } | 2672 } |
| OLD | NEW |