FileDocCategorySizeDatePackage
HardwareRenderer.javaAPI DocAndroid 5.1 API16084Thu Mar 12 22:22:10 GMT 2015android.view

HardwareRenderer

public abstract class HardwareRenderer extends Object
Interface for rendering a view hierarchy using hardware acceleration.
hide

Fields Summary
static final String
LOG_TAG
private static final String
CACHE_PATH_SHADERS
Name of the file that holds the shaders cache.
static final String
RENDER_DIRTY_REGIONS_PROPERTY
System property used to enable or disable dirty regions invalidation. This property is only queried if {@link #RENDER_DIRTY_REGIONS} is true. The default value of this property is assumed to be true. Possible values: "true", to enable partial invalidates "false", to disable partial invalidates
public static final String
PROFILE_PROPERTY
System property used to enable or disable hardware rendering profiling. The default value of this property is assumed to be false. When profiling is enabled, the adb shell dumpsys gfxinfo command will output extra information about the time taken to execute by the last frames. Possible values: "true", to enable profiling "visual_bars", to enable profiling and visualize the results on screen "false", to disable profiling
public static final String
PROFILE_PROPERTY_VISUALIZE_BARS
Value for {@link #PROFILE_PROPERTY}. When the property is set to this value, profiling data will be visualized on screen as a bar chart.
static final String
PROFILE_MAXFRAMES_PROPERTY
System property used to specify the number of frames to be used when doing hardware rendering profiling. The default value of this property is #PROFILE_MAX_FRAMES. When profiling is enabled, the adb shell dumpsys gfxinfo command will output extra information about the time taken to execute by the last frames. Possible values: "60", to set the limit of frames to 60
static final String
PRINT_CONFIG_PROPERTY
System property used to debug EGL configuration choice. Possible values: "choice", print the chosen configuration only "all", print all possible configurations
public static final String
DEBUG_DIRTY_REGIONS_PROPERTY
Turn on to draw dirty regions every other frame. Possible values: "true", to enable dirty regions debugging "false", to disable dirty regions debugging
public static final String
DEBUG_SHOW_LAYERS_UPDATES_PROPERTY
Turn on to flash hardware layers when they update. Possible values: "true", to enable hardware layers updates debugging "false", to disable hardware layers updates debugging
public static final String
DEBUG_OVERDRAW_PROPERTY
Controls overdraw debugging. Possible values: "false", to disable overdraw debugging "show", to show overdraw areas on screen "count", to display an overdraw counter
public static final String
OVERDRAW_PROPERTY_SHOW
Value for {@link #DEBUG_OVERDRAW_PROPERTY}. When the property is set to this value, overdraw will be shown on screen by coloring pixels.
public static final String
DEBUG_SHOW_NON_RECTANGULAR_CLIP_PROPERTY
Turn on to debug non-rectangular clip operations. Possible values: "hide", to disable this debug mode "highlight", highlight drawing commands tested against a non-rectangular clip "stencil", renders the clip region on screen when set
public static boolean
sRendererDisabled
A process can set this flag to false to prevent the use of hardware rendering.
public static boolean
sSystemRendererDisabled
Further hardware renderer disabling for the system process.
private boolean
mEnabled
private boolean
mRequested
public static boolean
sTrimForeground
Constructors Summary
Methods Summary
abstract voidbuildLayer(RenderNode node)

abstract booleancopyLayerInto(HardwareLayer layer, android.graphics.Bitmap bitmap)

static android.view.HardwareRenderercreate(android.content.Context context, boolean translucent)
Creates a hardware renderer using OpenGL.

param
translucent True if the surface is translucent, false otherwise
return
A hardware renderer backed by OpenGL.

        HardwareRenderer renderer = null;
        if (GLES20Canvas.isAvailable()) {
            renderer = new ThreadedRenderer(context, translucent);
        }
        return renderer;
    
abstract HardwareLayercreateTextureLayer()
Creates a new hardware layer. A hardware layer built by calling this method will be treated as a texture layer, instead of as a render target.

return
A hardware layer

abstract voiddestroy()
Destroys the hardware rendering context.

abstract voiddestroyHardwareResources(View view)
Destroys all hardware rendering resources associated with the specified view hierarchy.

param
view The root of the view hierarchy

abstract voiddetachSurfaceTexture(long hardwareLayer)
Detaches the layer's surface texture from the GL context and releases the texture id

public static voiddisable(boolean system)
Invoke this method to disable hardware rendering in the current process.

hide


                     
         
        sRendererDisabled = true;
        if (system) {
            sSystemRendererDisabled = true;
        }
    
abstract voiddraw(View view, View.AttachInfo attachInfo, android.view.HardwareRenderer$HardwareDrawCallbacks callbacks)
Draws the specified view.

param
view The view to draw.
param
attachInfo AttachInfo tied to the specified view.
param
callbacks Callbacks invoked when drawing happens.

abstract voiddumpGfxInfo(java.io.PrintWriter pw, java.io.FileDescriptor fd)
Outputs extra debugging information in the specified file descriptor.

public static voidenableForegroundTrimming()
Controls whether or not the hardware renderer should aggressively trim memory. Note that this must not be set for any process that uses WebView! This should be only used by system_process or similar that do not go into the background.


                                                 
        
        sTrimForeground = true;
    
abstract voidfence()
Blocks until all previously queued work has completed.

abstract intgetHeight()
Gets the current height of the surface. This is the height that the surface was last set to in a call to {@link #setup(int, int, Rect)}.

return
the current width of the surface

abstract intgetWidth()
Gets the current width of the surface. This is the width that the surface was last set to in a call to {@link #setup(int, int, Rect)}.

return
the current width of the surface

abstract booleaninitialize(Surface surface)
Initializes the hardware renderer for the specified surface.

param
surface The surface to hardware accelerate
return
True if the initialization was successful, false otherwise.

booleaninitializeIfNeeded(int width, int height, Surface surface, android.graphics.Rect surfaceInsets)
Initializes the hardware renderer for the specified surface and setup the renderer for drawing, if needed. This is invoked when the ViewAncestor has potentially lost the hardware renderer. The hardware renderer should be reinitialized and setup when the render {@link #isRequested()} and {@link #isEnabled()}.

param
width The width of the drawing surface.
param
height The height of the drawing surface.
param
surface The surface to hardware accelerate
param
surfaceInsets The drawing surface insets to apply
return
true if the surface was initialized, false otherwise. Returning false might mean that the surface was already initialized.

        if (isRequested()) {
            // We lost the gl context, so recreate it.
            if (!isEnabled()) {
                if (initialize(surface)) {
                    setup(width, height, surfaceInsets);
                    return true;
                }
            }
        }
        return false;
    
abstract voidinvalidate(Surface surface)
This method should be invoked whenever the current hardware renderer context should be reset.

param
surface The surface to hardware accelerate

abstract voidinvalidateRoot()
Indicates that the content drawn by HardwareDrawCallbacks needs to be updated, which will be done by the next call to draw()

public static booleanisAvailable()
Indicates whether hardware acceleration is available under any form for the view hierarchy.

return
True if the view hierarchy can potentially be hardware accelerated, false otherwise

        return GLES20Canvas.isAvailable();
    
booleanisEnabled()
Indicates whether hardware acceleration is currently enabled.

return
True if hardware acceleration is in use, false otherwise.

        return mEnabled;
    
booleanisRequested()
Indicates whether hardware acceleration is currently request but not necessarily enabled yet.

return
True if requested, false otherwise.

        return mRequested;
    
abstract booleanloadSystemProperties()
Loads system properties used by the renderer. This method is invoked whenever system properties are modified. Implementations can use this to trigger live updates of the renderer based on properties.

return
True if a property has changed.

abstract voidnotifyFramePending()
Called by {@link ViewRootImpl} when a new performTraverals is scheduled.

abstract voidonLayerDestroyed(HardwareLayer layer)
Tells the HardwareRenderer that the layer is destroyed. The renderer should remove the layer from any update queues.

abstract booleanpauseSurface(Surface surface)
Stops any rendering into the surface. Use this if it is unclear whether or not the surface used by the HardwareRenderer will be changing. It Suspends any rendering into the surface, but will not do any destruction

abstract voidpushLayerUpdate(HardwareLayer layer)
Indicates that the specified hardware layer needs to be updated as soon as possible.

param
layer The hardware layer that needs an update

abstract voidregisterAnimatingRenderNode(RenderNode animator)

voidsetEnabled(boolean enabled)
Indicates whether hardware acceleration is currently enabled.

param
enabled True if the hardware renderer is in use, false otherwise.

        mEnabled = enabled;
    
abstract voidsetName(java.lang.String name)
Optional, sets the name of the renderer. Useful for debugging purposes.

param
name The name of this renderer, can be null

abstract voidsetOpaque(boolean opaque)
Change the HardwareRenderer's opacity

voidsetRequested(boolean requested)
Indicates whether hardware acceleration is currently requested but not necessarily enabled yet.

return
True to request hardware acceleration, false otherwise.

        mRequested = requested;
    
abstract voidsetup(int width, int height, android.graphics.Rect surfaceInsets)
Sets up the renderer for drawing.

param
width The width of the drawing surface.
param
height The height of the drawing surface.
param
surfaceInsets The drawing surface insets to apply

public static voidsetupDiskCache(java.io.File cacheDir)
Sets the directory to use as a persistent storage for hardware rendering resources.

param
cacheDir A directory the current process can write to
hide

        ThreadedRenderer.setupShadersDiskCache(new File(cacheDir, CACHE_PATH_SHADERS).getAbsolutePath());
    
abstract voidstopDrawing()
Prevents any further drawing until draw() is called. This is a signal that the contents of the RenderNode tree are no longer safe to play back. In practice this usually means that there are Functor pointers in the display list that are no longer valid.

static voidtrimMemory(int level)
Invoke this method when the system is running out of memory. This method will attempt to recover as much memory as possible, based on the specified hint.

param
level Hint about the amount of memory that should be trimmed, see {@link android.content.ComponentCallbacks}

        ThreadedRenderer.trimMemory(level);
    
abstract voidupdateSurface(Surface surface)
Updates the hardware renderer for the specified surface.

param
surface The surface to hardware accelerate