Skip to content

Commit b68c0d8

Browse files
committed
ANDROID: fix resize crash
1 parent 15bf862 commit b68c0d8

File tree

11 files changed

+39
-50
lines changed

11 files changed

+39
-50
lines changed

Makefile.am

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,6 @@ EXTRA_DIST = \
6262
deb:
6363
fakeroot dpkg-buildpackage
6464

65-
install-exec-hook: \
66-
(mkdir -p $(pkgdatadir) && \
67-
mkdir -p $(pkgdatadir)/plugins && \
68-
mkdir -p $(pkgdatadir)/ide && \
69-
mkdir -p $(pkgdatadir)/samples && \
70-
cp documentation/sbasic_ref.csv $(pkgdatadir) && \
71-
cp plugins/*.* $(pkgdatadir)/plugins && \
72-
cp ide/*.* $(pkgdatadir)/ide)
73-
7465
test:
7566
(cd $(SUBDIRS) && make test)
7667

debian/changelog

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
smallbasic (0.11.10) unstable; urgency=low
2+
* Built using common code from the android project and SDL
3+
4+
-- Chris Warren-Smith <cwarrensmith@gmail.com> Sat, 19 July 2014 09:45:25 +1000
5+
16
smallbasic (0.10.8) unstable; urgency=low
27
* Fix misc issues with const char* uncovered with new gcc
38

49
-- Chris Warren-Smith <cwarrensmith@gmail.com> Sat, 31 July 2010 09:45:25 +1000
5-
10+
611
smallbasic (0.10.7) unstable; urgency=low
712
* Added defineKey and fixed delay problems with the inkey command
813

debian/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ Description: One more basic
1313
SmallBASIC is a fast and easy to learn BASIC language interpreter
1414
ideal for everyday calculations, scripts and prototypes.
1515
SmallBASIC includes trigonometric, matrices and algebra functions,
16-
a built in IDE, a powerful string library, system, sound, and graphic
16+
a powerful string library, system, sound, and graphic
1717
commands along with structured programming syntax.
1818
SmallBASIC is licensed under the GPL.

debian/rules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ endif
2828
ifneq "$(wildcard /usr/share/misc/config.guess)" ""
2929
cp -f /usr/share/misc/config.guess config.guess
3030
endif
31-
./configure $(CROSS) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs" --enable-fltk
31+
./configure $(CROSS) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs" --enable-sdl
3232

3333
build: build-stamp
3434

@@ -72,7 +72,7 @@ binary-arch: build install
7272
dh_installchangelogs ChangeLog
7373
dh_installdocs
7474
dh_installexamples
75-
dh_install --exclude=".svn" documentation/sbasic_ref.csv plugins samples/distro-examples usr/share/smallbasic
75+
dh_install --exclude=".git" documentation/sbasic_ref.csv plugins samples/distro-examples usr/share/smallbasic
7676
dh_installman
7777
dh_link
7878
dh_strip

ide/android/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<!-- This is the platform API where NativeActivity was introduced. -->
88
<uses-sdk android:minSdkVersion="9" />
99

10-
<!-- This .apk has no Java code itself, so set hasCode to false. -->
10+
<!-- This .apk has Java code, so set hasCode to true. -->
1111
<application android:label="@string/app_name"
1212
android:hasCode="true"
1313
android:hardwareAccelerated="true"

src/platform/android/common/Makefile.am

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ ant-build: ndk-build
8181

8282
test: ant-build
8383
(cd ../../../../ide/android && \
84-
adb -d logcat -c && \
85-
adb shell am start net.sourceforge.smallbasic/net.sourceforge.smallbasic.MainActivity && \
86-
adb -d logcat)
84+
adb -a logcat -c && \
85+
adb -a shell am start net.sourceforge.smallbasic/net.sourceforge.smallbasic.MainActivity && \
86+
adb -a logcat)
8787

8888

src/platform/android/jni/display.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
#define FONT_FACE_REGULAR "Envy Code R.ttf"
1717
#define FONT_FACE_BOLD "Envy Code R Bold.ttf"
18-
#define SIZE_LIMIT 10
1918

2019
extern common::Graphics *graphics;
2120

@@ -156,15 +155,3 @@ void maUpdateScreen(void) {
156155
((Graphics *)graphics)->redraw();
157156
}
158157

159-
int maCreateDrawableImage(MAHandle maHandle, int width, int height) {
160-
int result = RES_OK;
161-
if (height > graphics->getHeight() * SIZE_LIMIT) {
162-
result -= 1;
163-
} else {
164-
Canvas *drawable = (Canvas *)maHandle;
165-
result = drawable->create(width, height) ? RES_OK : -1;
166-
}
167-
return result;
168-
}
169-
170-

src/platform/common/canvas.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
typedef uint16_t pixel_t;
1313

1414
#if defined(_SDL)
15-
1615
#include <SDL.h>
16+
#define MAX_CANVAS_SIZE 10
17+
1718
struct Canvas {
1819
Canvas();
1920
virtual ~Canvas();
@@ -33,8 +34,9 @@ struct Canvas {
3334
};
3435

3536
#else
36-
3737
#include <android/rect.h>
38+
#define MAX_CANVAS_SIZE 10
39+
3840
struct Canvas {
3941
Canvas();
4042
virtual ~Canvas();

src/platform/common/graphics.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,3 +381,14 @@ MAHandle maSetDrawTarget(MAHandle maHandle) {
381381
return graphics->setDrawTarget(maHandle);
382382
}
383383

384+
int maCreateDrawableImage(MAHandle maHandle, int width, int height) {
385+
int result = RES_OK;
386+
int maxSize = max(graphics->getWidth(), graphics->getHeight());
387+
if (height > maxSize * MAX_CANVAS_SIZE) {
388+
result -= 1;
389+
} else {
390+
Canvas *drawable = (Canvas *)maHandle;
391+
result = drawable->create(width, height) ? RES_OK : -1;
392+
}
393+
return result;
394+
}

src/platform/common/screen.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -498,12 +498,17 @@ void GraphicScreen::resize(int newWidth, int newHeight, int oldWidth, int oldHei
498498
dstPoint.x = 0;
499499
dstPoint.y = 0;
500500

501-
maCreateDrawableImage(newImage, newImageWidth, newImageHeight);
502-
maSetDrawTarget(newImage);
503-
maSetColor(_bg);
504-
maFillRect(0, 0, newImageWidth, newImageHeight);
505-
maDrawImageRegion(_image, &srcRect, &dstPoint, TRANS_NONE);
506-
maDestroyPlaceholder(_image);
501+
if (maCreateDrawableImage(newImage, newImageWidth, newImageHeight) == RES_OK) {
502+
maSetDrawTarget(newImage);
503+
maSetColor(_bg);
504+
maFillRect(0, 0, newImageWidth, newImageHeight);
505+
maDrawImageRegion(_image, &srcRect, &dstPoint, TRANS_NONE);
506+
maDestroyPlaceholder(_image);
507+
} else {
508+
// cannot resize - alert and abort
509+
deviceLog("Failed to resize to %d %d", newImageWidth, newImageHeight);
510+
abort();
511+
}
507512

508513
_image = newImage;
509514
_imageWidth = newImageWidth;

0 commit comments

Comments
 (0)