Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Topic/ems #1611

Open
wants to merge 54 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
2656ce6
Changes needed to build with a newly-generated Android Studio project
TimSylvester Nov 29, 2022
4e046a2
Minimize includes of dependencies
TimSylvester Dec 1, 2022
90ebaf9
optional native build
TimSylvester Dec 1, 2022
a222abb
New JNI methods and helpers
TimSylvester Dec 6, 2022
2d7d0f5
More JNI support
TimSylvester Dec 7, 2022
7ef35e9
Add image formats.
TimSylvester Dec 8, 2022
0b97b67
More JNI and image format support
TimSylvester Dec 10, 2022
4256a39
more JNI
TimSylvester Dec 12, 2022
e487272
Adjust build settings to match lodepng options
TimSylvester Dec 13, 2022
1068475
More texture format support
TimSylvester Dec 13, 2022
9219786
Refactor to allow set/animatePositionGeo on BaseController
TimSylvester Dec 15, 2022
76a969d
null check, error logging, JNI cleanup
TimSylvester Dec 15, 2022
8194aaa
Expose texture filtering option on loaders.
TimSylvester Dec 15, 2022
d023df9
More texture format and filter type support
TimSylvester Dec 15, 2022
9d11e05
More JNI support
TimSylvester Dec 16, 2022
3a9977f
Track `QIFFrameAsset` smart pointers rather than raw pointers in Java…
TimSylvester Dec 19, 2022
009d766
Support more sampler types as uniforms.
TimSylvester Dec 21, 2022
a957445
Only check for and discard redundant values for the first element of …
TimSylvester Dec 21, 2022
a894a9b
Fix `TexTypeDoubleChannel` using the wrong pixel format.
TimSylvester Dec 21, 2022
efd9059
Don't render screen-space drawables multiple times when wrapping
TimSylvester Dec 22, 2022
f9bc75e
Fix flat map panning behavior at N/S bounds.
TimSylvester Dec 22, 2022
a1384b8
Check values to avoid a NRE when reloading specific frames
TimSylvester Dec 22, 2022
5647675
More image formats
TimSylvester Jan 11, 2023
9c446c1
Fix build issues, warnings
TimSylvester Dec 23, 2022
97855dc
Better endian check, Emscripten build was failing.
TimSylvester Dec 23, 2022
5aa0232
Move `RGBAColor` out of `WhirlyVector.h`
TimSylvester Jan 13, 2023
c8be90a
We only use dense Eigen matrices
TimSylvester Jan 17, 2023
71d4620
More color APIs to better match Swift/Kotlin code.
TimSylvester Jan 17, 2023
b464899
Potential memory leak in PNG decoder error conditions
TimSylvester Jan 23, 2023
97a9dcb
Extend API
TimSylvester Jan 23, 2023
d1aa0dd
minor API tweaks
TimSylvester Jan 26, 2023
a667d69
API tweaks
TimSylvester Jan 31, 2023
ac0459a
simplify
TimSylvester Feb 2, 2023
e580a0f
Get shader references
TimSylvester Feb 2, 2023
6a73bc4
Move more stuff down to `TextureBase`
TimSylvester Feb 6, 2023
36d92c1
Reset some errant GL state.
TimSylvester Feb 7, 2023
6b322ef
API tweaks, fix rebase merge.
TimSylvester Feb 9, 2023
ded1dee
Better LodePNG cleanup and error reporting.
TimSylvester Feb 9, 2023
0aee6c5
Make `QuadImageFrameLoader` always use two textures to avoid a shader…
TimSylvester Feb 10, 2023
a50a2ee
`MbrD` coordinate conversion
TimSylvester Feb 10, 2023
cb2d42e
Don't require dynamically-allocated strings
TimSylvester Feb 13, 2023
b140d18
Refactor to elide copies and improve error reporting
TimSylvester Feb 14, 2023
799a564
Allow setting any float clear value for GL, rather than forcing to [0…
TimSylvester Feb 14, 2023
1cc22d9
Fix clear value on GLES.
TimSylvester Feb 15, 2023
bcad218
Allow setting `uint` uniforms.
TimSylvester Feb 16, 2023
499d1f3
fix build issues
TimSylvester Feb 23, 2023
9f0de31
Fix coord bound units
TimSylvester Mar 2, 2023
248a513
Fix Android build.
TimSylvester Mar 2, 2023
8836360
Fix merge problems from rebase
TimSylvester Mar 2, 2023
f5f6573
Support 4-bit images
TimSylvester Mar 23, 2023
ae8a45d
Merge branch 'develop' into topic/ems
TimSylvester Aug 22, 2023
8d5dc1e
Add overlay view
TimSylvester Aug 23, 2023
920be4e
Map movement wasn't resulting in updates for overlay case.
mousebird Aug 28, 2023
4b677e2
Some tweaks to read data values from the variable target.
mousebird Jan 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions android/apps/AutoTesterAndroid/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ android {
storePassword System.getenv('BITRISEIO_ANDROID_KEYSTORE_PASSWORD')
}
}
compileSdkVersion 30
compileSdkVersion 32
defaultConfig {
applicationId "com.mousebirdconsulting.autotester"
minSdkVersion 26
targetSdkVersion 30
targetSdkVersion 32
versionCode 1
versionName "1.0"

Expand Down Expand Up @@ -57,18 +57,19 @@ android {
signingConfig signingConfigs.debug
}
}
lintOptions {
lint {
abortOnError false
}
namespace 'com.mousebirdconsulting.autotester'
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(path: ':maply')
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.11'
}
repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.mousebirdconsulting.autotester">
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Expand All @@ -18,6 +17,7 @@
<activity
android:name="com.mousebirdconsulting.autotester.MainActivity"
android:label="@string/app_name"
android:exported="true"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
1 change: 1 addition & 0 deletions android/apps/AutoTesterAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ buildscript {
allprojects {
repositories {
google()
mavenCentral()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,61 +30,70 @@ class QuadImageFrameLoader_Android;
class QIFBatchOps_Android : public QIFBatchOps
{
public:
QIFBatchOps_Android(PlatformInfo_Android *threadInfo);
QIFBatchOps_Android(PlatformInfo_Android *, jobject jobj);
virtual ~QIFBatchOps_Android();

public:
// Pointer to the Java side of things
jobject batchOpsObj;
// Returns a strong local reference
jobject getBatchOpsObj(PlatformInfo_Android *) const;
void setBatchOpsObj(PlatformInfo_Android *, jobject obj);

protected:
// Weak pointer to the Java side of things
jobject batchOpsObj = nullptr;
};

// Android version of the frame asset
class QIFFrameAsset_Android : public QIFFrameAsset
{
public:
QIFFrameAsset_Android(PlatformInfo_Android *threadInfo,QuadFrameInfoRef frameInfo);
QIFFrameAsset_Android(PlatformInfo_Android *,QuadFrameInfoRef frameInfo, jobject jobj = nullptr);
virtual ~QIFFrameAsset_Android();

// Clear out the texture and d
virtual void clear(PlatformThreadInfo *threadInfo,QuadImageFrameLoader *loader,QIFBatchOps *batchOps,ChangeSet &changes) override;
virtual void clear(PlatformThreadInfo *,QuadImageFrameLoader *loader,QIFBatchOps *batchOps,ChangeSet &changes) override;

// Update priority for an existing fetch request
virtual bool updateFetching(PlatformThreadInfo *threadInfo,QuadImageFrameLoader *loader,int newPriority,double newImportance) override;
virtual bool updateFetching(PlatformThreadInfo *,QuadImageFrameLoader *loader,int newPriority,double newImportance) override;

// Cancel an outstanding fetch
virtual void cancelFetch(PlatformThreadInfo *threadInfo,QuadImageFrameLoader *loader,QIFBatchOps *batchOps) override;
virtual void cancelFetch(PlatformThreadInfo *,QuadImageFrameLoader *loader,QIFBatchOps *batchOps) override;

// Keep track of the texture ID
virtual void loadSuccess(PlatformThreadInfo *threadInfo,QuadImageFrameLoader *loader,const std::vector<Texture *> &texs) override;
virtual void loadSuccess(PlatformThreadInfo *,QuadImageFrameLoader *loader,const std::vector<Texture *> &texs) override;

// Clear out state
virtual void loadFailed(PlatformThreadInfo *threadInfo,QuadImageFrameLoader *loader) override;
virtual void loadFailed(PlatformThreadInfo *,QuadImageFrameLoader *loader) override;

public:
// Cancel the fetch (with the tile fetcher) on the Java side
void cancelFetchJava(PlatformInfo_Android *threadInfo,QuadImageFrameLoader_Android *loader,QIFBatchOps_Android *batchOps);
void cancelFetchJava(PlatformInfo_Android *,QuadImageFrameLoader_Android *loader,QIFBatchOps_Android *batchOps);
// Dispose of the Java side frame asset object and cancel any fetches
void clearFrameAssetJava(PlatformInfo_Android *threadInfo,QuadImageFrameLoader_Android *loader,QIFBatchOps_Android *batchOps);
void clearFrameAssetJava(PlatformInfo_Android *,QuadImageFrameLoader_Android *loader,QIFBatchOps_Android *batchOps);
// Clear the reference to a fetch request
void clearRequestJava(PlatformInfo_Android *threadInfo,QuadImageFrameLoader_Android *loader);
void clearRequestJava(PlatformInfo_Android *,QuadImageFrameLoader_Android *loader);

jobject frameAssetObj;
jobject getFrameAssetObj() const { return frameAssetObj; }
void setFrameAssetObj(jobject obj);

protected:
jobject frameAssetObj = nullptr;
};
using QIFFrameAsset_AndroidRef = std::shared_ptr<QIFFrameAsset_Android>;

// Android version of the tile asset keeps the platform specific stuff around
class QIFTileAsset_Android : public QIFTileAsset
{
public:
QIFTileAsset_Android(PlatformInfo_Android *threadInfo,const QuadTreeNew::ImportantNode &ident);
virtual ~QIFTileAsset_Android();
QIFTileAsset_Android(PlatformInfo_Android *,const QuadTreeNew::ImportantNode &ident);
virtual ~QIFTileAsset_Android() = default;

// Fetch the tile frames. Just fetch them all for now.
virtual void startFetching(PlatformThreadInfo *threadInfo,QuadImageFrameLoader *loader,
virtual void startFetching(PlatformThreadInfo *,QuadImageFrameLoader *loader,
const QuadFrameInfoRef &frameToLoad,QIFBatchOps *batchOps,ChangeSet &changes) override;

protected:
// Specialized frame asset
virtual QIFFrameAssetRef makeFrameAsset(PlatformThreadInfo *threadInfo,const QuadFrameInfoRef &frameInfo,QuadImageFrameLoader *) override;
virtual QIFFrameAssetRef makeFrameAsset(PlatformThreadInfo *,const QuadFrameInfoRef &frameInfo,QuadImageFrameLoader *) override;
};

// Android version of the QuadFrameLoader
Expand All @@ -100,7 +109,9 @@ class QuadImageFrameLoader_Android : public QuadImageFrameLoader
virtual int getNumFrames() const override { return numFrames; }

jobject getFrameLoaderObj() const { return frameLoaderObj; }
void setFrameLoaderObj(jobject obj) { frameLoaderObj = obj; }
void setFrameLoaderObj(jobject obj) { oldFrameLoaderObj = frameLoaderObj; frameLoaderObj = obj; }

jobject oldFrameLoaderObj = nullptr;

virtual void teardown(PlatformThreadInfo*) override;

Expand Down
9 changes: 4 additions & 5 deletions android/library/maply/WhirlyGlobeLib/include/Shader_Android.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
* Shader_Android.h
/* Shader_Android.h
* WhirlyGlobeLib
*
* Created by Steve Gifford on 3/8/19.
Expand All @@ -15,7 +14,6 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#import "Maply_jni.h"
Expand All @@ -29,8 +27,8 @@ namespace WhirlyKit
*/
class Shader_Android : ProgramGLES {
public:
Shader_Android();
virtual ~Shader_Android();
Shader_Android() = default;
virtual ~Shader_Android() = default;

// Do the actual program setup
void setupProgram(const std::string &name,const std::string &vertProg,const std::string &fragProg);
Expand All @@ -40,6 +38,7 @@ class Shader_Android : ProgramGLES {

// Program after set up
ProgramGLESRef prog;

// Varyings if they exist. Need to be passed in during creation.
std::vector<std::string> varyings;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,84 @@
namespace WhirlyKit
{

QIFBatchOps_Android::QIFBatchOps_Android(PlatformInfo_Android *threadInfo)
QIFBatchOps_Android::QIFBatchOps_Android(PlatformInfo_Android *threadInfo, jobject jobj) :
batchOpsObj(jobj)
{
MakeQIFBatchOps(threadInfo->env,this);
}

QIFBatchOps_Android::~QIFBatchOps_Android()
{
if (batchOpsObj)
{
wkLogLevel(Warn,"Failed to clean up QIFBatchOps %llx / %x on Java side", this, batchOpsObj);
}
}

jobject QIFBatchOps_Android::getBatchOpsObj(PlatformInfo_Android *threadInfo) const
{
return batchOpsObj ? threadInfo->env->NewLocalRef(batchOpsObj) : nullptr;
}

void QIFBatchOps_Android::setBatchOpsObj(PlatformInfo_Android *pi, jobject obj)
{
if (batchOpsObj)
{
pi->env->DeleteWeakGlobalRef(batchOpsObj);
batchOpsObj = nullptr;
}
if (obj)
{
batchOpsObj = pi->env->NewWeakGlobalRef(obj);
}
}

QIFFrameAsset_Android::QIFFrameAsset_Android(PlatformInfo_Android *,QuadFrameInfoRef frameInfo)
: QIFFrameAsset(frameInfo)
QIFFrameAsset_Android::QIFFrameAsset_Android(PlatformInfo_Android *, QuadFrameInfoRef frameInfo, jobject jobj) :
QIFFrameAsset(std::move(frameInfo)),
frameAssetObj(jobj)
{
}

QIFFrameAsset_Android::~QIFFrameAsset_Android()
{
if (frameAssetObj) {
if (frameAssetObj)
{
wkLogLevel(Warn,"Failed to clean up QIFFrameAsset on Java side");
}
}

void QIFFrameAsset_Android::setFrameAssetObj(jobject obj)
{
if (frameAssetObj && obj)
{
wkLogLevel(Warn,"QIFFrameAsset %llx replacing live object");
}
frameAssetObj = obj;
}

void QIFFrameAsset_Android::cancelFetchJava(PlatformInfo_Android *threadInfo,QuadImageFrameLoader_Android *loader,QIFBatchOps_Android *batchOps)
{
threadInfo->env->CallVoidMethod(frameAssetObj,loader->cancelFrameFetchMethod,batchOps->batchOpsObj);
if (jobject localBatchObj = batchOps->getBatchOpsObj(threadInfo))
{
threadInfo->env->CallVoidMethod(frameAssetObj, loader->cancelFrameFetchMethod, localBatchObj);
threadInfo->env->DeleteLocalRef(localBatchObj);
}
}

void QIFFrameAsset_Android::clearFrameAssetJava(PlatformInfo_Android *threadInfo,QuadImageFrameLoader_Android *loader,QIFBatchOps_Android *batchOps)
{
if (const auto obj = loader->getFrameLoaderObj())
{
threadInfo->env->CallVoidMethod(frameAssetObj,loader->clearFrameMethod,obj,batchOps->batchOpsObj);
if (jobject localBatchObj = batchOps->getBatchOpsObj(threadInfo))
{
threadInfo->env->CallVoidMethod(frameAssetObj, loader->clearFrameMethod, obj, localBatchObj);
threadInfo->env->DeleteLocalRef(localBatchObj);
return;
}
}

// `clearFrame` doesn't clean up the frame asset object, so we need to do it.
DisposeQIFFrameAsset(threadInfo->env, this);
}

void QIFFrameAsset_Android::clearRequestJava(PlatformInfo_Android *threadInfo,QuadImageFrameLoader_Android *loader)
Expand Down Expand Up @@ -120,17 +166,13 @@ QIFTileAsset_Android::QIFTileAsset_Android(PlatformInfo_Android *,const QuadTree
{
}

QIFTileAsset_Android::~QIFTileAsset_Android()
{
}

QIFFrameAssetRef QIFTileAsset_Android::makeFrameAsset(PlatformThreadInfo *inThreadInfo,const QuadFrameInfoRef &frameInfo,QuadImageFrameLoader *)
{
//const auto loader = (QuadImageFrameLoader_Android *)inLoader;
const auto threadInfo = (PlatformInfo_Android *)inThreadInfo;

auto frame = std::make_shared<QIFFrameAsset_Android>(threadInfo,frameInfo);
MakeQIFFrameAsset(threadInfo->env,frame.get());
auto frame = std::make_shared<QIFFrameAsset_Android>(threadInfo, frameInfo, nullptr);
MakeQIFFrameAsset(threadInfo->env, frame);

return frame;
}
Expand All @@ -147,23 +189,30 @@ void QIFTileAsset_Android::startFetching(PlatformThreadInfo *inThreadInfo,QuadIm
std::vector<jobject> objVec(frames.size(),nullptr);
for (unsigned int ii=0;ii<frames.size();ii++)
{
if (!frameToLoad || frameToLoad->frameIndex == -1 || frameToLoad->frameIndex == ii) {
if (!frameToLoad || frameToLoad->frameIndex == -1 || frameToLoad->frameIndex == ii)
{
QIFFrameAsset_Android *frame = (QIFFrameAsset_Android *) (frames[ii].get());
frame->setupFetch(loader);
const int priority = loader->calcLoadPriority(ident,ii);
frame->updateFetching(threadInfo,loader,priority,ident.importance);
objVec[ii] = frame->frameAssetObj;
objVec[ii] = frame->getFrameAssetObj();
}
}

auto *frameAssetClassInfo = QIFFrameAssetClassInfo::getClassInfo(threadInfo->env,"com/mousebird/maply/QIFFrameAsset");
jclass frameAssetClass = frameAssetClassInfo->getClass();
// Give the Java side a list of frames to start fetching
jobjectArray frameArray = BuildObjectArray(threadInfo->env,QIFFrameAssetClassInfo::getClassInfo(threadInfo->env,"com/mousebird/maply/QIFFrameAsset")->getClass(),objVec);
jobjectArray frameArray = BuildObjectArray(threadInfo->env,frameAssetClass,objVec);

if (const auto obj = loader->getFrameLoaderObj())
{
threadInfo->env->CallVoidMethod(obj,loader->startTileFetchMethod,
batchOps->batchOpsObj,frameArray,
ident.x,ident.y,ident.level,0,ident.importance);
if (jobject localBatchObj = batchOps->getBatchOpsObj(threadInfo))
{
threadInfo->env->CallVoidMethod(obj, loader->startTileFetchMethod,
localBatchObj, frameArray,
ident.x, ident.y, ident.level, 0, ident.importance);
threadInfo->env->DeleteLocalRef(localBatchObj);
}
}

threadInfo->env->DeleteLocalRef(frameArray);
Expand Down Expand Up @@ -259,19 +308,22 @@ QIFTileAssetRef QuadImageFrameLoader_Android::makeTileAsset(PlatformThreadInfo *
QIFBatchOps *QuadImageFrameLoader_Android::makeBatchOps(PlatformThreadInfo *inThreadInfo)
{
PlatformInfo_Android *threadInfo = (PlatformInfo_Android *)inThreadInfo;
QIFBatchOps_Android *batchOps = new QIFBatchOps_Android(threadInfo);

QIFBatchOps_Android *batchOps = new QIFBatchOps_Android(threadInfo, nullptr);
return batchOps;
}

void QuadImageFrameLoader_Android::processBatchOps(PlatformThreadInfo *inThreadInfo,QIFBatchOps *inBatchOps)
{
PlatformInfo_Android *threadInfo = (PlatformInfo_Android *)inThreadInfo;
QIFBatchOps_Android *batchOps = (QIFBatchOps_Android *)inBatchOps;

if (frameLoaderObj)
if (QIFBatchOps_Android *batchOps = (QIFBatchOps_Android *)inBatchOps)
{
threadInfo->env->CallVoidMethod(frameLoaderObj,processBatchOpsMethod,batchOps->batchOpsObj);
if (frameLoaderObj)
if (jobject localBatchObj = batchOps->getBatchOpsObj(threadInfo))
{
threadInfo->env->CallVoidMethod(frameLoaderObj, processBatchOpsMethod, localBatchObj);
threadInfo->env->DeleteLocalRef(localBatchObj);
}
batchOps->setBatchOpsObj(threadInfo, nullptr);
}
}

Expand Down
Loading