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

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

Issue 23011012: Implement correct clipping for image filters. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Add morphology to the list of ignored tests Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/effects/SkDropShadowImageFilter.cpp ('k') | src/effects/SkMorphologyImageFilter.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 "SkMergeImageFilter.h" 8 #include "SkMergeImageFilter.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkDevice.h" 10 #include "SkDevice.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 this->initModes(modes); 58 this->initModes(modes);
59 } 59 }
60 60
61 SkMergeImageFilter::~SkMergeImageFilter() { 61 SkMergeImageFilter::~SkMergeImageFilter() {
62 62
63 if (fModes != SkTCast<uint8_t*>(fStorage)) { 63 if (fModes != SkTCast<uint8_t*>(fStorage)) {
64 sk_free(fModes); 64 sk_free(fModes);
65 } 65 }
66 } 66 }
67 67
68 bool SkMergeImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
69 SkIRect* dst) {
70 if (countInputs() < 1) {
71 return false;
72 }
73
74 SkIRect totalBounds;
75
76 int inputCount = countInputs();
77 for (int i = 0; i < inputCount; ++i) {
78 SkImageFilter* filter = getInput(i);
79 SkIRect r;
80 if (filter) {
81 if (!filter->filterBounds(src, ctm, &r)) {
82 return false;
83 }
84 } else {
85 r = src;
86 }
87 if (0 == i) {
88 totalBounds = r;
89 } else {
90 totalBounds.join(r);
91 }
92 }
93
94 // don't modify dst until now, so we don't accidentally change it in the
95 // loop, but then return false on the next filter.
96 *dst = totalBounds;
97 return true;
98 }
99
100 bool SkMergeImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, 68 bool SkMergeImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
101 const SkMatrix& ctm, 69 const SkMatrix& ctm,
102 SkBitmap* result, SkIPoint* offset) { 70 SkBitmap* result, SkIPoint* offset) {
103 if (countInputs() < 1) { 71 if (countInputs() < 1) {
104 return false; 72 return false;
105 } 73 }
106 74
107 SkIRect bounds; 75 SkIRect bounds;
108 src.getBounds(&bounds); 76 src.getBounds(&bounds);
109 if (!this->applyCropRect(&bounds, ctm)) { 77 if (!this->applyCropRect(&bounds, ctm)) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 if (buffer.validate(buffer.getArrayCount() == size) && 137 if (buffer.validate(buffer.getArrayCount() == size) &&
170 buffer.readByteArray(fModes, size)) { 138 buffer.readByteArray(fModes, size)) {
171 for (int i = 0; i < nbInputs; ++i) { 139 for (int i = 0; i < nbInputs; ++i) {
172 buffer.validate(SkIsValidMode((SkXfermode::Mode)fModes[i])); 140 buffer.validate(SkIsValidMode((SkXfermode::Mode)fModes[i]));
173 } 141 }
174 } 142 }
175 } else { 143 } else {
176 fModes = 0; 144 fModes = 0;
177 } 145 }
178 } 146 }
OLDNEW
« no previous file with comments | « src/effects/SkDropShadowImageFilter.cpp ('k') | src/effects/SkMorphologyImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698