Skip to content

Commit

Permalink
android gradle plugin version bumped to 1.3.0, #194 fixed, #196 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
koral-- committed Aug 9, 2015
1 parent ff3fbf0 commit bd1dea9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
### 1.1.9
- proguard configuration is now bundled with the library - [#193](https://github.com/koral--/android-gif-drawable/pull/193)
- Android gradle plugin updated to 1.3.0
- fixed segfault when frame is not confined to canvas - [#196](https://github.com/koral--/android-gif-drawable/issues/196), [#194](https://github.com/koral--/android-gif-drawable/issues/194)

### 1.1.8
- toolchain changed to clang
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.android.tools.build:gradle:1.3.0'
}
}

Expand Down
27 changes: 20 additions & 7 deletions src/main/jni/decoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,23 @@ void DDGifSlurp(GifInfo *info, bool shouldDecode) {
if (DGifGetImageDesc(info->gifFilePtr, !shouldDecode) == GIF_ERROR)
return;

if (info->gifFilePtr->Image.Left + info->gifFilePtr->Image.Width > info->gifFilePtr->SWidth) {
info->gifFilePtr->Image.Width = info->gifFilePtr->SWidth - info->gifFilePtr->Image.Left;
}
const uint_fast16_t requiredScreenWidth = info->gifFilePtr->Image.Left + info->gifFilePtr->Image.Width;
const uint_fast16_t requiredScreenHeight = info->gifFilePtr->Image.Top + info->gifFilePtr->Image.Height;

if (info->gifFilePtr->Image.Top + info->gifFilePtr->Image.Height > info->gifFilePtr->SHeight) {
info->gifFilePtr->Image.Height = info->gifFilePtr->SHeight - info->gifFilePtr->Image.Top;
if (requiredScreenWidth > info->gifFilePtr->SWidth || requiredScreenHeight > info->gifFilePtr->SHeight) {
if (shouldDecode) {
void *tmpRasterBits = realloc(info->rasterBits,
requiredScreenWidth * requiredScreenHeight * sizeof(GifPixelType));
if (tmpRasterBits == NULL) {
info->gifFilePtr->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
return;
}
info->rasterBits = tmpRasterBits;
}
else {
info->gifFilePtr->SWidth = requiredScreenWidth;
info->gifFilePtr->SHeight = requiredScreenHeight;
}
}

if (shouldDecode) {
Expand All @@ -41,7 +52,8 @@ void DDGifSlurp(GifInfo *info, bool shouldDecode) {
}
else {
if (DGifGetLine(
info->gifFilePtr, info->rasterBits, info->gifFilePtr->Image.Width * info->gifFilePtr->Image.Height) == GIF_ERROR)
info->gifFilePtr, info->rasterBits,
info->gifFilePtr->Image.Width * info->gifFilePtr->Image.Height) == GIF_ERROR)
return;
}
return;
Expand All @@ -61,7 +73,8 @@ void DDGifSlurp(GifInfo *info, bool shouldDecode) {
return;
if (!shouldDecode) {
GraphicsControlBlock *tmpInfos = realloc(info->controlBlock,
(info->gifFilePtr->ImageCount + 1) * sizeof(GraphicsControlBlock));
(info->gifFilePtr->ImageCount + 1) *
sizeof(GraphicsControlBlock));
if (tmpInfos == NULL) {
info->gifFilePtr->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
return;
Expand Down
2 changes: 1 addition & 1 deletion src/main/jni/gif.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ static JavaVM *g_jvm;

static struct JavaVMAttachArgs attachArgs = {.version=JNI_VERSION_1_6, .group=NULL, .name="GifIOThread"};

inline JNIEnv *getEnv() {
static inline JNIEnv *getEnv() {
JNIEnv *env;

if ((*g_jvm)->AttachCurrentThread(g_jvm, &env, &attachArgs) == JNI_OK)
Expand Down
2 changes: 0 additions & 2 deletions src/main/jni/gif.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ bool isSourceNull(void *ptr, JNIEnv *env);

static uint_fast8_t fileRead(GifFileType *gif, GifByteType *bytes, uint_fast8_t size);

inline JNIEnv *getEnv();

static uint_fast8_t directByteBufferReadFun(GifFileType *gif, GifByteType *bytes, uint_fast8_t size);

static uint_fast8_t byteArrayReadFun(GifFileType *gif, GifByteType *bytes, uint_fast8_t size);
Expand Down

0 comments on commit bd1dea9

Please sign in to comment.