| 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 SkRect bounds; | 302 SkRect bounds; |
| 303 input->computeFastBounds(src, &bounds); | 303 input->computeFastBounds(src, &bounds); |
| 304 dst->join(bounds); | 304 dst->join(bounds); |
| 305 } else { | 305 } else { |
| 306 dst->join(src); | 306 dst->join(src); |
| 307 } | 307 } |
| 308 } | 308 } |
| 309 } | 309 } |
| 310 | 310 |
| 311 bool SkImageFilter::canComputeFastBounds() const { | 311 bool SkImageFilter::canComputeFastBounds() const { |
| 312 if (this->affectsTransparentBlack()) { |
| 313 return false; |
| 314 } |
| 312 for (int i = 0; i < fInputCount; i++) { | 315 for (int i = 0; i < fInputCount; i++) { |
| 313 SkImageFilter* input = this->getInput(i); | 316 SkImageFilter* input = this->getInput(i); |
| 314 if (input && !input->canComputeFastBounds()) { | 317 if (input && !input->canComputeFastBounds()) { |
| 315 return false; | 318 return false; |
| 316 } | 319 } |
| 317 } | 320 } |
| 318 return true; | 321 return true; |
| 319 } | 322 } |
| 320 | 323 |
| 324 bool SkImageFilter::affectsTransparentBlack() const { |
| 325 return false; |
| 326 } |
| 327 |
| 321 bool SkImageFilter::onFilterImage(Proxy*, const SkBitmap&, const Context&, | 328 bool SkImageFilter::onFilterImage(Proxy*, const SkBitmap&, const Context&, |
| 322 SkBitmap*, SkIPoint*) const { | 329 SkBitmap*, SkIPoint*) const { |
| 323 return false; | 330 return false; |
| 324 } | 331 } |
| 325 | 332 |
| 326 bool SkImageFilter::canFilterImageGPU() const { | 333 bool SkImageFilter::canFilterImageGPU() const { |
| 327 return this->asFragmentProcessor(nullptr, nullptr, SkMatrix::I(), SkIRect())
; | 334 return this->asFragmentProcessor(nullptr, nullptr, SkMatrix::I(), SkIRect())
; |
| 328 } | 335 } |
| 329 | 336 |
| 330 bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Cont
ext& ctx, | 337 bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Cont
ext& ctx, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 drawContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, src
Rect); | 384 drawContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, src
Rect); |
| 378 | 385 |
| 379 WrapTexture(dst, bounds.width(), bounds.height(), result); | 386 WrapTexture(dst, bounds.width(), bounds.height(), result); |
| 380 return true; | 387 return true; |
| 381 } | 388 } |
| 382 } | 389 } |
| 383 #endif | 390 #endif |
| 384 return false; | 391 return false; |
| 385 } | 392 } |
| 386 | 393 |
| 387 bool SkImageFilter::asAColorFilter(SkColorFilter** filterPtr) const { | |
| 388 SkASSERT(nullptr != filterPtr); | |
| 389 return this->countInputs() > 0 && | |
| 390 NULL == this->getInput(0) && | |
| 391 this->isColorFilterNode(filterPtr) && | |
| 392 !(*filterPtr)->affectsTransparentBlack(); | |
| 393 } | |
| 394 | |
| 395 bool SkImageFilter::applyCropRect(const Context& ctx, const SkBitmap& src, | 394 bool SkImageFilter::applyCropRect(const Context& ctx, const SkBitmap& src, |
| 396 const SkIPoint& srcOffset, SkIRect* dstBounds, | 395 const SkIPoint& srcOffset, SkIRect* dstBounds, |
| 397 SkIRect* srcBounds) const { | 396 SkIRect* srcBounds) const { |
| 398 SkIRect storage; | 397 SkIRect storage; |
| 399 if (!srcBounds) { | 398 if (!srcBounds) { |
| 400 srcBounds = &storage; | 399 srcBounds = &storage; |
| 401 } | 400 } |
| 402 src.getBounds(srcBounds); | 401 src.getBounds(srcBounds); |
| 403 srcBounds->offset(srcOffset); | 402 srcBounds->offset(srcOffset); |
| 404 return fCropRect.applyTo(*srcBounds, ctx, dstBounds) && srcBounds->intersect
(*dstBounds); | 403 return fCropRect.applyTo(*srcBounds, ctx, dstBounds) && srcBounds->intersect
(*dstBounds); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 } | 633 } |
| 635 return dev; | 634 return dev; |
| 636 } | 635 } |
| 637 | 636 |
| 638 bool SkImageFilter::DeviceProxy::filterImage(const SkImageFilter* filter, const
SkBitmap& src, | 637 bool SkImageFilter::DeviceProxy::filterImage(const SkImageFilter* filter, const
SkBitmap& src, |
| 639 const SkImageFilter::Context& ctx, | 638 const SkImageFilter::Context& ctx, |
| 640 SkBitmap* result, SkIPoint* offset) { | 639 SkBitmap* result, SkIPoint* offset) { |
| 641 return fDevice->filterImage(filter, src, ctx, result, offset); | 640 return fDevice->filterImage(filter, src, ctx, result, offset); |
| 642 } | 641 } |
| 643 | 642 |
| OLD | NEW |