Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0d668e0
switch base layer to jpeg format by default
nicastel Apr 22, 2014
63cbbdb
update Manifest to claim uses of ETC texture compression
nicastel Apr 22, 2014
5e4fb68
Update Manifest to claim requirement of Opengl ES 2.0
nicastel Apr 22, 2014
954ab50
Add code to check ETC/DXTC support at startup
nicastel Apr 22, 2014
1be26c7
modify defqult view altitude in order to avoid starting on a black
nicastel Apr 22, 2014
b9c2a0b
add an empty string.xml file to avoid compilation problems after
nicastel Apr 23, 2014
dfd9855
Revert changes for OPENGL ES 3.0 compatibility, no change needed
nicastel Apr 23, 2014
f54252c
hide the status bar
nicastel Apr 23, 2014
3e7e783
Full screen mode without navigation bar
nicastel Apr 23, 2014
78c3ffc
identify function that can be offloaded to another thread
nicastel Apr 23, 2014
ee0a4bf
add suuport for DDS file with ETC1 compression
nicastel May 14, 2014
6e551b2
refactoring
nicastel May 14, 2014
d6cad91
refactoring
nicastel May 14, 2014
2c2a906
correct support for non pkm surface image
nicastel May 14, 2014
eb8732e
correct bug
nicastel May 14, 2014
d2992d5
optimize bitmap decoding to use RGB 565 when available
nicastel May 14, 2014
2d76e01
Integrates handling of server side dds with ETC1 compressed layer
nicastel May 16, 2014
0803f02
deactivation of the client side renderscript texture compression
nicastel May 17, 2014
59176cc
fix memory leak and add example layer from my openshift geoserver
nicastel May 18, 2014
cee5d9d
activate real time rendersctipt texture compression on BMNG and landsat
nicastel May 18, 2014
8f487f3
fix handling of DDS DXT/ETC texture without mipmap (from mapserver DDS
nicastel May 22, 2014
1d1f46d
Improvement and bugs fixes
nicastel May 24, 2014
294526b
Deactivation of mipmap generation by default
nicastel May 25, 2014
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: 8 additions & 4 deletions WorldWindAndroid/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
package="gov.nasa.worldwind"
android:versionCode="1"
android:versionName="1.0" >

<!-- Specify that World Wind Android applications require SDK Platform Android 4.0.3, API 15. -->
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="18" />
<!-- Specify that World Wind Android applications require SDK Platform Android 4.0.3, API 15. -->
<uses-sdk android:minSdkVersion="15" />
android:targetSdkVersion="19" />

<!-- Specify all of the Android features that World Wind requires: OpenGL ES 2.0. -->
<uses-feature android:glEsVersion="0x00020000" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />

<supports-gl-texture android:name="GL_OES_compressed_ETC1_RGB8_texture" />

<!-- Specify all of the Android permissions that World Wind requires: internet. -->
<uses-permission android:name="android.permission.INTERNET" />
<application android:allowBackup="true" >
Expand Down
5 changes: 4 additions & 1 deletion WorldWindAndroid/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-15
target=android-19
android.library=true
renderscript.target=18
renderscript.support.mode=true
sdk.buildtools=19.0.3
8 changes: 8 additions & 0 deletions WorldWindAndroid/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2011 United States Government as represented by the Administrator of the
National Aeronautics and Space Administration.
All Rights Reserved.
-->
<resources>
</resources>
7 changes: 5 additions & 2 deletions WorldWindAndroid/src/config/Earth/BMNGWMSLayer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
<!-- day month year hours:minutes:seconds timezone -->
<LastUpdate>26 03 2009 00:00:00 GMT</LastUpdate>
<DataCacheName>Earth/BMNGWMS/BMNG(Shaded + Bathymetry) Tiled - Version 1.1 - 5.2004</DataCacheName>
<ImageFormat>image/png</ImageFormat>
<ImageFormat>image/jpeg</ImageFormat>
<AvailableImageFormats>
<ImageFormat>image/jpeg</ImageFormat>
<ImageFormat>image/png</ImageFormat>
<ImageFormat>image/dds</ImageFormat>
</AvailableImageFormats>
<FormatSuffix>.png</FormatSuffix>
<FormatSuffix>.dds</FormatSuffix>
<!-- to activate client side texture compression
<FormatSuffix>.dds</FormatSuffix>-->
<NumLevels count="6" numEmpty="0"/>
<TileOrigin>
<LatLon units="degrees" latitude="-90" longitude="-180"/>
Expand Down
7 changes: 5 additions & 2 deletions WorldWindAndroid/src/config/Earth/LandsatI3WMSLayer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@
<!-- day month year hours:minutes:seconds timezone -->
<LastUpdate>26 03 2009 00:00:00 GMT</LastUpdate>
<DataCacheName>Earth/NASA LandSat I3 WMS</DataCacheName>
<ImageFormat>image/png</ImageFormat>
<ImageFormat>image/jpeg</ImageFormat>
<AvailableImageFormats>
<ImageFormat>image/jpeg</ImageFormat>
<ImageFormat>image/png</ImageFormat>
<ImageFormat>image/dds</ImageFormat>
</AvailableImageFormats>
<FormatSuffix>.png</FormatSuffix>
<FormatSuffix>.jpg</FormatSuffix>
<!-- to activate client side texture compression
<FormatSuffix>.dds</FormatSuffix>-->
<NumLevels count="11" numEmpty="5"/>
<TileOrigin>
<LatLon units="degrees" latitude="-90" longitude="-180"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@
import gov.nasa.worldwind.geom.Position;
import gov.nasa.worldwind.pick.*;
import gov.nasa.worldwind.util.Logging;
import gov.nasa.worldwind.util.pkm.PKMGpuTextureData;

import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.opengles.GL10;

import java.beans.*;
import java.util.*;

Expand All @@ -29,6 +34,8 @@
*/
public class WorldWindowGLSurfaceView extends GLSurfaceView implements GLSurfaceView.Renderer, WorldWindow, WWObject
{
protected static String glVersion;

protected WWObjectImpl wwo = new WWObjectImpl(this);
protected SceneController sceneController;
protected InputHandler inputHandler;
Expand All @@ -42,7 +49,7 @@ public class WorldWindowGLSurfaceView extends GLSurfaceView implements GLSurface
public WorldWindowGLSurfaceView(Context context)
{
super(context);

try
{
this.init(null);
Expand Down Expand Up @@ -74,7 +81,7 @@ public WorldWindowGLSurfaceView(Context context, AttributeSet attrs)
public WorldWindowGLSurfaceView(Context context, EGLConfigChooser configChooser)
{
super(context);

try
{
this.init(configChooser);
Expand Down Expand Up @@ -162,9 +169,17 @@ public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
// recognize.
if (this.gpuResourceCache != null)
this.gpuResourceCache.clear();

initGlVersion();
PKMGpuTextureData.initTCSupport();
}

@Override
private void initGlVersion() {
glVersion = GLES20.glGetString(GLES20.GL_VERSION);
Logging.warning("GL version : "+glVersion);
}

@Override
public boolean onTouchEvent(MotionEvent event)
{
// Let the InputHandler process the touch event first. If it returns true indicating that it handled the event,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
import gov.nasa.worldwind.geom.Matrix;
import gov.nasa.worldwind.util.Logging;
import gov.nasa.worldwind.util.pkm.PKMGpuTextureData;
import nicastel.renderscripttexturecompressor.etc1.rs.RsETC1Util.ETC1Texture;
import android.graphics.Bitmap;
import android.opengl.ETC1;
import android.opengl.GLES20;
import android.opengl.GLUtils;
import android.opengl.ETC1Util.ETC1Texture;

/**
* Edited By: Nicola Dorigatti, Trilogis
Expand Down
43 changes: 36 additions & 7 deletions WorldWindAndroid/src/gov/nasa/worldwind/render/GpuTextureData.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,25 @@
*/
package gov.nasa.worldwind.render;

import android.graphics.*;
import android.opengl.*;
import gov.nasa.worldwind.cache.Cacheable;
import gov.nasa.worldwind.util.*;
import gov.nasa.worldwind.util.Logging;
import gov.nasa.worldwind.util.WWIO;
import gov.nasa.worldwind.util.WWUtil;
import gov.nasa.worldwind.util.dds.DDSTextureReader;

import java.io.*;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;

import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.opengl.GLES20;
import android.opengl.GLUtils;


/**
* @author dcollins
* @version $Id: GpuTextureData.java 764 2012-09-11 00:17:17Z tgaskins $
Expand Down Expand Up @@ -142,6 +152,9 @@ public static GpuTextureData createTextureData(Object source)
}

protected static final int DEFAULT_MARK_LIMIT = 1024;

// public static RenderScript rs;
// public static ScriptC_etc1compressor script;

protected static GpuTextureData fromStream(InputStream stream)
{
Expand All @@ -155,9 +168,25 @@ protected static GpuTextureData fromStream(InputStream stream)
if (data != null)
return data;

stream.reset();

Bitmap bitmap = BitmapFactory.decodeStream(stream);
stream.reset();

Options opts = new BitmapFactory.Options();
opts.inPreferQualityOverSpeed = false;
opts.inPreferredConfig = Config.RGB_565;
Bitmap bitmap = BitmapFactory.decodeStream(stream, null, opts);
//
// if(bitmap != null) {
// ETC1Texture texture = RsETC1Util.compressBitmap(rs, script, bitmap);
// if (texture != null) {
// int estimatedMemorySize = ETC1.ETC_PKM_HEADER_SIZE
// + texture.getHeight() * texture.getWidth() / 2;
// return PKMGpuTextureData.fromPKMETC1CompressedData(texture,
// estimatedMemorySize);
// } else {
// return null;
// }
// }

return bitmap != null ? new GpuTextureData(bitmap, estimateMemorySize(bitmap)) : null;
}
catch (IOException e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public void applyInternalTransform(DrawContext dc, Matrix matrix) {
}

protected GpuTexture getOrCreateTexture(DrawContext dc) {
if (this.textureData != null) {
if (this.textureData != null) {
GpuTexture texture = this.createTexture(dc, this.textureData);
if (texture != null) this.setTexture(dc.getGpuResourceCache(), texture);
else {
Expand All @@ -203,6 +203,7 @@ protected GpuTexture getOrCreateTexture(DrawContext dc) {
}

protected GpuTexture createTexture(DrawContext dc, GpuTextureData textureData) {
// TODO : offload texture creation to another thread
return GpuTexture.createTexture(dc, textureData);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ protected GpuTexture loadGpuTexture(DrawContext dc)
GpuTexture texture = null;

GpuTextureData textureData = PKMGpuTextureData.createTextureData(this.imagePath);
if (textureData == null)
{
GpuTextureData.createTextureData(this.imagePath);
}
if (textureData != null)
{
texture = GpuTexture.createTexture(dc, textureData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,24 @@

package gov.nasa.worldwind.retrieve;

import android.graphics.Bitmap;
import gov.nasa.worldwind.avlist.*;
import gov.nasa.worldwind.util.*;
import gov.nasa.worldwind.util.dds.DDSCompressor;

import java.io.*;
import gov.nasa.worldwind.avlist.AVKey;
import gov.nasa.worldwind.avlist.AVList;
import gov.nasa.worldwind.util.ImageUtil;
import gov.nasa.worldwind.util.Logging;
import gov.nasa.worldwind.util.WWIO;
import gov.nasa.worldwind.util.WWUtil;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedByInterruptException;

import nicastel.renderscripttexturecompressor.dds.ETC1DDSCompressor;
import android.graphics.Bitmap;

/**
* Abstract base class for retrieval post-processors. Verifies the retrieval operation and dispatches the content to the
* a subclasses content handlers.
Expand Down Expand Up @@ -226,6 +234,7 @@ protected boolean saveBuffer() throws IOException
protected boolean saveBuffer(ByteBuffer buffer) throws IOException
{
File outFile = this.getOutputFile();
System.out.println("outFile : "+outFile);

if (outFile == null)
return false;
Expand Down Expand Up @@ -264,6 +273,7 @@ protected File getOutputFile()
*/
protected boolean overwriteExistingFile()
{
// TODO
return false;
}

Expand Down Expand Up @@ -635,11 +645,12 @@ protected ByteBuffer convertToDDS() throws IOException
{
ByteBuffer buffer;

Bitmap image = this.transformPixels();
if (image != null)
buffer = DDSCompressor.compressImage(image);
else
buffer = DDSCompressor.compressImageBuffer(this.getRetriever().getBuffer());
// TODO
// Bitmap image = this.transformPixels();
// if (image != null)
// buffer = DDSCompressor.compressImage(image);
// else
buffer = ETC1DDSCompressor.compressImageBuffer(this.getRetriever().getBuffer());

return buffer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,7 @@ protected void renderOutline(DrawContext dc, TerrainTile tile) {
}

protected void loadGeometryVbos(DrawContext dc, TerrainGeometry geom) {
// TODO : offload vbo creation to another thread
// Load the terrain geometry into the GpuResourceCache.
GpuResourceCache cache = dc.getGpuResourceCache();
int[] vboIds = (int[]) cache.get(geom.vboCacheKey);
Expand Down Expand Up @@ -1198,6 +1199,7 @@ protected void loadGeometryVbos(DrawContext dc, TerrainGeometry geom) {
}

protected void loadSharedGeometryVBOs(DrawContext dc, TerrainSharedGeometry geom) {
// TODO : offload vbo creation to another thread
GpuResourceCache cache = dc.getGpuResourceCache();
int[] vboIds = (int[]) cache.get(geom.vboCacheKey);
if (vboIds != null) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public static Bitmap bitmapFromByteBuffer(ByteBuffer imageBuffer)
return BitmapFactory.decodeStream(inputStream);
}

// TODO : what is this method for ??
public static Bitmap mapTransparencyColors(Bitmap sourceImage, int[] originalColors)
{
if (sourceImage == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
import gov.nasa.worldwind.util.Logging;
import gov.nasa.worldwind.util.WWIO;
import gov.nasa.worldwind.util.WWMath;
import nicastel.renderscripttexturecompressor.dds.ETC1Compressor;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;

/**
* DDSCompressor converts in-memory images into a DDS file encoded with one of the DXT block compression algorithms. If
Expand Down Expand Up @@ -58,8 +61,12 @@ public static java.nio.ByteBuffer compressImageStream(java.io.InputStream inputS
Logging.error(message);
throw new IllegalArgumentException(message);
}

Bitmap image = BitmapFactory.decodeStream(inputStream);

Options opts = new BitmapFactory.Options();
//opts.inPreferQualityOverSpeed = false;
opts.inPreferredConfig = Config.ARGB_8888;
Bitmap image = BitmapFactory.decodeStream(inputStream, null, opts);

if (image == null) {
return null;
}
Expand Down Expand Up @@ -191,9 +198,12 @@ public static java.nio.ByteBuffer compressImage(Bitmap image) {
*/
public static DXTCompressionAttributes getDefaultCompressionAttributes() {
DXTCompressionAttributes attributes = new DXTCompressionAttributes();

// TODO bug with 2*2 image but bug with worldwind dds reader if there is no mimmap
attributes.setBuildMipmaps(true); // Always build mipmaps.

attributes.setPremultiplyAlpha(true); // Always create premultiplied alpha format files..
attributes.setDXTFormat(0); // Allow the DDSCompressor to choose the appropriate DXT format.
attributes.setDXTFormat(DDSConstants.D3DFMT_ETC1); // Allow the DDSCompressor to choose the appropriate DXT format.
return attributes;
}

Expand Down Expand Up @@ -347,12 +357,14 @@ protected DXTCompressor getDXTCompressor(Bitmap image, DXTCompressionAttributes
// Otherwise, we choose one automatically from the image type. If no choice can be made from the image type,
// we default to using a DXT3 compressor.

if (attributes.getDXTFormat() == DDSConstants.D3DFMT_DXT1) {
if (attributes.getDXTFormat() == DDSConstants.D3DFMT_ETC1) {
return new ETC1Compressor();
} else if (attributes.getDXTFormat() == DDSConstants.D3DFMT_DXT1) {
return new DXT1Compressor();
} else if (attributes.getDXTFormat() == DDSConstants.D3DFMT_DXT2 || attributes.getDXTFormat() == DDSConstants.D3DFMT_DXT3) {
return new DXT3Compressor();
} else if (!image.hasAlpha()) {
return new DXT1Compressor();
return new ETC1Compressor();
} else {
return new DXT3Compressor();
}
Expand Down
Loading