Merge "Disable Webview Overlay when invisible" into sc-dev
This commit is contained in:
@@ -133,6 +133,12 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onRemovedFromTree() {
|
||||||
|
if (mImpl) {
|
||||||
|
mImpl->onRemovedFromTree();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] bool hasText() const {
|
[[nodiscard]] bool hasText() const {
|
||||||
return mImpl && mImpl->hasText();
|
return mImpl && mImpl->hasText();
|
||||||
}
|
}
|
||||||
@@ -172,6 +178,7 @@ private:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void syncContents(const WebViewSyncData& data) { }
|
void syncContents(const WebViewSyncData& data) { }
|
||||||
|
void onRemovedFromTree() { }
|
||||||
void applyColorTransform(ColorTransform transform) { }
|
void applyColorTransform(ColorTransform transform) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -298,6 +305,10 @@ public:
|
|||||||
apply([&](auto& it) { it.syncContents(data); });
|
apply([&](auto& it) { it.syncContents(data); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onRemovedFromTree() {
|
||||||
|
apply([&](auto& it) { it.onRemovedFromTree(); });
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] bool hasText() const {
|
[[nodiscard]] bool hasText() const {
|
||||||
return apply([](const auto& it) -> auto { return it.hasText(); });
|
return apply([](const auto& it) -> auto { return it.hasText(); });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "DamageAccumulator.h"
|
#include "DamageAccumulator.h"
|
||||||
#include "Debug.h"
|
#include "Debug.h"
|
||||||
|
#include "Properties.h"
|
||||||
#include "TreeInfo.h"
|
#include "TreeInfo.h"
|
||||||
#include "VectorDrawable.h"
|
#include "VectorDrawable.h"
|
||||||
#include "private/hwui/WebViewFunctor.h"
|
#include "private/hwui/WebViewFunctor.h"
|
||||||
@@ -473,6 +474,9 @@ void RenderNode::decParentRefCount(TreeObserver& observer, TreeInfo* info) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RenderNode::onRemovedFromTree(TreeInfo* info) {
|
void RenderNode::onRemovedFromTree(TreeInfo* info) {
|
||||||
|
if (Properties::enableWebViewOverlays && mDisplayList) {
|
||||||
|
mDisplayList.onRemovedFromTree();
|
||||||
|
}
|
||||||
destroyHardwareResources(info);
|
destroyHardwareResources(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,6 +108,13 @@ void WebViewFunctor::sync(const WebViewSyncData& syncData) const {
|
|||||||
mCallbacks.onSync(mFunctor, mData, syncData);
|
mCallbacks.onSync(mFunctor, mData, syncData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebViewFunctor::onRemovedFromTree() {
|
||||||
|
ATRACE_NAME("WebViewFunctor::onRemovedFromTree");
|
||||||
|
if (mSurfaceControl) {
|
||||||
|
removeOverlays();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WebViewFunctor::drawGl(const DrawGlInfo& drawInfo) {
|
void WebViewFunctor::drawGl(const DrawGlInfo& drawInfo) {
|
||||||
ATRACE_NAME("WebViewFunctor::drawGl");
|
ATRACE_NAME("WebViewFunctor::drawGl");
|
||||||
if (!mHasContext) {
|
if (!mHasContext) {
|
||||||
@@ -185,6 +192,7 @@ void WebViewFunctor::removeOverlays() {
|
|||||||
ScopedCurrentFunctor currentFunctor(this);
|
ScopedCurrentFunctor currentFunctor(this);
|
||||||
mCallbacks.removeOverlays(mFunctor, mData, currentFunctor.mergeTransaction);
|
mCallbacks.removeOverlays(mFunctor, mData, currentFunctor.mergeTransaction);
|
||||||
if (mSurfaceControl) {
|
if (mSurfaceControl) {
|
||||||
|
reparentSurfaceControl(nullptr);
|
||||||
auto funcs = renderthread::RenderThread::getInstance().getASurfaceControlFunctions();
|
auto funcs = renderthread::RenderThread::getInstance().getASurfaceControlFunctions();
|
||||||
funcs.releaseFunc(mSurfaceControl);
|
funcs.releaseFunc(mSurfaceControl);
|
||||||
mSurfaceControl = nullptr;
|
mSurfaceControl = nullptr;
|
||||||
@@ -217,9 +225,12 @@ ASurfaceControl* WebViewFunctor::getSurfaceControl() {
|
|||||||
void WebViewFunctor::mergeTransaction(ASurfaceTransaction* transaction) {
|
void WebViewFunctor::mergeTransaction(ASurfaceTransaction* transaction) {
|
||||||
ATRACE_NAME("WebViewFunctor::mergeTransaction");
|
ATRACE_NAME("WebViewFunctor::mergeTransaction");
|
||||||
if (transaction == nullptr) return;
|
if (transaction == nullptr) return;
|
||||||
|
bool done = false;
|
||||||
renderthread::CanvasContext* activeContext = renderthread::CanvasContext::getActiveContext();
|
renderthread::CanvasContext* activeContext = renderthread::CanvasContext::getActiveContext();
|
||||||
LOG_ALWAYS_FATAL_IF(activeContext == nullptr, "Null active canvas context!");
|
// activeContext might be null when called from mCallbacks.removeOverlays()
|
||||||
bool done = activeContext->mergeTransaction(transaction, mSurfaceControl);
|
if (activeContext != nullptr) {
|
||||||
|
done = activeContext->mergeTransaction(transaction, mSurfaceControl);
|
||||||
|
}
|
||||||
if (!done) {
|
if (!done) {
|
||||||
auto funcs = renderthread::RenderThread::getInstance().getASurfaceControlFunctions();
|
auto funcs = renderthread::RenderThread::getInstance().getASurfaceControlFunctions();
|
||||||
funcs.transactionApplyFunc(transaction);
|
funcs.transactionApplyFunc(transaction);
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ public:
|
|||||||
|
|
||||||
void removeOverlays() { mReference.removeOverlays(); }
|
void removeOverlays() { mReference.removeOverlays(); }
|
||||||
|
|
||||||
|
void onRemovedFromTree() { mReference.onRemovedFromTree(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class WebViewFunctor;
|
friend class WebViewFunctor;
|
||||||
|
|
||||||
@@ -74,6 +76,7 @@ public:
|
|||||||
void postDrawVk();
|
void postDrawVk();
|
||||||
void destroyContext();
|
void destroyContext();
|
||||||
void removeOverlays();
|
void removeOverlays();
|
||||||
|
void onRemovedFromTree();
|
||||||
|
|
||||||
ASurfaceControl* getSurfaceControl();
|
ASurfaceControl* getSurfaceControl();
|
||||||
void mergeTransaction(ASurfaceTransaction* transaction);
|
void mergeTransaction(ASurfaceTransaction* transaction);
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ void CanvasOpBuffer::syncContents(const WebViewSyncData& data) {
|
|||||||
LOG_ALWAYS_FATAL("TODO");
|
LOG_ALWAYS_FATAL("TODO");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CanvasOpBuffer::onRemovedFromTree() {
|
||||||
|
LOG_ALWAYS_FATAL("TODO");
|
||||||
|
}
|
||||||
|
|
||||||
void CanvasOpBuffer::applyColorTransform(ColorTransform transform) {
|
void CanvasOpBuffer::applyColorTransform(ColorTransform transform) {
|
||||||
LOG_ALWAYS_FATAL("TODO");
|
LOG_ALWAYS_FATAL("TODO");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ public:
|
|||||||
TreeObserver& observer, TreeInfo& info, bool functorsNeedLayer,
|
TreeObserver& observer, TreeInfo& info, bool functorsNeedLayer,
|
||||||
std::function<void(RenderNode*, TreeObserver&, TreeInfo&, bool)> childFn);
|
std::function<void(RenderNode*, TreeObserver&, TreeInfo&, bool)> childFn);
|
||||||
void syncContents(const WebViewSyncData& data);
|
void syncContents(const WebViewSyncData& data);
|
||||||
|
void onRemovedFromTree();
|
||||||
void applyColorTransform(ColorTransform transform);
|
void applyColorTransform(ColorTransform transform);
|
||||||
|
|
||||||
[[nodiscard]] bool isEmpty() const { return !mHas.content; }
|
[[nodiscard]] bool isEmpty() const { return !mHas.content; }
|
||||||
|
|||||||
@@ -44,6 +44,10 @@ public:
|
|||||||
mWebViewHandle->sync(data);
|
mWebViewHandle->sync(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void onRemovedFromTree() {
|
||||||
|
mWebViewHandle->onRemovedFromTree();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual SkRect onGetBounds() override { return mBounds; }
|
virtual SkRect onGetBounds() override { return mBounds; }
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,12 @@ void SkiaDisplayList::syncContents(const WebViewSyncData& data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SkiaDisplayList::onRemovedFromTree() {
|
||||||
|
for (auto& functor : mChildFunctors) {
|
||||||
|
functor->onRemovedFromTree();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool SkiaDisplayList::reuseDisplayList(RenderNode* node) {
|
bool SkiaDisplayList::reuseDisplayList(RenderNode* node) {
|
||||||
reset();
|
reset();
|
||||||
node->attachAvailableList(this);
|
node->attachAvailableList(this);
|
||||||
|
|||||||
@@ -111,6 +111,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
void syncContents(const WebViewSyncData& data);
|
void syncContents(const WebViewSyncData& data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ONLY to be called by RenderNode::onRemovedFromTree so that we can notify any
|
||||||
|
* contained VectorDrawables or GLFunctors.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void onRemovedFromTree();
|
||||||
|
|
||||||
void applyColorTransform(ColorTransform transform) {
|
void applyColorTransform(ColorTransform transform) {
|
||||||
mDisplayList.applyColorTransform(transform);
|
mDisplayList.applyColorTransform(transform);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user