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

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

Issue 1404743005: Image Filters: refactor all CPU input processing into a filterInput helper function. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Tweak comment Created 5 years, 2 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 | « src/effects/SkMorphologyImageFilter.cpp ('k') | src/effects/SkTileImageFilter.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 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 "SkOffsetImageFilter.h" 8 #include "SkOffsetImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkDevice.h" 11 #include "SkDevice.h"
12 #include "SkReadBuffer.h" 12 #include "SkReadBuffer.h"
13 #include "SkWriteBuffer.h" 13 #include "SkWriteBuffer.h"
14 #include "SkMatrix.h" 14 #include "SkMatrix.h"
15 #include "SkPaint.h" 15 #include "SkPaint.h"
16 16
17 bool SkOffsetImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source, 17 bool SkOffsetImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source,
18 const Context& ctx, 18 const Context& ctx,
19 SkBitmap* result, 19 SkBitmap* result,
20 SkIPoint* offset) const { 20 SkIPoint* offset) const {
21 SkImageFilter* input = getInput(0);
22 SkBitmap src = source; 21 SkBitmap src = source;
23 SkIPoint srcOffset = SkIPoint::Make(0, 0); 22 SkIPoint srcOffset = SkIPoint::Make(0, 0);
24 #ifdef SK_DISABLE_OFFSETIMAGEFILTER_OPTIMIZATION 23 #ifdef SK_DISABLE_OFFSETIMAGEFILTER_OPTIMIZATION
25 if (false) { 24 if (false) {
26 #else 25 #else
27 if (!cropRectIsSet()) { 26 if (!cropRectIsSet()) {
28 #endif 27 #endif
29 if (input && !input->filterImage(proxy, source, ctx, &src, &srcOffset)) { 28 if (!this->filterInput(0, proxy, source, ctx, &src, &srcOffset)) {
30 return false; 29 return false;
31 } 30 }
32 31
33 SkVector vec; 32 SkVector vec;
34 ctx.ctm().mapVectors(&vec, &fOffset, 1); 33 ctx.ctm().mapVectors(&vec, &fOffset, 1);
35 34
36 offset->fX = srcOffset.fX + SkScalarRoundToInt(vec.fX); 35 offset->fX = srcOffset.fX + SkScalarRoundToInt(vec.fX);
37 offset->fY = srcOffset.fY + SkScalarRoundToInt(vec.fY); 36 offset->fY = srcOffset.fY + SkScalarRoundToInt(vec.fY);
38 *result = src; 37 *result = src;
39 } else { 38 } else {
40 if (input && !input->filterImage(proxy, source, ctx, &src, &srcOffset)) { 39 if (!this->filterInput(0, proxy, source, ctx, &src, &srcOffset)) {
41 return false; 40 return false;
42 } 41 }
43 42
44 SkIRect bounds; 43 SkIRect bounds;
45 if (!this->applyCropRect(ctx, src, srcOffset, &bounds)) { 44 if (!this->applyCropRect(ctx, src, srcOffset, &bounds)) {
46 return false; 45 return false;
47 } 46 }
48 47
49 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bo unds.height())); 48 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bo unds.height()));
50 if (nullptr == device.get()) { 49 if (nullptr == device.get()) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 void SkOffsetImageFilter::toString(SkString* str) const { 112 void SkOffsetImageFilter::toString(SkString* str) const {
114 str->appendf("SkOffsetImageFilter: ("); 113 str->appendf("SkOffsetImageFilter: (");
115 str->appendf("offset: (%f, %f) ", fOffset.fX, fOffset.fY); 114 str->appendf("offset: (%f, %f) ", fOffset.fX, fOffset.fY);
116 str->append("input: ("); 115 str->append("input: (");
117 if (this->getInput(0)) { 116 if (this->getInput(0)) {
118 this->getInput(0)->toString(str); 117 this->getInput(0)->toString(str);
119 } 118 }
120 str->append("))"); 119 str->append("))");
121 } 120 }
122 #endif 121 #endif
OLDNEW
« no previous file with comments | « src/effects/SkMorphologyImageFilter.cpp ('k') | src/effects/SkTileImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698