| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 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 "SkPDFDevice.h" | 8 #include "SkPDFDevice.h" |
| 9 | 9 |
| 10 #include "SkAdvancedTypefaceMetrics.h" | 10 #include "SkAdvancedTypefaceMetrics.h" |
| 11 #include "SkAnnotationKeys.h" | 11 #include "SkAnnotationKeys.h" |
| 12 #include "SkBitmapDevice.h" | 12 #include "SkBitmapDevice.h" |
| 13 #include "SkBitmapKey.h" | 13 #include "SkBitmapKey.h" |
| 14 #include "SkColor.h" | 14 #include "SkColor.h" |
| 15 #include "SkColorFilter.h" | 15 #include "SkColorFilter.h" |
| 16 #include "SkDraw.h" | 16 #include "SkDraw.h" |
| 17 #include "SkDrawFilter.h" | 17 #include "SkDrawFilter.h" |
| 18 #include "SkGlyphCache.h" | 18 #include "SkGlyphCache.h" |
| 19 #include "SkImageFilterCache.h" |
| 19 #include "SkMakeUnique.h" | 20 #include "SkMakeUnique.h" |
| 20 #include "SkPath.h" | 21 #include "SkPath.h" |
| 21 #include "SkPathEffect.h" | 22 #include "SkPathEffect.h" |
| 22 #include "SkPathOps.h" | 23 #include "SkPathOps.h" |
| 23 #include "SkPDFBitmap.h" | 24 #include "SkPDFBitmap.h" |
| 24 #include "SkPDFCanon.h" | 25 #include "SkPDFCanon.h" |
| 25 #include "SkPDFDocument.h" | 26 #include "SkPDFDocument.h" |
| 26 #include "SkPDFFont.h" | 27 #include "SkPDFFont.h" |
| 27 #include "SkPDFFormXObject.h" | 28 #include "SkPDFFormXObject.h" |
| 28 #include "SkPDFGraphicState.h" | 29 #include "SkPDFGraphicState.h" |
| (...skipping 2250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2279 SkASSERT(!srcImg->isTextureBacked()); | 2280 SkASSERT(!srcImg->isTextureBacked()); |
| 2280 | 2281 |
| 2281 SkBitmap resultBM; | 2282 SkBitmap resultBM; |
| 2282 | 2283 |
| 2283 SkImageFilter* filter = paint.getImageFilter(); | 2284 SkImageFilter* filter = paint.getImageFilter(); |
| 2284 if (filter) { | 2285 if (filter) { |
| 2285 SkIPoint offset = SkIPoint::Make(0, 0); | 2286 SkIPoint offset = SkIPoint::Make(0, 0); |
| 2286 SkMatrix matrix = *draw.fMatrix; | 2287 SkMatrix matrix = *draw.fMatrix; |
| 2287 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); | 2288 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); |
| 2288 const SkIRect clipBounds = draw.fRC->getBounds().makeOffset(-x, -y); | 2289 const SkIRect clipBounds = draw.fRC->getBounds().makeOffset(-x, -y); |
| 2289 // SkAutoTUnref<SkImageFilterCache> cache(this->getImageFilterCache()); | 2290 SkAutoTUnref<SkImageFilterCache> cache(this->getImageFilterCache()); |
| 2290 SkImageFilter::Context ctx(matrix, clipBounds, nullptr /*cache.get()*/); | 2291 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); |
| 2291 | 2292 |
| 2292 sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg, ctx, &offset
)); | 2293 sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg, ctx, &offset
)); |
| 2293 if (resultImg) { | 2294 if (resultImg) { |
| 2294 SkPaint tmpUnfiltered(paint); | 2295 SkPaint tmpUnfiltered(paint); |
| 2295 tmpUnfiltered.setImageFilter(nullptr); | 2296 tmpUnfiltered.setImageFilter(nullptr); |
| 2296 if (resultImg->getROPixels(&resultBM)) { | 2297 if (resultImg->getROPixels(&resultBM)) { |
| 2297 this->drawSprite(draw, resultBM, x + offset.x(), y + offset.y(),
tmpUnfiltered); | 2298 this->drawSprite(draw, resultBM, x + offset.x(), y + offset.y(),
tmpUnfiltered); |
| 2298 } | 2299 } |
| 2299 } | 2300 } |
| 2300 } else { | 2301 } else { |
| 2301 if (srcImg->getROPixels(&resultBM)) { | 2302 if (srcImg->getROPixels(&resultBM)) { |
| 2302 this->drawSprite(draw, resultBM, x, y, paint); | 2303 this->drawSprite(draw, resultBM, x, y, paint); |
| 2303 } | 2304 } |
| 2304 } | 2305 } |
| 2305 } | 2306 } |
| 2306 | 2307 |
| 2307 sk_sp<SkSpecialImage> SkPDFDevice::makeSpecial(const SkBitmap& bitmap) { | 2308 sk_sp<SkSpecialImage> SkPDFDevice::makeSpecial(const SkBitmap& bitmap) { |
| 2308 return SkSpecialImage::MakeFromRaster(bitmap.bounds(), bitmap); | 2309 return SkSpecialImage::MakeFromRaster(bitmap.bounds(), bitmap); |
| 2309 } | 2310 } |
| 2310 | 2311 |
| 2311 sk_sp<SkSpecialImage> SkPDFDevice::makeSpecial(const SkImage* image) { | 2312 sk_sp<SkSpecialImage> SkPDFDevice::makeSpecial(const SkImage* image) { |
| 2312 return SkSpecialImage::MakeFromImage(SkIRect::MakeWH(image->width(), image->
height()), | 2313 return SkSpecialImage::MakeFromImage(SkIRect::MakeWH(image->width(), image->
height()), |
| 2313 image->makeNonTextureImage()); | 2314 image->makeNonTextureImage()); |
| 2314 } | 2315 } |
| 2315 | 2316 |
| 2316 sk_sp<SkSpecialImage> SkPDFDevice::snapSpecial() { | 2317 sk_sp<SkSpecialImage> SkPDFDevice::snapSpecial() { |
| 2317 return nullptr; | 2318 return nullptr; |
| 2318 } | 2319 } |
| 2320 |
| 2321 SkImageFilterCache* SkPDFDevice::getImageFilterCache() { |
| 2322 // We always return a transient cache, so it is freed after each |
| 2323 // filter traversal. |
| 2324 return SkImageFilterCache::Create(SkImageFilterCache::kDefaultTransientSize)
; |
| 2325 } |
| OLD | NEW |