OLD | NEW |
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 #include "SkConvolver.h" | 5 #include "SkConvolver.h" |
6 #include "SkOpts.h" | 6 #include "SkOpts.h" |
7 #include "SkTArray.h" | 7 #include "SkTArray.h" |
8 | 8 |
9 namespace { | 9 namespace { |
10 // Stores a list of rows in a circular buffer. The usage is you write into i
t | 10 // Stores a list of rows in a circular buffer. The usage is you write into i
t |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 filterY.FilterForValue(0, &filterOffset, &filterLength); | 185 filterY.FilterForValue(0, &filterOffset, &filterLength); |
186 int nextXRow = filterOffset; | 186 int nextXRow = filterOffset; |
187 | 187 |
188 // We loop over each row in the input doing a horizontal convolution. This | 188 // We loop over each row in the input doing a horizontal convolution. This |
189 // will result in a horizontally convolved image. We write the results into | 189 // will result in a horizontally convolved image. We write the results into |
190 // a circular buffer of convolved rows and do vertical convolution as rows | 190 // a circular buffer of convolved rows and do vertical convolution as rows |
191 // are available. This prevents us from having to store the entire | 191 // are available. This prevents us from having to store the entire |
192 // intermediate image and helps cache coherency. | 192 // intermediate image and helps cache coherency. |
193 // We will need four extra rows to allow horizontal convolution could be don
e | 193 // We will need four extra rows to allow horizontal convolution could be don
e |
194 // simultaneously. We also pad each row in row buffer to be aligned-up to | 194 // simultaneously. We also pad each row in row buffer to be aligned-up to |
195 // 16 bytes. | 195 // 32 bytes. |
196 // TODO(jiesun): We do not use aligned load from row buffer in vertical | 196 // TODO(jiesun): We do not use aligned load from row buffer in vertical |
197 // convolution pass yet. Somehow Windows does not like it. | 197 // convolution pass yet. Somehow Windows does not like it. |
198 int rowBufferWidth = (filterX.numValues() + 15) & ~0xF; | 198 int rowBufferWidth = (filterX.numValues() + 31) & ~0x1F; |
199 int rowBufferHeight = maxYFilterSize + | 199 int rowBufferHeight = maxYFilterSize + |
200 (SkOpts::convolve_4_rows_horizontally != nullptr ? 4 :
0); | 200 (SkOpts::convolve_4_rows_horizontally != nullptr ? 4 :
0); |
201 | 201 |
202 // check for too-big allocation requests : crbug.com/528628 | 202 // check for too-big allocation requests : crbug.com/528628 |
203 { | 203 { |
204 int64_t size = sk_64_mul(rowBufferWidth, rowBufferHeight); | 204 int64_t size = sk_64_mul(rowBufferWidth, rowBufferHeight); |
205 // need some limit, to avoid over-committing success from malloc, but th
en | 205 // need some limit, to avoid over-committing success from malloc, but th
en |
206 // crashing when we try to actually use the memory. | 206 // crashing when we try to actually use the memory. |
207 // 100meg seems big enough to allow "normal" zoom factors and image size
s through | 207 // 100meg seems big enough to allow "normal" zoom factors and image size
s through |
208 // while avoiding the crash seen by the bug (crbug.com/528628) | 208 // while avoiding the crash seen by the bug (crbug.com/528628) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 unsigned char* const* firstRowForFilter = | 263 unsigned char* const* firstRowForFilter = |
264 &rowsToConvolve[filterOffset - firstRowInCircularBuffer]; | 264 &rowsToConvolve[filterOffset - firstRowInCircularBuffer]; |
265 | 265 |
266 SkOpts::convolve_vertically(filterValues, filterLength, | 266 SkOpts::convolve_vertically(filterValues, filterLength, |
267 firstRowForFilter, | 267 firstRowForFilter, |
268 filterX.numValues(), curOutputRow, | 268 filterX.numValues(), curOutputRow, |
269 sourceHasAlpha); | 269 sourceHasAlpha); |
270 } | 270 } |
271 return true; | 271 return true; |
272 } | 272 } |
OLD | NEW |