Skip to content

Commit db141aa

Browse files
committed
Produced Texture recreate issue fixed;version 1.2.2.3
1 parent 6958c29 commit db141aa

File tree

7 files changed

+69
-25
lines changed

7 files changed

+69
-25
lines changed

README-en.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ allprojects {
4343
4444
// module build.gradle
4545
dependencies {
46-
compile 'com.github.ChillingVan:android-openGL-canvas:v1.2.2.2'
46+
compile 'com.github.ChillingVan:android-openGL-canvas:v1.2.2.3'
4747
}
4848
```
4949

@@ -119,8 +119,7 @@ Use this sample and the stream publisher sample of [AndroidInstantVideo](https:/
119119
* Remember to call onResume and onPause in the Activity lifecycle when using GLContinuousView and GLContinuousTextureView.
120120

121121
## Latest Update
122-
* Fix issue that when close screen, the TextureCamera will stuck.
123-
* Add FileLogger
122+
* Fix issue that recreate for producedTexture of GLProducedTextureView.
124123

125124
## License
126125
Copyright 2016 ChillingVan.

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ allprojects {
4848
4949
// module build.gradle
5050
dependencies {
51-
compile 'com.github.ChillingVan:android-openGL-canvas:v1.2.2.2'
51+
compile 'com.github.ChillingVan:android-openGL-canvas:v1.2.2.3'
5252
}
5353
```
5454

@@ -129,8 +129,7 @@ public class MyGLView extends GLView {
129129

130130

131131
## 最近更新
132-
* 修复熄屏再亮屏,TextureCamera 卡住的问题
133-
* 添加FileLogger,支持文件log。
132+
* 修复在GLProducedTextureView尺寸改变时重复创建producedTexture
134133

135134
## License
136135
Copyright 2016 ChillingVan.

canvasgl/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ android {
2828
defaultConfig {
2929
minSdkVersion 14
3030
targetSdkVersion 27
31-
versionCode 102022
32-
versionName "1.2.2.2"
31+
versionCode 102023
32+
versionName "1.2.2.3"
3333
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
3434
}
3535
buildTypes {

canvasgl/src/main/java/com/chillingvan/canvasgl/glview/texture/BaseGLTextureView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int h
266266
}
267267

268268
/**
269-
* This will be called when windows detached. Activity onPause will cause window detached.
269+
* This will be called when windows detached. Activity onStop will cause window detached.
270270
*/
271271
@Override
272272
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {

canvasgl/src/main/java/com/chillingvan/canvasgl/glview/texture/GLSurfaceTextureProducerView.java

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,23 @@ public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int hei
9696
public void onSurfaceChanged(int width, int height) {
9797
super.onSurfaceChanged(width, height);
9898
Loggers.d(TAG, "onSurfaceChanged: ");
99-
producedRawTexture = new RawTexture(width, height, false, producedTextureTarget);
100-
if (!producedRawTexture.isLoaded()) {
101-
producedRawTexture.prepare(mCanvas.getGlCanvas());
102-
}
103-
producedSurfaceTexture = new SurfaceTexture(producedRawTexture.getId());
104-
post(new Runnable() {
105-
@Override
106-
public void run() {
107-
if (onSurfaceTextureSet != null) {
108-
onSurfaceTextureSet.onSet(producedSurfaceTexture, producedRawTexture);
109-
}
99+
if (producedRawTexture == null) {
100+
producedRawTexture = new RawTexture(width, height, false, producedTextureTarget);
101+
if (!producedRawTexture.isLoaded()) {
102+
producedRawTexture.prepare(mCanvas.getGlCanvas());
110103
}
111-
});
104+
producedSurfaceTexture = new SurfaceTexture(producedRawTexture.getId());
105+
post(new Runnable() {
106+
@Override
107+
public void run() {
108+
if (onSurfaceTextureSet != null) {
109+
onSurfaceTextureSet.onSet(producedSurfaceTexture, producedRawTexture);
110+
}
111+
}
112+
});
113+
} else {
114+
producedRawTexture.setSize(width, height);
115+
}
112116
}
113117

114118
@Override
@@ -136,14 +140,14 @@ protected void surfaceDestroyed() {
136140
}
137141

138142
private void recycleProduceTexture() {
139-
if (producedRawTexture != null) {
143+
if (producedRawTexture != null && !producedRawTexture.isRecycled()) {
140144
producedRawTexture.recycle();
141-
producedRawTexture = null;
142145
}
143-
if (producedSurfaceTexture != null) {
146+
producedRawTexture = null;
147+
if (producedSurfaceTexture != null && !producedSurfaceTexture.isReleased()) {
144148
producedSurfaceTexture.release();
145-
producedSurfaceTexture = null;
146149
}
150+
producedSurfaceTexture = null;
147151
}
148152

149153
}

canvasglsample/src/main/java/com/chillingvan/canvasglsample/textureView/TextureCameraActivity.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import android.os.Bundle;
2828
import android.support.v7.app.AppCompatActivity;
2929
import android.view.View;
30+
import android.view.ViewGroup;
3031
import android.widget.ImageView;
3132

3233
import com.chillingvan.canvasgl.util.Loggers;
@@ -161,4 +162,30 @@ protected void onPause() {
161162
cameraTextureView.onPause();
162163
previewConsumerTextureView.onPause();
163164
}
165+
166+
public void onClickChangeSize(View view) {
167+
if (cameraTextureView.getScaleY() < 1) {
168+
cameraTextureView.setScaleY(1.5f);
169+
previewConsumerTextureView.setScaleY(1.5f);
170+
} else {
171+
cameraTextureView.setScaleY(0.7f);
172+
previewConsumerTextureView.setScaleY(0.7f);
173+
}
174+
}
175+
176+
public void onClickChangeLayoutSize(View view) {
177+
ViewGroup.LayoutParams layoutParams = cameraTextureView.getLayoutParams();
178+
ViewGroup.LayoutParams consumerLayoutParams = previewConsumerTextureView.getLayoutParams();
179+
if (layoutParams.height < 500) {
180+
layoutParams.height += 50;
181+
cameraTextureView.setLayoutParams(layoutParams);
182+
consumerLayoutParams.height += 50;
183+
previewConsumerTextureView.setLayoutParams(consumerLayoutParams);
184+
} else {
185+
layoutParams.height -= 50;
186+
cameraTextureView.setLayoutParams(layoutParams);
187+
consumerLayoutParams.height -= 50;
188+
previewConsumerTextureView.setLayoutParams(consumerLayoutParams);
189+
}
190+
}
164191
}

canvasglsample/src/main/res/layout/activity_texture_canvas.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,21 @@
6868

6969
</LinearLayout>
7070

71+
<Button
72+
android:layout_width="match_parent"
73+
android:layout_height="40dp"
74+
android:layout_margin="5dp"
75+
android:text="Change Scale"
76+
android:onClick="onClickChangeSize"
77+
/>
78+
79+
<Button
80+
android:layout_width="match_parent"
81+
android:layout_height="40dp"
82+
android:layout_margin="5dp"
83+
android:text="Change Layout"
84+
android:onClick="onClickChangeLayoutSize"
85+
/>
7186

7287

7388
</LinearLayout>

0 commit comments

Comments
 (0)