Android: minor simplifications

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12703 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher 2018-03-02 20:57:02 +00:00
parent 4b00b0f320
commit 5365d9f716
4 changed files with 11 additions and 102 deletions

View File

@ -12,7 +12,7 @@ Getting Started
1. [Download Android Studio](http://developer.android.com/sdk/index.html)
1. Launch Android Studio.
1. Open the Android directory inside the FLTK directory.
1. Load the Android Studio project in the HelloAndroid directory.
1. Open the AndroidStudio project by loading the HelloAndroid directory.
1. Click *Run/Run 'app'*.
Support

View File

@ -56,14 +56,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/assets" type="java-test-resource" />
@ -72,6 +64,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />

View File

@ -198,90 +198,6 @@ static void init_tables(void)
init_angles();
}
static void fill_plasma(ANativeWindow_Buffer* buffer, double t)
{
Fixed yt1 = FIXED_FROM_FLOAT(t/1230.);
Fixed yt2 = yt1;
Fixed xt10 = FIXED_FROM_FLOAT(t/3000.);
Fixed xt20 = xt10;
#define YT1_INCR FIXED_FROM_FLOAT(1/100.)
#define YT2_INCR FIXED_FROM_FLOAT(1/163.)
void* pixels = buffer->bits;
//LOGI("width=%d height=%d stride=%d format=%d", buffer->width, buffer->height,
// buffer->stride, buffer->format);
int yy;
for (yy = 0; yy < buffer->height; yy++) {
uint16_t* line = (uint16_t*)pixels;
Fixed base = fixed_sin(yt1) + fixed_sin(yt2);
Fixed xt1 = xt10;
Fixed xt2 = xt20;
yt1 += YT1_INCR;
yt2 += YT2_INCR;
#define XT1_INCR FIXED_FROM_FLOAT(1/173.)
#define XT2_INCR FIXED_FROM_FLOAT(1/242.)
#if OPTIMIZE_WRITES
/* optimize memory writes by generating one aligned 32-bit store
* for every pair of pixels.
*/
uint16_t* line_end = line + buffer->width;
if (line < line_end) {
if (((uint32_t)(uintptr_t)line & 3) != 0) {
Fixed ii = base + fixed_sin(xt1) + fixed_sin(xt2);
xt1 += XT1_INCR;
xt2 += XT2_INCR;
line[0] = palette_from_fixed(ii >> 2);
line++;
}
while (line + 2 <= line_end) {
Fixed i1 = base + fixed_sin(xt1) + fixed_sin(xt2);
xt1 += XT1_INCR;
xt2 += XT2_INCR;
Fixed i2 = base + fixed_sin(xt1) + fixed_sin(xt2);
xt1 += XT1_INCR;
xt2 += XT2_INCR;
uint32_t pixel = ((uint32_t)palette_from_fixed(i1 >> 2) << 16) |
(uint32_t)palette_from_fixed(i2 >> 2);
((uint32_t*)line)[0] = pixel;
line += 2;
}
if (line < line_end) {
Fixed ii = base + fixed_sin(xt1) + fixed_sin(xt2);
line[0] = palette_from_fixed(ii >> 2);
line++;
}
}
#else /* !OPTIMIZE_WRITES */
int xx;
for (xx = 0; xx < buffer->width; xx++) {
Fixed ii = base + fixed_sin(xt1) + fixed_sin(xt2);
xt1 += XT1_INCR;
xt2 += XT2_INCR;
line[xx] = palette_from_fixed(ii / 4);
}
#endif /* !OPTIMIZE_WRITES */
// go to next line
pixels = (uint16_t*)pixels + buffer->stride;
}
}
/* simple stats management */
typedef struct {
double renderTime;
@ -410,15 +326,10 @@ static void engine_draw_frame(struct engine* engine) {
time_ms -= start_ms;
/* Now fill the values with a nice little plasma */
#if 0
fill_plasma(&buffer, time_ms);
#else
// LOGE("Fl::flush()");
gAGraphicsBuffer = &buffer;
Fl::damage(FL_DAMAGE_ALL);
win->redraw();
Fl::flush();
#endif
ANativeWindow_unlockAndPost(engine->app->window);

View File

@ -15,9 +15,6 @@ WARNING: FLTK FOR ANDROID IS WORK IN PROGRESS IN A PRETTY EARLY STAGE.
BUILDING FLTK SAMPLE WITH ANDROID STUDIO 3
============================================
March 2nd, 2018: This is a first commit to SVN to have a file structure in
place. None of this compiles or runs at this point.
There is no need to ever write a single line of Java.
Download and install AndroidStudio on your developer machine. If you use
@ -26,7 +23,8 @@ AndroidStudio for the first time, use the IDE to download and build the
FLTK will be installed. Once Native Plasm runs on your emulator or physical
device, you are ready to install FLTK.
TODO: there will be an Android Studio project in the Android/ directory soon.
Open the Android/HelloAndroid directory in AndroidStudio. The project should compile and run out of the box.
DOCUMENT HISTORY
==================