diff options
author | Urvang Joshi <urvang@google.com> | 2014-04-03 16:07:05 -0700 |
---|---|---|
committer | Urvang Joshi <urvang@google.com> | 2014-04-07 11:33:14 -0700 |
commit | 9b38510c08561d2c71cc2aa2ea5432e46d27e82f (patch) | |
tree | 4e2803e115ec4a14d47634cffd6b89cb6747a343 /framesequence | |
parent | 0b0cefbe9f1e37e3d2300909792d1263545a7521 (diff) | |
download | android_frameworks_ex-9b38510c08561d2c71cc2aa2ea5432e46d27e82f.tar.gz android_frameworks_ex-9b38510c08561d2c71cc2aa2ea5432e46d27e82f.tar.bz2 android_frameworks_ex-9b38510c08561d2c71cc2aa2ea5432e46d27e82f.zip |
Animated WebP decoder: rectify post-processing when disposing to background.
See the corresponding (correct) logic on Chrome side:
https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp&l=446
Change-Id: Ife17e24b3263ff6148ffc38849c5e3527d341945
Diffstat (limited to 'framesequence')
-rw-r--r-- | framesequence/jni/FrameSequence_webp.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/framesequence/jni/FrameSequence_webp.cpp b/framesequence/jni/FrameSequence_webp.cpp index bced919..602feb7 100644 --- a/framesequence/jni/FrameSequence_webp.cpp +++ b/framesequence/jni/FrameSequence_webp.cpp @@ -37,6 +37,15 @@ static bool isFullFrame(const WebPIterator& frame, int canvasWidth, int canvasHe return (frame.width == canvasWidth && frame.height == canvasHeight); } +// Returns true if the rectangle defined by 'frame' contains pixel (x, y). +static bool FrameContainsPixel(const WebPIterator& frame, int x, int y) { + const int left = frame.x_offset; + const int right = left + frame.width; + const int top = frame.y_offset; + const int bottom = top + frame.height; + return x >= left && x < right && y >= top && y < bottom; +} + // Construct mIsKeyFrame array. void FrameSequence_webp::constructDependencyChain() { const size_t frameCount = getFrameCount(); @@ -247,8 +256,8 @@ bool FrameSequenceState_webp::decodeFrame(const WebPIterator& currIter, Color888 const int canvasX = currIter.x_offset + x; Color8888& currPixel = currBuffer[canvasY * currStride + canvasX]; // FIXME: Use alpha-blending when alpha is between 0 and 255. - if (!(currPixel & COLOR_8888_ALPHA_MASK) && - isFullFrame(prevIter, canvasWidth, canvasHeight)) { + if (!(currPixel & COLOR_8888_ALPHA_MASK) + && !FrameContainsPixel(prevIter, canvasX, canvasY)) { const Color8888 prevPixel = prevBuffer[canvasY * prevStride + canvasX]; currPixel = prevPixel; } |