| 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" |
| 11 #include "SkFuzzLogging.h" | 11 #include "SkFuzzLogging.h" |
| 12 #include "SkImageFilterCache.h" | 12 #include "SkImageFilterCache.h" |
| 13 #include "SkLocalMatrixImageFilter.h" | 13 #include "SkLocalMatrixImageFilter.h" |
| 14 #include "SkMatrixImageFilter.h" | 14 #include "SkMatrixImageFilter.h" |
| 15 #include "SkReadBuffer.h" | 15 #include "SkReadBuffer.h" |
| 16 #include "SkRect.h" | 16 #include "SkRect.h" |
| 17 #include "SkSpecialImage.h" | 17 #include "SkSpecialImage.h" |
| 18 #include "SkSpecialSurface.h" | 18 #include "SkSpecialSurface.h" |
| 19 #include "SkValidationUtils.h" | 19 #include "SkValidationUtils.h" |
| 20 #include "SkWriteBuffer.h" | 20 #include "SkWriteBuffer.h" |
| 21 #if SK_SUPPORT_GPU | 21 #if SK_SUPPORT_GPU |
| 22 #include "GrContext.h" | 22 #include "GrContext.h" |
| 23 #include "GrDrawContext.h" | 23 #include "GrDrawContext.h" |
| 24 #include "GrFixedClip.h" | 24 #include "GrFixedClip.h" |
| 25 #include "SkGrPriv.h" |
| 25 #endif | 26 #endif |
| 26 | 27 |
| 27 #ifndef SK_IGNORE_TO_STRING | 28 #ifndef SK_IGNORE_TO_STRING |
| 28 void SkImageFilter::CropRect::toString(SkString* str) const { | 29 void SkImageFilter::CropRect::toString(SkString* str) const { |
| 29 if (!fFlags) { | 30 if (!fFlags) { |
| 30 return; | 31 return; |
| 31 } | 32 } |
| 32 | 33 |
| 33 str->appendf("cropRect ("); | 34 str->appendf("cropRect ("); |
| 34 if (fFlags & CropRect::kHasLeft_CropEdge) { | 35 if (fFlags & CropRect::kHasLeft_CropEdge) { |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 | 276 |
| 276 #if SK_SUPPORT_GPU | 277 #if SK_SUPPORT_GPU |
| 277 sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context, | 278 sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context, |
| 278 sk_sp<GrFragmentProcessor> fp, | 279 sk_sp<GrFragmentProcessor> fp, |
| 279 const SkIRect& bounds, | 280 const SkIRect& bounds, |
| 280 sk_sp<SkColorSpace> colorSpace)
{ | 281 sk_sp<SkColorSpace> colorSpace)
{ |
| 281 GrPaint paint; | 282 GrPaint paint; |
| 282 paint.addColorFragmentProcessor(std::move(fp)); | 283 paint.addColorFragmentProcessor(std::move(fp)); |
| 283 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 284 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
| 284 | 285 |
| 286 GrPixelConfig config = GrRenderableConfigForColorSpace(colorSpace.get()); |
| 285 sk_sp<GrDrawContext> drawContext(context->makeDrawContext(SkBackingFit::kApp
rox, | 287 sk_sp<GrDrawContext> drawContext(context->makeDrawContext(SkBackingFit::kApp
rox, |
| 286 bounds.width(), bo
unds.height(), | 288 bounds.width(), bo
unds.height(), |
| 287 kRGBA_8888_GrPixel
Config, | 289 config, |
| 288 std::move(colorSpa
ce))); | 290 std::move(colorSpa
ce))); |
| 289 if (!drawContext) { | 291 if (!drawContext) { |
| 290 return nullptr; | 292 return nullptr; |
| 291 } | 293 } |
| 292 | 294 |
| 293 SkIRect dstIRect = SkIRect::MakeWH(bounds.width(), bounds.height()); | 295 SkIRect dstIRect = SkIRect::MakeWH(bounds.width(), bounds.height()); |
| 294 SkRect srcRect = SkRect::Make(bounds); | 296 SkRect srcRect = SkRect::Make(bounds); |
| 295 SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height()); | 297 SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height()); |
| 296 GrFixedClip clip(dstIRect); | 298 GrFixedClip clip(dstIRect); |
| 297 drawContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect); | 299 drawContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 sk_sp<SkSpecialImage> result(input->filterImage(src, this->mapContext(ctx),
offset)); | 445 sk_sp<SkSpecialImage> result(input->filterImage(src, this->mapContext(ctx),
offset)); |
| 444 | 446 |
| 445 SkASSERT(!result || src->isTextureBacked() == result->isTextureBacked()); | 447 SkASSERT(!result || src->isTextureBacked() == result->isTextureBacked()); |
| 446 | 448 |
| 447 return result; | 449 return result; |
| 448 } | 450 } |
| 449 | 451 |
| 450 void SkImageFilter::PurgeCache() { | 452 void SkImageFilter::PurgeCache() { |
| 451 SkImageFilterCache::Get()->purge(); | 453 SkImageFilterCache::Get()->purge(); |
| 452 } | 454 } |
| OLD | NEW |