| 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 "SkBitmap.h" | 10 #include "SkBitmap.h" |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 bool SkImageFilter::affectsTransparentBlack() const { | 300 bool SkImageFilter::affectsTransparentBlack() const { |
| 301 return false; | 301 return false; |
| 302 } | 302 } |
| 303 | 303 |
| 304 bool SkImageFilter::onFilterImage(Proxy*, const SkBitmap&, const Context&, | 304 bool SkImageFilter::onFilterImage(Proxy*, const SkBitmap&, const Context&, |
| 305 SkBitmap*, SkIPoint*) const { | 305 SkBitmap*, SkIPoint*) const { |
| 306 return false; | 306 return false; |
| 307 } | 307 } |
| 308 | 308 |
| 309 bool SkImageFilter::canFilterImageGPU() const { | 309 bool SkImageFilter::canFilterImageGPU() const { |
| 310 return this->asFragmentProcessor(nullptr, nullptr, nullptr, SkMatrix::I(), S
kIRect()); | 310 return this->asFragmentProcessor(nullptr, nullptr, SkMatrix::I(), SkIRect())
; |
| 311 } | 311 } |
| 312 | 312 |
| 313 bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Cont
ext& ctx, | 313 bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Cont
ext& ctx, |
| 314 SkBitmap* result, SkIPoint* offset) const { | 314 SkBitmap* result, SkIPoint* offset) const { |
| 315 #if SK_SUPPORT_GPU | 315 #if SK_SUPPORT_GPU |
| 316 SkBitmap input = src; | 316 SkBitmap input = src; |
| 317 SkASSERT(fInputCount == 1); | 317 SkASSERT(fInputCount == 1); |
| 318 SkIPoint srcOffset = SkIPoint::Make(0, 0); | 318 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
| 319 if (this->getInput(0) && | 319 if (this->getInput(0) && |
| 320 !this->getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffse
t)) { | 320 !this->getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffse
t)) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 343 // setup new clip | 343 // setup new clip |
| 344 GrClip clip(dstRect); | 344 GrClip clip(dstRect); |
| 345 | 345 |
| 346 GrFragmentProcessor* fp; | 346 GrFragmentProcessor* fp; |
| 347 offset->fX = bounds.left(); | 347 offset->fX = bounds.left(); |
| 348 offset->fY = bounds.top(); | 348 offset->fY = bounds.top(); |
| 349 bounds.offset(-srcOffset); | 349 bounds.offset(-srcOffset); |
| 350 SkMatrix matrix(ctx.ctm()); | 350 SkMatrix matrix(ctx.ctm()); |
| 351 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to
p())); | 351 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to
p())); |
| 352 GrPaint paint; | 352 GrPaint paint; |
| 353 if (this->asFragmentProcessor(&fp, paint.getProcessorDataManager(), srcTextu
re, matrix, bounds)) { | 353 if (this->asFragmentProcessor(&fp, srcTexture, matrix, bounds)) { |
| 354 SkASSERT(fp); | 354 SkASSERT(fp); |
| 355 paint.addColorFragmentProcessor(fp)->unref(); | 355 paint.addColorFragmentProcessor(fp)->unref(); |
| 356 | 356 |
| 357 SkAutoTUnref<GrDrawContext> drawContext(context->drawContext()); | 357 SkAutoTUnref<GrDrawContext> drawContext(context->drawContext()); |
| 358 if (drawContext) { | 358 if (drawContext) { |
| 359 drawContext->drawNonAARectToRect(dst->asRenderTarget(), clip, paint,
SkMatrix::I(), | 359 drawContext->drawNonAARectToRect(dst->asRenderTarget(), clip, paint,
SkMatrix::I(), |
| 360 dstRect, srcRect); | 360 dstRect, srcRect); |
| 361 | 361 |
| 362 WrapTexture(dst, bounds.width(), bounds.height(), result); | 362 WrapTexture(dst, bounds.width(), bounds.height(), result); |
| 363 return true; | 363 return true; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 bounds.join(rect); | 421 bounds.join(rect); |
| 422 } | 422 } |
| 423 } | 423 } |
| 424 | 424 |
| 425 // don't modify dst until now, so we don't accidentally change it in the | 425 // don't modify dst until now, so we don't accidentally change it in the |
| 426 // loop, but then return false on the next filter. | 426 // loop, but then return false on the next filter. |
| 427 *dst = bounds; | 427 *dst = bounds; |
| 428 return true; | 428 return true; |
| 429 } | 429 } |
| 430 | 430 |
| 431 bool SkImageFilter::asFragmentProcessor(GrFragmentProcessor**, GrProcessorDataMa
nager*, GrTexture*, | 431 bool SkImageFilter::asFragmentProcessor(GrFragmentProcessor**, GrTexture*, |
| 432 const SkMatrix&, const SkIRect&) const { | 432 const SkMatrix&, const SkIRect&) const { |
| 433 return false; | 433 return false; |
| 434 } | 434 } |
| 435 | 435 |
| 436 SkImageFilter* SkImageFilter::CreateMatrixFilter(const SkMatrix& matrix, | 436 SkImageFilter* SkImageFilter::CreateMatrixFilter(const SkMatrix& matrix, |
| 437 SkFilterQuality filterQuality, | 437 SkFilterQuality filterQuality, |
| 438 SkImageFilter* input) { | 438 SkImageFilter* input) { |
| 439 return SkMatrixImageFilter::Create(matrix, filterQuality, input); | 439 return SkMatrixImageFilter::Create(matrix, filterQuality, input); |
| 440 } | 440 } |
| 441 | 441 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 } | 590 } |
| 591 return dev; | 591 return dev; |
| 592 } | 592 } |
| 593 | 593 |
| 594 bool SkImageFilter::Proxy::filterImage(const SkImageFilter* filter, const SkBitm
ap& src, | 594 bool SkImageFilter::Proxy::filterImage(const SkImageFilter* filter, const SkBitm
ap& src, |
| 595 const SkImageFilter::Context& ctx, | 595 const SkImageFilter::Context& ctx, |
| 596 SkBitmap* result, SkIPoint* offset) { | 596 SkBitmap* result, SkIPoint* offset) { |
| 597 return fDevice->filterImage(filter, src, ctx, result, offset); | 597 return fDevice->filterImage(filter, src, ctx, result, offset); |
| 598 } | 598 } |
| 599 | 599 |
| OLD | NEW |