Fix WebView disappearing
bug:27528563
Change-Id: Ib9fefa18ef9fb8eb11edd097cbadf8ab2b911576
diff --git a/libs/hwui/RecordingCanvas.cpp b/libs/hwui/RecordingCanvas.cpp
index ddf0528..4e3ed36 100644
--- a/libs/hwui/RecordingCanvas.cpp
+++ b/libs/hwui/RecordingCanvas.cpp
@@ -24,8 +24,8 @@
namespace android {
namespace uirenderer {
-
-static Rect sUnreasonablyLargeBounds(-10000, -10000, 10000, 10000);
+#define MIL_PIX 1000000
+static Rect sUnreasonablyLargeBounds(-MIL_PIX, -MIL_PIX, MIL_PIX, MIL_PIX);
static const Rect& getConservativeOpBounds(const ClipBase* clip) {
// if op is clipped, that rect can be used, but otherwise just use a conservatively large rect
@@ -595,7 +595,7 @@
mDisplayList->functors.push_back(functor);
auto clip = getRecordedClip();
addOp(alloc().create_trivial<FunctorOp>(
- getConservativeOpBounds(clip), // TODO: explicitly define bounds
+ getConservativeOpBounds(clip),
*(mState.currentSnapshot()->transform),
clip,
functor));
diff --git a/libs/hwui/tests/unit/FrameBuilderTests.cpp b/libs/hwui/tests/unit/FrameBuilderTests.cpp
index 4c56a22..f147fd4 100644
--- a/libs/hwui/tests/unit/FrameBuilderTests.cpp
+++ b/libs/hwui/tests/unit/FrameBuilderTests.cpp
@@ -349,6 +349,29 @@
EXPECT_EQ(1, renderer.getIndex());
}
+TEST(FrameBuilder, functor_reject) {
+ class FunctorTestRenderer : public TestRendererBase {
+ public:
+ void onFunctorOp(const FunctorOp& op, const BakedOpState& state) override {
+ EXPECT_EQ(0, mIndex++);
+ }
+ };
+ Functor noopFunctor;
+
+ // 1 million pixel tall view, scrolled down 80%
+ auto scrolledFunctorView = TestUtils::createNode(0, 0, 400, 1000000,
+ [&noopFunctor](RenderProperties& props, RecordingCanvas& canvas) {
+ canvas.translate(0, -800000);
+ canvas.callDrawGLFunction(&noopFunctor);
+ });
+
+ FrameBuilder frameBuilder(sEmptyLayerUpdateQueue, SkRect::MakeWH(200, 200), 200, 200,
+ TestUtils::createSyncedNodeList(scrolledFunctorView), sLightGeometry, nullptr);
+ FunctorTestRenderer renderer;
+ frameBuilder.replayBakedOps<TestDispatcher>(renderer);
+ EXPECT_EQ(1, renderer.getIndex()) << "Functor should not be rejected";
+}
+
TEST(FrameBuilder, renderNode) {
class RenderNodeTestRenderer : public TestRendererBase {
public:
@@ -391,6 +414,7 @@
TestUtils::createSyncedNodeList(parent), sLightGeometry, nullptr);
RenderNodeTestRenderer renderer;
frameBuilder.replayBakedOps<TestDispatcher>(renderer);
+ EXPECT_EQ(2, renderer.getIndex());
}
TEST(FrameBuilder, clipped) {