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

Side by Side Diff: skia/ext/convolver.h

Issue 6334070: SIMD implementation of Convolver for Lanczos filter etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review issue/adding comments. Created 9 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 | « no previous file | skia/ext/convolver.cc » ('j') | skia/ext/convolver.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 SKIA_EXT_CONVOLVER_H_ 5 #ifndef SKIA_EXT_CONVOLVER_H_
6 #define SKIA_EXT_CONVOLVER_H_ 6 #define SKIA_EXT_CONVOLVER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/cpu.h"
13 14
14 // avoid confusion with Mac OS X's math library (Carbon) 15 // avoid confusion with Mac OS X's math library (Carbon)
15 #if defined(__APPLE__) 16 #if defined(__APPLE__)
16 #undef FloatToFixed 17 #undef FloatToFixed
17 #undef FixedToFloat 18 #undef FixedToFloat
18 #endif 19 #endif
19 20
20 namespace skia { 21 namespace skia {
21 22
22 // Represents a filter in one dimension. Each output pixel has one entry in this 23 // Represents a filter in one dimension. Each output pixel has one entry in this
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 int* filter_length) const { 92 int* filter_length) const {
92 const FilterInstance& filter = filters_[value_offset]; 93 const FilterInstance& filter = filters_[value_offset];
93 *filter_offset = filter.offset; 94 *filter_offset = filter.offset;
94 *filter_length = filter.length; 95 *filter_length = filter.length;
95 if (filter.length == 0) { 96 if (filter.length == 0) {
96 return NULL; 97 return NULL;
97 } 98 }
98 return &filter_values_[filter.data_location]; 99 return &filter_values_[filter.data_location];
99 } 100 }
100 101
102
103 inline void PaddingForSIMD(int padding_count) {
104 // Padding |padding_count| of more dummy coefficients after the coefficients
105 // of last filter to prevent SIMD instructions which load 8 or 16 bytes
106 // together to access invalid memory areas. We are not trying to align the
107 // coefficients right now due to the opaqueness of <vector> implementation.
108 // This has to be done after all |AddFilter| calls.
brettw 2011/02/25 06:43:02 I get this now, thanks! I presume that in the futu
jiesun 2011/03/07 18:57:15 correct. it is not done in this patch, because I a
109 for (int i = 0; i < padding_count; ++i)
110 filter_values_.push_back(static_cast<Fixed>(0));
111 }
112
101 private: 113 private:
102 struct FilterInstance { 114 struct FilterInstance {
103 // Offset within filter_values for this instance of the filter. 115 // Offset within filter_values for this instance of the filter.
104 int data_location; 116 int data_location;
105 117
106 // Distance from the left of the filter to the center. IN PIXELS 118 // Distance from the left of the filter to the center. IN PIXELS
107 int offset; 119 int offset;
108 120
109 // Number of values in this filter instance. 121 // Number of values in this filter instance.
110 int length; 122 int length;
(...skipping 30 matching lines...) Expand all
141 // The layout in memory is assumed to be 4-bytes per pixel in B-G-R-A order 153 // The layout in memory is assumed to be 4-bytes per pixel in B-G-R-A order
142 // (this is ARGB when loaded into 32-bit words on a little-endian machine). 154 // (this is ARGB when loaded into 32-bit words on a little-endian machine).
143 void BGRAConvolve2D(const unsigned char* source_data, 155 void BGRAConvolve2D(const unsigned char* source_data,
144 int source_byte_row_stride, 156 int source_byte_row_stride,
145 bool source_has_alpha, 157 bool source_has_alpha,
146 const ConvolutionFilter1D& xfilter, 158 const ConvolutionFilter1D& xfilter,
147 const ConvolutionFilter1D& yfilter, 159 const ConvolutionFilter1D& yfilter,
148 int output_byte_row_stride, 160 int output_byte_row_stride,
149 unsigned char* output); 161 unsigned char* output);
150 162
163 // Note: You should never use these functions externally; these functions are
164 // exposed only for testing purpose.
165 void BGRAConvolve2D_C(const unsigned char* source_data,
166 int source_byte_row_stride,
167 bool source_has_alpha,
168 const ConvolutionFilter1D& filter_x,
169 const ConvolutionFilter1D& filter_y,
170 int output_byte_row_stride,
171 unsigned char* output);
172
173 void BGRAConvolve2D_SSE2(const unsigned char* source_data,
174 int source_byte_row_stride,
175 bool source_has_alpha,
176 const ConvolutionFilter1D& filter_x,
177 const ConvolutionFilter1D& filter_y,
178 int output_byte_row_stride,
179 unsigned char* output);
151 } // namespace skia 180 } // namespace skia
152 181
153 #endif // SKIA_EXT_CONVOLVER_H_ 182 #endif // SKIA_EXT_CONVOLVER_H_
OLDNEW
« no previous file with comments | « no previous file | skia/ext/convolver.cc » ('j') | skia/ext/convolver.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698