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

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

Issue 908273002: Fix SkComposeImageFilter's bounds computation and offset handling (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Add curly braces Created 5 years, 10 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 | « include/effects/SkComposeImageFilter.h ('k') | 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkComposeImageFilter.h" 9 #include "SkComposeImageFilter.h"
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
11 #include "SkWriteBuffer.h" 11 #include "SkWriteBuffer.h"
12 12
13 SkComposeImageFilter::~SkComposeImageFilter() { 13 SkComposeImageFilter::~SkComposeImageFilter() {
14 } 14 }
15 15
16 void SkComposeImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) con st {
17 SkImageFilter* outer = getInput(0);
18 SkImageFilter* inner = getInput(1);
19
20 SkRect tmp;
21 inner->computeFastBounds(src, &tmp);
22 outer->computeFastBounds(tmp, dst);
23 }
24
16 bool SkComposeImageFilter::onFilterImage(Proxy* proxy, 25 bool SkComposeImageFilter::onFilterImage(Proxy* proxy,
17 const SkBitmap& src, 26 const SkBitmap& src,
18 const Context& ctx, 27 const Context& ctx,
19 SkBitmap* result, 28 SkBitmap* result,
20 SkIPoint* offset) const { 29 SkIPoint* offset) const {
21 SkImageFilter* outer = getInput(0); 30 SkImageFilter* outer = getInput(0);
22 SkImageFilter* inner = getInput(1); 31 SkImageFilter* inner = getInput(1);
23 32
24 SkBitmap tmp; 33 SkBitmap tmp;
25 return inner->filterImage(proxy, src, ctx, &tmp, offset) && 34 SkIPoint innerOffset = SkIPoint::Make(0, 0);
26 outer->filterImage(proxy, tmp, ctx, result, offset); 35 SkIPoint outerOffset = SkIPoint::Make(0, 0);
36 if (!inner->filterImage(proxy, src, ctx, &tmp, &innerOffset))
37 return false;
38
39 SkMatrix outerMatrix(ctx.ctm());
40 outerMatrix.postTranslate(SkIntToScalar(-innerOffset.x()), SkIntToScalar(-in nerOffset.y()));
41 Context outerContext(outerMatrix, ctx.clipBounds(), ctx.cache());
42 if (!outer->filterImage(proxy, tmp, outerContext, result, &outerOffset)) {
43 return false;
44 }
45
46 *offset = innerOffset + outerOffset;
47 return true;
27 } 48 }
28 49
29 bool SkComposeImageFilter::onFilterBounds(const SkIRect& src, 50 bool SkComposeImageFilter::onFilterBounds(const SkIRect& src,
30 const SkMatrix& ctm, 51 const SkMatrix& ctm,
31 SkIRect* dst) const { 52 SkIRect* dst) const {
32 SkImageFilter* outer = getInput(0); 53 SkImageFilter* outer = getInput(0);
33 SkImageFilter* inner = getInput(1); 54 SkImageFilter* inner = getInput(1);
34 55
35 SkIRect tmp; 56 SkIRect tmp;
36 return inner->filterBounds(src, ctm, &tmp) && outer->filterBounds(tmp, ctm, dst); 57 return inner->filterBounds(src, ctm, &tmp) && outer->filterBounds(tmp, ctm, dst);
(...skipping 13 matching lines...) Expand all
50 71
51 str->appendf("outer: "); 72 str->appendf("outer: ");
52 outer->toString(str); 73 outer->toString(str);
53 74
54 str->appendf("inner: "); 75 str->appendf("inner: ");
55 inner->toString(str); 76 inner->toString(str);
56 77
57 str->appendf(")"); 78 str->appendf(")");
58 } 79 }
59 #endif 80 #endif
OLDNEW
« no previous file with comments | « include/effects/SkComposeImageFilter.h ('k') | tests/ImageFilterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698