| 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 if (input && !input->canComputeFastBounds()) { | 268 if (input && !input->canComputeFastBounds()) { |
| 269 return false; | 269 return false; |
| 270 } | 270 } |
| 271 } | 271 } |
| 272 return true; | 272 return true; |
| 273 } | 273 } |
| 274 | 274 |
| 275 #if SK_SUPPORT_GPU | 275 #if SK_SUPPORT_GPU |
| 276 sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context, | 276 sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context, |
| 277 sk_sp<GrFragmentProcessor> fp, | 277 sk_sp<GrFragmentProcessor> fp, |
| 278 const SkIRect& bounds) { | 278 const SkIRect& bounds, |
| 279 sk_sp<SkColorSpace> colorSpace)
{ |
| 279 GrPaint paint; | 280 GrPaint paint; |
| 280 paint.addColorFragmentProcessor(std::move(fp)); | 281 paint.addColorFragmentProcessor(std::move(fp)); |
| 281 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 282 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
| 282 | 283 |
| 283 sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kAppr
ox, | 284 sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kAppr
ox, |
| 284 bounds.width(), bou
nds.height(), | 285 bounds.width(), bou
nds.height(), |
| 285 kRGBA_8888_GrPixelC
onfig)); | 286 kRGBA_8888_GrPixelC
onfig)); |
| 286 if (!drawContext) { | 287 if (!drawContext) { |
| 287 return nullptr; | 288 return nullptr; |
| 288 } | 289 } |
| 289 | 290 |
| 290 SkIRect dstIRect = SkIRect::MakeWH(bounds.width(), bounds.height()); | 291 SkIRect dstIRect = SkIRect::MakeWH(bounds.width(), bounds.height()); |
| 291 SkRect srcRect = SkRect::Make(bounds); | 292 SkRect srcRect = SkRect::Make(bounds); |
| 292 SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height()); | 293 SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height()); |
| 293 GrFixedClip clip(dstIRect); | 294 GrFixedClip clip(dstIRect); |
| 294 drawContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect); | 295 drawContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect); |
| 295 | 296 |
| 297 // TODO: Get the colorSpace from the drawContext (once it has one) |
| 296 return SkSpecialImage::MakeFromGpu(dstIRect, kNeedNewImageUniqueID_SpecialIm
age, | 298 return SkSpecialImage::MakeFromGpu(dstIRect, kNeedNewImageUniqueID_SpecialIm
age, |
| 297 drawContext->asTexture()); | 299 drawContext->asTexture(), std::move(color
Space)); |
| 298 } | 300 } |
| 299 #endif | 301 #endif |
| 300 | 302 |
| 301 bool SkImageFilter::asAColorFilter(SkColorFilter** filterPtr) const { | 303 bool SkImageFilter::asAColorFilter(SkColorFilter** filterPtr) const { |
| 302 SkASSERT(nullptr != filterPtr); | 304 SkASSERT(nullptr != filterPtr); |
| 303 if (!this->isColorFilterNode(filterPtr)) { | 305 if (!this->isColorFilterNode(filterPtr)) { |
| 304 return false; | 306 return false; |
| 305 } | 307 } |
| 306 if (nullptr != this->getInput(0) || (*filterPtr)->affectsTransparentBlack())
{ | 308 if (nullptr != this->getInput(0) || (*filterPtr)->affectsTransparentBlack())
{ |
| 307 (*filterPtr)->unref(); | 309 (*filterPtr)->unref(); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 sk_sp<SkSpecialImage> result(input->filterImage(src, this->mapContext(ctx),
offset)); | 441 sk_sp<SkSpecialImage> result(input->filterImage(src, this->mapContext(ctx),
offset)); |
| 440 | 442 |
| 441 SkASSERT(!result || src->isTextureBacked() == result->isTextureBacked()); | 443 SkASSERT(!result || src->isTextureBacked() == result->isTextureBacked()); |
| 442 | 444 |
| 443 return result; | 445 return result; |
| 444 } | 446 } |
| 445 | 447 |
| 446 void SkImageFilter::PurgeCache() { | 448 void SkImageFilter::PurgeCache() { |
| 447 SkImageFilterCache::Get()->purge(); | 449 SkImageFilterCache::Get()->purge(); |
| 448 } | 450 } |
| OLD | NEW |