Index: src/core/SkBitmapProcShader.cpp |
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp |
index 5f5eb1866e4282ba2a6e6b12237d5ea5a13deb08..7aa62ba2f2a7c21b817757074eb5d8a5225752fe 100644 |
--- a/src/core/SkBitmapProcShader.cpp |
+++ b/src/core/SkBitmapProcShader.cpp |
@@ -205,13 +205,23 @@ SkBitmapProcShader::BitmapProcShaderContext::~BitmapProcShaderContext() { |
fState->~SkBitmapProcState(); |
} |
-#define BUF_MAX 128 |
+/* Defines the buffer size for sample pixel indexes, used in the sample proc function calls. |
+ * If the operation is bigger than the buffer, it's split into multiple calls. This split is bad |
+ * for the performance of SIMD optimizations. |
+ * A display in portrait mode, with a width of 720 pixels, requires a buffer size of at least 361 |
+ * to run uninterrupted in the most basic operations. (Formula: Width / 2 + 1) |
+ */ |
+#ifdef ANDROID_LARGE_MEMORY_DEVICE |
+ #define BUF_MAX 541 // 1080p phone display |
+#else |
+ #define BUF_MAX 241 // 480p phone display |
+#endif |
#define TEST_BUFFER_OVERRITEx |
#ifdef TEST_BUFFER_OVERRITE |
#define TEST_BUFFER_EXTRA 32 |
- #define TEST_PATTERN 0x88888888 |
+ #define TEST_PATTERN 0x88888888 |
#else |
#define TEST_BUFFER_EXTRA 0 |
#endif |
@@ -224,7 +234,12 @@ void SkBitmapProcShader::BitmapProcShaderContext::shadeSpan(int x, int y, SkPMCo |
return; |
} |
- uint32_t buffer[BUF_MAX + TEST_BUFFER_EXTRA]; |
+ // Align buffer to 16 bytes to enable more efficient SIMD optimizations. |
+#ifdef _MSC_VER |
+ __declspec(align(16)) uint32_t buffer[BUF_MAX + TEST_BUFFER_EXTRA]; |
scroggo
2014/04/22 15:18:40
Is there a way to turn this into a macro? Or does
henrik.smiding
2014/04/23 13:34:46
Done.
|
+#else |
+ uint32_t __attribute__((aligned(16))) buffer[BUF_MAX + TEST_BUFFER_EXTRA]; |
+#endif |
SkBitmapProcState::MatrixProc mproc = state.getMatrixProc(); |
SkBitmapProcState::SampleProc32 sproc = state.getSampleProc32(); |
int max = state.maxCountForBufferSize(sizeof(buffer[0]) * BUF_MAX); |