| 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 #include "SkImageFilterCacheKey.h" | 9 #include "SkImageFilterCacheKey.h" |
| 10 | 10 |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 if (!this->isColorFilterNode(filterPtr)) { | 323 if (!this->isColorFilterNode(filterPtr)) { |
| 324 return false; | 324 return false; |
| 325 } | 325 } |
| 326 if (nullptr != this->getInput(0) || (*filterPtr)->affectsTransparentBlack())
{ | 326 if (nullptr != this->getInput(0) || (*filterPtr)->affectsTransparentBlack())
{ |
| 327 (*filterPtr)->unref(); | 327 (*filterPtr)->unref(); |
| 328 return false; | 328 return false; |
| 329 } | 329 } |
| 330 return true; | 330 return true; |
| 331 } | 331 } |
| 332 | 332 |
| 333 bool SkImageFilter::onCanHandleAffine() const { | 333 bool SkImageFilter::canHandleComplexCTM() const { |
| 334 bool hasInputs = false; | 334 if (!this->onCanHandleComplexCTM()) { |
| 335 | 335 return false; |
| 336 } |
| 336 const int count = this->countInputs(); | 337 const int count = this->countInputs(); |
| 337 for (int i = 0; i < count; ++i) { | 338 for (int i = 0; i < count; ++i) { |
| 338 SkImageFilter* input = this->getInput(i); | 339 SkImageFilter* input = this->getInput(i); |
| 339 if (input) { | 340 if (input && !input->canHandleComplexCTM()) { |
| 340 if (!input->canHandleAffine()) { | 341 return false; |
| 341 return false; | |
| 342 } | |
| 343 hasInputs = true; | |
| 344 } | 342 } |
| 345 } | 343 } |
| 346 // We return true iff we had 1 or more inputs, and all of them can handle af
fine. | 344 return true; |
| 347 // If we have no inputs, or 1 or more of them do not handle affine, then we
return false. | |
| 348 return hasInputs; | |
| 349 } | 345 } |
| 350 | 346 |
| 351 bool SkImageFilter::applyCropRect(const Context& ctx, const SkIRect& srcBounds, | 347 bool SkImageFilter::applyCropRect(const Context& ctx, const SkIRect& srcBounds, |
| 352 SkIRect* dstBounds) const { | 348 SkIRect* dstBounds) const { |
| 353 SkIRect temp = this->onFilterNodeBounds(srcBounds, ctx.ctm(), kForward_MapDi
rection); | 349 SkIRect temp = this->onFilterNodeBounds(srcBounds, ctx.ctm(), kForward_MapDi
rection); |
| 354 fCropRect.applyTo(temp, ctx.ctm(), this->affectsTransparentBlack(), dstBound
s); | 350 fCropRect.applyTo(temp, ctx.ctm(), this->affectsTransparentBlack(), dstBound
s); |
| 355 // Intersect against the clip bounds, in case the crop rect has | 351 // Intersect against the clip bounds, in case the crop rect has |
| 356 // grown the bounds beyond the original clip. This can happen for | 352 // grown the bounds beyond the original clip. This can happen for |
| 357 // example in tiling, where the clip is much smaller than the filtered | 353 // example in tiling, where the clip is much smaller than the filtered |
| 358 // primitive. If we didn't do this, we would be processing the filter | 354 // primitive. If we didn't do this, we would be processing the filter |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 | 568 |
| 573 SK_DECLARE_STATIC_ONCE_PTR(SkImageFilter::Cache, cache); | 569 SK_DECLARE_STATIC_ONCE_PTR(SkImageFilter::Cache, cache); |
| 574 SkImageFilter::Cache* SkImageFilter::Cache::Get() { | 570 SkImageFilter::Cache* SkImageFilter::Cache::Get() { |
| 575 return cache.get([]{ return SkImageFilter::Cache::Create(kDefaultCacheSize);
}); | 571 return cache.get([]{ return SkImageFilter::Cache::Create(kDefaultCacheSize);
}); |
| 576 } | 572 } |
| 577 | 573 |
| 578 void SkImageFilter::PurgeCache() { | 574 void SkImageFilter::PurgeCache() { |
| 579 Cache::Get()->purge(); | 575 Cache::Get()->purge(); |
| 580 } | 576 } |
| 581 | 577 |
| OLD | NEW |