aboutsummaryrefslogtreecommitdiff
path: root/src/codec/SkSwizzler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/codec/SkSwizzler.cpp')
-rw-r--r--src/codec/SkSwizzler.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/codec/SkSwizzler.cpp b/src/codec/SkSwizzler.cpp
index 133736879f..f4be612c4d 100644
--- a/src/codec/SkSwizzler.cpp
+++ b/src/codec/SkSwizzler.cpp
@@ -11,6 +11,10 @@
#include "SkSwizzler.h"
#include "SkTemplates.h"
+#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
+ #include "SkAndroidFrameworkUtils.h"
+#endif
+
static void copy(void* dst, const uint8_t* src, int width, int bpp, int deltaSrc, int offset,
const SkPMColor ctable[]) {
// This function must not be called if we are sampling. If we are not
@@ -937,6 +941,18 @@ int SkSwizzler::onSetSampleX(int sampleX) {
fSwizzleWidth = get_scaled_dimension(fSrcWidth, sampleX);
fAllocatedWidth = get_scaled_dimension(fDstWidth, sampleX);
+ if (fDstOffsetBytes > 0) {
+ const size_t dstSwizzleBytes = fSwizzleWidth * fDstBPP;
+ const size_t dstAllocatedBytes = fAllocatedWidth * fDstBPP;
+ if (fDstOffsetBytes + dstSwizzleBytes > dstAllocatedBytes) {
+#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
+ SkAndroidFrameworkUtils::SafetyNetLog("118143775");
+#endif
+ SkASSERT(dstSwizzleBytes < dstAllocatedBytes);
+ fDstOffsetBytes = dstAllocatedBytes - dstSwizzleBytes;
+ }
+ }
+
// The optimized swizzler functions do not support sampling. Sampled swizzles
// are already fast because they skip pixels. We haven't seen a situation
// where speeding up sampling has a significant impact on total decode time.