OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2012 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 "SkImageFilter.h" | 8 #include "SkImageFilter.h" |
9 | 9 |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 return false; | 271 return false; |
272 } | 272 } |
273 } | 273 } |
274 return true; | 274 return true; |
275 } | 275 } |
276 | 276 |
277 #if SK_SUPPORT_GPU | 277 #if SK_SUPPORT_GPU |
278 sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context, | 278 sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context, |
279 sk_sp<GrFragmentProcessor> fp, | 279 sk_sp<GrFragmentProcessor> fp, |
280 const SkIRect& bounds, | 280 const SkIRect& bounds, |
281 sk_sp<SkColorSpace> colorSpace)
{ | 281 const OutputProperties& outputPr
operties) { |
282 GrPaint paint; | 282 GrPaint paint; |
283 paint.addColorFragmentProcessor(std::move(fp)); | 283 paint.addColorFragmentProcessor(std::move(fp)); |
284 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 284 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
285 | 285 |
| 286 sk_sp<SkColorSpace> colorSpace = sk_ref_sp(outputProperties.colorSpace()); |
286 GrPixelConfig config = GrRenderableConfigForColorSpace(colorSpace.get()); | 287 GrPixelConfig config = GrRenderableConfigForColorSpace(colorSpace.get()); |
287 sk_sp<GrDrawContext> drawContext(context->makeDrawContext(SkBackingFit::kApp
rox, | 288 sk_sp<GrDrawContext> drawContext(context->makeDrawContext(SkBackingFit::kApp
rox, |
288 bounds.width(), bo
unds.height(), | 289 bounds.width(), bo
unds.height(), |
289 config, | 290 config, |
290 std::move(colorSpa
ce))); | 291 std::move(colorSpa
ce))); |
291 if (!drawContext) { | 292 if (!drawContext) { |
292 return nullptr; | 293 return nullptr; |
293 } | 294 } |
294 | 295 |
295 SkIRect dstIRect = SkIRect::MakeWH(bounds.width(), bounds.height()); | 296 SkIRect dstIRect = SkIRect::MakeWH(bounds.width(), bounds.height()); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 } | 410 } |
410 | 411 |
411 SkIRect SkImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix&, M
apDirection) const { | 412 SkIRect SkImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix&, M
apDirection) const { |
412 return src; | 413 return src; |
413 } | 414 } |
414 | 415 |
415 | 416 |
416 SkImageFilter::Context SkImageFilter::mapContext(const Context& ctx) const { | 417 SkImageFilter::Context SkImageFilter::mapContext(const Context& ctx) const { |
417 SkIRect clipBounds = this->onFilterNodeBounds(ctx.clipBounds(), ctx.ctm(), | 418 SkIRect clipBounds = this->onFilterNodeBounds(ctx.clipBounds(), ctx.ctm(), |
418 MapDirection::kReverse_MapDire
ction); | 419 MapDirection::kReverse_MapDire
ction); |
419 return Context(ctx.ctm(), clipBounds, ctx.cache()); | 420 return Context(ctx.ctm(), clipBounds, ctx.cache(), ctx.outputProperties()); |
420 } | 421 } |
421 | 422 |
422 sk_sp<SkImageFilter> SkImageFilter::MakeMatrixFilter(const SkMatrix& matrix, | 423 sk_sp<SkImageFilter> SkImageFilter::MakeMatrixFilter(const SkMatrix& matrix, |
423 SkFilterQuality filterQuali
ty, | 424 SkFilterQuality filterQuali
ty, |
424 sk_sp<SkImageFilter> input)
{ | 425 sk_sp<SkImageFilter> input)
{ |
425 return SkMatrixImageFilter::Make(matrix, filterQuality, std::move(input)); | 426 return SkMatrixImageFilter::Make(matrix, filterQuality, std::move(input)); |
426 } | 427 } |
427 | 428 |
428 sk_sp<SkImageFilter> SkImageFilter::makeWithLocalMatrix(const SkMatrix& matrix)
const { | 429 sk_sp<SkImageFilter> SkImageFilter::makeWithLocalMatrix(const SkMatrix& matrix)
const { |
429 // SkLocalMatrixImageFilter takes SkImage* in its factory, but logically tha
t parameter | 430 // SkLocalMatrixImageFilter takes SkImage* in its factory, but logically tha
t parameter |
(...skipping 15 matching lines...) Expand all Loading... |
445 sk_sp<SkSpecialImage> result(input->filterImage(src, this->mapContext(ctx),
offset)); | 446 sk_sp<SkSpecialImage> result(input->filterImage(src, this->mapContext(ctx),
offset)); |
446 | 447 |
447 SkASSERT(!result || src->isTextureBacked() == result->isTextureBacked()); | 448 SkASSERT(!result || src->isTextureBacked() == result->isTextureBacked()); |
448 | 449 |
449 return result; | 450 return result; |
450 } | 451 } |
451 | 452 |
452 void SkImageFilter::PurgeCache() { | 453 void SkImageFilter::PurgeCache() { |
453 SkImageFilterCache::Get()->purge(); | 454 SkImageFilterCache::Get()->purge(); |
454 } | 455 } |
OLD | NEW |