LayerTypeGuard

Guards View.LAYER_TYPE_HARDWARE promotions against the device's GPU max texture size.

A hardware layer is backed by a single GPU texture; if a view is larger than the device's GL_MAX_TEXTURE_SIZE, hwui fails to allocate the layer and aborts at draw time with an UNCATCHABLE native crash ("Unable to create layer for , size WxH max size N"). This object lets the host app supply the device cap so oversized hardware layers are downgraded to LayerType.LAYER_TYPE_NONE instead of crashing the app.

Properties

Link copied to clipboard

Max width/height in px allowed for a LayerType.LAYER_TYPE_HARDWARE layer before guardHardwareLayerForSize downgrades it. The host app should set this to the device's GL_MAX_TEXTURE_SIZE (e.g. from a cached glGetIntegerv(GL_MAX_TEXTURE_SIZE)) at startup.

Functions

Link copied to clipboard

Returns requested unchanged, except a LayerType.LAYER_TYPE_HARDWARE request for a view whose width or height exceeds maxHardwareLayerSizePx (when that is set > 0) is downgraded to LayerType.LAYER_TYPE_NONE, to avoid the uncatchable hwui "Unable to create layer" native abort on views larger than the GPU's GL_MAX_TEXTURE_SIZE.