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" |
(...skipping 2270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2281 | 2281 |
2282 SkBitmap resultBM; | 2282 SkBitmap resultBM; |
2283 | 2283 |
2284 SkImageFilter* filter = paint.getImageFilter(); | 2284 SkImageFilter* filter = paint.getImageFilter(); |
2285 if (filter) { | 2285 if (filter) { |
2286 SkIPoint offset = SkIPoint::Make(0, 0); | 2286 SkIPoint offset = SkIPoint::Make(0, 0); |
2287 SkMatrix matrix = *draw.fMatrix; | 2287 SkMatrix matrix = *draw.fMatrix; |
2288 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); | 2288 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); |
2289 const SkIRect clipBounds = draw.fRC->getBounds().makeOffset(-x, -y); | 2289 const SkIRect clipBounds = draw.fRC->getBounds().makeOffset(-x, -y); |
2290 SkAutoTUnref<SkImageFilterCache> cache(this->getImageFilterCache()); | 2290 SkAutoTUnref<SkImageFilterCache> cache(this->getImageFilterCache()); |
2291 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); | 2291 // TODO: Should PDF be operating in a specified color space? For now, ru
n the filter |
| 2292 // in the same color space as the source (this is different from all oth
er backends). |
| 2293 SkImageFilter::OutputProperties outputProperties(srcImg->getColorSpace()
); |
| 2294 SkImageFilter::Context ctx(matrix, clipBounds, cache.get(), outputProper
ties); |
2292 | 2295 |
2293 sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg, ctx, &offset
)); | 2296 sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg, ctx, &offset
)); |
2294 if (resultImg) { | 2297 if (resultImg) { |
2295 SkPaint tmpUnfiltered(paint); | 2298 SkPaint tmpUnfiltered(paint); |
2296 tmpUnfiltered.setImageFilter(nullptr); | 2299 tmpUnfiltered.setImageFilter(nullptr); |
2297 if (resultImg->getROPixels(&resultBM)) { | 2300 if (resultImg->getROPixels(&resultBM)) { |
2298 this->drawSprite(draw, resultBM, x + offset.x(), y + offset.y(),
tmpUnfiltered); | 2301 this->drawSprite(draw, resultBM, x + offset.x(), y + offset.y(),
tmpUnfiltered); |
2299 } | 2302 } |
2300 } | 2303 } |
2301 } else { | 2304 } else { |
(...skipping 14 matching lines...) Expand all Loading... |
2316 | 2319 |
2317 sk_sp<SkSpecialImage> SkPDFDevice::snapSpecial() { | 2320 sk_sp<SkSpecialImage> SkPDFDevice::snapSpecial() { |
2318 return nullptr; | 2321 return nullptr; |
2319 } | 2322 } |
2320 | 2323 |
2321 SkImageFilterCache* SkPDFDevice::getImageFilterCache() { | 2324 SkImageFilterCache* SkPDFDevice::getImageFilterCache() { |
2322 // We always return a transient cache, so it is freed after each | 2325 // We always return a transient cache, so it is freed after each |
2323 // filter traversal. | 2326 // filter traversal. |
2324 return SkImageFilterCache::Create(SkImageFilterCache::kDefaultTransientSize)
; | 2327 return SkImageFilterCache::Create(SkImageFilterCache::kDefaultTransientSize)
; |
2325 } | 2328 } |
OLD | NEW |