public class GLTextureView
extends android.view.TextureView
implements android.view.TextureView.SurfaceTextureListener, android.view.View.OnLayoutChangeListener
A GLSurfaceView provides the following features:
For more information about how to use OpenGL, read the OpenGL developer guide.
Typically you use GLSurfaceView by subclassing it and overriding one or more of the
View system input event methods. If your application does not need to override event
methods then GLSurfaceView can be used as-is. For the most part
GLSurfaceView behavior is customized by calling "set" methods rather than by subclassing.
For example, unlike a regular View, drawing is delegated to a separate Renderer object which
is registered with the GLSurfaceView
using the setRenderer(Renderer)
call.
setRenderer(Renderer)
.
However, if desired, you can modify the default behavior of GLSurfaceView by calling one or
more of these methods before calling setRenderer:
setDebugFlags(int)
setEGLConfigChooser(boolean)
setEGLConfigChooser(EGLConfigChooser)
setEGLConfigChooser(int, int, int, int, int, int)
setGLWrapper(GLWrapper)
By default GLSurfaceView chooses a EGLConfig that has an RGB_888 pixel format, with at least a 16-bit depth buffer and no stencil.
If you would prefer a different EGLConfig you can override the default behavior by calling one of the setEGLConfigChooser methods.
setDebugFlags(int)
,
and setGLWrapper(com.mousebird.maply.GLTextureView.GLWrapper)
. These methods may be called before and/or after setRenderer, but
typically they are called before setRenderer so that they take effect immediately.
setRenderer(com.mousebird.maply.GLTextureView.Renderer)
to register a GLTextureView.Renderer
.
The renderer is
responsible for doing the actual OpenGL rendering.
setRenderMode(int)
. The default is continuous rendering.
onPause()
when the activity pauses and
onResume()
when the activity resumes. These calls allow GLSurfaceView to
pause and resume the rendering thread, and also allow GLSurfaceView to release and recreate
the OpenGL display.
To handle an event you will typically subclass GLSurfaceView and override the
appropriate method, just as you would with any other View. However, when handling
the event, you may need to communicate with the Renderer object
that's running in the rendering thread. You can do this using any
standard Java cross-thread communication mechanism. In addition,
one relatively easy way to communicate with your renderer is
to call
queueEvent(Runnable)
. For example:
class MyGLSurfaceView extends GLSurfaceView { private MyRenderer mMyRenderer; public void start() { mMyRenderer = ...; setRenderer(mMyRenderer); } public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) { queueEvent(new Runnable() { // This method will be called on the rendering // thread: public void run() { mMyRenderer.handleDpadCenter(); }}); return true; } return super.onKeyDown(keyCode, event); } }
Modifier and Type | Class and Description |
---|---|
static interface |
GLTextureView.EGLConfigChooser
An interface for choosing an EGLConfig configuration from a list of
potential configurations.
|
static interface |
GLTextureView.EGLContextFactory
An interface for customizing the eglCreateContext and eglDestroyContext calls.
|
static interface |
GLTextureView.EGLWindowSurfaceFactory
An interface for customizing the eglCreateWindowSurface and eglDestroySurface calls.
|
static interface |
GLTextureView.GLWrapper
An interface used to wrap a GL interface.
|
static interface |
GLTextureView.Renderer
A generic renderer interface.
|
android.view.TextureView.SurfaceTextureListener
android.view.View.AccessibilityDelegate, android.view.View.BaseSavedState, android.view.View.DragShadowBuilder, android.view.View.MeasureSpec, android.view.View.OnApplyWindowInsetsListener, android.view.View.OnAttachStateChangeListener, android.view.View.OnCapturedPointerListener, android.view.View.OnClickListener, android.view.View.OnContextClickListener, android.view.View.OnCreateContextMenuListener, android.view.View.OnDragListener, android.view.View.OnFocusChangeListener, android.view.View.OnGenericMotionListener, android.view.View.OnHoverListener, android.view.View.OnKeyListener, android.view.View.OnLayoutChangeListener, android.view.View.OnLongClickListener, android.view.View.OnScrollChangeListener, android.view.View.OnSystemUiVisibilityChangeListener, android.view.View.OnTouchListener, android.view.View.OnUnhandledKeyEventListener
Modifier and Type | Field and Description |
---|---|
static int |
DEBUG_CHECK_GL_ERROR
Check glError() after every GL call and throw an exception if glError indicates
that an error has occurred.
|
static int |
DEBUG_LOG_GL_CALLS
Log GL calls to the system log at "verbose" level with tag "GLSurfaceView".
|
static int |
RENDERMODE_CONTINUOUSLY
The renderer is called
continuously to re-render the scene.
|
static int |
RENDERMODE_WHEN_DIRTY
The renderer only renders
when the surface is created, or when
requestRender() is called. |
ACCESSIBILITY_LIVE_REGION_ASSERTIVE, ACCESSIBILITY_LIVE_REGION_NONE, ACCESSIBILITY_LIVE_REGION_POLITE, ALPHA, AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR, AUTOFILL_HINT_CREDIT_CARD_NUMBER, AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE, AUTOFILL_HINT_EMAIL_ADDRESS, AUTOFILL_HINT_NAME, AUTOFILL_HINT_PASSWORD, AUTOFILL_HINT_PHONE, AUTOFILL_HINT_POSTAL_ADDRESS, AUTOFILL_HINT_POSTAL_CODE, AUTOFILL_HINT_USERNAME, AUTOFILL_TYPE_DATE, AUTOFILL_TYPE_LIST, AUTOFILL_TYPE_NONE, AUTOFILL_TYPE_TEXT, AUTOFILL_TYPE_TOGGLE, DRAG_FLAG_GLOBAL, DRAG_FLAG_GLOBAL_PERSISTABLE_URI_PERMISSION, DRAG_FLAG_GLOBAL_PREFIX_URI_PERMISSION, DRAG_FLAG_GLOBAL_URI_READ, DRAG_FLAG_GLOBAL_URI_WRITE, DRAG_FLAG_OPAQUE, DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FIND_VIEWS_WITH_CONTENT_DESCRIPTION, FIND_VIEWS_WITH_TEXT, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLE, FOCUSABLE_AUTO, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, HAPTIC_FEEDBACK_ENABLED, IMPORTANT_FOR_ACCESSIBILITY_AUTO, IMPORTANT_FOR_ACCESSIBILITY_NO, IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS, IMPORTANT_FOR_ACCESSIBILITY_YES, IMPORTANT_FOR_AUTOFILL_AUTO, IMPORTANT_FOR_AUTOFILL_NO, IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS, IMPORTANT_FOR_AUTOFILL_YES, IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS, INVISIBLE, KEEP_SCREEN_ON, LAYER_TYPE_HARDWARE, LAYER_TYPE_NONE, LAYER_TYPE_SOFTWARE, LAYOUT_DIRECTION_INHERIT, LAYOUT_DIRECTION_LOCALE, LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, NO_ID, NOT_FOCUSABLE, OVER_SCROLL_ALWAYS, OVER_SCROLL_IF_CONTENT_SCROLLS, OVER_SCROLL_NEVER, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, ROTATION, ROTATION_X, ROTATION_Y, SCALE_X, SCALE_Y, SCREEN_STATE_OFF, SCREEN_STATE_ON, SCROLL_AXIS_HORIZONTAL, SCROLL_AXIS_NONE, SCROLL_AXIS_VERTICAL, SCROLL_INDICATOR_BOTTOM, SCROLL_INDICATOR_END, SCROLL_INDICATOR_LEFT, SCROLL_INDICATOR_RIGHT, SCROLL_INDICATOR_START, SCROLL_INDICATOR_TOP, SCROLLBAR_POSITION_DEFAULT, SCROLLBAR_POSITION_LEFT, SCROLLBAR_POSITION_RIGHT, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, STATUS_BAR_HIDDEN, STATUS_BAR_VISIBLE, SYSTEM_UI_FLAG_FULLSCREEN, SYSTEM_UI_FLAG_HIDE_NAVIGATION, SYSTEM_UI_FLAG_IMMERSIVE, SYSTEM_UI_FLAG_IMMERSIVE_STICKY, SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, SYSTEM_UI_FLAG_LAYOUT_STABLE, SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR, SYSTEM_UI_FLAG_LIGHT_STATUS_BAR, SYSTEM_UI_FLAG_LOW_PROFILE, SYSTEM_UI_FLAG_VISIBLE, SYSTEM_UI_LAYOUT_FLAGS, TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_GRAVITY, TEXT_ALIGNMENT_INHERIT, TEXT_ALIGNMENT_TEXT_END, TEXT_ALIGNMENT_TEXT_START, TEXT_ALIGNMENT_VIEW_END, TEXT_ALIGNMENT_VIEW_START, TEXT_DIRECTION_ANY_RTL, TEXT_DIRECTION_FIRST_STRONG, TEXT_DIRECTION_FIRST_STRONG_LTR, TEXT_DIRECTION_FIRST_STRONG_RTL, TEXT_DIRECTION_INHERIT, TEXT_DIRECTION_LOCALE, TEXT_DIRECTION_LTR, TEXT_DIRECTION_RTL, TRANSLATION_X, TRANSLATION_Y, TRANSLATION_Z, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET, X, Y, Z
Constructor and Description |
---|
GLTextureView(android.content.Context context)
Standard View constructor.
|
GLTextureView(android.content.Context context,
android.util.AttributeSet attrs)
Standard View constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
finalize() |
int |
getDebugFlags()
Get the current value of the debug flags.
|
boolean |
getPreserveEGLContextOnPause() |
int |
getRenderMode()
Get the current rendering mode.
|
protected void |
onAttachedToWindow()
This method is used as part of the View class and is not normally
called or subclassed by clients of GLSurfaceView.
|
protected void |
onDetachedFromWindow() |
void |
onLayoutChange(android.view.View v,
int left,
int top,
int right,
int bottom,
int oldLeft,
int oldTop,
int oldRight,
int oldBottom) |
void |
onPause()
Inform the view that the activity is paused.
|
void |
onResume()
Inform the view that the activity is resumed.
|
void |
onSurfaceTextureAvailable(android.graphics.SurfaceTexture surface,
int width,
int height) |
boolean |
onSurfaceTextureDestroyed(android.graphics.SurfaceTexture surface) |
void |
onSurfaceTextureSizeChanged(android.graphics.SurfaceTexture surface,
int width,
int height) |
void |
onSurfaceTextureUpdated(android.graphics.SurfaceTexture surface) |
void |
queueEvent(java.lang.Runnable r)
Queue a runnable to be run on the GL rendering thread.
|
void |
requestRender()
Request that the renderer render a frame.
|
void |
setDebugFlags(int debugFlags)
Set the debug flags to a new value.
|
void |
setEGLConfigChooser(boolean needDepth)
Install a config chooser which will choose a config
as close to 16-bit RGB as possible, with or without an optional depth
buffer as close to 16-bits as possible.
|
void |
setEGLConfigChooser(GLTextureView.EGLConfigChooser configChooser)
Install a custom EGLConfigChooser.
|
void |
setEGLConfigChooser(int redSize,
int greenSize,
int blueSize,
int alphaSize,
int depthSize,
int stencilSize)
Install a config chooser which will choose a config
with at least the specified depthSize and stencilSize,
and exactly the specified redSize, greenSize, blueSize and alphaSize.
|
void |
setEGLContextClientVersion(int version)
Inform the default EGLContextFactory and default EGLConfigChooser
which EGLContext client version to pick.
|
void |
setEGLContextFactory(GLTextureView.EGLContextFactory factory)
Install a custom EGLContextFactory.
|
void |
setEGLWindowSurfaceFactory(GLTextureView.EGLWindowSurfaceFactory factory)
Install a custom EGLWindowSurfaceFactory.
|
void |
setGLWrapper(GLTextureView.GLWrapper glWrapper)
Set the glWrapper.
|
void |
setPreserveEGLContextOnPause(boolean preserveOnPause)
Control whether the EGL context is preserved when the GLSurfaceView is paused and
resumed.
|
void |
setRenderer(GLTextureView.Renderer renderer)
Set the renderer associated with this view.
|
void |
setRenderMode(int renderMode)
Set the rendering mode.
|
void |
surfaceChanged(android.graphics.SurfaceTexture holder,
int format,
int w,
int h)
This method is part of the SurfaceTextureListener.Callback interface, and is
not normally called or subclassed by clients of GLSurfaceView.
|
void |
surfaceCreated(android.graphics.SurfaceTexture holder)
This method is part of the SurfaceTextureListener.Callback interface, and is
not normally called or subclassed by clients of GLSurfaceView.
|
void |
surfaceDestroyed(android.graphics.SurfaceTexture holder)
This method is part of the SurfaceTextureListener.Callback interface, and is
not normally called or subclassed by clients of GLSurfaceView.
|
buildLayer, draw, getBitmap, getBitmap, getBitmap, getLayerType, getSurfaceTexture, getSurfaceTextureListener, getTransform, isAvailable, isOpaque, lockCanvas, lockCanvas, onDraw, onSizeChanged, onVisibilityChanged, setBackgroundDrawable, setForeground, setLayerPaint, setLayerType, setOpaque, setSurfaceTexture, setSurfaceTextureListener, setTransform, unlockCanvasAndPost
addChildrenForAccessibility, addExtraDataToAccessibilityNodeInfo, addFocusables, addFocusables, addKeyboardNavigationClusters, addOnAttachStateChangeListener, addOnLayoutChangeListener, addOnUnhandledKeyEventListener, addTouchables, animate, announceForAccessibility, autofill, autofill, awakenScrollBars, awakenScrollBars, awakenScrollBars, bringToFront, buildDrawingCache, buildDrawingCache, callOnClick, cancelDragAndDrop, cancelLongPress, cancelPendingInputEvents, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, checkInputConnectionProxy, clearAnimation, clearFocus, combineMeasuredStates, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, computeSystemWindowInsets, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createAccessibilityNodeInfo, createContextMenu, destroyDrawingCache, dispatchApplyWindowInsets, dispatchCapturedPointerEvent, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDragEvent, dispatchDraw, dispatchDrawableHotspotChanged, dispatchFinishTemporaryDetach, dispatchGenericFocusedEvent, dispatchGenericMotionEvent, dispatchGenericPointerEvent, dispatchHoverEvent, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPrePerformAccessibilityAction, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPointerCaptureChanged, dispatchPopulateAccessibilityEvent, dispatchProvideAutofillStructure, dispatchProvideStructure, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchSystemUiVisibilityChanged, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, drawableHotspotChanged, drawableStateChanged, findFocus, findViewById, findViewsWithText, findViewWithTag, fitSystemWindows, focusSearch, forceHasOverlappingRendering, forceLayout, generateViewId, getAccessibilityClassName, getAccessibilityDelegate, getAccessibilityLiveRegion, getAccessibilityNodeProvider, getAccessibilityPaneTitle, getAccessibilityTraversalAfter, getAccessibilityTraversalBefore, getAlpha, getAnimation, getAnimationMatrix, getApplicationWindowToken, getAttributeResolutionStack, getAttributeSourceResourceMap, getAutofillHints, getAutofillId, getAutofillType, getAutofillValue, getBackground, getBackgroundTintBlendMode, getBackgroundTintList, getBackgroundTintMode, getBaseline, getBottom, getBottomFadingEdgeStrength, getBottomPaddingOffset, getCameraDistance, getClipBounds, getClipBounds, getClipToOutline, getContentCaptureSession, getContentDescription, getContext, getContextMenuInfo, getDefaultFocusHighlightEnabled, getDefaultSize, getDisplay, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getElevation, getExplicitStyle, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusable, getFocusables, getFocusedRect, getForeground, getForegroundGravity, getForegroundTintBlendMode, getForegroundTintList, getForegroundTintMode, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getHorizontalScrollbarThumbDrawable, getHorizontalScrollbarTrackDrawable, getId, getImportantForAccessibility, getImportantForAutofill, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayoutDirection, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLeftPaddingOffset, getLocalVisibleRect, getLocationInSurface, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextClusterForwardId, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOutlineAmbientShadowColor, getOutlineProvider, getOutlineSpotShadowColor, getOverlay, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getPointerIcon, getResources, getRevealOnFocusHint, getRight, getRightFadingEdgeStrength, getRightPaddingOffset, getRootView, getRootWindowInsets, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollIndicators, getScrollX, getScrollY, getSolidColor, getSourceLayoutResId, getStateListAnimator, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getSystemGestureExclusionRects, getSystemUiVisibility, getTag, getTag, getTextAlignment, getTextDirection, getTooltipText, getTop, getTopFadingEdgeStrength, getTopPaddingOffset, getTouchables, getTouchDelegate, getTransitionAlpha, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getUniqueDrawingId, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarThumbDrawable, getVerticalScrollbarTrackDrawable, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowId, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, getZ, hasExplicitFocusable, hasFocus, hasFocusable, hasNestedScrollingParent, hasOnClickListeners, hasOverlappingRendering, hasPointerCapture, hasTransientState, hasWindowFocus, inflate, invalidate, invalidate, invalidate, invalidateDrawable, invalidateOutline, isAccessibilityFocused, isAccessibilityHeading, isActivated, isAttachedToWindow, isClickable, isContextClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isFocusedByDefault, isForceDarkAllowed, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isImportantForAccessibility, isImportantForAutofill, isInEditMode, isInLayout, isInTouchMode, isKeyboardNavigationCluster, isLaidOut, isLayoutDirectionResolved, isLayoutRequested, isLongClickable, isNestedScrollingEnabled, isPaddingOffsetRequired, isPaddingRelative, isPivotSet, isPressed, isSaveEnabled, isSaveFromParentEnabled, isScreenReaderFocusable, isScrollbarFadingEnabled, isScrollContainer, isSelected, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentResolved, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVisibleToUserForAutofill, jumpDrawablesToCurrentState, keyboardNavigationClusterSearch, layout, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAnimationEnd, onAnimationStart, onApplyWindowInsets, onCancelPendingInputEvents, onCapturedPointerEvent, onCheckIsTextEditor, onConfigurationChanged, onCreateContextMenu, onCreateDrawableState, onCreateInputConnection, onDisplayHint, onDragEvent, onDrawForeground, onDrawScrollBars, onFilterTouchEventForSecurity, onFinishInflate, onFinishTemporaryDetach, onFocusChanged, onGenericMotionEvent, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onLayout, onMeasure, onOverScrolled, onPointerCaptureChange, onPopulateAccessibilityEvent, onProvideAutofillStructure, onProvideAutofillVirtualStructure, onProvideStructure, onProvideVirtualStructure, onResolvePointerIcon, onRestoreInstanceState, onRtlPropertiesChanged, onSaveInstanceState, onScreenStateChanged, onScrollChanged, onSetAlpha, onStartTemporaryDetach, onTouchEvent, onTrackballEvent, onVisibilityAggregated, onWindowFocusChanged, onWindowSystemUiVisibilityChanged, onWindowVisibilityChanged, overScrollBy, performAccessibilityAction, performClick, performContextClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, postInvalidateOnAnimation, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, releasePointerCapture, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, removeOnUnhandledKeyEventListener, requestApplyInsets, requestFitSystemWindows, requestFocus, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestPointerCapture, requestRectangleOnScreen, requestRectangleOnScreen, requestUnbufferedDispatch, requireViewById, resetPivot, resolveSize, resolveSizeAndState, restoreDefaultFocus, restoreHierarchyState, saveAttributeDataForStyleable, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setAccessibilityDelegate, setAccessibilityHeading, setAccessibilityLiveRegion, setAccessibilityPaneTitle, setAccessibilityTraversalAfter, setAccessibilityTraversalBefore, setActivated, setAlpha, setAnimation, setAnimationMatrix, setAutofillHints, setAutofillId, setBackground, setBackgroundColor, setBackgroundResource, setBackgroundTintBlendMode, setBackgroundTintList, setBackgroundTintMode, setBottom, setCameraDistance, setClickable, setClipBounds, setClipToOutline, setContentCaptureSession, setContentDescription, setContextClickable, setDefaultFocusHighlightEnabled, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setElevation, setEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusable, setFocusableInTouchMode, setFocusedByDefault, setForceDarkAllowed, setForegroundGravity, setForegroundTintBlendMode, setForegroundTintList, setForegroundTintMode, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHorizontalScrollbarThumbDrawable, setHorizontalScrollbarTrackDrawable, setHovered, setId, setImportantForAccessibility, setImportantForAutofill, setKeepScreenOn, setKeyboardNavigationCluster, setLabelFor, setLayoutDirection, setLayoutParams, setLeft, setLeftTopRightBottom, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextClusterForwardId, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnApplyWindowInsetsListener, setOnCapturedPointerListener, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOutlineAmbientShadowColor, setOutlineProvider, setOutlineSpotShadowColor, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPointerIcon, setPressed, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScreenReaderFocusable, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollContainer, setScrollIndicators, setScrollIndicators, setScrollX, setScrollY, setSelected, setSoundEffectsEnabled, setStateListAnimator, setSystemGestureExclusionRects, setSystemUiVisibility, setTag, setTag, setTextAlignment, setTextDirection, setTooltipText, setTop, setTouchDelegate, setTransitionAlpha, setTransitionName, setTransitionVisibility, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVerticalScrollbarThumbDrawable, setVerticalScrollbarTrackDrawable, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setX, setY, setZ, showContextMenu, showContextMenu, startActionMode, startActionMode, startAnimation, startDrag, startDragAndDrop, startNestedScroll, stopNestedScroll, toString, transformMatrixToGlobal, transformMatrixToLocal, unscheduleDrawable, unscheduleDrawable, updateDragShadow, verifyDrawable, willNotCacheDrawing, willNotDraw
public static final int RENDERMODE_WHEN_DIRTY
requestRender()
is called.public static final int RENDERMODE_CONTINUOUSLY
getRenderMode()
,
setRenderMode(int)
,
Constant Field Valuespublic static final int DEBUG_CHECK_GL_ERROR
getDebugFlags()
,
setDebugFlags(int)
,
Constant Field Valuespublic static final int DEBUG_LOG_GL_CALLS
getDebugFlags()
,
setDebugFlags(int)
,
Constant Field Valuespublic GLTextureView(android.content.Context context)
setRenderer(com.mousebird.maply.GLTextureView.Renderer)
to register a renderer.public GLTextureView(android.content.Context context, android.util.AttributeSet attrs)
setRenderer(com.mousebird.maply.GLTextureView.Renderer)
to register a renderer.protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public void setGLWrapper(GLTextureView.GLWrapper glWrapper)
GLTextureView.GLWrapper.wrap(GL)
method is called
whenever a surface is created. A GLWrapper can be used to wrap
the GL object that's passed to the renderer. Wrapping a GL
object enables examining and modifying the behavior of the
GL calls made by the renderer.
Wrapping is typically used for debugging purposes.
The default value is null.
glWrapper
- the new GLWrapperpublic void setDebugFlags(int debugFlags)
debugFlags
- the new debug flagsDEBUG_CHECK_GL_ERROR
,
DEBUG_LOG_GL_CALLS
public int getDebugFlags()
public void setPreserveEGLContextOnPause(boolean preserveOnPause)
If set to true, then the EGL context may be preserved when the GLSurfaceView is paused. Whether the EGL context is actually preserved or not depends upon whether the Android device that the program is running on can support an arbitrary number of EGL contexts or not. Devices that can only support a limited number of EGL contexts must release the EGL context in order to allow multiple applications to share the GPU.
If set to false, the EGL context will be released when the GLSurfaceView is paused, and recreated when the GLSurfaceView is resumed.
The default is false.
preserveOnPause
- preserve the EGL context when pausedpublic boolean getPreserveEGLContextOnPause()
public void setRenderer(GLTextureView.Renderer renderer)
This method should be called once and only once in the life-cycle of a GLSurfaceView.
The following GLSurfaceView methods can only be called before setRenderer is called:
setEGLConfigChooser(boolean)
setEGLConfigChooser(EGLConfigChooser)
setEGLConfigChooser(int, int, int, int, int, int)
The following GLSurfaceView methods can only be called after setRenderer is called:
renderer
- the renderer to use to perform OpenGL drawing.public void setEGLContextFactory(GLTextureView.EGLContextFactory factory)
If this method is
called, it must be called before setRenderer(Renderer)
is called.
If this method is not called, then by default a context will be created with no shared context and with a null attribute list.
public void setEGLWindowSurfaceFactory(GLTextureView.EGLWindowSurfaceFactory factory)
If this method is
called, it must be called before setRenderer(Renderer)
is called.
If this method is not called, then by default a window surface will be created with a null attribute list.
public void setEGLConfigChooser(GLTextureView.EGLConfigChooser configChooser)
If this method is
called, it must be called before setRenderer(Renderer)
is called.
If no setEGLConfigChooser method is called, then by default the view will choose an EGLConfig that is compatible with the current android.view.Surface, with a depth buffer depth of at least 16 bits.
configChooser
- public void setEGLConfigChooser(boolean needDepth)
If this method is
called, it must be called before setRenderer(Renderer)
is called.
If no setEGLConfigChooser method is called, then by default the view will choose an RGB_888 surface with a depth buffer depth of at least 16 bits.
needDepth
- public void setEGLConfigChooser(int redSize, int greenSize, int blueSize, int alphaSize, int depthSize, int stencilSize)
If this method is
called, it must be called before setRenderer(Renderer)
is called.
If no setEGLConfigChooser method is called, then by default the view will choose an RGB_888 surface with a depth buffer depth of at least 16 bits.
public void setEGLContextClientVersion(int version)
Use this method to create an OpenGL ES 2.0-compatible context. Example:
public MyView(Context context) { super(context); setEGLContextClientVersion(2); // Pick an OpenGL ES 2.0 context. setRenderer(new MyRenderer()); }
Note: Activities which require OpenGL ES 2.0 should indicate this by setting @lt;uses-feature android:glEsVersion="0x00020000" /> in the activity's AndroidManifest.xml file.
If this method is called, it must be called before setRenderer(Renderer)
is called.
This method only affects the behavior of the default EGLContexFactory and the
default EGLConfigChooser. If
setEGLContextFactory(EGLContextFactory)
has been called, then the supplied
EGLContextFactory is responsible for creating an OpenGL ES 2.0-compatible context.
If
setEGLConfigChooser(EGLConfigChooser)
has been called, then the supplied
EGLConfigChooser is responsible for choosing an OpenGL ES 2.0-compatible config.
version
- The EGLContext client version to choose. Use 2 for OpenGL ES 2.0public void setRenderMode(int renderMode)
requestRender()
is called. Defaults to RENDERMODE_CONTINUOUSLY.
Using RENDERMODE_WHEN_DIRTY can improve battery life and overall system performance by allowing the GPU and CPU to idle when the view does not need to be updated.
This method can only be called after setRenderer(Renderer)
renderMode
- one of the RENDERMODE_X constantsRENDERMODE_CONTINUOUSLY
,
RENDERMODE_WHEN_DIRTY
public int getRenderMode()
RENDERMODE_CONTINUOUSLY
,
RENDERMODE_WHEN_DIRTY
public void requestRender()
RENDERMODE_WHEN_DIRTY
, so that frames are only rendered on demand.
May be called
from any thread. Must not be called before a renderer has been set.public void onSurfaceTextureUpdated(android.graphics.SurfaceTexture surface)
onSurfaceTextureUpdated
in interface android.view.TextureView.SurfaceTextureListener
public void surfaceCreated(android.graphics.SurfaceTexture holder)
public void onSurfaceTextureAvailable(android.graphics.SurfaceTexture surface, int width, int height)
onSurfaceTextureAvailable
in interface android.view.TextureView.SurfaceTextureListener
public void surfaceDestroyed(android.graphics.SurfaceTexture holder)
public boolean onSurfaceTextureDestroyed(android.graphics.SurfaceTexture surface)
onSurfaceTextureDestroyed
in interface android.view.TextureView.SurfaceTextureListener
public void surfaceChanged(android.graphics.SurfaceTexture holder, int format, int w, int h)
public void onSurfaceTextureSizeChanged(android.graphics.SurfaceTexture surface, int width, int height)
onSurfaceTextureSizeChanged
in interface android.view.TextureView.SurfaceTextureListener
public void onLayoutChange(android.view.View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom)
onLayoutChange
in interface android.view.View.OnLayoutChangeListener
public void onPause()
public void onResume()
public void queueEvent(java.lang.Runnable r)
r
- the runnable to be run on the GL rendering thread.protected void onAttachedToWindow()
onAttachedToWindow
in class android.view.TextureView
protected void onDetachedFromWindow()
onDetachedFromWindow
in class android.view.View