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

Side by Side Diff: src/core/SkConvolver.h

Issue 2500113004: Port convolve functions to SkOpts (Closed)
Patch Set: Fix typo Created 4 years, 1 month 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/core/SkBitmapScaler.cpp ('k') | src/core/SkConvolver.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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SK_CONVOLVER_H 5 #ifndef SK_CONVOLVER_H
6 #define SK_CONVOLVER_H 6 #define SK_CONVOLVER_H
7 7
8 #include "SkSize.h" 8 #include "SkSize.h"
9 #include "SkTDArray.h" 9 #include "SkTDArray.h"
10 10
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 // We store all the filter values in this flat list, indexed by 134 // We store all the filter values in this flat list, indexed by
135 // |FilterInstance.data_location| to avoid the mallocs required for storing 135 // |FilterInstance.data_location| to avoid the mallocs required for storing
136 // each one separately. 136 // each one separately.
137 SkTDArray<ConvolutionFixed> fFilterValues; 137 SkTDArray<ConvolutionFixed> fFilterValues;
138 138
139 // The maximum size of any filter we've added. 139 // The maximum size of any filter we've added.
140 int fMaxFilter; 140 int fMaxFilter;
141 }; 141 };
142 142
143 typedef void (*SkConvolveVertically_pointer)(
144 const SkConvolutionFilter1D::ConvolutionFixed* filterValues,
145 int filterLength,
146 unsigned char* const* sourceDataRows,
147 int pixelWidth,
148 unsigned char* outRow,
149 bool hasAlpha);
150 typedef void (*SkConvolve4RowsHorizontally_pointer)(
151 const unsigned char* srcData[4],
152 const SkConvolutionFilter1D& filter,
153 unsigned char* outRow[4],
154 size_t outRowBytes);
155 typedef void (*SkConvolveHorizontally_pointer)(
156 const unsigned char* srcData,
157 const SkConvolutionFilter1D& filter,
158 unsigned char* outRow,
159 bool hasAlpha);
160
161 struct SkConvolutionProcs {
162 SkConvolveVertically_pointer fConvolveVertically;
163 SkConvolve4RowsHorizontally_pointer fConvolve4RowsHorizontally;
164 SkConvolveHorizontally_pointer fConvolveHorizontally;
165 };
166
167
168
169 // Does a two-dimensional convolution on the given source image. 143 // Does a two-dimensional convolution on the given source image.
170 // 144 //
171 // It is assumed the source pixel offsets referenced in the input filters 145 // It is assumed the source pixel offsets referenced in the input filters
172 // reference only valid pixels, so the source image size is not required. Each 146 // reference only valid pixels, so the source image size is not required. Each
173 // row of the source image starts |sourceByteRowStride| after the previous 147 // row of the source image starts |sourceByteRowStride| after the previous
174 // one (this allows you to have rows with some padding at the end). 148 // one (this allows you to have rows with some padding at the end).
175 // 149 //
176 // The result will be put into the given output buffer. The destination image 150 // The result will be put into the given output buffer. The destination image
177 // size will be xfilter.numValues() * yfilter.numValues() pixels. It will be 151 // size will be xfilter.numValues() * yfilter.numValues() pixels. It will be
178 // in rows of exactly xfilter.numValues() * 4 bytes. 152 // in rows of exactly xfilter.numValues() * 4 bytes.
179 // 153 //
180 // |sourceHasAlpha| is a hint that allows us to avoid doing computations on 154 // |sourceHasAlpha| is a hint that allows us to avoid doing computations on
181 // the alpha channel if the image is opaque. If you don't know, set this to 155 // the alpha channel if the image is opaque. If you don't know, set this to
182 // true and it will work properly, but setting this to false will be a few 156 // true and it will work properly, but setting this to false will be a few
183 // percent faster if you know the image is opaque. 157 // percent faster if you know the image is opaque.
184 // 158 //
185 // The layout in memory is assumed to be 4-bytes per pixel in B-G-R-A order 159 // The layout in memory is assumed to be 4-bytes per pixel in B-G-R-A order
186 // (this is ARGB when loaded into 32-bit words on a little-endian machine). 160 // (this is ARGB when loaded into 32-bit words on a little-endian machine).
187 /** 161 /**
188 * Returns false if it was unable to perform the convolution/rescale. in which case the output 162 * Returns false if it was unable to perform the convolution/rescale. in which case the output
189 * buffer is assumed to be undefined. 163 * buffer is assumed to be undefined.
190 */ 164 */
191 SK_API bool BGRAConvolve2D(const unsigned char* sourceData, 165 SK_API bool BGRAConvolve2D(const unsigned char* sourceData,
192 int sourceByteRowStride, 166 int sourceByteRowStride,
193 bool sourceHasAlpha, 167 bool sourceHasAlpha,
194 const SkConvolutionFilter1D& xfilter, 168 const SkConvolutionFilter1D& xfilter,
195 const SkConvolutionFilter1D& yfilter, 169 const SkConvolutionFilter1D& yfilter,
196 int outputByteRowStride, 170 int outputByteRowStride,
197 unsigned char* output, 171 unsigned char* output);
198 const SkConvolutionProcs&,
199 bool useSimdIfPossible);
200 172
201 #endif // SK_CONVOLVER_H 173 #endif // SK_CONVOLVER_H
OLDNEW
« no previous file with comments | « src/core/SkBitmapScaler.cpp ('k') | src/core/SkConvolver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698