/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// rectangular area which is actually covered by the sprite. // coordinates are relative to the sprite origin.
::basegfx::B2DRectangle aSpriteRectPixel = ::canvas::tools::calcTransformedRectBounds(
aBounds,
maTransform );
// aClipBoundsA = new clip bound rect, intersected // with sprite area
::basegfx::B2DRectangle aClipBoundsA(aClipBounds);
aClipBoundsA.intersect( aSpriteRectPixel );
if( nNumClipPolygons != 1 )
{ // clip cannot be a single rectangle -> cannot // optimize update
mbIsCurrClipRectangle = false;
maCurrClipBounds = aClipBoundsA;
} else
{ // new clip could be a single rectangle - check // that now: constbool bNewClipIsRect(
::basegfx::utils::isRectangle( aClipPath.getB2DPolygon(0) ) );
// both new and old clip are truly rectangles // - can now take the optimized path constbool bUseOptimizedUpdate( bNewClipIsRect &&
mbIsCurrClipRectangle );
// store new current clip type
maCurrClipBounds = aClipBoundsA;
mbIsCurrClipRectangle = bNewClipIsRect;
if( mbActive &&
bUseOptimizedUpdate )
{ // aClipBoundsB = maCurrClipBounds, i.e. last // clip, intersected with sprite area
std::vector< ::basegfx::B2DRectangle > aClipDifferences;
// get all rectangles covered by exactly one // of the polygons (aka XOR)
::basegfx::computeSetDifference(aClipDifferences,
aClipBoundsA,
aOldBounds);
// aClipDifferences now contains the final // update areas, coordinates are still relative // to the sprite origin. before submitting // this area to 'updateSprite()' we need to // translate this area to the final position, // coordinates need to be relative to the // spritecanvas. for( constauto& rClipDiff : aClipDifferences )
{
mpSpriteCanvas->updateSprite(
rSprite,
maPosition,
::basegfx::B2DRectangle(
maPosition + rClipDiff.getMinimum(),
maPosition + rClipDiff.getMaximum() ) );
}
// update calls all done returntrue;
}
}
}
// caller needs to perform update calls returnfalse;
}
bool CanvasCustomSpriteHelper::isAreaUpdateOpaque( const ::basegfx::B2DRange& rUpdateArea ) const
{ if( !mbIsCurrClipRectangle ||
!mbIsContentFullyOpaque ||
!::rtl::math::approxEqual(mfAlpha, 1.0) )
{ // sprite either transparent, or clip rect does not // represent exact bounds -> update might not be fully // opaque returnfalse;
} else
{ // make sure sprite rect fully covers update area - // although the update area originates from the sprite, // it's by no means guaranteed that it's limited to this // sprite's update area - after all, other sprites might // have been merged, or this sprite is moving. return getUpdateArea().isInside( rUpdateArea );
}
}
// transform bounds at origin, as the sprite transformation is // formulated that way return ::canvas::tools::calcTransformedRectBounds(
rBounds,
aTransform );
}
::basegfx::B2DRange CanvasCustomSpriteHelper::getUpdateArea() const
{ // Internal! Only call with locked object mutex!
// return effective sprite rect, i.e. take active clip into // account if( maCurrClipBounds.isEmpty() ) return getUpdateArea( ::basegfx::B2DRectangle( 0.0, 0.0,
maSize.getX(),
maSize.getY() ) ); else return ::basegfx::B2DRectangle(
maPosition + maCurrClipBounds.getMinimum(),
maPosition + maCurrClipBounds.getMaximum() );
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.