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

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

Issue 1768283002: Switch SkComposeImageFilter over to new onFilterImage interface (Closed) Base URL: https://skia.googlesource.com/skia.git@if-follow-on
Patch Set: Update for naming convention 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 | « include/effects/SkComposeImageFilter.h ('k') | no next file » | 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"
9 #include "SkComposeImageFilter.h" 8 #include "SkComposeImageFilter.h"
9
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
11 #include "SkSpecialImage.h"
11 #include "SkWriteBuffer.h" 12 #include "SkWriteBuffer.h"
12 13
13 SkComposeImageFilter::~SkComposeImageFilter() {
14 }
15 14
16 void SkComposeImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) con st { 15 void SkComposeImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) con st {
17 SkImageFilter* outer = getInput(0); 16 SkImageFilter* outer = getInput(0);
18 SkImageFilter* inner = getInput(1); 17 SkImageFilter* inner = getInput(1);
19 18
20 SkRect tmp; 19 SkRect tmp;
21 inner->computeFastBounds(src, &tmp); 20 inner->computeFastBounds(src, &tmp);
22 outer->computeFastBounds(tmp, dst); 21 outer->computeFastBounds(tmp, dst);
23 } 22 }
24 23
25 bool SkComposeImageFilter::onFilterImageDeprecated(Proxy* proxy, 24 SkSpecialImage* SkComposeImageFilter::onFilterImage(SkSpecialImage* source, cons t Context& ctx,
26 const SkBitmap& src, 25 SkIPoint* offset) const {
27 const Context& ctx,
28 SkBitmap* result,
29 SkIPoint* offset) const {
30 SkBitmap tmp;
31 SkIPoint innerOffset = SkIPoint::Make(0, 0); 26 SkIPoint innerOffset = SkIPoint::Make(0, 0);
32 SkIPoint outerOffset = SkIPoint::Make(0, 0); 27 SkAutoTUnref<SkSpecialImage> inner(this->filterInput(1, source, ctx, &innerO ffset));
33 if (!this->filterInputDeprecated(1, proxy, src, ctx, &tmp, &innerOffset)) 28 if (!inner) {
34 return false; 29 return nullptr;
30 }
35 31
36 SkMatrix outerMatrix(ctx.ctm()); 32 SkMatrix outerMatrix(ctx.ctm());
37 outerMatrix.postTranslate(SkIntToScalar(-innerOffset.x()), SkIntToScalar(-in nerOffset.y())); 33 outerMatrix.postTranslate(SkIntToScalar(-innerOffset.x()), SkIntToScalar(-in nerOffset.y()));
38 SkIRect clipBounds = ctx.clipBounds(); 34 SkIRect clipBounds = ctx.clipBounds();
39 clipBounds.offset(-innerOffset.x(), -innerOffset.y()); 35 clipBounds.offset(-innerOffset.x(), -innerOffset.y());
40 Context outerContext(outerMatrix, clipBounds, ctx.cache()); 36 Context outerContext(outerMatrix, clipBounds, ctx.cache());
41 if (!this->filterInputDeprecated(0, proxy, tmp, outerContext, result, &outer Offset)) { 37
42 return false; 38 SkIPoint outerOffset = SkIPoint::Make(0, 0);
39 SkAutoTUnref<SkSpecialImage> outer(this->filterInput(0, inner, outerContext, &outerOffset));
40 if (!outer) {
41 return nullptr;
43 } 42 }
44 43
45 *offset = innerOffset + outerOffset; 44 *offset = innerOffset + outerOffset;
46 return true; 45 return outer.release();
47 } 46 }
48 47
49 bool SkComposeImageFilter::onFilterBounds(const SkIRect& src, 48 bool SkComposeImageFilter::onFilterBounds(const SkIRect& src,
50 const SkMatrix& ctm, 49 const SkMatrix& ctm,
51 SkIRect* dst, 50 SkIRect* dst,
52 MapDirection direction) const { 51 MapDirection direction) const {
53 SkImageFilter* outer = getInput(0); 52 SkImageFilter* outer = this->getInput(0);
54 SkImageFilter* inner = getInput(1); 53 SkImageFilter* inner = this->getInput(1);
55 54
56 SkIRect tmp; 55 SkIRect tmp;
57 return inner->filterBounds(src, ctm, &tmp, direction) && 56 return inner->filterBounds(src, ctm, &tmp, direction) &&
58 outer->filterBounds(tmp, ctm, dst, direction); 57 outer->filterBounds(tmp, ctm, dst, direction);
59 } 58 }
60 59
61 SkFlattenable* SkComposeImageFilter::CreateProc(SkReadBuffer& buffer) { 60 SkFlattenable* SkComposeImageFilter::CreateProc(SkReadBuffer& buffer) {
62 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2); 61 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2);
63 return SkComposeImageFilter::Create(common.getInput(0), common.getInput(1)); 62 return SkComposeImageFilter::Create(common.getInput(0), common.getInput(1));
64 } 63 }
65 64
66 #ifndef SK_IGNORE_TO_STRING 65 #ifndef SK_IGNORE_TO_STRING
67 void SkComposeImageFilter::toString(SkString* str) const { 66 void SkComposeImageFilter::toString(SkString* str) const {
68 SkImageFilter* outer = getInput(0); 67 SkImageFilter* outer = getInput(0);
69 SkImageFilter* inner = getInput(1); 68 SkImageFilter* inner = getInput(1);
70 69
71 str->appendf("SkComposeImageFilter: ("); 70 str->appendf("SkComposeImageFilter: (");
72 71
73 str->appendf("outer: "); 72 str->appendf("outer: ");
74 outer->toString(str); 73 outer->toString(str);
75 74
76 str->appendf("inner: "); 75 str->appendf("inner: ");
77 inner->toString(str); 76 inner->toString(str);
78 77
79 str->appendf(")"); 78 str->appendf(")");
80 } 79 }
81 #endif 80 #endif
OLDNEW
« no previous file with comments | « include/effects/SkComposeImageFilter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698