Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe852e21 authored by Alex Sakhartchouk's avatar Alex Sakhartchouk
Browse files

Updating cubemap loading code.

Change-Id: I93bb00e5fd1ccc622d17eba70a510664c2093723
parent 3045bbaf
Loading
Loading
Loading
Loading
+0 −37
Original line number Diff line number Diff line
@@ -166366,8 +166366,6 @@
</parameter>
<parameter name="mips" type="android.renderscript.Allocation.MipmapControl">
</parameter>
<parameter name="layout" type="android.renderscript.Allocation.CubemapLayout">
</parameter>
<parameter name="usage" type="int">
</parameter>
</method>
@@ -166385,8 +166383,6 @@
</parameter>
<parameter name="b" type="android.graphics.Bitmap">
</parameter>
<parameter name="layout" type="android.renderscript.Allocation.CubemapLayout">
</parameter>
</method>
<method name="createFromBitmap"
 return="android.renderscript.Allocation"
@@ -166646,39 +166642,6 @@
>
</field>
</class>
<class name="Allocation.CubemapLayout"
 extends="java.lang.Enum"
 abstract="false"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
<method name="valueOf"
 return="android.renderscript.Allocation.CubemapLayout"
 abstract="false"
 native="false"
 synchronized="false"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="name" type="java.lang.String">
</parameter>
</method>
<method name="values"
 return="android.renderscript.Allocation.CubemapLayout[]"
 abstract="false"
 native="false"
 synchronized="false"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</method>
</class>
<class name="Allocation.MipmapControl"
 extends="java.lang.Enum"
 abstract="false"
+19 −25
Original line number Diff line number Diff line
@@ -53,19 +53,6 @@ public class Allocation extends BaseObj {
    public static final int USAGE_GRAPHICS_CONSTANTS = 0x0008;


    public enum CubemapLayout {
        VERTICAL_FACE_LIST (0),
        HORIZONTAL_FACE_LIST (1),
        VERTICAL_CROSS (2),
        HORIZONTAL_CROSS (3);

        int mID;
        CubemapLayout(int id) {
            mID = id;
        }
    }


    public enum MipmapControl {
        MIPMAP_NONE(0),
        MIPMAP_FULL(1),
@@ -416,33 +403,41 @@ public class Allocation extends BaseObj {
                                USAGE_GRAPHICS_TEXTURE);
    }

    /**
    * Creates a cubemap allocation from a bitmap containing the
    * horizontal list of cube faces. Each individual face must be
    * the same size and power of 2
    *
    * @param rs
    * @param b bitmap with cubemap faces layed out in the following
    *          format: right, left, top, bottom, front, back
    * @param mips specifies desired mipmap behaviour for the cubemap
    * @param usage bitfield specifying how the cubemap is utilized
    *
    **/
    static public Allocation createCubemapFromBitmap(RenderScript rs, Bitmap b,
                                                     MipmapControl mips,
                                                     CubemapLayout layout,
                                                     int usage) {
        rs.validate();

        int height = b.getHeight();
        int width = b.getWidth();

        if (layout != CubemapLayout.VERTICAL_FACE_LIST) {
            throw new RSIllegalArgumentException("Only vertical face list supported");
        }
        if (height % 6 != 0) {
        if (width % 6 != 0) {
            throw new RSIllegalArgumentException("Cubemap height must be multiple of 6");
        }
        if (height / 6 != width) {
        if (width / 6 != height) {
            throw new RSIllegalArgumentException("Only square cobe map faces supported");
        }
        boolean isPow2 = (width & (width - 1)) == 0;
        boolean isPow2 = (height & (height - 1)) == 0;
        if (!isPow2) {
            throw new RSIllegalArgumentException("Only power of 2 cube faces supported");
        }

        Element e = elementFromBitmap(rs, b);
        Type.Builder tb = new Type.Builder(rs, e);
        tb.setX(width);
        tb.setY(width);
        tb.setX(height);
        tb.setY(height);
        tb.setFaces(true);
        tb.setMipmaps(mips == MipmapControl.MIPMAP_FULL);
        Type t = tb.create();
@@ -454,10 +449,9 @@ public class Allocation extends BaseObj {
        return new Allocation(id, rs, t, usage);
    }

    static public Allocation createCubemapFromBitmap(RenderScript rs, Bitmap b,
                                                     CubemapLayout layout) {
    static public Allocation createCubemapFromBitmap(RenderScript rs, Bitmap b) {
        return createCubemapFromBitmap(rs, b, MipmapControl.MIPMAP_NONE,
                                       layout, USAGE_GRAPHICS_TEXTURE);
                                       USAGE_GRAPHICS_TEXTURE);
    }

    static public Allocation createFromBitmapResource(RenderScript rs,
−28 B (2.8 KiB)
Loading image diff...
+1 −3
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.renderscript.*;
import android.renderscript.Allocation.CubemapLayout;
import android.renderscript.Allocation.MipmapControl;
import android.renderscript.Program.TextureType;
import android.renderscript.ProgramStore.DepthFunc;
@@ -318,8 +317,7 @@ public class RsBenchRS {
        mTexTransparent = loadTextureARGB(R.drawable.leaf);
        mTexChecker = loadTextureRGB(R.drawable.checker);
        Bitmap b = BitmapFactory.decodeResource(mRes, R.drawable.cubemap_test);
        mTexCube = Allocation.createCubemapFromBitmap(mRS, b,
                                                      Allocation.CubemapLayout.VERTICAL_FACE_LIST);
        mTexCube = Allocation.createCubemapFromBitmap(mRS, b);

        mScript.set_gTexTorus(mTexTorus);
        mScript.set_gTexOpaque(mTexOpaque);
+1 −3
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.renderscript.*;
import android.renderscript.Allocation.CubemapLayout;
import android.renderscript.Font.Style;
import android.renderscript.Program.TextureType;
import android.renderscript.ProgramStore.DepthFunc;
@@ -308,8 +307,7 @@ public class RsRenderStatesRS {
        mTexTransparent = loadTextureARGB(R.drawable.leaf);
        mTexChecker = loadTextureRGB(R.drawable.checker);
        Bitmap b = BitmapFactory.decodeResource(mRes, R.drawable.cubemap_test);
        mTexCube = Allocation.createCubemapFromBitmap(mRS, b,
                                                      Allocation.CubemapLayout.VERTICAL_FACE_LIST);
        mTexCube = Allocation.createCubemapFromBitmap(mRS, b);

        mScript.set_gTexTorus(mTexTorus);
        mScript.set_gTexOpaque(mTexOpaque);
Loading