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

Side by Side Diff: src/effects/SkComposeImageFilter.cpp

Issue 1813373002: Make SkComposeImageFilter::onFilterImage filter the bounds given to the inner filter. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: skip innerClipBounds initialization per senorblanco Created 4 years, 9 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
« no previous file with comments | « no previous file | tests/ImageFilterTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
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 "SkComposeImageFilter.h" 8 #include "SkComposeImageFilter.h"
9 9
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
11 #include "SkSpecialImage.h" 11 #include "SkSpecialImage.h"
12 #include "SkWriteBuffer.h" 12 #include "SkWriteBuffer.h"
13 13
14 14
15 void SkComposeImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) con st { 15 void SkComposeImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) con st {
16 SkImageFilter* outer = getInput(0); 16 SkImageFilter* outer = getInput(0);
17 SkImageFilter* inner = getInput(1); 17 SkImageFilter* inner = getInput(1);
18 18
19 SkRect tmp; 19 SkRect tmp;
20 inner->computeFastBounds(src, &tmp); 20 inner->computeFastBounds(src, &tmp);
21 outer->computeFastBounds(tmp, dst); 21 outer->computeFastBounds(tmp, dst);
22 } 22 }
23 23
24 SkSpecialImage* SkComposeImageFilter::onFilterImage(SkSpecialImage* source, cons t Context& ctx, 24 SkSpecialImage* SkComposeImageFilter::onFilterImage(SkSpecialImage* source, cons t Context& ctx,
25 SkIPoint* offset) const { 25 SkIPoint* offset) const {
26 // The bounds passed to the inner filter must be filtered by the outer
27 // filter, so that the inner filter produces the pixels that the outer
28 // filter requires as input. This matters if the outer filter moves pixels.
29 SkIRect innerClipBounds;
30 getInput(0)->filterBounds(ctx.clipBounds(), ctx.ctm(), &innerClipBounds);
31 Context innerContext(ctx.ctm(), innerClipBounds, ctx.cache());
26 SkIPoint innerOffset = SkIPoint::Make(0, 0); 32 SkIPoint innerOffset = SkIPoint::Make(0, 0);
27 SkAutoTUnref<SkSpecialImage> inner(this->filterInput(1, source, ctx, &innerO ffset)); 33 SkAutoTUnref<SkSpecialImage> inner(this->filterInput(1, source, innerContext , &innerOffset));
28 if (!inner) { 34 if (!inner) {
29 return nullptr; 35 return nullptr;
30 } 36 }
31 37
32 SkMatrix outerMatrix(ctx.ctm()); 38 SkMatrix outerMatrix(ctx.ctm());
33 outerMatrix.postTranslate(SkIntToScalar(-innerOffset.x()), SkIntToScalar(-in nerOffset.y())); 39 outerMatrix.postTranslate(SkIntToScalar(-innerOffset.x()), SkIntToScalar(-in nerOffset.y()));
34 SkIRect clipBounds = ctx.clipBounds(); 40 SkIRect clipBounds = ctx.clipBounds();
35 clipBounds.offset(-innerOffset.x(), -innerOffset.y()); 41 clipBounds.offset(-innerOffset.x(), -innerOffset.y());
36 Context outerContext(outerMatrix, clipBounds, ctx.cache()); 42 Context outerContext(outerMatrix, clipBounds, ctx.cache());
37 43
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 77
72 str->appendf("outer: "); 78 str->appendf("outer: ");
73 outer->toString(str); 79 outer->toString(str);
74 80
75 str->appendf("inner: "); 81 str->appendf("inner: ");
76 inner->toString(str); 82 inner->toString(str);
77 83
78 str->appendf(")"); 84 str->appendf(")");
79 } 85 }
80 #endif 86 #endif
OLDNEW
« no previous file with comments | « no previous file | tests/ImageFilterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698