aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/core/SkBitmapProcState.cpp12
-rw-r--r--src/core/SkBitmapProcState.h4
-rw-r--r--src/core/SkBitmapScaler.cpp16
-rw-r--r--src/core/SkBitmapScaler.h4
-rw-r--r--src/core/SkConvolver.cpp18
-rw-r--r--src/core/SkConvolver.h2
-rw-r--r--src/opts/SkBitmapProcState_opts_arm.cpp14
-rw-r--r--src/opts/opts_check_SSE2.cpp12
8 files changed, 37 insertions, 45 deletions
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp
index 821d383e15..353248f627 100644
--- a/src/core/SkBitmapProcState.cpp
+++ b/src/core/SkBitmapProcState.cpp
@@ -124,15 +124,9 @@ void SkBitmapProcState::possiblyScaleImage() {
// recompiles a lot less painful.
SkConvolutionProcs simd;
- fConvolutionProcs = &simd;
+ sk_bzero(&simd, sizeof(simd));
- fConvolutionProcs->fExtraHorizontalReads = 0;
- fConvolutionProcs->fConvolveVertically = NULL;
- fConvolutionProcs->fConvolve4RowsHorizontally = NULL;
- fConvolutionProcs->fConvolveHorizontally = NULL;
- fConvolutionProcs->fApplySIMDPadding = NULL;
-
- this->platformConvolutionProcs();
+ this->platformConvolutionProcs(&simd);
// STEP 1: Highest quality direct scale?
@@ -162,7 +156,7 @@ void SkBitmapProcState::possiblyScaleImage() {
SkBitmapScaler::RESIZE_BEST,
dest_width,
dest_height,
- fConvolutionProcs)) {
+ simd)) {
// we failed to create fScaledBitmap, so just return and let
// the scanline proc handle it.
return;
diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h
index 3a1d7bad62..2522a69e7f 100644
--- a/src/core/SkBitmapProcState.h
+++ b/src/core/SkBitmapProcState.h
@@ -79,8 +79,6 @@ struct SkBitmapProcState {
SkFixed fFilterOneX;
SkFixed fFilterOneY;
- SkConvolutionProcs* fConvolutionProcs; // possiblyScaleImage
-
SkPMColor fPaintPMColor; // chooseProcs - A8 config
SkFixed fInvSx; // chooseProcs
SkFixed fInvKy; // chooseProcs
@@ -115,7 +113,7 @@ struct SkBitmapProcState {
if we have SIMD versions of them.
*/
- void platformConvolutionProcs();
+ void platformConvolutionProcs(SkConvolutionProcs*);
/** Given the byte size of the index buffer to be passed to the matrix proc,
return the maximum number of resulting pixels that can be computed
diff --git a/src/core/SkBitmapScaler.cpp b/src/core/SkBitmapScaler.cpp
index 807696277e..114836dd79 100644
--- a/src/core/SkBitmapScaler.cpp
+++ b/src/core/SkBitmapScaler.cpp
@@ -15,7 +15,7 @@ public:
int srcFullWidth, int srcFullHeight,
int destWidth, int destHeight,
const SkIRect& destSubset,
- SkConvolutionProcs* convolveProcs);
+ const SkConvolutionProcs& convolveProcs);
~SkResizeFilter() {
SkDELETE( fBitmapFilter );
}
@@ -43,7 +43,7 @@ private:
int destSubsetLo, int destSubsetSize,
float scale,
SkConvolutionFilter1D* output,
- SkConvolutionProcs* convolveProcs);
+ const SkConvolutionProcs& convolveProcs);
SkConvolutionFilter1D fXFilter;
SkConvolutionFilter1D fYFilter;
@@ -53,7 +53,7 @@ SkResizeFilter::SkResizeFilter(SkBitmapScaler::ResizeMethod method,
int srcFullWidth, int srcFullHeight,
int destWidth, int destHeight,
const SkIRect& destSubset,
- SkConvolutionProcs* convolveProcs) {
+ const SkConvolutionProcs& convolveProcs) {
// method will only ever refer to an "algorithm method".
SkASSERT((SkBitmapScaler::RESIZE_FIRST_ALGORITHM_METHOD <= method) &&
@@ -108,7 +108,7 @@ void SkResizeFilter::computeFilters(int srcSize,
int destSubsetLo, int destSubsetSize,
float scale,
SkConvolutionFilter1D* output,
- SkConvolutionProcs* convolveProcs) {
+ const SkConvolutionProcs& convolveProcs) {
int destSubsetHi = destSubsetLo + destSubsetSize; // [lo, hi)
// When we're doing a magnification, the scale will be larger than one. This
@@ -197,8 +197,8 @@ void SkResizeFilter::computeFilters(int srcSize,
static_cast<int>(fixedFilterValues.count()));
}
- if (convolveProcs->fApplySIMDPadding) {
- convolveProcs->fApplySIMDPadding( output );
+ if (convolveProcs.fApplySIMDPadding) {
+ convolveProcs.fApplySIMDPadding( output );
}
}
@@ -238,7 +238,7 @@ bool SkBitmapScaler::Resize(SkBitmap* resultPtr,
ResizeMethod method,
int destWidth, int destHeight,
const SkIRect& destSubset,
- SkConvolutionProcs* convolveProcs,
+ const SkConvolutionProcs& convolveProcs,
SkBitmap::Allocator* allocator) {
// Ensure that the ResizeMethod enumeration is sound.
SkASSERT(((RESIZE_FIRST_QUALITY_METHOD <= method) &&
@@ -310,7 +310,7 @@ bool SkBitmapScaler::Resize(SkBitmap* resultPtr,
const SkBitmap& source,
ResizeMethod method,
int destWidth, int destHeight,
- SkConvolutionProcs* convolveProcs,
+ const SkConvolutionProcs& convolveProcs,
SkBitmap::Allocator* allocator) {
SkIRect destSubset = { 0, 0, destWidth, destHeight };
return Resize(resultPtr, source, method, destWidth, destHeight, destSubset,
diff --git a/src/core/SkBitmapScaler.h b/src/core/SkBitmapScaler.h
index b88fb9e775..c8d8a84185 100644
--- a/src/core/SkBitmapScaler.h
+++ b/src/core/SkBitmapScaler.h
@@ -92,7 +92,7 @@ public:
ResizeMethod method,
int dest_width, int dest_height,
const SkIRect& dest_subset,
- SkConvolutionProcs *convolveProcs = NULL,
+ const SkConvolutionProcs&,
SkBitmap::Allocator* allocator = NULL);
// Alternate version for resizing and returning the entire bitmap rather than
@@ -101,7 +101,7 @@ public:
const SkBitmap& source,
ResizeMethod method,
int dest_width, int dest_height,
- SkConvolutionProcs *convolveProcs = NULL,
+ const SkConvolutionProcs&,
SkBitmap::Allocator* allocator = NULL);
};
diff --git a/src/core/SkConvolver.cpp b/src/core/SkConvolver.cpp
index f426ef00d1..7666e6fadc 100644
--- a/src/core/SkConvolver.cpp
+++ b/src/core/SkConvolver.cpp
@@ -337,7 +337,7 @@ void BGRAConvolve2D(const unsigned char* sourceData,
const SkConvolutionFilter1D& filterY,
int outputByteRowStride,
unsigned char* output,
- SkConvolutionProcs* convolveProcs,
+ const SkConvolutionProcs& convolveProcs,
bool useSimdIfPossible) {
int maxYFilterSize = filterY.maxFilter();
@@ -364,7 +364,7 @@ void BGRAConvolve2D(const unsigned char* sourceData,
// convolution pass yet. Somehow Windows does not like it.
int rowBufferWidth = (filterX.numValues() + 15) & ~0xF;
int rowBufferHeight = maxYFilterSize +
- (convolveProcs->fConvolve4RowsHorizontally ? 4 : 0);
+ (convolveProcs.fConvolve4RowsHorizontally ? 4 : 0);
CircularRowBuffer rowBuffer(rowBufferWidth,
rowBufferHeight,
filterOffset);
@@ -387,7 +387,7 @@ void BGRAConvolve2D(const unsigned char* sourceData,
// rows we need to avoid the SSE implementation for here.
filterX.FilterForValue(filterX.numValues() - 1, &lastFilterOffset,
&lastFilterLength);
- int avoidSimdRows = 1 + convolveProcs->fExtraHorizontalReads /
+ int avoidSimdRows = 1 + convolveProcs.fExtraHorizontalReads /
(lastFilterOffset + lastFilterLength);
filterY.FilterForValue(numOutputRows - 1, &lastFilterOffset,
@@ -399,7 +399,7 @@ void BGRAConvolve2D(const unsigned char* sourceData,
// Generate output rows until we have enough to run the current filter.
while (nextXRow < filterOffset + filterLength) {
- if (convolveProcs->fConvolve4RowsHorizontally &&
+ if (convolveProcs.fConvolve4RowsHorizontally &&
nextXRow + 3 < lastFilterOffset + lastFilterLength -
avoidSimdRows) {
const unsigned char* src[4];
@@ -408,14 +408,14 @@ void BGRAConvolve2D(const unsigned char* sourceData,
src[i] = &sourceData[(nextXRow + i) * sourceByteRowStride];
outRow[i] = rowBuffer.advanceRow();
}
- convolveProcs->fConvolve4RowsHorizontally(src, filterX, outRow);
+ convolveProcs.fConvolve4RowsHorizontally(src, filterX, outRow);
nextXRow += 4;
} else {
// Check if we need to avoid SSE2 for this row.
- if (convolveProcs->fConvolveHorizontally &&
+ if (convolveProcs.fConvolveHorizontally &&
nextXRow < lastFilterOffset + lastFilterLength -
avoidSimdRows) {
- convolveProcs->fConvolveHorizontally(
+ convolveProcs.fConvolveHorizontally(
&sourceData[nextXRow * sourceByteRowStride],
filterX, rowBuffer.advanceRow(), sourceHasAlpha);
} else {
@@ -446,8 +446,8 @@ void BGRAConvolve2D(const unsigned char* sourceData,
unsigned char* const* firstRowForFilter =
&rowsToConvolve[filterOffset - firstRowInCircularBuffer];
- if (convolveProcs->fConvolveVertically) {
- convolveProcs->fConvolveVertically(filterValues, filterLength,
+ if (convolveProcs.fConvolveVertically) {
+ convolveProcs.fConvolveVertically(filterValues, filterLength,
firstRowForFilter,
filterX.numValues(), curOutputRow,
sourceHasAlpha);
diff --git a/src/core/SkConvolver.h b/src/core/SkConvolver.h
index 4327afaf18..94a5e91598 100644
--- a/src/core/SkConvolver.h
+++ b/src/core/SkConvolver.h
@@ -197,7 +197,7 @@ SK_API void BGRAConvolve2D(const unsigned char* sourceData,
const SkConvolutionFilter1D& yfilter,
int outputByteRowStride,
unsigned char* output,
- SkConvolutionProcs* convolveProcs,
+ const SkConvolutionProcs&,
bool useSimdIfPossible);
#endif // SK_CONVOLVER_H
diff --git a/src/opts/SkBitmapProcState_opts_arm.cpp b/src/opts/SkBitmapProcState_opts_arm.cpp
index a9b44daa89..3a3cb8567c 100644
--- a/src/opts/SkBitmapProcState_opts_arm.cpp
+++ b/src/opts/SkBitmapProcState_opts_arm.cpp
@@ -401,10 +401,10 @@ void applySIMDPadding_arm(SkConvolutionFilter1D *filter) {
}
}
-void SkBitmapProcState::platformConvolutionProcs() {
+void SkBitmapProcState::platformConvolutionProcs(SkConvolutionProcs* procs) {
if (sk_cpu_arm_has_neon()) {
- fConvolutionProcs->fExtraHorizontalReads = 3;
- fConvolutionProcs->fConvolveVertically = &convolveVertically_arm;
+ procs->fExtraHorizontalReads = 3;
+ procs->fConvolveVertically = &convolveVertically_arm;
// next line is commented out because the four-row convolution function above is
// just a no-op. Please see the comment above its definition, and the SSE implementation
@@ -412,11 +412,11 @@ void SkBitmapProcState::platformConvolutionProcs() {
// leaving it as NULL will just cause the convolution system to not attempt
// to operate on four rows at once, which is correct but not performance-optimal.
- // fConvolutionProcs->fConvolve4RowsHorizontally = &convolve4RowsHorizontally_arm;
+ // procs->fConvolve4RowsHorizontally = &convolve4RowsHorizontally_arm;
- fConvolutionProcs->fConvolve4RowsHorizontally = NULL;
+ procs->fConvolve4RowsHorizontally = NULL;
- fConvolutionProcs->fConvolveHorizontally = &convolveHorizontally_arm;
- fConvolutionProcs->fApplySIMDPadding = &applySIMDPadding_arm;
+ procs->fConvolveHorizontally = &convolveHorizontally_arm;
+ procs->fApplySIMDPadding = &applySIMDPadding_arm;
}
}
diff --git a/src/opts/opts_check_SSE2.cpp b/src/opts/opts_check_SSE2.cpp
index 8d43390a22..8f0bdac8fd 100644
--- a/src/opts/opts_check_SSE2.cpp
+++ b/src/opts/opts_check_SSE2.cpp
@@ -107,13 +107,13 @@ static bool cachedHasSSSE3() {
SK_CONF_DECLARE( bool, c_hqfilter_sse, "bitmap.filter.highQualitySSE", false, "Use SSE optimized version of high quality image filters");
-void SkBitmapProcState::platformConvolutionProcs() {
+void SkBitmapProcState::platformConvolutionProcs(SkConvolutionProcs* procs) {
if (cachedHasSSE2()) {
- fConvolutionProcs->fExtraHorizontalReads = 3;
- fConvolutionProcs->fConvolveVertically = &convolveVertically_SSE2;
- fConvolutionProcs->fConvolve4RowsHorizontally = &convolve4RowsHorizontally_SSE2;
- fConvolutionProcs->fConvolveHorizontally = &convolveHorizontally_SSE2;
- fConvolutionProcs->fApplySIMDPadding = &applySIMDPadding_SSE2;
+ procs->fExtraHorizontalReads = 3;
+ procs->fConvolveVertically = &convolveVertically_SSE2;
+ procs->fConvolve4RowsHorizontally = &convolve4RowsHorizontally_SSE2;
+ procs->fConvolveHorizontally = &convolveHorizontally_SSE2;
+ procs->fApplySIMDPadding = &applySIMDPadding_SSE2;
}
}