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

Fix AA surface #803

Open
wants to merge 1 commit into
base: r4.9
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 7 additions & 5 deletions wrappers/android/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,20 @@ buildArch()
fi
}

buildArch "armeabi-v7a"
buildArch "arm64-v8a"
retcode=$?
if [[ $retcode -ne 0 ]]; then
echo "buildArch(armeabi-v7a) failed with $retcode, exiting..."
echo "buildArch(arm64-v8a) failed with $retcode, exiting..."
exit $retcode
fi

buildArch "arm64-v8a"
#exit 0; # for testing purposes

buildArch "armeabi-v7a"
retcode=$?
if [[ $retcode -ne 0 ]]; then
echo "buildArch(arm64-v8a) failed with $retcode, exiting..."
exit $retcode
echo "buildArch(armeabi-v7a) failed with $retcode, exiting..."
exit $retcode
fi

buildArch "x86"
Expand Down
33 changes: 15 additions & 18 deletions wrappers/android/src/net/osmand/core/android/MapRendererView.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.Log;
Expand Down Expand Up @@ -77,7 +79,7 @@ public abstract class MapRendererView extends FrameLayout {
/**
* Optional bitmap for offscreen rendering
*/
private Bitmap _resultBitmap;
private Bitmap _offscreenBitmap;

/**
* Offscreen rendering result is ready
Expand Down Expand Up @@ -302,25 +304,20 @@ public IMapRendererSetupOptionsConfigurator getMapRendererSetupOptionsConfigurat
*/
protected abstract IMapRenderer createMapRendererInstance();

public Bitmap getBitmap() {
public Bitmap getBitmap(Bitmap toDraw) {
if (_byteBuffer != null) {
if (_renderingResultIsReady) {
Bitmap bitmap = Bitmap.createBitmap(_windowWidth, _windowHeight, Bitmap.Config.ARGB_8888);
if (_offscreenBitmap == null || _offscreenBitmap.getWidth() != _windowWidth || _offscreenBitmap.getHeight() != _windowHeight) {
_offscreenBitmap = Bitmap.createBitmap(_windowWidth, _windowHeight, Bitmap.Config.ARGB_8888);
}
synchronized (_byteBuffer) {
_byteBuffer.rewind();
bitmap.copyPixelsFromBuffer(_byteBuffer);
_offscreenBitmap.copyPixelsFromBuffer(_byteBuffer);
_renderingResultIsReady = false;
}
Matrix matrix = new Matrix();
matrix.preScale(1.0f, -1.0f);
_resultBitmap = Bitmap.createBitmap(bitmap, 0, 0, _windowWidth, _windowHeight, matrix, true);
}
if (_resultBitmap == null)
_resultBitmap = Bitmap.createBitmap(_windowWidth, _windowHeight, Bitmap.Config.ARGB_8888);
return _resultBitmap;
}
else
return null;
return _offscreenBitmap;
}

public IMapRenderer getRenderer() {
Expand All @@ -338,8 +335,8 @@ public void stopRenderer() {
releaseRendering();
removeAllViews();
_byteBuffer = null;
_resultBitmap = null;
_mapAnimator = null;
_offscreenBitmap = null;
_mapMarkersAnimator = null;
_glSurfaceView = null;
}
Expand All @@ -358,7 +355,7 @@ public void run() {
synchronized (this) {
waitRelease = false;
this.notifyAll();
}
}
}
};
_glSurfaceView.queueEvent(releaseTask);
Expand Down Expand Up @@ -1186,7 +1183,7 @@ public final float getSurfaceZoomAfterPinchWithParams(
firstLocation31, firstHeightInMeters, firstScreenPoint,
secondLocation31, secondHeightInMeters, secondScreenPoint
);
}
}

public final boolean getZoomAndRotationAfterPinch(
PointI firstLocation31, float firstHeightInMeters, PointI firstPoint,
Expand Down Expand Up @@ -1304,7 +1301,7 @@ public final double getTileSizeOnScreenInPixels() {

return _mapRenderer.getTileSizeOnScreenInPixels();
}

public final int getMaxMissingDataZoomShift() {
NativeCore.checkIfLoaded();

Expand Down Expand Up @@ -1628,7 +1625,7 @@ private int findConfigAttrib(EGL10 egl, EGLDisplay display,
* Implements creation of main and GPU-worker contexts along with needed resources
*/
private final class EGLContextFactory implements GLSurfaceView.EGLContextFactory {
private int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
private int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
/**
* EGL attributes used to initialize EGL context:
* - EGL context must support at least OpenGLES 3.0
Expand Down Expand Up @@ -1815,7 +1812,7 @@ public void onSurfaceChanged(GL10 gl, int width, int height) {
_setupOptions.setGpuWorkerThreadPrologue(null);
_setupOptions.setGpuWorkerThreadEpilogue(null);
}
_setupOptions.setFrameUpdateRequestCallback(_renderRequestCallback.getBinding());
_setupOptions.setFrameUpdateRequestCallback(_renderRequestCallback.getBinding());
_mapRenderer.setup(_setupOptions);
if (!_mapRenderer.initializeRendering(true))
Log.e(TAG, "Failed to initialize rendering");
Expand Down