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 | 8 |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 SkImageFilter* filter = paint->getImageFilter(); | 1127 SkImageFilter* filter = paint->getImageFilter(); |
1128 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; | 1128 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; |
1129 if (filter && !dstDev->canHandleImageFilter(filter)) { | 1129 if (filter && !dstDev->canHandleImageFilter(filter)) { |
1130 SkDeviceImageFilterProxy proxy(dstDev); | 1130 SkDeviceImageFilterProxy proxy(dstDev); |
1131 SkBitmap dst; | 1131 SkBitmap dst; |
1132 SkIPoint offset = SkIPoint::Make(0, 0); | 1132 SkIPoint offset = SkIPoint::Make(0, 0); |
1133 const SkBitmap& src = srcDev->accessBitmap(false); | 1133 const SkBitmap& src = srcDev->accessBitmap(false); |
1134 SkMatrix matrix = *iter.fMatrix; | 1134 SkMatrix matrix = *iter.fMatrix; |
1135 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y()
)); | 1135 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y()
)); |
1136 SkIRect clipBounds = SkIRect::MakeWH(srcDev->width(), srcDev->height
()); | 1136 SkIRect clipBounds = SkIRect::MakeWH(srcDev->width(), srcDev->height
()); |
1137 SkAutoTUnref<SkImageFilter::UniqueIDCache> cache(dstDev->getImageFil
terCache()); | 1137 SkAutoTUnref<SkImageFilter::Cache> cache(dstDev->getImageFilterCache
()); |
1138 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); | 1138 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); |
1139 if (filter->filterImage(&proxy, src, ctx, &dst, &offset)) { | 1139 if (filter->filterImage(&proxy, src, ctx, &dst, &offset)) { |
1140 SkPaint tmpUnfiltered(*paint); | 1140 SkPaint tmpUnfiltered(*paint); |
1141 tmpUnfiltered.setImageFilter(NULL); | 1141 tmpUnfiltered.setImageFilter(NULL); |
1142 dstDev->drawSprite(iter, dst, pos.x() + offset.x(), pos.y() + of
fset.y(), | 1142 dstDev->drawSprite(iter, dst, pos.x() + offset.x(), pos.y() + of
fset.y(), |
1143 tmpUnfiltered); | 1143 tmpUnfiltered); |
1144 } | 1144 } |
1145 } else { | 1145 } else { |
1146 dstDev->drawDevice(iter, srcDev, pos.x(), pos.y(), *paint); | 1146 dstDev->drawDevice(iter, srcDev, pos.x(), pos.y(), *paint); |
1147 } | 1147 } |
(...skipping 19 matching lines...) Expand all Loading... |
1167 paint = &looper.paint(); | 1167 paint = &looper.paint(); |
1168 SkImageFilter* filter = paint->getImageFilter(); | 1168 SkImageFilter* filter = paint->getImageFilter(); |
1169 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; | 1169 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; |
1170 if (filter && !iter.fDevice->canHandleImageFilter(filter)) { | 1170 if (filter && !iter.fDevice->canHandleImageFilter(filter)) { |
1171 SkDeviceImageFilterProxy proxy(iter.fDevice); | 1171 SkDeviceImageFilterProxy proxy(iter.fDevice); |
1172 SkBitmap dst; | 1172 SkBitmap dst; |
1173 SkIPoint offset = SkIPoint::Make(0, 0); | 1173 SkIPoint offset = SkIPoint::Make(0, 0); |
1174 SkMatrix matrix = *iter.fMatrix; | 1174 SkMatrix matrix = *iter.fMatrix; |
1175 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y()
)); | 1175 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y()
)); |
1176 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height()
); | 1176 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height()
); |
1177 SkAutoTUnref<SkImageFilter::UniqueIDCache> cache(iter.fDevice->getIm
ageFilterCache()); | 1177 SkAutoTUnref<SkImageFilter::Cache> cache(iter.fDevice->getImageFilte
rCache()); |
1178 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); | 1178 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); |
1179 if (filter->filterImage(&proxy, bitmap, ctx, &dst, &offset)) { | 1179 if (filter->filterImage(&proxy, bitmap, ctx, &dst, &offset)) { |
1180 SkPaint tmpUnfiltered(*paint); | 1180 SkPaint tmpUnfiltered(*paint); |
1181 tmpUnfiltered.setImageFilter(NULL); | 1181 tmpUnfiltered.setImageFilter(NULL); |
1182 iter.fDevice->drawSprite(iter, dst, pos.x() + offset.x(), pos.y(
) + offset.y(), | 1182 iter.fDevice->drawSprite(iter, dst, pos.x() + offset.x(), pos.y(
) + offset.y(), |
1183 tmpUnfiltered); | 1183 tmpUnfiltered); |
1184 } | 1184 } |
1185 } else { | 1185 } else { |
1186 iter.fDevice->drawSprite(iter, bitmap, pos.x(), pos.y(), *paint); | 1186 iter.fDevice->drawSprite(iter, bitmap, pos.x(), pos.y(), *paint); |
1187 } | 1187 } |
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2504 if (!supported_for_raster_canvas(info)) { | 2504 if (!supported_for_raster_canvas(info)) { |
2505 return NULL; | 2505 return NULL; |
2506 } | 2506 } |
2507 | 2507 |
2508 SkBitmap bitmap; | 2508 SkBitmap bitmap; |
2509 if (!bitmap.installPixels(info, pixels, rowBytes)) { | 2509 if (!bitmap.installPixels(info, pixels, rowBytes)) { |
2510 return NULL; | 2510 return NULL; |
2511 } | 2511 } |
2512 return SkNEW_ARGS(SkCanvas, (bitmap)); | 2512 return SkNEW_ARGS(SkCanvas, (bitmap)); |
2513 } | 2513 } |
OLD | NEW |