} // unnamed namespace
#endif
-const int partialUpdateMargin = 4u;
+namespace
+{
const float partialUpdateRatio = 0.8f; // If the partial update area exceeds 80%, change to full update.
/**
+ * @brief Find the intersection of two AABB rectangles.
+ * This is a logical AND operation. IE. The intersection is the area overlapped by both rectangles.
+ * @param[in] aabbA Rectangle A
+ * @param[in] aabbB Rectangle B
+ * @return The intersection of rectangle A & B (result is a rectangle)
+ */
+inline ClippingBox IntersectAABB( const ClippingBox& aabbA, const ClippingBox& aabbB )
+{
+ ClippingBox intersectionBox;
+
+ // First calculate the largest starting positions in X and Y.
+ intersectionBox.x = std::max( aabbA.x, aabbB.x );
+ intersectionBox.y = std::max( aabbA.y, aabbB.y );
+
+ // Now calculate the smallest ending positions, and take the largest starting
+ // positions from the result, to get the width and height respectively.
+ // If the two boxes do not intersect at all, then we need a 0 width and height clipping area.
+ // We use max here to clamp both width and height to >= 0 for this use-case.
+ intersectionBox.width = std::max( std::min( aabbA.x + aabbA.width, aabbB.x + aabbB.width ) - intersectionBox.x, 0 );
+ intersectionBox.height = std::max( std::min( aabbA.y + aabbA.height, aabbB.y + aabbB.height ) - intersectionBox.y, 0 );
+
+ return intersectionBox;
+}
+
+}
+
+/**
* Structure to contain internal data
*/
struct RenderManager::Impl
if( isPartialUpdate )
{
- damagedRect.x = dx1 - partialUpdateMargin;
- damagedRect.y = dy1 - partialUpdateMargin;
- damagedRect.width = dx2 - dx1 + ( 2 * partialUpdateMargin );
- damagedRect.height = dy2 - dy1 + ( 2 * partialUpdateMargin );
+ if( dx1 < 0.0f )
+ {
+ dx1 = 0.0f;
+ }
+ if( dy1 < 0.0f )
+ {
+ dy1 = 0.0f;
+ }
+ if( dx2 > viewportRect.width )
+ {
+ dx2 = viewportRect.width;
+ }
+ if( dy2 > viewportRect.height )
+ {
+ dy2 = viewportRect.height;
+ }
+
+ damagedRect.x = dx1;
+ damagedRect.y = dy1;
+ damagedRect.width = dx2 - dx1;
+ damagedRect.height = dy2 - dy1;
}
return isPartialUpdate;
Rect<int32_t> damagedRect;
Rect<int32_t> mergedRect;
Dali::ClippingBox scissorBox;
+ Dali::ClippingBox intersectRect;
if ( instruction.mIsClearColorSet )
{
// It is important to clear all 3 buffers when they are being used, for performance on deferred renderers
// e.g. previously when the depth & stencil buffers were NOT cleared, it caused the DDK to exceed a "vertex count limit",
// and then stall. That problem is only noticeable when rendering a large number of vertices per frame.
- mImpl->currentContext->SetScissorTest( false );
-
if( isPartialUpdate )
{
mImpl->currentContext->SetScissorTest( true );
mImpl->currentContext->Scissor( scissorBox.x, scissorBox.y, scissorBox.width, scissorBox.height );
}
+ else
+ {
+ mImpl->currentContext->SetScissorTest( false );
+ }
GLbitfield clearMask = GL_COLOR_BUFFER_BIT;
mImpl->currentContext->SetScissorTest( true );
if( isPartialUpdate )
{
- mImpl->currentContext->Scissor( scissorBox.x, scissorBox.y, scissorBox.width, scissorBox.height );
+ intersectRect = IntersectAABB( scissorBox, viewportRect );
+ mImpl->currentContext->Scissor( intersectRect.x, intersectRect.y, intersectRect.width, intersectRect.height );
}
else
{