Loading core/java/android/view/DisplayListCanvas.java +12 −3 Original line number Diff line number Diff line Loading @@ -20,7 +20,12 @@ import android.annotation.NonNull; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.CanvasProperty; import android.graphics.NinePatch; import android.graphics.Paint; import android.graphics.Path; import android.graphics.Picture; import android.graphics.Rect; import android.graphics.RectF; import android.util.Pools.SynchronizedPool; /** Loading Loading @@ -201,12 +206,16 @@ public class DisplayListCanvas extends Canvas { * Draws the specified layer onto this canvas. * * @param layer The layer to composite on this canvas * @param x The left coordinate of the layer * @param y The top coordinate of the layer * @param paint The paint used to draw the layer */ void drawHardwareLayer(HardwareLayer layer) { nDrawLayer(mNativeCanvasWrapper, layer.getLayerHandle()); void drawHardwareLayer(HardwareLayer layer, float x, float y, Paint paint) { layer.setLayerPaint(paint); nDrawLayer(mNativeCanvasWrapper, layer.getLayerHandle(), x, y); } private static native void nDrawLayer(long renderer, long layer); private static native void nDrawLayer(long renderer, long layer, float x, float y); /////////////////////////////////////////////////////////////////////////// // Drawing Loading core/java/android/view/HardwareLayer.java +4 −0 Original line number Diff line number Diff line Loading @@ -150,4 +150,8 @@ final class HardwareLayer { private static native void nSetSurfaceTexture(long layerUpdater, SurfaceTexture surface, boolean isAlreadyAttached); private static native void nUpdateSurfaceTexture(long layerUpdater); private static native void nUpdateRenderLayer(long layerUpdater, long displayList, int left, int top, int right, int bottom); private static native int nGetTexName(long layerUpdater); } core/java/android/view/TextureView.java +11 −17 Original line number Diff line number Diff line Loading @@ -319,25 +319,11 @@ public class TextureView extends View { */ @Override public final void draw(Canvas canvas) { // NOTE: Maintain this carefully (see View#draw) // NOTE: Maintain this carefully (see View.java) mPrivateFlags = (mPrivateFlags & ~PFLAG_DIRTY_MASK) | PFLAG_DRAWN; /* Simplify drawing to guarantee the layer is the only thing drawn - so e.g. no background, scrolling, or fading edges. This guarantees all drawing is in the layer, so drawing properties (alpha, layer paint) affect all of the content of a TextureView. */ if (canvas.isHardwareAccelerated()) { DisplayListCanvas displayListCanvas = (DisplayListCanvas) canvas; HardwareLayer layer = getHardwareLayer(); if (layer != null) { applyUpdate(); applyTransformMatrix(); mLayer.setLayerPaint(mLayerPaint); // ensure layer paint is up to date displayListCanvas.drawHardwareLayer(layer); } } } /** Loading Loading @@ -373,7 +359,12 @@ public class TextureView extends View { invalidate(true); } @Override HardwareLayer getHardwareLayer() { // NOTE: Maintain these two lines very carefully (see View.java) mPrivateFlags |= PFLAG_DRAWN | PFLAG_DRAWING_CACHE_VALID; mPrivateFlags &= ~PFLAG_DIRTY_MASK; if (mLayer == null) { if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) { return null; Loading Loading @@ -411,6 +402,9 @@ public class TextureView extends View { mSurface.setDefaultBufferSize(getWidth(), getHeight()); } applyUpdate(); applyTransformMatrix(); return mLayer; } Loading core/java/android/view/View.java +14 −1 Original line number Diff line number Diff line Loading @@ -15001,6 +15001,16 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } } /** * If this View draws with a HardwareLayer, returns it. * Otherwise returns null * * TODO: Only TextureView uses this, can we eliminate it? */ HardwareLayer getHardwareLayer() { return null; } /** * Destroys all hardware rendering resources. This method is invoked * when the system needs to reclaim resources. Upon execution of this Loading Loading @@ -15151,7 +15161,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, canvas.setHighContrastText(mAttachInfo.mHighContrastText); try { if (layerType == LAYER_TYPE_SOFTWARE) { final HardwareLayer layer = getHardwareLayer(); if (layer != null && layer.isValid()) { canvas.drawHardwareLayer(layer, 0, 0, mLayerPaint); } else if (layerType == LAYER_TYPE_SOFTWARE) { buildDrawingCache(true); Bitmap cache = getDrawingCache(true); if (cache != null) { core/jni/android_view_DisplayListCanvas.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -139,10 +139,10 @@ static void android_view_DisplayListCanvas_drawRenderNode(JNIEnv* env, // ---------------------------------------------------------------------------- static void android_view_DisplayListCanvas_drawLayer(JNIEnv* env, jobject clazz, jlong rendererPtr, jlong layerPtr) { jlong rendererPtr, jlong layerPtr, jfloat x, jfloat y) { DisplayListCanvas* renderer = reinterpret_cast<DisplayListCanvas*>(rendererPtr); DeferredLayerUpdater* layer = reinterpret_cast<DeferredLayerUpdater*>(layerPtr); renderer->drawLayer(layer); renderer->drawLayer(layer, x, y); } // ---------------------------------------------------------------------------- Loading Loading @@ -192,7 +192,7 @@ static JNINativeMethod gMethods[] = { { "nCreateDisplayListCanvas", "(II)J", (void*) android_view_DisplayListCanvas_createDisplayListCanvas }, { "nResetDisplayListCanvas", "(JII)V", (void*) android_view_DisplayListCanvas_resetDisplayListCanvas }, { "nDrawLayer", "(JJ)V", (void*) android_view_DisplayListCanvas_drawLayer }, { "nDrawLayer", "(JJFF)V", (void*) android_view_DisplayListCanvas_drawLayer }, { "nGetMaximumTextureWidth", "()I", (void*) android_view_DisplayListCanvas_getMaxTextureWidth }, { "nGetMaximumTextureHeight", "()I", (void*) android_view_DisplayListCanvas_getMaxTextureHeight }, Loading Loading
core/java/android/view/DisplayListCanvas.java +12 −3 Original line number Diff line number Diff line Loading @@ -20,7 +20,12 @@ import android.annotation.NonNull; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.CanvasProperty; import android.graphics.NinePatch; import android.graphics.Paint; import android.graphics.Path; import android.graphics.Picture; import android.graphics.Rect; import android.graphics.RectF; import android.util.Pools.SynchronizedPool; /** Loading Loading @@ -201,12 +206,16 @@ public class DisplayListCanvas extends Canvas { * Draws the specified layer onto this canvas. * * @param layer The layer to composite on this canvas * @param x The left coordinate of the layer * @param y The top coordinate of the layer * @param paint The paint used to draw the layer */ void drawHardwareLayer(HardwareLayer layer) { nDrawLayer(mNativeCanvasWrapper, layer.getLayerHandle()); void drawHardwareLayer(HardwareLayer layer, float x, float y, Paint paint) { layer.setLayerPaint(paint); nDrawLayer(mNativeCanvasWrapper, layer.getLayerHandle(), x, y); } private static native void nDrawLayer(long renderer, long layer); private static native void nDrawLayer(long renderer, long layer, float x, float y); /////////////////////////////////////////////////////////////////////////// // Drawing Loading
core/java/android/view/HardwareLayer.java +4 −0 Original line number Diff line number Diff line Loading @@ -150,4 +150,8 @@ final class HardwareLayer { private static native void nSetSurfaceTexture(long layerUpdater, SurfaceTexture surface, boolean isAlreadyAttached); private static native void nUpdateSurfaceTexture(long layerUpdater); private static native void nUpdateRenderLayer(long layerUpdater, long displayList, int left, int top, int right, int bottom); private static native int nGetTexName(long layerUpdater); }
core/java/android/view/TextureView.java +11 −17 Original line number Diff line number Diff line Loading @@ -319,25 +319,11 @@ public class TextureView extends View { */ @Override public final void draw(Canvas canvas) { // NOTE: Maintain this carefully (see View#draw) // NOTE: Maintain this carefully (see View.java) mPrivateFlags = (mPrivateFlags & ~PFLAG_DIRTY_MASK) | PFLAG_DRAWN; /* Simplify drawing to guarantee the layer is the only thing drawn - so e.g. no background, scrolling, or fading edges. This guarantees all drawing is in the layer, so drawing properties (alpha, layer paint) affect all of the content of a TextureView. */ if (canvas.isHardwareAccelerated()) { DisplayListCanvas displayListCanvas = (DisplayListCanvas) canvas; HardwareLayer layer = getHardwareLayer(); if (layer != null) { applyUpdate(); applyTransformMatrix(); mLayer.setLayerPaint(mLayerPaint); // ensure layer paint is up to date displayListCanvas.drawHardwareLayer(layer); } } } /** Loading Loading @@ -373,7 +359,12 @@ public class TextureView extends View { invalidate(true); } @Override HardwareLayer getHardwareLayer() { // NOTE: Maintain these two lines very carefully (see View.java) mPrivateFlags |= PFLAG_DRAWN | PFLAG_DRAWING_CACHE_VALID; mPrivateFlags &= ~PFLAG_DIRTY_MASK; if (mLayer == null) { if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) { return null; Loading Loading @@ -411,6 +402,9 @@ public class TextureView extends View { mSurface.setDefaultBufferSize(getWidth(), getHeight()); } applyUpdate(); applyTransformMatrix(); return mLayer; } Loading
core/java/android/view/View.java +14 −1 Original line number Diff line number Diff line Loading @@ -15001,6 +15001,16 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } } /** * If this View draws with a HardwareLayer, returns it. * Otherwise returns null * * TODO: Only TextureView uses this, can we eliminate it? */ HardwareLayer getHardwareLayer() { return null; } /** * Destroys all hardware rendering resources. This method is invoked * when the system needs to reclaim resources. Upon execution of this Loading Loading @@ -15151,7 +15161,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, canvas.setHighContrastText(mAttachInfo.mHighContrastText); try { if (layerType == LAYER_TYPE_SOFTWARE) { final HardwareLayer layer = getHardwareLayer(); if (layer != null && layer.isValid()) { canvas.drawHardwareLayer(layer, 0, 0, mLayerPaint); } else if (layerType == LAYER_TYPE_SOFTWARE) { buildDrawingCache(true); Bitmap cache = getDrawingCache(true); if (cache != null) {
core/jni/android_view_DisplayListCanvas.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -139,10 +139,10 @@ static void android_view_DisplayListCanvas_drawRenderNode(JNIEnv* env, // ---------------------------------------------------------------------------- static void android_view_DisplayListCanvas_drawLayer(JNIEnv* env, jobject clazz, jlong rendererPtr, jlong layerPtr) { jlong rendererPtr, jlong layerPtr, jfloat x, jfloat y) { DisplayListCanvas* renderer = reinterpret_cast<DisplayListCanvas*>(rendererPtr); DeferredLayerUpdater* layer = reinterpret_cast<DeferredLayerUpdater*>(layerPtr); renderer->drawLayer(layer); renderer->drawLayer(layer, x, y); } // ---------------------------------------------------------------------------- Loading Loading @@ -192,7 +192,7 @@ static JNINativeMethod gMethods[] = { { "nCreateDisplayListCanvas", "(II)J", (void*) android_view_DisplayListCanvas_createDisplayListCanvas }, { "nResetDisplayListCanvas", "(JII)V", (void*) android_view_DisplayListCanvas_resetDisplayListCanvas }, { "nDrawLayer", "(JJ)V", (void*) android_view_DisplayListCanvas_drawLayer }, { "nDrawLayer", "(JJFF)V", (void*) android_view_DisplayListCanvas_drawLayer }, { "nGetMaximumTextureWidth", "()I", (void*) android_view_DisplayListCanvas_getMaxTextureWidth }, { "nGetMaximumTextureHeight", "()I", (void*) android_view_DisplayListCanvas_getMaxTextureHeight }, Loading