今奥全景相机
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

760 lines
18 KiB

.class public Lcom/via/gpuimage/GPUTexture;
.super Ljava/lang/Object;
.source "GPUTexture.java"
# static fields
.field static final CUBE:[F
# instance fields
.field protected mFilter:Lcom/via/gpuimage/GPUImageFilter;
.field protected mFramebuffer:[I
.field protected mFramebufferNum:I
.field protected mGLCubeBuffer:Ljava/nio/FloatBuffer;
.field protected mGLTextureBuffer:Ljava/nio/FloatBuffer;
.field protected mHeight:I
.field protected mMediaTexture:I
.field protected mOffscreenTexture:[I
.field protected mWidth:I
# direct methods
.method static constructor <clinit>()V
.locals 1
.prologue
.line 21
const/16 v0, 0x8
new-array v0, v0, [F
fill-array-data v0, :array_0
sput-object v0, Lcom/via/gpuimage/GPUTexture;->CUBE:[F
return-void
:array_0
.array-data 4
-0x40800000 # -1.0f
-0x40800000 # -1.0f
0x3f800000 # 1.0f
-0x40800000 # -1.0f
-0x40800000 # -1.0f
0x3f800000 # 1.0f
0x3f800000 # 1.0f
0x3f800000 # 1.0f
.end array-data
.end method
.method public constructor <init>()V
.locals 1
.prologue
.line 38
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 36
const/4 v0, 0x1
iput v0, p0, Lcom/via/gpuimage/GPUTexture;->mFramebufferNum:I
.line 39
return-void
.end method
.method private dumpTexture(ILjava/lang/String;)V
.locals 9
.prologue
const/4 v2, 0x1
const v8, 0x8d40
const/16 v7, 0xde1
const/4 v0, 0x0
.line 138
new-array v1, v2, [I
.line 140
invoke-static {v2, v1, v0}, Landroid/opengl/GLES20;->glGenFramebuffers(I[II)V
.line 141
aget v1, v1, v0
.line 143
invoke-static {v8, v1}, Landroid/opengl/GLES20;->glBindFramebuffer(II)V
.line 144
invoke-static {v7, p1}, Landroid/opengl/GLES20;->glBindTexture(II)V
.line 145
const v1, 0x8ce0
invoke-static {v8, v1, v7, p1, v0}, Landroid/opengl/GLES20;->glFramebufferTexture2D(IIIII)V
.line 148
iget v1, p0, Lcom/via/gpuimage/GPUTexture;->mWidth:I
iget v2, p0, Lcom/via/gpuimage/GPUTexture;->mHeight:I
mul-int/2addr v1, v2
mul-int/lit8 v1, v1, 0x4
invoke-static {v1}, Ljava/nio/ByteBuffer;->allocateDirect(I)Ljava/nio/ByteBuffer;
move-result-object v6
.line 149
invoke-static {}, Ljava/nio/ByteOrder;->nativeOrder()Ljava/nio/ByteOrder;
move-result-object v1
invoke-virtual {v6, v1}, Ljava/nio/ByteBuffer;->order(Ljava/nio/ByteOrder;)Ljava/nio/ByteBuffer;
.line 150
iget v2, p0, Lcom/via/gpuimage/GPUTexture;->mWidth:I
iget v3, p0, Lcom/via/gpuimage/GPUTexture;->mHeight:I
const/16 v4, 0x1908
const/16 v5, 0x1401
move v1, v0
invoke-static/range {v0 .. v6}, Landroid/opengl/GLES20;->glReadPixels(IIIIIILjava/nio/Buffer;)V
.line 152
iget v1, p0, Lcom/via/gpuimage/GPUTexture;->mWidth:I
iget v2, p0, Lcom/via/gpuimage/GPUTexture;->mHeight:I
sget-object v3, Landroid/graphics/Bitmap$Config;->ARGB_8888:Landroid/graphics/Bitmap$Config;
invoke-static {v1, v2, v3}, Landroid/graphics/Bitmap;->createBitmap(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;
move-result-object v1
.line 153
invoke-virtual {v1, v6}, Landroid/graphics/Bitmap;->copyPixelsFromBuffer(Ljava/nio/Buffer;)V
.line 155
invoke-direct {p0, p2, v1}, Lcom/via/gpuimage/GPUTexture;->savebitmap(Ljava/lang/String;Landroid/graphics/Bitmap;)Ljava/io/File;
.line 157
invoke-static {v7, v0}, Landroid/opengl/GLES20;->glBindTexture(II)V
.line 158
invoke-static {v8, v0}, Landroid/opengl/GLES20;->glBindFramebuffer(II)V
.line 160
return-void
.end method
.method private prepareFrameBuffer()V
.locals 12
.prologue
const v11, 0x46180400 # 9729.0f
const/4 v8, 0x0
const v10, 0x8d40
const/16 v0, 0xde1
const/4 v1, 0x0
.line 42
iget-object v2, p0, Lcom/via/gpuimage/GPUTexture;->mOffscreenTexture:[I
if-eqz v2, :cond_0
.line 43
iget v2, p0, Lcom/via/gpuimage/GPUTexture;->mFramebufferNum:I
iget-object v3, p0, Lcom/via/gpuimage/GPUTexture;->mOffscreenTexture:[I
invoke-static {v2, v3, v1}, Landroid/opengl/GLES20;->glDeleteTextures(I[II)V
.line 44
iput-object v8, p0, Lcom/via/gpuimage/GPUTexture;->mOffscreenTexture:[I
.line 47
:cond_0
iget-object v2, p0, Lcom/via/gpuimage/GPUTexture;->mFramebuffer:[I
if-eqz v2, :cond_1
.line 48
iget v2, p0, Lcom/via/gpuimage/GPUTexture;->mFramebufferNum:I
iget-object v3, p0, Lcom/via/gpuimage/GPUTexture;->mFramebuffer:[I
invoke-static {v2, v3, v1}, Landroid/opengl/GLES20;->glDeleteFramebuffers(I[II)V
.line 49
iput-object v8, p0, Lcom/via/gpuimage/GPUTexture;->mFramebuffer:[I
.line 52
:cond_1
iget v2, p0, Lcom/via/gpuimage/GPUTexture;->mFramebufferNum:I
new-array v2, v2, [I
iput-object v2, p0, Lcom/via/gpuimage/GPUTexture;->mOffscreenTexture:[I
.line 53
iget v2, p0, Lcom/via/gpuimage/GPUTexture;->mFramebufferNum:I
new-array v2, v2, [I
iput-object v2, p0, Lcom/via/gpuimage/GPUTexture;->mFramebuffer:[I
.line 54
iget v2, p0, Lcom/via/gpuimage/GPUTexture;->mFramebufferNum:I
iget-object v3, p0, Lcom/via/gpuimage/GPUTexture;->mFramebuffer:[I
invoke-static {v2, v3, v1}, Landroid/opengl/GLES20;->glGenFramebuffers(I[II)V
.line 55
iget v2, p0, Lcom/via/gpuimage/GPUTexture;->mFramebufferNum:I
iget-object v3, p0, Lcom/via/gpuimage/GPUTexture;->mOffscreenTexture:[I
invoke-static {v2, v3, v1}, Landroid/opengl/GLES20;->glGenTextures(I[II)V
move v9, v1
.line 57
:goto_0
iget v2, p0, Lcom/via/gpuimage/GPUTexture;->mFramebufferNum:I
if-ge v9, v2, :cond_2
.line 58
const v2, 0x84c0
invoke-static {v2}, Landroid/opengl/GLES20;->glActiveTexture(I)V
.line 59
iget-object v2, p0, Lcom/via/gpuimage/GPUTexture;->mOffscreenTexture:[I
aget v2, v2, v9
invoke-static {v0, v2}, Landroid/opengl/GLES20;->glBindTexture(II)V
.line 60
const/16 v2, 0x1908
iget v3, p0, Lcom/via/gpuimage/GPUTexture;->mWidth:I
iget v4, p0, Lcom/via/gpuimage/GPUTexture;->mHeight:I
const/16 v6, 0x1908
const/16 v7, 0x1401
move v5, v1
invoke-static/range {v0 .. v8}, Landroid/opengl/GLES20;->glTexImage2D(IIIIIIIILjava/nio/Buffer;)V
.line 62
const/16 v2, 0x2800
invoke-static {v0, v2, v11}, Landroid/opengl/GLES20;->glTexParameterf(IIF)V
.line 64
const/16 v2, 0x2801
invoke-static {v0, v2, v11}, Landroid/opengl/GLES20;->glTexParameterf(IIF)V
.line 66
const/16 v2, 0x2802
const v3, 0x47012f00 # 33071.0f
invoke-static {v0, v2, v3}, Landroid/opengl/GLES20;->glTexParameterf(IIF)V
.line 68
const/16 v2, 0x2803
const v3, 0x47012f00 # 33071.0f
invoke-static {v0, v2, v3}, Landroid/opengl/GLES20;->glTexParameterf(IIF)V
.line 71
iget-object v2, p0, Lcom/via/gpuimage/GPUTexture;->mFramebuffer:[I
aget v2, v2, v9
invoke-static {v10, v2}, Landroid/opengl/GLES20;->glBindFramebuffer(II)V
.line 72
const v2, 0x8ce0
iget-object v3, p0, Lcom/via/gpuimage/GPUTexture;->mOffscreenTexture:[I
aget v3, v3, v9
invoke-static {v10, v2, v0, v3, v1}, Landroid/opengl/GLES20;->glFramebufferTexture2D(IIIII)V
.line 75
invoke-static {v0, v1}, Landroid/opengl/GLES20;->glBindTexture(II)V
.line 76
invoke-static {v10, v1}, Landroid/opengl/GLES20;->glBindFramebuffer(II)V
.line 57
add-int/lit8 v2, v9, 0x1
move v9, v2
goto :goto_0
.line 78
:cond_2
return-void
.end method
.method private savebitmap(Ljava/lang/String;Landroid/graphics/Bitmap;)Ljava/io/File;
.locals 4
.prologue
.line 114
invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;
move-result-object v0
invoke-virtual {v0}, Ljava/io/File;->toString()Ljava/lang/String;
move-result-object v1
.line 117
new-instance v0, Ljava/io/File;
new-instance v2, Ljava/lang/StringBuilder;
invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
invoke-virtual {v2, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v2
const-string v3, ".png"
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v2
invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v2
invoke-direct {v0, v1, v2}, Ljava/io/File;-><init>(Ljava/lang/String;Ljava/lang/String;)V
.line 118
invoke-virtual {v0}, Ljava/io/File;->exists()Z
move-result v2
if-eqz v2, :cond_0
.line 119
invoke-virtual {v0}, Ljava/io/File;->delete()Z
.line 120
new-instance v0, Ljava/io/File;
new-instance v2, Ljava/lang/StringBuilder;
invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
invoke-virtual {v2, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v2
const-string v3, ".png"
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v2
invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v2
invoke-direct {v0, v1, v2}, Ljava/io/File;-><init>(Ljava/lang/String;Ljava/lang/String;)V
.line 121
const-string v1, "file exist"
new-instance v2, Ljava/lang/StringBuilder;
invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
const-string v3, ""
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v2
invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
move-result-object v2
const-string v3, ",Bitmap= "
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v2
invoke-virtual {v2, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v2
invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v2
invoke-static {v1, v2}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I
move-object v1, v0
.line 125
:goto_0
:try_start_0
new-instance v0, Ljava/io/FileOutputStream;
invoke-direct {v0, v1}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V
.line 126
sget-object v2, Landroid/graphics/Bitmap$CompressFormat;->PNG:Landroid/graphics/Bitmap$CompressFormat;
const/16 v3, 0x64
invoke-virtual {p2, v2, v3, v0}, Landroid/graphics/Bitmap;->compress(Landroid/graphics/Bitmap$CompressFormat;ILjava/io/OutputStream;)Z
.line 127
invoke-virtual {v0}, Ljava/io/OutputStream;->flush()V
.line 128
invoke-virtual {v0}, Ljava/io/OutputStream;->close()V
:try_end_0
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
.line 132
:goto_1
const-string v0, "file"
new-instance v2, Ljava/lang/StringBuilder;
invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
const-string v3, ""
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v2
invoke-virtual {v2, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
move-result-object v2
invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v2
invoke-static {v0, v2}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I
.line 133
return-object v1
.line 129
:catch_0
move-exception v0
.line 130
invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V
goto :goto_1
:cond_0
move-object v1, v0
goto :goto_0
.end method
# virtual methods
.method public applyFilter()I
.locals 1
.prologue
.line 183
invoke-virtual {p0}, Lcom/via/gpuimage/GPUTexture;->draw()V
.line 187
invoke-virtual {p0}, Lcom/via/gpuimage/GPUTexture;->getOffscreenTexture()I
move-result v0
return v0
.end method
.method public draw()V
.locals 7
.prologue
const v6, 0x8d40
const/16 v5, 0xde1
const/4 v4, 0x0
.line 163
iget-object v0, p0, Lcom/via/gpuimage/GPUTexture;->mFilter:Lcom/via/gpuimage/GPUImageFilter;
if-nez v0, :cond_0
.line 164
new-instance v0, Lcom/via/gpuimage/GPUImageFilter;
invoke-direct {v0}, Lcom/via/gpuimage/GPUImageFilter;-><init>()V
iput-object v0, p0, Lcom/via/gpuimage/GPUTexture;->mFilter:Lcom/via/gpuimage/GPUImageFilter;
.line 165
iget-object v0, p0, Lcom/via/gpuimage/GPUTexture;->mFilter:Lcom/via/gpuimage/GPUImageFilter;
invoke-virtual {v0}, Lcom/via/gpuimage/GPUImageFilter;->init()V
.line 168
:cond_0
iget-object v0, p0, Lcom/via/gpuimage/GPUTexture;->mFramebuffer:[I
aget v0, v0, v4
invoke-static {v6, v0}, Landroid/opengl/GLES20;->glBindFramebuffer(II)V
.line 169
const/16 v0, 0x4000
invoke-static {v0}, Landroid/opengl/GLES20;->glClear(I)V
.line 171
iget v0, p0, Lcom/via/gpuimage/GPUTexture;->mWidth:I
iget v1, p0, Lcom/via/gpuimage/GPUTexture;->mHeight:I
invoke-static {v4, v4, v0, v1}, Landroid/opengl/GLES20;->glViewport(IIII)V
.line 172
iget-object v0, p0, Lcom/via/gpuimage/GPUTexture;->mFilter:Lcom/via/gpuimage/GPUImageFilter;
iget v1, p0, Lcom/via/gpuimage/GPUTexture;->mMediaTexture:I
iget-object v2, p0, Lcom/via/gpuimage/GPUTexture;->mGLCubeBuffer:Ljava/nio/FloatBuffer;
iget-object v3, p0, Lcom/via/gpuimage/GPUTexture;->mGLTextureBuffer:Ljava/nio/FloatBuffer;
invoke-virtual {v0, v5, v1, v2, v3}, Lcom/via/gpuimage/GPUImageFilter;->onDraw(IILjava/nio/FloatBuffer;Ljava/nio/FloatBuffer;)V
.line 174
invoke-static {v6, v4}, Landroid/opengl/GLES20;->glBindFramebuffer(II)V
.line 175
invoke-static {v5, v4}, Landroid/opengl/GLES20;->glBindTexture(II)V
.line 176
return-void
.end method
.method public getHeight()I
.locals 1
.prologue
.line 98
iget v0, p0, Lcom/via/gpuimage/GPUTexture;->mHeight:I
return v0
.end method
.method public getOffscreenTexture()I
.locals 2
.prologue
.line 179
iget-object v0, p0, Lcom/via/gpuimage/GPUTexture;->mOffscreenTexture:[I
const/4 v1, 0x0
aget v0, v0, v1
return v0
.end method
.method public getWidth()I
.locals 1
.prologue
.line 94
iget v0, p0, Lcom/via/gpuimage/GPUTexture;->mWidth:I
return v0
.end method
.method public releaseGL()V
.locals 4
.prologue
const/4 v3, 0x0
const/4 v2, 0x0
.line 191
iget-object v0, p0, Lcom/via/gpuimage/GPUTexture;->mOffscreenTexture:[I
if-eqz v0, :cond_0
.line 192
iget v0, p0, Lcom/via/gpuimage/GPUTexture;->mFramebufferNum:I
iget-object v1, p0, Lcom/via/gpuimage/GPUTexture;->mOffscreenTexture:[I
invoke-static {v0, v1, v2}, Landroid/opengl/GLES20;->glDeleteTextures(I[II)V
.line 193
iput-object v3, p0, Lcom/via/gpuimage/GPUTexture;->mOffscreenTexture:[I
.line 196
:cond_0
iget-object v0, p0, Lcom/via/gpuimage/GPUTexture;->mFramebuffer:[I
if-eqz v0, :cond_1
.line 197
iget v0, p0, Lcom/via/gpuimage/GPUTexture;->mFramebufferNum:I
iget-object v1, p0, Lcom/via/gpuimage/GPUTexture;->mFramebuffer:[I
invoke-static {v0, v1, v2}, Landroid/opengl/GLES20;->glDeleteFramebuffers(I[II)V
.line 198
iput-object v3, p0, Lcom/via/gpuimage/GPUTexture;->mFramebuffer:[I
.line 201
:cond_1
iget-object v0, p0, Lcom/via/gpuimage/GPUTexture;->mFilter:Lcom/via/gpuimage/GPUImageFilter;
if-eqz v0, :cond_2
.line 202
iget-object v0, p0, Lcom/via/gpuimage/GPUTexture;->mFilter:Lcom/via/gpuimage/GPUImageFilter;
invoke-virtual {v0}, Lcom/via/gpuimage/GPUImageFilter;->destroy()V
.line 204
:cond_2
return-void
.end method
.method public setFilter(Lcom/via/gpuimage/GPUImageFilter;)V
.locals 3
.prologue
.line 102
iget-object v0, p0, Lcom/via/gpuimage/GPUTexture;->mFilter:Lcom/via/gpuimage/GPUImageFilter;
.line 103
iput-object p1, p0, Lcom/via/gpuimage/GPUTexture;->mFilter:Lcom/via/gpuimage/GPUImageFilter;
.line 104
if-eqz v0, :cond_0
.line 105
invoke-virtual {v0}, Lcom/via/gpuimage/GPUImageFilter;->destroy()V
.line 107
:cond_0
iget-object v0, p0, Lcom/via/gpuimage/GPUTexture;->mFilter:Lcom/via/gpuimage/GPUImageFilter;
invoke-virtual {v0}, Lcom/via/gpuimage/GPUImageFilter;->init()V
.line 108
iget-object v0, p0, Lcom/via/gpuimage/GPUTexture;->mFilter:Lcom/via/gpuimage/GPUImageFilter;
invoke-virtual {v0}, Lcom/via/gpuimage/GPUImageFilter;->getProgram()I
move-result v0
invoke-static {v0}, Landroid/opengl/GLES20;->glUseProgram(I)V
.line 109
iget-object v0, p0, Lcom/via/gpuimage/GPUTexture;->mFilter:Lcom/via/gpuimage/GPUImageFilter;
iget v1, p0, Lcom/via/gpuimage/GPUTexture;->mWidth:I
iget v2, p0, Lcom/via/gpuimage/GPUTexture;->mHeight:I
invoke-virtual {v0, v1, v2}, Lcom/via/gpuimage/GPUImageFilter;->onOutputSizeChanged(II)V
.line 110
return-void
.end method
.method public setMediaTexture(I)V
.locals 0
.prologue
.line 81
iput p1, p0, Lcom/via/gpuimage/GPUTexture;->mMediaTexture:I
.line 82
return-void
.end method
.method public setMediaTextureSize(II)V
.locals 1
.prologue
.line 85
iget v0, p0, Lcom/via/gpuimage/GPUTexture;->mWidth:I
if-ne p1, v0, :cond_0
iget v0, p0, Lcom/via/gpuimage/GPUTexture;->mHeight:I
if-ne p2, v0, :cond_0
.line 91
:goto_0
return-void
.line 88
:cond_0
iput p1, p0, Lcom/via/gpuimage/GPUTexture;->mWidth:I
.line 89
iput p2, p0, Lcom/via/gpuimage/GPUTexture;->mHeight:I
.line 90
invoke-direct {p0}, Lcom/via/gpuimage/GPUTexture;->prepareFrameBuffer()V
goto :goto_0
.end method