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 "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkCanvasPriv.h" | 10 #include "SkCanvasPriv.h" |
(...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 const SkPaint* paint = rec.fPaint; | 1194 const SkPaint* paint = rec.fPaint; |
1195 SaveLayerFlags saveLayerFlags = rec.fSaveLayerFlags; | 1195 SaveLayerFlags saveLayerFlags = rec.fSaveLayerFlags; |
1196 | 1196 |
1197 #ifndef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG | 1197 #ifndef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG |
1198 saveLayerFlags &= ~kDontClipToLayer_PrivateSaveLayerFlag; | 1198 saveLayerFlags &= ~kDontClipToLayer_PrivateSaveLayerFlag; |
1199 #endif | 1199 #endif |
1200 | 1200 |
1201 SkLazyPaint lazyP; | 1201 SkLazyPaint lazyP; |
1202 SkImageFilter* imageFilter = paint ? paint->getImageFilter() : NULL; | 1202 SkImageFilter* imageFilter = paint ? paint->getImageFilter() : NULL; |
1203 SkMatrix stashedMatrix = fMCRec->fMatrix; | 1203 SkMatrix stashedMatrix = fMCRec->fMatrix; |
1204 #ifndef SK_SUPPORT_LEGACY_IMAGEFILTER_CTM | |
1205 SkMatrix remainder; | 1204 SkMatrix remainder; |
1206 SkSize scale; | 1205 SkSize scale; |
1207 /* | 1206 /* |
1208 * ImageFilters (so far) do not correctly handle matrices (CTM) that contai
n rotation/skew/etc. | 1207 * ImageFilters (so far) do not correctly handle matrices (CTM) that contai
n rotation/skew/etc. |
1209 * but they do handle scaling. To accommodate this, we do the following: | 1208 * but they do handle scaling. To accommodate this, we do the following: |
1210 * | 1209 * |
1211 * 1. Stash off the current CTM | 1210 * 1. Stash off the current CTM |
1212 * 2. Decompose the CTM into SCALE and REMAINDER | 1211 * 2. Decompose the CTM into SCALE and REMAINDER |
1213 * 3. Wack the CTM to be just SCALE, and wrap the imagefilter with a Matrix
ImageFilter that | 1212 * 3. Wack the CTM to be just SCALE, and wrap the imagefilter with a Matrix
ImageFilter that |
1214 * contains the REMAINDER | 1213 * contains the REMAINDER |
(...skipping 10 matching lines...) Expand all Loading... |
1225 { | 1224 { |
1226 // We will restore the matrix (which we are overwriting here) in restore
via fStashedMatrix | 1225 // We will restore the matrix (which we are overwriting here) in restore
via fStashedMatrix |
1227 this->internalSetMatrix(SkMatrix::MakeScale(scale.width(), scale.height(
))); | 1226 this->internalSetMatrix(SkMatrix::MakeScale(scale.width(), scale.height(
))); |
1228 SkPaint* p = lazyP.set(*paint); | 1227 SkPaint* p = lazyP.set(*paint); |
1229 p->setImageFilter(SkImageFilter::MakeMatrixFilter(remainder, | 1228 p->setImageFilter(SkImageFilter::MakeMatrixFilter(remainder, |
1230 SkFilterQuality::kLow_
SkFilterQuality, | 1229 SkFilterQuality::kLow_
SkFilterQuality, |
1231 sk_ref_sp(imageFilter)
)); | 1230 sk_ref_sp(imageFilter)
)); |
1232 imageFilter = p->getImageFilter(); | 1231 imageFilter = p->getImageFilter(); |
1233 paint = p; | 1232 paint = p; |
1234 } | 1233 } |
1235 #endif | |
1236 | 1234 |
1237 // do this before we create the layer. We don't call the public save() since | 1235 // do this before we create the layer. We don't call the public save() since |
1238 // that would invoke a possibly overridden virtual | 1236 // that would invoke a possibly overridden virtual |
1239 this->internalSave(); | 1237 this->internalSave(); |
1240 | 1238 |
1241 fDeviceCMDirty = true; | 1239 fDeviceCMDirty = true; |
1242 | 1240 |
1243 SkIRect ir; | 1241 SkIRect ir; |
1244 if (!this->clipRectBounds(bounds, saveLayerFlags, &ir, imageFilter)) { | 1242 if (!this->clipRectBounds(bounds, saveLayerFlags, &ir, imageFilter)) { |
1245 return; | 1243 return; |
(...skipping 1818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3064 | 3062 |
3065 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 3063 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
3066 fCanvas->restoreToCount(fSaveCount); | 3064 fCanvas->restoreToCount(fSaveCount); |
3067 } | 3065 } |
3068 | 3066 |
3069 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API | 3067 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API |
3070 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { | 3068 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { |
3071 return this->makeSurface(info, props).release(); | 3069 return this->makeSurface(info, props).release(); |
3072 } | 3070 } |
3073 #endif | 3071 #endif |
OLD | NEW |