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 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1251 SkImageFilter* filter = paint->getImageFilter(); | 1251 SkImageFilter* filter = paint->getImageFilter(); |
1252 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; | 1252 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; |
1253 if (filter && !dstDev->canHandleImageFilter(filter)) { | 1253 if (filter && !dstDev->canHandleImageFilter(filter)) { |
1254 SkDeviceImageFilterProxy proxy(dstDev); | 1254 SkDeviceImageFilterProxy proxy(dstDev); |
1255 SkBitmap dst; | 1255 SkBitmap dst; |
1256 SkIPoint offset = SkIPoint::Make(0, 0); | 1256 SkIPoint offset = SkIPoint::Make(0, 0); |
1257 const SkBitmap& src = srcDev->accessBitmap(false); | 1257 const SkBitmap& src = srcDev->accessBitmap(false); |
1258 SkMatrix matrix = *iter.fMatrix; | 1258 SkMatrix matrix = *iter.fMatrix; |
1259 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y()
)); | 1259 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y()
)); |
1260 SkIRect clipBounds = SkIRect::MakeWH(srcDev->width(), srcDev->height
()); | 1260 SkIRect clipBounds = SkIRect::MakeWH(srcDev->width(), srcDev->height
()); |
1261 SkImageFilter::Cache* cache = SkImageFilter::Cache::Create(); | 1261 SkImageFilter::Cache* cache = SkImageFilter::GetExternalCache(); |
1262 SkAutoUnref aur(cache); | 1262 SkAutoUnref aur(NULL); |
| 1263 if (!cache) { |
| 1264 cache = SkImageFilter::Cache::Create(); |
| 1265 aur.reset(cache); |
| 1266 } |
1263 SkImageFilter::Context ctx(matrix, clipBounds, cache); | 1267 SkImageFilter::Context ctx(matrix, clipBounds, cache); |
1264 if (filter->filterImage(&proxy, src, ctx, &dst, &offset)) { | 1268 if (filter->filterImage(&proxy, src, ctx, &dst, &offset)) { |
1265 SkPaint tmpUnfiltered(*paint); | 1269 SkPaint tmpUnfiltered(*paint); |
1266 tmpUnfiltered.setImageFilter(NULL); | 1270 tmpUnfiltered.setImageFilter(NULL); |
1267 dstDev->drawSprite(iter, dst, pos.x() + offset.x(), pos.y() + of
fset.y(), | 1271 dstDev->drawSprite(iter, dst, pos.x() + offset.x(), pos.y() + of
fset.y(), |
1268 tmpUnfiltered); | 1272 tmpUnfiltered); |
1269 } | 1273 } |
1270 } else { | 1274 } else { |
1271 dstDev->drawDevice(iter, srcDev, pos.x(), pos.y(), *paint); | 1275 dstDev->drawDevice(iter, srcDev, pos.x(), pos.y(), *paint); |
1272 } | 1276 } |
(...skipping 20 matching lines...) Expand all Loading... |
1293 paint = &looper.paint(); | 1297 paint = &looper.paint(); |
1294 SkImageFilter* filter = paint->getImageFilter(); | 1298 SkImageFilter* filter = paint->getImageFilter(); |
1295 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; | 1299 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; |
1296 if (filter && !iter.fDevice->canHandleImageFilter(filter)) { | 1300 if (filter && !iter.fDevice->canHandleImageFilter(filter)) { |
1297 SkDeviceImageFilterProxy proxy(iter.fDevice); | 1301 SkDeviceImageFilterProxy proxy(iter.fDevice); |
1298 SkBitmap dst; | 1302 SkBitmap dst; |
1299 SkIPoint offset = SkIPoint::Make(0, 0); | 1303 SkIPoint offset = SkIPoint::Make(0, 0); |
1300 SkMatrix matrix = *iter.fMatrix; | 1304 SkMatrix matrix = *iter.fMatrix; |
1301 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y()
)); | 1305 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y()
)); |
1302 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height()
); | 1306 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height()
); |
1303 SkImageFilter::Cache* cache = SkImageFilter::Cache::Create(); | 1307 SkImageFilter::Cache* cache = SkImageFilter::GetExternalCache(); |
1304 SkAutoUnref aur(cache); | 1308 SkAutoUnref aur(NULL); |
| 1309 if (!cache) { |
| 1310 cache = SkImageFilter::Cache::Create(); |
| 1311 aur.reset(cache); |
| 1312 } |
1305 SkImageFilter::Context ctx(matrix, clipBounds, cache); | 1313 SkImageFilter::Context ctx(matrix, clipBounds, cache); |
1306 if (filter->filterImage(&proxy, bitmap, ctx, &dst, &offset)) { | 1314 if (filter->filterImage(&proxy, bitmap, ctx, &dst, &offset)) { |
1307 SkPaint tmpUnfiltered(*paint); | 1315 SkPaint tmpUnfiltered(*paint); |
1308 tmpUnfiltered.setImageFilter(NULL); | 1316 tmpUnfiltered.setImageFilter(NULL); |
1309 iter.fDevice->drawSprite(iter, dst, pos.x() + offset.x(), pos.y(
) + offset.y(), | 1317 iter.fDevice->drawSprite(iter, dst, pos.x() + offset.x(), pos.y(
) + offset.y(), |
1310 tmpUnfiltered); | 1318 tmpUnfiltered); |
1311 } | 1319 } |
1312 } else { | 1320 } else { |
1313 iter.fDevice->drawSprite(iter, bitmap, pos.x(), pos.y(), *paint); | 1321 iter.fDevice->drawSprite(iter, bitmap, pos.x(), pos.y(), *paint); |
1314 } | 1322 } |
(...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2659 if (!bitmap.installPixels(info, pixels, rowBytes)) { | 2667 if (!bitmap.installPixels(info, pixels, rowBytes)) { |
2660 return NULL; | 2668 return NULL; |
2661 } | 2669 } |
2662 | 2670 |
2663 // should this functionality be moved into allocPixels()? | 2671 // should this functionality be moved into allocPixels()? |
2664 if (!bitmap.info().isOpaque()) { | 2672 if (!bitmap.info().isOpaque()) { |
2665 bitmap.eraseColor(0); | 2673 bitmap.eraseColor(0); |
2666 } | 2674 } |
2667 return SkNEW_ARGS(SkCanvas, (bitmap)); | 2675 return SkNEW_ARGS(SkCanvas, (bitmap)); |
2668 } | 2676 } |
OLD | NEW |