Merge "Clip buffer damage to viewport bounds" into nyc-dev
am: 83b28c0e67
* commit '83b28c0e67c1660d4a675218c8b49c4f68a822f3':
Clip buffer damage to viewport bounds
This commit is contained in:
@@ -296,12 +296,9 @@ void BakedOpRenderer::prepareRender(const Rect* dirtyBounds, const ClipBase* cli
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// dirty offscreenbuffer
|
if (dirtyBounds) {
|
||||||
if (dirtyBounds && mRenderTarget.offscreenBuffer) {
|
// dirty offscreenbuffer if present
|
||||||
// register layer damage to draw-back region
|
dirtyRenderTarget(*dirtyBounds);
|
||||||
android::Rect dirty(dirtyBounds->left, dirtyBounds->top,
|
|
||||||
dirtyBounds->right, dirtyBounds->bottom);
|
|
||||||
mRenderTarget.offscreenBuffer->region.orSelf(dirty);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,29 +326,9 @@ void BakedOpRenderer::renderFunctor(const FunctorOp& op, const BakedOpState& sta
|
|||||||
mRenderState.invokeFunctor(op.functor, DrawGlInfo::kModeDraw, &info);
|
mRenderState.invokeFunctor(op.functor, DrawGlInfo::kModeDraw, &info);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define VALIDATE_RECT_ARG(rect, arg) \
|
|
||||||
((isnanf(rect.arg) || rect.arg < -10000 || rect.arg > 10000) ? (\
|
|
||||||
ALOGW("suspicious " #rect "." #arg "! %f", rect.arg),\
|
|
||||||
false) : true)
|
|
||||||
|
|
||||||
#define VALIDATE_RECT(rect) \
|
|
||||||
VALIDATE_RECT_ARG(rect, bottom) & \
|
|
||||||
VALIDATE_RECT_ARG(rect, left) & \
|
|
||||||
VALIDATE_RECT_ARG(rect, top) & \
|
|
||||||
VALIDATE_RECT_ARG(rect, right)
|
|
||||||
|
|
||||||
void BakedOpRenderer::dirtyRenderTarget(const Rect& uiDirty) {
|
void BakedOpRenderer::dirtyRenderTarget(const Rect& uiDirty) {
|
||||||
if (mRenderTarget.offscreenBuffer) {
|
if (mRenderTarget.offscreenBuffer) {
|
||||||
bool valid = VALIDATE_RECT(uiDirty);
|
mRenderTarget.offscreenBuffer->dirty(uiDirty);
|
||||||
android::Rect dirty;
|
|
||||||
if (valid) {
|
|
||||||
dirty = android::Rect(uiDirty.left, uiDirty.top, uiDirty.right, uiDirty.bottom);
|
|
||||||
} else {
|
|
||||||
dirty = android::Rect(
|
|
||||||
mRenderTarget.offscreenBuffer->viewportWidth,
|
|
||||||
mRenderTarget.offscreenBuffer->viewportHeight);
|
|
||||||
}
|
|
||||||
mRenderTarget.offscreenBuffer->region.orSelf(dirty);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,14 @@ Rect OffscreenBuffer::getTextureCoordinates() {
|
|||||||
return Rect(0, viewportHeight * texY, viewportWidth * texX, 0);
|
return Rect(0, viewportHeight * texY, viewportWidth * texX, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OffscreenBuffer::dirty(Rect dirtyArea) {
|
||||||
|
dirtyArea.doIntersect(0, 0, viewportWidth, viewportHeight);
|
||||||
|
if (!dirtyArea.isEmpty()) {
|
||||||
|
region.orSelf(android::Rect(dirtyArea.left, dirtyArea.top,
|
||||||
|
dirtyArea.right, dirtyArea.bottom));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OffscreenBuffer::updateMeshFromRegion() {
|
void OffscreenBuffer::updateMeshFromRegion() {
|
||||||
// avoid T-junctions as they cause artifacts in between the resultant
|
// avoid T-junctions as they cause artifacts in between the resultant
|
||||||
// geometry when complex transforms occur.
|
// geometry when complex transforms occur.
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ public:
|
|||||||
|
|
||||||
Rect getTextureCoordinates();
|
Rect getTextureCoordinates();
|
||||||
|
|
||||||
|
void dirty(Rect dirtyArea);
|
||||||
|
|
||||||
// must be called prior to rendering, to construct/update vertex buffer
|
// must be called prior to rendering, to construct/update vertex buffer
|
||||||
void updateMeshFromRegion();
|
void updateMeshFromRegion();
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,14 @@ TEST(OffscreenBuffer, getTextureCoordinates) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(OffscreenBuffer, dirty) {
|
||||||
|
TestUtils::runOnRenderThread([] (renderthread::RenderThread& thread) {
|
||||||
|
OffscreenBuffer buffer(thread.renderState(), Caches::getInstance(), 256u, 256u);
|
||||||
|
buffer.dirty(Rect(-100, -100, 100, 100));
|
||||||
|
EXPECT_EQ(android::Rect(100, 100), buffer.region.getBounds());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
TEST(OffscreenBufferPool, construct) {
|
TEST(OffscreenBufferPool, construct) {
|
||||||
TestUtils::runOnRenderThread([] (renderthread::RenderThread& thread) {
|
TestUtils::runOnRenderThread([] (renderthread::RenderThread& thread) {
|
||||||
OffscreenBufferPool pool;
|
OffscreenBufferPool pool;
|
||||||
|
|||||||
Reference in New Issue
Block a user