diff options
| author | Chris Craik <ccraik@google.com> | 2015-08-19 14:21:42 -0700 |
|---|---|---|
| committer | Chris Craik <ccraik@google.com> | 2015-08-19 16:59:45 -0700 |
| commit | 20a248934c67b19c8734362dba76a5cc94254686 (patch) | |
| tree | 4e85f51c30b3fb3d8fdafdbec40dc5a09947dcf9 /core/java/android/view/TextureView.java | |
| parent | e264f9a51ef2158df345c3c4b19dd6098e959141 (diff) | |
Simplify TextureView draw path
bug:20461288
Change-Id: I239fbd26ab2177481c84feb62a1da68faeb634ac
Diffstat (limited to 'core/java/android/view/TextureView.java')
| -rw-r--r-- | core/java/android/view/TextureView.java | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java index cdc196e1c371..23bd3ac17954 100644 --- a/core/java/android/view/TextureView.java +++ b/core/java/android/view/TextureView.java @@ -302,11 +302,25 @@ public class TextureView extends View { */ @Override public final void draw(Canvas canvas) { - // NOTE: Maintain this carefully (see View.java) + // NOTE: Maintain this carefully (see View#draw) mPrivateFlags = (mPrivateFlags & ~PFLAG_DIRTY_MASK) | PFLAG_DRAWN; - applyUpdate(); - applyTransformMatrix(); + /* 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); + } + } } /** @@ -342,12 +356,7 @@ 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; @@ -385,9 +394,6 @@ public class TextureView extends View { mSurface.setDefaultBufferSize(getWidth(), getHeight()); } - applyUpdate(); - applyTransformMatrix(); - return mLayer; } |
