From 9b7887736a2af9806e30447453b22b86c12969e5 Mon Sep 17 00:00:00 2001 From: Stan Iliev Date: Fri, 28 Sep 2018 18:44:26 -0400 Subject: [PATCH] Disable blending for opaque TextureView Opaque TextureView set by TextureView.setOpaque(true), should draw with SRC blending, which in practice disables GL blending. Test: Ran Naver app, which is using opaque TextureView Bug: 113845024 Change-Id: I5daa455a72b0ded50d6f9578f3b8a8701532f9d4 Merged-In: I5daa455a72b0ded50d6f9578f3b8a8701532f9d4 (cherry picked from commit 8fc3d8e09d7788a96559d31dc502e99fce4f1378) --- libs/hwui/GlLayer.cpp | 8 ++++++++ libs/hwui/GlLayer.h | 2 ++ libs/hwui/Layer.cpp | 4 ++-- libs/hwui/Layer.h | 12 ++++++------ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/libs/hwui/GlLayer.cpp b/libs/hwui/GlLayer.cpp index 42ae29d768985..8357f8ebde2e4 100644 --- a/libs/hwui/GlLayer.cpp +++ b/libs/hwui/GlLayer.cpp @@ -72,5 +72,13 @@ void GlLayer::generateTexture() { } } +SkBlendMode GlLayer::getMode() const { + if (texture.blend || mode != SkBlendMode::kSrcOver) { + return mode; + } else { + return SkBlendMode::kSrc; + } +} + }; // namespace uirenderer }; // namespace android diff --git a/libs/hwui/GlLayer.h b/libs/hwui/GlLayer.h index 28749a0d125c6..4cf8f2522ff96 100644 --- a/libs/hwui/GlLayer.h +++ b/libs/hwui/GlLayer.h @@ -66,6 +66,8 @@ public: */ void onGlContextLost(); + SkBlendMode getMode() const override; + private: Caches& caches; diff --git a/libs/hwui/Layer.cpp b/libs/hwui/Layer.cpp index fb8f0337c95e4..b86ae121af554 100644 --- a/libs/hwui/Layer.cpp +++ b/libs/hwui/Layer.cpp @@ -27,10 +27,10 @@ Layer::Layer(RenderState& renderState, Api api, sk_sp colorFilter SkBlendMode mode) : GpuMemoryTracker(GpuObjectType::Layer) , mRenderState(renderState) + , mode(mode) , mApi(api) , mColorFilter(colorFilter) - , alpha(alpha) - , mode(mode) { + , alpha(alpha) { // TODO: This is a violation of Android's typical ref counting, but it // preserves the old inc/dec ref locations. This should be changed... incStrong(nullptr); diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h index 89bcddcc96d0b..d2736adf2f56b 100644 --- a/libs/hwui/Layer.h +++ b/libs/hwui/Layer.h @@ -72,7 +72,7 @@ public: inline int getAlpha() const { return alpha; } - inline SkBlendMode getMode() const { return mode; } + virtual SkBlendMode getMode() const { return mode; } inline SkColorFilter* getColorFilter() const { return mColorFilter.get(); } @@ -100,6 +100,11 @@ protected: RenderState& mRenderState; + /** + * Blending mode of the layer. + */ + SkBlendMode mode; + private: void buildColorSpaceWithFilter(); @@ -130,11 +135,6 @@ private: */ int alpha; - /** - * Blending mode of the layer. - */ - SkBlendMode mode; - /** * Optional texture coordinates transform. */