예제 #1
0
void Stage::render(lua_State *L)
{
    LOOM_PROFILE_START(stageRenderBegin);
    GFX::Graphics::setNativeSize(getWidth(), getHeight());
    GFX::Graphics::beginFrame();
    
    updateLocalTransform();

    lualoom_pushnative<Stage>(L, this);

    renderState.alpha          = alpha;
    renderState.clipRect       = Loom2D::Rectangle(0, 0, -1, -1);
    renderState.blendMode      = blendMode;
    LOOM_PROFILE_END(stageRenderBegin);


    LOOM_PROFILE_START(stageRenderDisplayList);
    renderChildren(L);
    LOOM_PROFILE_END(stageRenderDisplayList);

    
    LOOM_PROFILE_START(stageRenderEnd);
    lua_pop(L, 1);
    GFX::Graphics::endFrame();
    LOOM_PROFILE_END(stageRenderEnd);


    LOOM_PROFILE_START(waitForVSync);
    /* Update the screen! */
    SDL_GL_SwapWindow(sdlWindow);
    LOOM_PROFILE_END(waitForVSync);
}
예제 #2
0
void Shape::render(lua_State *L)
{
	renderState.alpha = parent ? parent->renderState.alpha * alpha : alpha;
	renderState.clampAlpha();
	if (renderState.alpha == 0.0f)
	{
		return;
	}

	DisplayObject::render(L);

	updateLocalTransform();

    
	if (!renderCached(L)) {
		Matrix transform;

		getTargetTransformationMatrix(NULL, &transform);

		renderState.clipRect = parent ? parent->renderState.clipRect : Loom2D::Rectangle(0, 0, -1, -1);
		renderState.blendMode = (blendMode == BlendMode::AUTO && parent) ? parent->renderState.blendMode : blendMode;

		if (GFX::Graphics::getFlags() & GFX::Graphics::FLAG_INVERTED) {
			transform.scale(1, -1);
			transform.translate(0, GFX::Graphics::getHeight());
		}

		graphics->render(&renderState, &transform);
	}
}
예제 #3
0
void LayoutSVGShape::layout()
{
    bool updateCachedBoundariesInParents = false;
    LayoutAnalyzer::Scope analyzer(*this);

    if (m_needsShapeUpdate || m_needsBoundariesUpdate) {
        updateShapeFromElement();
        m_needsShapeUpdate = false;
        updatePaintInvalidationBoundingBox();
        m_needsBoundariesUpdate = false;
        updateCachedBoundariesInParents = true;
    }

    if (m_needsTransformUpdate) {
        updateLocalTransform();
        m_needsTransformUpdate = false;
        updateCachedBoundariesInParents = true;
    }

    // Invalidate all resources of this client if our layout changed.
    if (everHadLayout() && selfNeedsLayout())
        SVGResourcesCache::clientLayoutChanged(this);

    // If our bounds changed, notify the parents.
    if (updateCachedBoundariesInParents)
        LayoutSVGModelObject::setNeedsBoundariesUpdate();

    clearNeedsLayout();
}
예제 #4
0
//==============================================================================
const Eigen::Isometry3d& FreeJoint::getQ() const
{
  if(mNeedTransformUpdate)
  {
    updateLocalTransform();
    mNeedTransformUpdate = false;
  }

  return mQ;
}
예제 #5
0
void SVGTextElement::parseMappedAttribute(MappedAttribute *attr)
{
    if (attr->name() == SVGNames::transformAttr) {
        SVGTransformList *localTransforms = transform()->baseVal();
        localTransforms->clear();
        
        SVGTransformable::parseTransformAttribute(localTransforms, attr->value());
        updateLocalTransform(localTransforms);
    } else
        SVGTextPositioningElement::parseMappedAttribute(attr);
}
void SVGStyledTransformableElement::parseMappedAttribute(MappedAttribute* attr)
{
    if (attr->name() == SVGNames::transformAttr) {
        SVGTransformList* localTransforms = transformBaseValue();

        ExceptionCode ec = 0;
        localTransforms->clear(ec);
 
        if (!SVGTransformable::parseTransformAttribute(localTransforms, attr->value()))
            localTransforms->clear(ec);
        else
            updateLocalTransform(localTransforms);
    } else
        SVGStyledLocatableElement::parseMappedAttribute(attr);
}
예제 #7
0
void LayoutSVGShape::layout() {
  LayoutAnalyzer::Scope analyzer(*this);

  // Invalidate all resources of this client if our layout changed.
  if (everHadLayout() && selfNeedsLayout())
    SVGResourcesCache::clientLayoutChanged(this);

  bool updateParentBoundaries = false;
  // updateShapeFromElement() also updates the object & stroke bounds - which
  // feeds into the visual rect - so we need to call it for both the
  // shape-update and the bounds-update flag.
  if (m_needsShapeUpdate || m_needsBoundariesUpdate) {
    FloatRect oldObjectBoundingBox = objectBoundingBox();
    updateShapeFromElement();
    if (oldObjectBoundingBox != objectBoundingBox())
      setShouldDoFullPaintInvalidation();
    m_needsShapeUpdate = false;

    m_localVisualRect = strokeBoundingBox();
    SVGLayoutSupport::adjustVisualRectWithResources(this, m_localVisualRect);
    m_needsBoundariesUpdate = false;

    updateParentBoundaries = true;
  }

  if (m_needsTransformUpdate) {
    updateLocalTransform();
    m_needsTransformUpdate = false;
    updateParentBoundaries = true;
  }

  // If our bounds changed, notify the parents.
  if (updateParentBoundaries)
    LayoutSVGModelObject::setNeedsBoundariesUpdate();

  ASSERT(!m_needsShapeUpdate);
  ASSERT(!m_needsBoundariesUpdate);
  ASSERT(!m_needsTransformUpdate);
  clearNeedsLayout();
}
예제 #8
0
/** Creates a matrix that represents the transformation from the local coordinate system
 *  to another. If you pass a 'resultMatrix', the result will be stored in this matrix
 *  instead of creating a new object. */
void DisplayObject::getTargetTransformationMatrix(DisplayObject *targetSpace, Matrix *resultMatrix)
{
    if (!resultMatrix)
    {
        return;
    }

    resultMatrix->identity();

    if (transformDirty)
    {
        updateLocalTransform();
    }

    if (targetSpace == this)
    {
        return;
    }

    if ((targetSpace == parent) || ((targetSpace == NULL) && (parent == NULL)))
    {
        resultMatrix->copyFrom(&transformMatrix);
        return;
    }

    DisplayObject *base = this;
    while (base->parent)
    {
        base = base->parent;
    }

    DisplayObject *currentObject = NULL;

    if ((targetSpace == NULL) || (targetSpace == base))
    {
        // targetCoordinateSpace 'null' represents the target space of the base object.
        // -> move up from this to base

        currentObject = this;
        while (currentObject != targetSpace)
        {
            if (currentObject->transformDirty) {
                currentObject->updateLocalTransform();
            }
            resultMatrix->concat(&currentObject->transformMatrix);

            currentObject = currentObject->parent;
        }

        return;
    }
    else if (targetSpace->parent == this) // optimization
    {
        targetSpace->getTargetTransformationMatrix(this, resultMatrix);
        resultMatrix->invert();
        return;
    }

    // 1. find a common parent of this and the target space

    DisplayObject *commonParent = NULL;

    currentObject = this;

    while (currentObject)
    {
        DisplayObject *target = targetSpace;
        while (target)
        {
            if (target == currentObject)
            {
                commonParent = target;
                break;
            }

            target = target->parent;
        }

        if (commonParent)
        {
            break;
        }

        currentObject = currentObject->parent;
    }

    lmAssert(commonParent, "Object not connected to target.");
    //else throw new ArgumentError("Object not connected to target");

    // 2. move up from this to common parent

    currentObject = this;
    while (currentObject != commonParent)
    {
        if (currentObject->transformDirty) {
            currentObject->updateLocalTransform();
        }
        resultMatrix->concat(&currentObject->transformMatrix);
        currentObject = currentObject->parent;
    }

    if (commonParent == targetSpace)
    {
        return;
    }

    // 3. now move up from target until we reach the common parent

    Matrix helperMatrix;
    //helperMatrix.identity();
    currentObject = targetSpace;
    while (currentObject != commonParent)
    {
        helperMatrix.concat(&currentObject->transformMatrix);
        currentObject = currentObject->parent;
    }

    // 4. now combine the two matrices

    helperMatrix.invert();
    resultMatrix->concat(&helperMatrix);
}