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 "GrFixedClip.h" |
23 #include "GrRenderTargetContext.h" | 24 #include "GrRenderTargetContext.h" |
24 #include "GrFixedClip.h" | 25 #include "GrTextureProxy.h" |
25 #include "SkGrPriv.h" | 26 #include "SkGrPriv.h" |
26 #endif | 27 #endif |
27 | 28 |
28 #ifndef SK_IGNORE_TO_STRING | 29 #ifndef SK_IGNORE_TO_STRING |
29 void SkImageFilter::CropRect::toString(SkString* str) const { | 30 void SkImageFilter::CropRect::toString(SkString* str) const { |
30 if (!fFlags) { | 31 if (!fFlags) { |
31 return; | 32 return; |
32 } | 33 } |
33 | 34 |
34 str->appendf("cropRect ("); | 35 str->appendf("cropRect ("); |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context, | 279 sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context, |
279 sk_sp<GrFragmentProcessor> fp, | 280 sk_sp<GrFragmentProcessor> fp, |
280 const SkIRect& bounds, | 281 const SkIRect& bounds, |
281 const OutputProperties& outputPr
operties) { | 282 const OutputProperties& outputPr
operties) { |
282 GrPaint paint; | 283 GrPaint paint; |
283 paint.addColorFragmentProcessor(std::move(fp)); | 284 paint.addColorFragmentProcessor(std::move(fp)); |
284 paint.setPorterDuffXPFactory(SkBlendMode::kSrc); | 285 paint.setPorterDuffXPFactory(SkBlendMode::kSrc); |
285 | 286 |
286 sk_sp<SkColorSpace> colorSpace = sk_ref_sp(outputProperties.colorSpace()); | 287 sk_sp<SkColorSpace> colorSpace = sk_ref_sp(outputProperties.colorSpace()); |
287 GrPixelConfig config = GrRenderableConfigForColorSpace(colorSpace.get()); | 288 GrPixelConfig config = GrRenderableConfigForColorSpace(colorSpace.get()); |
288 sk_sp<GrRenderTargetContext> renderTargetContext(context->makeRenderTargetCo
ntext( | 289 sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRender
TargetContext( |
289 SkBackingFit::kApprox, bounds.width(), bounds.height(), config, std::mov
e(colorSpace))); | 290 SkBackingFit::kApprox, bounds.width(), bounds.height(), config, std::mov
e(colorSpace))); |
290 if (!renderTargetContext) { | 291 if (!renderTargetContext) { |
291 return nullptr; | 292 return nullptr; |
292 } | 293 } |
293 paint.setGammaCorrect(renderTargetContext->isGammaCorrect()); | 294 paint.setGammaCorrect(renderTargetContext->isGammaCorrect()); |
294 | 295 |
295 SkIRect dstIRect = SkIRect::MakeWH(bounds.width(), bounds.height()); | 296 SkIRect dstIRect = SkIRect::MakeWH(bounds.width(), bounds.height()); |
296 SkRect srcRect = SkRect::Make(bounds); | 297 SkRect srcRect = SkRect::Make(bounds); |
297 SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height()); | 298 SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height()); |
298 GrFixedClip clip(dstIRect); | 299 GrFixedClip clip(dstIRect); |
299 renderTargetContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, src
Rect); | 300 renderTargetContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, src
Rect); |
300 | 301 |
301 return SkSpecialImage::MakeFromGpu(dstIRect, kNeedNewImageUniqueID_SpecialIm
age, | 302 return SkSpecialImage::MakeDeferredFromGpu(context, dstIRect, |
302 renderTargetContext->asTexture(), | 303 kNeedNewImageUniqueID_SpecialImag
e, |
303 sk_ref_sp(renderTargetContext->getColorSp
ace())); | 304 sk_ref_sp(renderTargetContext->as
DeferredTexture()), |
| 305 sk_ref_sp(renderTargetContext->ge
tColorSpace())); |
304 } | 306 } |
305 #endif | 307 #endif |
306 | 308 |
307 bool SkImageFilter::asAColorFilter(SkColorFilter** filterPtr) const { | 309 bool SkImageFilter::asAColorFilter(SkColorFilter** filterPtr) const { |
308 SkASSERT(nullptr != filterPtr); | 310 SkASSERT(nullptr != filterPtr); |
309 if (!this->isColorFilterNode(filterPtr)) { | 311 if (!this->isColorFilterNode(filterPtr)) { |
310 return false; | 312 return false; |
311 } | 313 } |
312 if (nullptr != this->getInput(0) || (*filterPtr)->affectsTransparentBlack())
{ | 314 if (nullptr != this->getInput(0) || (*filterPtr)->affectsTransparentBlack())
{ |
313 (*filterPtr)->unref(); | 315 (*filterPtr)->unref(); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 sk_sp<SkSpecialImage> result(input->filterImage(src, this->mapContext(ctx),
offset)); | 462 sk_sp<SkSpecialImage> result(input->filterImage(src, this->mapContext(ctx),
offset)); |
461 | 463 |
462 SkASSERT(!result || src->isTextureBacked() == result->isTextureBacked()); | 464 SkASSERT(!result || src->isTextureBacked() == result->isTextureBacked()); |
463 | 465 |
464 return result; | 466 return result; |
465 } | 467 } |
466 | 468 |
467 void SkImageFilter::PurgeCache() { | 469 void SkImageFilter::PurgeCache() { |
468 SkImageFilterCache::Get()->purge(); | 470 SkImageFilterCache::Get()->purge(); |
469 } | 471 } |
OLD | NEW |