blob: 3cfd659e76042bfab1f24bdad609a548d8ec955f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
package com.mapbox.mapboxsdk.maps.renderer.textureview;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.TextureView;
import com.mapbox.mapboxsdk.maps.renderer.MapRenderer;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
/**
* The {@link TextureViewMapRenderer} encapsulates the GL thread and
* {@link TextureView} specifics to render the map.
*
* @see MapRenderer
*/
public class TextureViewMapRenderer extends MapRenderer {
@Nullable
private TextureViewRenderThread renderThread;
private boolean translucentSurface;
/**
* Create a {@link MapRenderer} for the given {@link TextureView}
*
* @param context the current Context
* @param textureView the TextureView
* @param localIdeographFontFamily the local font family
* @param translucentSurface the translucency flag
*/
public TextureViewMapRenderer(@NonNull Context context,
@NonNull final MapboxTextureView textureView,
String localIdeographFontFamily,
boolean translucentSurface) {
super(context, localIdeographFontFamily);
this.translucentSurface = translucentSurface;
textureView.setOnViewAttachedListener(new MapboxTextureView.OnViewAttachedListener() {
@Override
public void onViewAttached() {
if (renderThread == null) {
renderThread = new TextureViewRenderThread(textureView, TextureViewMapRenderer.this);
renderThread.start();
}
}
});
}
/**
* Overridden to provide package access
*/
@Override
protected void onSurfaceCreated(GL10 gl, EGLConfig config) {
super.onSurfaceCreated(gl, config);
}
/**
* Overridden to provide package access
*/
@Override
protected void onSurfaceChanged(GL10 gl, int width, int height) {
super.onSurfaceChanged(gl, width, height);
}
/**
* Overridden to provide package access
*/
@Override
protected void onSurfaceDestroyed() {
super.onSurfaceDestroyed();
}
/**
* Overridden to provide package access
*/
@Override
protected void onDrawFrame(GL10 gl) {
super.onDrawFrame(gl);
}
/**
* {@inheritDoc}
*/
@Override
public void requestRender() {
assert renderThread != null;
renderThread.requestRender();
}
/**
* {@inheritDoc}
*/
@Override
public void queueEvent(Runnable runnable) {
assert renderThread != null;
renderThread.queueEvent(runnable);
}
/**
* {@inheritDoc}
*/
@Override
public void onStop() {
if (renderThread != null) {
renderThread.onPause();
}
}
/**
* {@inheritDoc}
*/
@Override
public void onStart() {
if (renderThread != null) {
renderThread.onResume();
}
}
/**
* {@inheritDoc}
*/
@Override
public void onDestroy() {
if (renderThread != null) {
renderThread.onDestroy();
}
}
public boolean isTranslucentSurface() {
return translucentSurface;
}
}
|