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 "SkCanvasDrawable.h" | 9 #include "SkCanvasDrawable.h" |
10 #include "SkCanvasPriv.h" | 10 #include "SkCanvasPriv.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 | 163 |
164 /* This is the record we keep for each save/restore level in the stack. | 164 /* This is the record we keep for each save/restore level in the stack. |
165 Since a level optionally copies the matrix and/or stack, we have pointers | 165 Since a level optionally copies the matrix and/or stack, we have pointers |
166 for these fields. If the value is copied for this level, the copy is | 166 for these fields. If the value is copied for this level, the copy is |
167 stored in the ...Storage field, and the pointer points to that. If the | 167 stored in the ...Storage field, and the pointer points to that. If the |
168 value is not copied for this level, we ignore ...Storage, and just point | 168 value is not copied for this level, we ignore ...Storage, and just point |
169 at the corresponding value in the previous level in the stack. | 169 at the corresponding value in the previous level in the stack. |
170 */ | 170 */ |
171 class SkCanvas::MCRec { | 171 class SkCanvas::MCRec { |
172 public: | 172 public: |
173 SkRasterClip fRasterClip; | |
174 SkMatrix fMatrix; | |
175 SkDrawFilter* fFilter; // the current filter (or null) | 173 SkDrawFilter* fFilter; // the current filter (or null) |
176 DeviceCM* fLayer; | 174 DeviceCM* fLayer; |
177 /* If there are any layers in the stack, this points to the top-most | 175 /* If there are any layers in the stack, this points to the top-most |
178 one that is at or below this level in the stack (so we know what | 176 one that is at or below this level in the stack (so we know what |
179 bitmap/device to draw into from this level. This value is NOT | 177 bitmap/device to draw into from this level. This value is NOT |
180 reference counted, since the real owner is either our fLayer field, | 178 reference counted, since the real owner is either our fLayer field, |
181 or a previous one in a lower level.) | 179 or a previous one in a lower level.) |
182 */ | 180 */ |
183 DeviceCM* fTopLayer; | 181 DeviceCM* fTopLayer; |
182 SkRasterClip fRasterClip; | |
183 SkMatrix fMatrix; | |
184 int fDeferredSaveCount; | |
184 | 185 |
185 MCRec(bool conservativeRasterClip) : fRasterClip(conservativeRasterClip) { | 186 MCRec(bool conservativeRasterClip) : fRasterClip(conservativeRasterClip) { |
186 fMatrix.reset(); | |
187 fFilter = NULL; | 187 fFilter = NULL; |
188 fLayer = NULL; | 188 fLayer = NULL; |
189 fTopLayer = NULL; | 189 fTopLayer = NULL; |
190 fMatrix.reset(); | |
191 fDeferredSaveCount = 0; | |
190 | 192 |
191 // don't bother initializing fNext | 193 // don't bother initializing fNext |
192 inc_rec(); | 194 inc_rec(); |
193 } | 195 } |
194 MCRec(const MCRec& prev) : fRasterClip(prev.fRasterClip) { | 196 MCRec(const MCRec& prev) : fRasterClip(prev.fRasterClip), fMatrix(prev.fMatr ix) { |
195 fMatrix = prev.fMatrix; | |
196 fFilter = SkSafeRef(prev.fFilter); | 197 fFilter = SkSafeRef(prev.fFilter); |
197 fLayer = NULL; | 198 fLayer = NULL; |
198 fTopLayer = prev.fTopLayer; | 199 fTopLayer = prev.fTopLayer; |
200 fDeferredSaveCount = 0; | |
199 | 201 |
200 // don't bother initializing fNext | 202 // don't bother initializing fNext |
201 inc_rec(); | 203 inc_rec(); |
202 } | 204 } |
203 ~MCRec() { | 205 ~MCRec() { |
204 SkSafeUnref(fFilter); | 206 SkSafeUnref(fFilter); |
205 SkDELETE(fLayer); | 207 SkDELETE(fLayer); |
206 dec_rec(); | 208 dec_rec(); |
207 } | 209 } |
208 }; | 210 }; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
406 | 408 |
407 //////////////////////////////////////////////////////////////////////////// | 409 //////////////////////////////////////////////////////////////////////////// |
408 | 410 |
409 SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) { | 411 SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) { |
410 fConservativeRasterClip = SkToBool(flags & kConservativeRasterClip_InitFlag) ; | 412 fConservativeRasterClip = SkToBool(flags & kConservativeRasterClip_InitFlag) ; |
411 fCachedLocalClipBounds.setEmpty(); | 413 fCachedLocalClipBounds.setEmpty(); |
412 fCachedLocalClipBoundsDirty = true; | 414 fCachedLocalClipBoundsDirty = true; |
413 fAllowSoftClip = true; | 415 fAllowSoftClip = true; |
414 fAllowSimplifyClip = false; | 416 fAllowSimplifyClip = false; |
415 fDeviceCMDirty = true; | 417 fDeviceCMDirty = true; |
418 fSaveCount = 1; | |
416 fSaveLayerCount = 0; | 419 fSaveLayerCount = 0; |
417 fCullCount = 0; | 420 fCullCount = 0; |
418 fMetaData = NULL; | 421 fMetaData = NULL; |
419 | 422 |
420 fMCRec = (MCRec*)fMCStack.push_back(); | 423 fMCRec = (MCRec*)fMCStack.push_back(); |
421 new (fMCRec) MCRec(fConservativeRasterClip); | 424 new (fMCRec) MCRec(fConservativeRasterClip); |
422 | 425 |
423 fMCRec->fLayer = SkNEW_ARGS(DeviceCM, (NULL, 0, 0, NULL, NULL, fConservative RasterClip)); | 426 fMCRec->fLayer = SkNEW_ARGS(DeviceCM, (NULL, 0, 0, NULL, NULL, fConservative RasterClip)); |
424 fMCRec->fTopLayer = fMCRec->fLayer; | 427 fMCRec->fTopLayer = fMCRec->fLayer; |
425 | 428 |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
778 do { | 781 do { |
779 layer->updateMC(totalMatrix, clip, fClipStack, &clip); | 782 layer->updateMC(totalMatrix, clip, fClipStack, &clip); |
780 } while ((layer = layer->fNext) != NULL); | 783 } while ((layer = layer->fNext) != NULL); |
781 } | 784 } |
782 fDeviceCMDirty = false; | 785 fDeviceCMDirty = false; |
783 } | 786 } |
784 } | 787 } |
785 | 788 |
786 /////////////////////////////////////////////////////////////////////////////// | 789 /////////////////////////////////////////////////////////////////////////////// |
787 | 790 |
791 void SkCanvas::checkForDeferredSave() { | |
792 if (fMCRec->fDeferredSaveCount > 0) { | |
793 fMCRec->fDeferredSaveCount -= 1; | |
794 this->doSave(); | |
795 } | |
796 } | |
797 | |
788 int SkCanvas::getSaveCount() const { | 798 int SkCanvas::getSaveCount() const { |
789 return fMCStack.count(); | 799 #ifdef SK_DEBUG |
800 int count = 0; | |
801 SkDeque::Iter iter(fMCStack, SkDeque::Iter::kFront_IterStart); | |
802 for (;;) { | |
803 const MCRec* rec = (const MCRec*)iter.next(); | |
804 if (!rec) { | |
805 break; | |
806 } | |
807 count += 1 + rec->fDeferredSaveCount; | |
808 } | |
809 SkASSERT(count == fSaveCount); | |
810 #endif | |
811 return fSaveCount; | |
790 } | 812 } |
791 | 813 |
792 int SkCanvas::save() { | 814 int SkCanvas::save() { |
815 fSaveCount += 1; | |
816 fMCRec->fDeferredSaveCount += 1; | |
robertphillips
2014/12/11 13:24:36
rm this ?
reed1
2014/12/11 14:54:08
Done.
| |
817 #if 0 | |
818 this->checkForDeferredSave(); | |
819 #endif | |
820 return this->getSaveCount() - 1; // return our prev value | |
821 } | |
822 | |
823 void SkCanvas::doSave() { | |
793 this->willSave(); | 824 this->willSave(); |
794 return this->internalSave(); | 825 this->internalSave(); |
795 } | 826 } |
796 | 827 |
797 void SkCanvas::restore() { | 828 void SkCanvas::restore() { |
798 // check for underflow | 829 if (fMCRec->fDeferredSaveCount > 0) { |
799 if (fMCStack.count() > 1) { | 830 SkASSERT(fSaveCount > 1); |
800 this->willRestore(); | 831 fSaveCount -= 1; |
801 this->internalRestore(); | 832 fMCRec->fDeferredSaveCount -= 1; |
802 this->didRestore(); | 833 } else { |
834 // check for underflow | |
835 if (fMCStack.count() > 1) { | |
836 this->willRestore(); | |
837 SkASSERT(fSaveCount > 1); | |
838 fSaveCount -= 1; | |
839 this->internalRestore(); | |
840 this->didRestore(); | |
841 } | |
803 } | 842 } |
804 } | 843 } |
805 | 844 |
806 void SkCanvas::restoreToCount(int count) { | 845 void SkCanvas::restoreToCount(int count) { |
807 // sanity check | 846 // sanity check |
808 if (count < 1) { | 847 if (count < 1) { |
809 count = 1; | 848 count = 1; |
810 } | 849 } |
811 | 850 |
812 int n = this->getSaveCount() - count; | 851 int n = this->getSaveCount() - count; |
813 for (int i = 0; i < n; ++i) { | 852 for (int i = 0; i < n; ++i) { |
814 this->restore(); | 853 this->restore(); |
815 } | 854 } |
816 } | 855 } |
817 | 856 |
818 int SkCanvas::internalSave() { | 857 void SkCanvas::internalSave() { |
819 int saveCount = this->getSaveCount(); // record this before the actual save | |
820 | |
821 MCRec* newTop = (MCRec*)fMCStack.push_back(); | 858 MCRec* newTop = (MCRec*)fMCStack.push_back(); |
822 new (newTop) MCRec(*fMCRec); // balanced in restore() | 859 new (newTop) MCRec(*fMCRec); // balanced in restore() |
823 fMCRec = newTop; | 860 fMCRec = newTop; |
824 | 861 |
825 fClipStack.save(); | 862 fClipStack.save(); |
826 | |
827 return saveCount; | |
828 } | 863 } |
829 | 864 |
830 static bool bounds_affects_clip(SkCanvas::SaveFlags flags) { | 865 static bool bounds_affects_clip(SkCanvas::SaveFlags flags) { |
831 #ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG | 866 #ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG |
832 return (flags & SkCanvas::kClipToLayer_SaveFlag) != 0; | 867 return (flags & SkCanvas::kClipToLayer_SaveFlag) != 0; |
833 #else | 868 #else |
834 return true; | 869 return true; |
835 #endif | 870 #endif |
836 } | 871 } |
837 | 872 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
874 } | 909 } |
875 | 910 |
876 if (intersection) { | 911 if (intersection) { |
877 *intersection = ir; | 912 *intersection = ir; |
878 } | 913 } |
879 return true; | 914 return true; |
880 } | 915 } |
881 | 916 |
882 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint) { | 917 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint) { |
883 SaveLayerStrategy strategy = this->willSaveLayer(bounds, paint, kARGB_ClipLa yer_SaveFlag); | 918 SaveLayerStrategy strategy = this->willSaveLayer(bounds, paint, kARGB_ClipLa yer_SaveFlag); |
884 return this->internalSaveLayer(bounds, paint, kARGB_ClipLayer_SaveFlag, fals e, strategy); | 919 fSaveCount += 1; |
920 this->internalSaveLayer(bounds, paint, kARGB_ClipLayer_SaveFlag, false, stra tegy); | |
921 return this->getSaveCount() - 1; | |
885 } | 922 } |
886 | 923 |
887 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint, | 924 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags fl ags) { |
888 SaveFlags flags) { | |
889 SaveLayerStrategy strategy = this->willSaveLayer(bounds, paint, flags); | 925 SaveLayerStrategy strategy = this->willSaveLayer(bounds, paint, flags); |
890 return this->internalSaveLayer(bounds, paint, flags, false, strategy); | 926 fSaveCount += 1; |
927 this->internalSaveLayer(bounds, paint, flags, false, strategy); | |
928 return this->getSaveCount() - 1; | |
891 } | 929 } |
892 | 930 |
893 int SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, Save Flags flags, | 931 void SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, Sav eFlags flags, |
894 bool justForImageFilter, SaveLayerStrategy strat egy) { | 932 bool justForImageFilter, SaveLayerStrategy strat egy) { |
895 #ifndef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG | 933 #ifndef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG |
896 flags |= kClipToLayer_SaveFlag; | 934 flags |= kClipToLayer_SaveFlag; |
897 #endif | 935 #endif |
898 | 936 |
899 // do this before we create the layer. We don't call the public save() since | 937 // do this before we create the layer. We don't call the public save() since |
900 // that would invoke a possibly overridden virtual | 938 // that would invoke a possibly overridden virtual |
901 int count = this->internalSave(); | 939 this->internalSave(); |
902 | 940 |
903 fDeviceCMDirty = true; | 941 fDeviceCMDirty = true; |
904 | 942 |
905 SkIRect ir; | 943 SkIRect ir; |
906 if (!this->clipRectBounds(bounds, flags, &ir, paint ? paint->getImageFilter( ) : NULL)) { | 944 if (!this->clipRectBounds(bounds, flags, &ir, paint ? paint->getImageFilter( ) : NULL)) { |
907 return count; | 945 return; |
908 } | 946 } |
909 | 947 |
910 // FIXME: do willSaveLayer() overriders returning kNoLayer_SaveLayerStrategy really care about | 948 // FIXME: do willSaveLayer() overriders returning kNoLayer_SaveLayerStrategy really care about |
911 // the clipRectBounds() call above? | 949 // the clipRectBounds() call above? |
912 if (kNoLayer_SaveLayerStrategy == strategy) { | 950 if (kNoLayer_SaveLayerStrategy == strategy) { |
913 return count; | 951 return; |
914 } | 952 } |
915 | 953 |
916 // Kill the imagefilter if our device doesn't allow it | 954 // Kill the imagefilter if our device doesn't allow it |
917 SkLazyPaint lazyP; | 955 SkLazyPaint lazyP; |
918 if (paint && paint->getImageFilter()) { | 956 if (paint && paint->getImageFilter()) { |
919 if (!this->getTopDevice()->allowImageFilter(paint->getImageFilter())) { | 957 if (!this->getTopDevice()->allowImageFilter(paint->getImageFilter())) { |
920 if (justForImageFilter) { | 958 if (justForImageFilter) { |
921 // early exit if the layer was just for the imageFilter | 959 // early exit if the layer was just for the imageFilter |
922 return count; | 960 return; |
923 } | 961 } |
924 SkPaint* p = lazyP.set(*paint); | 962 SkPaint* p = lazyP.set(*paint); |
925 p->setImageFilter(NULL); | 963 p->setImageFilter(NULL); |
926 paint = p; | 964 paint = p; |
927 } | 965 } |
928 } | 966 } |
929 | 967 |
930 bool isOpaque = !SkToBool(flags & kHasAlphaLayer_SaveFlag); | 968 bool isOpaque = !SkToBool(flags & kHasAlphaLayer_SaveFlag); |
931 SkImageInfo info = SkImageInfo::MakeN32(ir.width(), ir.height(), | 969 SkImageInfo info = SkImageInfo::MakeN32(ir.width(), ir.height(), |
932 isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); | 970 isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); |
933 | 971 |
934 SkBaseDevice* device = this->getTopDevice(); | 972 SkBaseDevice* device = this->getTopDevice(); |
935 if (NULL == device) { | 973 if (NULL == device) { |
936 SkDebugf("Unable to find device for layer."); | 974 SkDebugf("Unable to find device for layer."); |
937 return count; | 975 return; |
938 } | 976 } |
939 | 977 |
940 SkBaseDevice::Usage usage = SkBaseDevice::kSaveLayer_Usage; | 978 SkBaseDevice::Usage usage = SkBaseDevice::kSaveLayer_Usage; |
941 if (paint && paint->getImageFilter()) { | 979 if (paint && paint->getImageFilter()) { |
942 usage = SkBaseDevice::kImageFilter_Usage; | 980 usage = SkBaseDevice::kImageFilter_Usage; |
943 } | 981 } |
944 device = device->onCreateCompatibleDevice(SkBaseDevice::CreateInfo(info, usa ge, | 982 device = device->onCreateCompatibleDevice(SkBaseDevice::CreateInfo(info, usa ge, |
945 fProps.pi xelGeometry())); | 983 fProps.pi xelGeometry())); |
946 if (NULL == device) { | 984 if (NULL == device) { |
947 SkDebugf("Unable to create device for layer."); | 985 SkDebugf("Unable to create device for layer."); |
948 return count; | 986 return; |
949 } | 987 } |
950 | 988 |
951 device->setOrigin(ir.fLeft, ir.fTop); | 989 device->setOrigin(ir.fLeft, ir.fTop); |
952 DeviceCM* layer = SkNEW_ARGS(DeviceCM, | 990 DeviceCM* layer = SkNEW_ARGS(DeviceCM, |
953 (device, ir.fLeft, ir.fTop, paint, this, fConse rvativeRasterClip)); | 991 (device, ir.fLeft, ir.fTop, paint, this, fConse rvativeRasterClip)); |
954 device->unref(); | 992 device->unref(); |
955 | 993 |
956 layer->fNext = fMCRec->fTopLayer; | 994 layer->fNext = fMCRec->fTopLayer; |
957 fMCRec->fLayer = layer; | 995 fMCRec->fLayer = layer; |
958 fMCRec->fTopLayer = layer; // this field is NOT an owner of layer | 996 fMCRec->fTopLayer = layer; // this field is NOT an owner of layer |
959 | 997 |
960 fSaveLayerCount += 1; | 998 fSaveLayerCount += 1; |
961 return count; | |
962 } | 999 } |
963 | 1000 |
964 int SkCanvas::saveLayerAlpha(const SkRect* bounds, U8CPU alpha) { | 1001 int SkCanvas::saveLayerAlpha(const SkRect* bounds, U8CPU alpha) { |
965 return this->saveLayerAlpha(bounds, alpha, kARGB_ClipLayer_SaveFlag); | 1002 return this->saveLayerAlpha(bounds, alpha, kARGB_ClipLayer_SaveFlag); |
966 } | 1003 } |
967 | 1004 |
968 int SkCanvas::saveLayerAlpha(const SkRect* bounds, U8CPU alpha, | 1005 int SkCanvas::saveLayerAlpha(const SkRect* bounds, U8CPU alpha, |
969 SaveFlags flags) { | 1006 SaveFlags flags) { |
970 if (0xFF == alpha) { | 1007 if (0xFF == alpha) { |
971 return this->saveLayer(bounds, NULL, flags); | 1008 return this->saveLayer(bounds, NULL, flags); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1279 SkMatrix m; | 1316 SkMatrix m; |
1280 m.setSkew(sx, sy); | 1317 m.setSkew(sx, sy); |
1281 this->concat(m); | 1318 this->concat(m); |
1282 } | 1319 } |
1283 | 1320 |
1284 void SkCanvas::concat(const SkMatrix& matrix) { | 1321 void SkCanvas::concat(const SkMatrix& matrix) { |
1285 if (matrix.isIdentity()) { | 1322 if (matrix.isIdentity()) { |
1286 return; | 1323 return; |
1287 } | 1324 } |
1288 | 1325 |
1326 this->checkForDeferredSave(); | |
1289 fDeviceCMDirty = true; | 1327 fDeviceCMDirty = true; |
1290 fCachedLocalClipBoundsDirty = true; | 1328 fCachedLocalClipBoundsDirty = true; |
1291 fMCRec->fMatrix.preConcat(matrix); | 1329 fMCRec->fMatrix.preConcat(matrix); |
1292 | 1330 |
1293 this->didConcat(matrix); | 1331 this->didConcat(matrix); |
1294 } | 1332 } |
1295 | 1333 |
1296 void SkCanvas::setMatrix(const SkMatrix& matrix) { | 1334 void SkCanvas::setMatrix(const SkMatrix& matrix) { |
1335 this->checkForDeferredSave(); | |
1297 fDeviceCMDirty = true; | 1336 fDeviceCMDirty = true; |
1298 fCachedLocalClipBoundsDirty = true; | 1337 fCachedLocalClipBoundsDirty = true; |
1299 fMCRec->fMatrix = matrix; | 1338 fMCRec->fMatrix = matrix; |
1300 this->didSetMatrix(matrix); | 1339 this->didSetMatrix(matrix); |
1301 } | 1340 } |
1302 | 1341 |
1303 void SkCanvas::resetMatrix() { | 1342 void SkCanvas::resetMatrix() { |
1304 SkMatrix matrix; | 1343 SkMatrix matrix; |
1305 | 1344 |
1306 matrix.reset(); | 1345 matrix.reset(); |
1307 this->setMatrix(matrix); | 1346 this->setMatrix(matrix); |
1308 } | 1347 } |
1309 | 1348 |
1310 ////////////////////////////////////////////////////////////////////////////// | 1349 ////////////////////////////////////////////////////////////////////////////// |
1311 | 1350 |
1312 void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { | 1351 void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { |
1352 this->checkForDeferredSave(); | |
1313 ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle; | 1353 ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle; |
1314 this->onClipRect(rect, op, edgeStyle); | 1354 this->onClipRect(rect, op, edgeStyle); |
1315 } | 1355 } |
1316 | 1356 |
1317 void SkCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edg eStyle) { | 1357 void SkCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edg eStyle) { |
1318 #ifdef SK_ENABLE_CLIP_QUICKREJECT | 1358 #ifdef SK_ENABLE_CLIP_QUICKREJECT |
1319 if (SkRegion::kIntersect_Op == op) { | 1359 if (SkRegion::kIntersect_Op == op) { |
1320 if (fMCRec->fRasterClip.isEmpty()) { | 1360 if (fMCRec->fRasterClip.isEmpty()) { |
1321 return false; | 1361 return false; |
1322 } | 1362 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1360 this->SkCanvas::onClipPath(path, op, edgeStyle); | 1400 this->SkCanvas::onClipPath(path, op, edgeStyle); |
1361 } | 1401 } |
1362 } | 1402 } |
1363 | 1403 |
1364 static void rasterclip_path(SkRasterClip* rc, const SkCanvas* canvas, const SkPa th& devPath, | 1404 static void rasterclip_path(SkRasterClip* rc, const SkCanvas* canvas, const SkPa th& devPath, |
1365 SkRegion::Op op, bool doAA) { | 1405 SkRegion::Op op, bool doAA) { |
1366 rc->op(devPath, canvas->getBaseLayerSize(), op, doAA); | 1406 rc->op(devPath, canvas->getBaseLayerSize(), op, doAA); |
1367 } | 1407 } |
1368 | 1408 |
1369 void SkCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) { | 1409 void SkCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) { |
1410 this->checkForDeferredSave(); | |
1370 ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle; | 1411 ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle; |
1371 if (rrect.isRect()) { | 1412 if (rrect.isRect()) { |
1372 this->onClipRect(rrect.getBounds(), op, edgeStyle); | 1413 this->onClipRect(rrect.getBounds(), op, edgeStyle); |
1373 } else { | 1414 } else { |
1374 this->onClipRRect(rrect, op, edgeStyle); | 1415 this->onClipRRect(rrect, op, edgeStyle); |
1375 } | 1416 } |
1376 } | 1417 } |
1377 | 1418 |
1378 void SkCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { | 1419 void SkCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { |
1379 SkRRect transformedRRect; | 1420 SkRRect transformedRRect; |
(...skipping 15 matching lines...) Expand all Loading... | |
1395 return; | 1436 return; |
1396 } | 1437 } |
1397 | 1438 |
1398 SkPath path; | 1439 SkPath path; |
1399 path.addRRect(rrect); | 1440 path.addRRect(rrect); |
1400 // call the non-virtual version | 1441 // call the non-virtual version |
1401 this->SkCanvas::onClipPath(path, op, edgeStyle); | 1442 this->SkCanvas::onClipPath(path, op, edgeStyle); |
1402 } | 1443 } |
1403 | 1444 |
1404 void SkCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) { | 1445 void SkCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) { |
1446 this->checkForDeferredSave(); | |
1405 ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle; | 1447 ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle; |
1406 SkRect r; | 1448 SkRect r; |
1407 if (!path.isInverseFillType() && path.isRect(&r)) { | 1449 if (!path.isInverseFillType() && path.isRect(&r)) { |
1408 this->onClipRect(r, op, edgeStyle); | 1450 this->onClipRect(r, op, edgeStyle); |
1409 } else { | 1451 } else { |
1410 this->onClipPath(path, op, edgeStyle); | 1452 this->onClipPath(path, op, edgeStyle); |
1411 } | 1453 } |
1412 } | 1454 } |
1413 | 1455 |
1414 void SkCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edg eStyle) { | 1456 void SkCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edg eStyle) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1477 edgeStyle = kSoft_ClipEdgeStyle; | 1519 edgeStyle = kSoft_ClipEdgeStyle; |
1478 } | 1520 } |
1479 } | 1521 } |
1480 op = SkRegion::kReplace_Op; | 1522 op = SkRegion::kReplace_Op; |
1481 } | 1523 } |
1482 | 1524 |
1483 rasterclip_path(&fMCRec->fRasterClip, this, devPath, op, edgeStyle); | 1525 rasterclip_path(&fMCRec->fRasterClip, this, devPath, op, edgeStyle); |
1484 } | 1526 } |
1485 | 1527 |
1486 void SkCanvas::clipRegion(const SkRegion& rgn, SkRegion::Op op) { | 1528 void SkCanvas::clipRegion(const SkRegion& rgn, SkRegion::Op op) { |
1529 this->checkForDeferredSave(); | |
1487 this->onClipRegion(rgn, op); | 1530 this->onClipRegion(rgn, op); |
1488 } | 1531 } |
1489 | 1532 |
1490 void SkCanvas::onClipRegion(const SkRegion& rgn, SkRegion::Op op) { | 1533 void SkCanvas::onClipRegion(const SkRegion& rgn, SkRegion::Op op) { |
1491 AutoValidateClip avc(this); | 1534 AutoValidateClip avc(this); |
1492 | 1535 |
1493 fDeviceCMDirty = true; | 1536 fDeviceCMDirty = true; |
1494 fCachedLocalClipBoundsDirty = true; | 1537 fCachedLocalClipBoundsDirty = true; |
1495 | 1538 |
1496 // todo: signal fClipStack that we have a region, and therefore (I guess) | 1539 // todo: signal fClipStack that we have a region, and therefore (I guess) |
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2526 } | 2569 } |
2527 | 2570 |
2528 if (matrix) { | 2571 if (matrix) { |
2529 canvas->concat(*matrix); | 2572 canvas->concat(*matrix); |
2530 } | 2573 } |
2531 } | 2574 } |
2532 | 2575 |
2533 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 2576 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
2534 fCanvas->restoreToCount(fSaveCount); | 2577 fCanvas->restoreToCount(fSaveCount); |
2535 } | 2578 } |
OLD | NEW |