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

Commit bbad09d6 authored by Jason Sams's avatar Jason Sams Committed by Android (Google) Code Review
Browse files

Merge "Move ImageProcessing and ModelViewer to reflected files. Implement boolean support."

parents 9856f2de f110d4b7
Loading
Loading
Loading
Loading
+23 −14
Original line number Diff line number Diff line
@@ -47,20 +47,22 @@ public class Element extends BaseObj {
        UNSIGNED_32 (10, 4),
        //UNSIGNED_64 (11, 8),

        UNSIGNED_5_6_5 (12, 2),
        UNSIGNED_5_5_5_1 (13, 2),
        UNSIGNED_4_4_4_4 (14, 2),

        RS_ELEMENT (15, 4),
        RS_TYPE (16, 4),
        RS_ALLOCATION (17, 4),
        RS_SAMPLER (18, 4),
        RS_SCRIPT (19, 4),
        RS_MESH (20, 4),
        RS_PROGRAM_FRAGMENT (21, 4),
        RS_PROGRAM_VERTEX (22, 4),
        RS_PROGRAM_RASTER (23, 4),
        RS_PROGRAM_STORE (24, 4);
        BOOLEAN(12, 1),

        UNSIGNED_5_6_5 (13, 2),
        UNSIGNED_5_5_5_1 (14, 2),
        UNSIGNED_4_4_4_4 (15, 2),

        RS_ELEMENT (16, 4),
        RS_TYPE (17, 4),
        RS_ALLOCATION (18, 4),
        RS_SAMPLER (19, 4),
        RS_SCRIPT (20, 4),
        RS_MESH (21, 4),
        RS_PROGRAM_FRAGMENT (22, 4),
        RS_PROGRAM_VERTEX (23, 4),
        RS_PROGRAM_RASTER (24, 4),
        RS_PROGRAM_STORE (25, 4);

        int mID;
        int mSize;
@@ -85,6 +87,13 @@ public class Element extends BaseObj {
        }
    }

    public static Element BOOLEAN(RenderScript rs) {
        if(rs.mElement_BOOLEAN == null) {
            rs.mElement_BOOLEAN = createUser(rs, DataType.BOOLEAN);
        }
        return rs.mElement_BOOLEAN;
    }

    public static Element U8(RenderScript rs) {
        if(rs.mElement_U8 == null) {
            rs.mElement_U8 = createUser(rs, DataType.UNSIGNED_8);
+4 −0
Original line number Diff line number Diff line
@@ -244,6 +244,10 @@ public class FieldPacker {
        addU32(v.w);
    }

    public void addBoolean(Boolean v) {
        addI8(v ? 1 : 0);
    }

    public final byte[] getData() {
        return mData;
    }
+1 −0
Original line number Diff line number Diff line
@@ -204,6 +204,7 @@ public class RenderScript {
    Element mElement_U32;
    Element mElement_I32;
    Element mElement_F32;
    Element mElement_BOOLEAN;

    Element mElement_ELEMENT;
    Element mElement_TYPE;
+2 −0
Original line number Diff line number Diff line
@@ -85,6 +85,8 @@ enum RsDataType {
    RS_TYPE_UNSIGNED_32,
    RS_TYPE_UNSIGNED_64,

    RS_TYPE_BOOLEAN,

    RS_TYPE_UNSIGNED_5_6_5,
    RS_TYPE_UNSIGNED_5_5_5_1,
    RS_TYPE_UNSIGNED_4_4_4_4,
+39 −41
Original line number Diff line number Diff line
@@ -10,13 +10,9 @@ int height;
int width;
int radius;

typedef struct c4u_s {
    uint8_t r, g, b, a;
} c4u_t;

c4u_t * InPixel;
c4u_t * OutPixel;
c4u_t * ScratchPixel;
uchar4 * InPixel;
uchar4 * OutPixel;
uchar4 * ScratchPixel;

float inBlack;
float outBlack;
@@ -31,7 +27,7 @@ static float outWMinOutB;
static float overInWMinInB;
//static float3 gammaV;

#pragma rs export_var(height, width, radius, InPixel, OutPixel, ScratchPixel, inBlack, outBlack, inWhite, outWhite, gamma, saturation)
#pragma rs export_var(height, width, radius, InPixel, OutPixel, ScratchPixel, inBlack, outBlack, inWhite, outWhite, gamma, saturation, InPixel, OutPixel, ScratchPixel)
#pragma rs export_func(filter, filterBenchmark);

// Store our coefficients here
@@ -166,19 +162,21 @@ static void processNoBlur() {

    for(h = 0; h < height; h ++) {
        for(w = 0; w < width; w ++) {
            c4u_t *input = InPixel + h*width + w;
            uchar4 *input = InPixel + h*width + w;

            currentPixel.x = (float)(input->r);
            currentPixel.y = (float)(input->g);
            currentPixel.z = (float)(input->b);
            //currentPixel.xyz = convert_float3(input.xyz);
            currentPixel.x = (float)(input->x);
            currentPixel.y = (float)(input->y);
            currentPixel.z = (float)(input->z);

            currentPixel = levelsSaturation(currentPixel);

            c4u_t *output = OutPixel + h*width + w;
            output->r = (uint8_t)currentPixel.x;
            output->g = (uint8_t)currentPixel.y;
            output->b = (uint8_t)currentPixel.z;
            output->a = input->a;
            uchar4 *output = OutPixel + h*width + w;
            //output.xyz = convert_uchar3(currentPixel.xyz);
            output->x = (uint8_t)currentPixel.x;
            output->y = (uint8_t)currentPixel.y;
            output->z = (uint8_t)currentPixel.z;
            output->w = input->w;
        }
    }
    rsSendToClient(&count, 1, 4, 0);
@@ -205,21 +203,21 @@ static void horizontalBlur() {
                    validW = width - 1;
                }

                c4u_t *input = InPixel + h*width + validW;
                uchar4 *input = InPixel + h*width + validW;

                float weight = gaussian[r + radius];
                currentPixel.x = (float)(input->r);
                currentPixel.y = (float)(input->g);
                currentPixel.z = (float)(input->b);
                currentPixel.x = (float)(input->x);
                currentPixel.y = (float)(input->y);
                currentPixel.z = (float)(input->z);
                //currentPixel.w = (float)(input->a);

                blurredPixel += currentPixel*weight;
            }

            c4u_t *output = ScratchPixel + h*width + w;
            output->r = (uint8_t)blurredPixel.x;
            output->g = (uint8_t)blurredPixel.y;
            output->b = (uint8_t)blurredPixel.z;
            uchar4 *output = ScratchPixel + h*width + w;
            output->x = (uint8_t)blurredPixel.x;
            output->y = (uint8_t)blurredPixel.y;
            output->z = (uint8_t)blurredPixel.z;
            //output->a = (uint8_t)blurredPixel.w;
        }
    }
@@ -246,12 +244,12 @@ static void horizontalBlurLevels() {
                    validW = width - 1;
                }

                c4u_t *input = InPixel + h*width + validW;
                uchar4 *input = InPixel + h*width + validW;

                float weight = gaussian[r + radius];
                currentPixel.x = (float)(input->r);
                currentPixel.y = (float)(input->g);
                currentPixel.z = (float)(input->b);
                currentPixel.x = (float)(input->x);
                currentPixel.y = (float)(input->y);
                currentPixel.z = (float)(input->z);
                //currentPixel.w = (float)(input->a);

                blurredPixel += currentPixel*weight;
@@ -259,10 +257,10 @@ static void horizontalBlurLevels() {

            blurredPixel = levelsSaturation(blurredPixel);

            c4u_t *output = ScratchPixel + h*width + w;
            output->r = (uint8_t)blurredPixel.x;
            output->g = (uint8_t)blurredPixel.y;
            output->b = (uint8_t)blurredPixel.z;
            uchar4 *output = ScratchPixel + h*width + w;
            output->x = (uint8_t)blurredPixel.x;
            output->y = (uint8_t)blurredPixel.y;
            output->z = (uint8_t)blurredPixel.z;
            //output->a = (uint8_t)blurredPixel.w;
        }
    }
@@ -287,23 +285,23 @@ static void verticalBlur() {
                    validH = height - 1;
                }

                c4u_t *input = ScratchPixel + validH*width + w;
                uchar4 *input = ScratchPixel + validH*width + w;

                float weight = gaussian[r + radius];

                currentPixel.x = (float)(input->r);
                currentPixel.y = (float)(input->g);
                currentPixel.z = (float)(input->b);
                currentPixel.x = (float)(input->x);
                currentPixel.y = (float)(input->y);
                currentPixel.z = (float)(input->z);
                //currentPixel.w = (float)(input->a);

                blurredPixel += currentPixel*weight;
            }

            c4u_t *output = OutPixel + h*width + w;
            uchar4 *output = OutPixel + h*width + w;

            output->r = (uint8_t)blurredPixel.x;
            output->g = (uint8_t)blurredPixel.y;
            output->b = (uint8_t)blurredPixel.z;
            output->x = (uint8_t)blurredPixel.x;
            output->y = (uint8_t)blurredPixel.y;
            output->z = (uint8_t)blurredPixel.z;
            //output->a = (uint8_t)blurredPixel.w;
        }
    }
Loading