Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/core/SkImageFilter.cpp

Issue 1908173006: allow imagefilter to manage CTM decomposition (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: switch to simple canHandleAffine pattern Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 {
Stephen White 2016/04/25 14:09:34 Wouldn't it be simpler to have (non-virtual) canHa
reed1 2016/04/25 14:13:35 Good idea! See follow-on CL https://codereview.chr
334 bool hasInputs = false;
335
336 const int count = this->countInputs();
337 for (int i = 0; i < count; ++i) {
338 SkImageFilter* input = this->getInput(i);
339 if (input) {
340 if (!input->canHandleAffine()) {
341 return false;
342 }
343 hasInputs = true;
344 }
345 }
346 // We return true iff we had 1 or more inputs, and all of them can handle af fine.
347 // If we have no inputs, or 1 or more of them do not handle affine, then we return false.
Stephen White 2016/04/25 14:09:34 Why would a null input imply we can't handle affin
348 return hasInputs;
349 }
350
333 bool SkImageFilter::applyCropRect(const Context& ctx, const SkIRect& srcBounds, 351 bool SkImageFilter::applyCropRect(const Context& ctx, const SkIRect& srcBounds,
334 SkIRect* dstBounds) const { 352 SkIRect* dstBounds) const {
335 SkIRect temp = this->onFilterNodeBounds(srcBounds, ctx.ctm(), kForward_MapDi rection); 353 SkIRect temp = this->onFilterNodeBounds(srcBounds, ctx.ctm(), kForward_MapDi rection);
336 fCropRect.applyTo(temp, ctx.ctm(), this->affectsTransparentBlack(), dstBound s); 354 fCropRect.applyTo(temp, ctx.ctm(), this->affectsTransparentBlack(), dstBound s);
337 // Intersect against the clip bounds, in case the crop rect has 355 // Intersect against the clip bounds, in case the crop rect has
338 // grown the bounds beyond the original clip. This can happen for 356 // grown the bounds beyond the original clip. This can happen for
339 // example in tiling, where the clip is much smaller than the filtered 357 // example in tiling, where the clip is much smaller than the filtered
340 // primitive. If we didn't do this, we would be processing the filter 358 // primitive. If we didn't do this, we would be processing the filter
341 // at the full crop rect size in every tile. 359 // at the full crop rect size in every tile.
342 return dstBounds->intersect(ctx.clipBounds()); 360 return dstBounds->intersect(ctx.clipBounds());
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 572
555 SK_DECLARE_STATIC_ONCE_PTR(SkImageFilter::Cache, cache); 573 SK_DECLARE_STATIC_ONCE_PTR(SkImageFilter::Cache, cache);
556 SkImageFilter::Cache* SkImageFilter::Cache::Get() { 574 SkImageFilter::Cache* SkImageFilter::Cache::Get() {
557 return cache.get([]{ return SkImageFilter::Cache::Create(kDefaultCacheSize); }); 575 return cache.get([]{ return SkImageFilter::Cache::Create(kDefaultCacheSize); });
558 } 576 }
559 577
560 void SkImageFilter::PurgeCache() { 578 void SkImageFilter::PurgeCache() {
561 Cache::Get()->purge(); 579 Cache::Get()->purge();
562 } 580 }
563 581
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698