void LayerAndroid::dumpLayers(FILE* file, int indentLevel) const
{
    writeln(file, indentLevel, "{");

    writeHexVal(file, indentLevel + 1, "layer", (int)this);
    writeIntVal(file, indentLevel + 1, "layerId", m_uniqueId);
    writeIntVal(file, indentLevel + 1, "haveClip", m_haveClip);
    writeIntVal(file, indentLevel + 1, "isRootLayer", m_isRootLayer);
    writeIntVal(file, indentLevel + 1, "isFixed", m_isFixed);

    writeFloatVal(file, indentLevel + 1, "opacity", getOpacity());
    writeSize(file, indentLevel + 1, "size", getSize());
    writePoint(file, indentLevel + 1, "position", getPosition());
    writePoint(file, indentLevel + 1, "translation", m_translation);
    writePoint(file, indentLevel + 1, "anchor", getAnchorPoint());
    writePoint(file, indentLevel + 1, "scale", m_scale);

    if (m_doRotation)
        writeFloatVal(file, indentLevel + 1, "angle", m_angleTransform);

    if (m_isFixed) {
        writeLength(file, indentLevel + 1, "fixedLeft", m_fixedLeft);
        writeLength(file, indentLevel + 1, "fixedTop", m_fixedTop);
        writeLength(file, indentLevel + 1, "fixedRight", m_fixedRight);
        writeLength(file, indentLevel + 1, "fixedBottom", m_fixedBottom);
        writeLength(file, indentLevel + 1, "fixedMarginLeft", m_fixedMarginLeft);
        writeLength(file, indentLevel + 1, "fixedMarginTop", m_fixedMarginTop);
        writeLength(file, indentLevel + 1, "fixedMarginRight", m_fixedMarginRight);
        writeLength(file, indentLevel + 1, "fixedMarginBottom", m_fixedMarginBottom);
        writePoint(file, indentLevel + 1, "fixedOffset", m_fixedOffset);
        writeIntVal(file, indentLevel + 1, "fixedWidth", m_fixedWidth);
        writeIntVal(file, indentLevel + 1, "fixedHeight", m_fixedHeight);
    }

    if (m_recordingPicture) {
        writeIntVal(file, indentLevel + 1, "picture width", m_recordingPicture->width());
        writeIntVal(file, indentLevel + 1, "picture height", m_recordingPicture->height());
    }

    if (countChildren()) {
        writeln(file, indentLevel + 1, "children = [");
        for (int i = 0; i < countChildren(); i++) {
            if (i > 0)
                writeln(file, indentLevel + 1, ", ");
            getChild(i)->dumpLayers(file, indentLevel + 1);
        }
        writeln(file, indentLevel + 1, "];");
    }
    writeln(file, indentLevel, "}");
}
Beispiel #2
0
void LayerAndroid::updateGLPositionsAndScale(const TransformationMatrix& parentMatrix,
                                             const FloatRect& clipping, float opacity,
                                             float scale, bool forceCalculation,
                                             bool disableFixedElemUpdate)
{
    m_scale = scale;

    opacity *= getOpacity();
    setDrawOpacity(opacity);

    // constantly recalculate the draw transform of layers that may require it (and their children)
    forceCalculation |= hasDynamicTransform();

    forceCalculation &= !(disableFixedElemUpdate && isPositionFixed());
    if (forceCalculation)
        updateLocalTransformAndClip(parentMatrix, clipping);

    if (!countChildren() || !m_visible)
        return;

    TransformationMatrix localMatrix = m_drawTransformUnfudged;

    // Flatten to 2D if the layer doesn't preserve 3D.
    if (!preserves3D()) {
        localMatrix.setM13(0);
        localMatrix.setM23(0);
        localMatrix.setM31(0);
        localMatrix.setM32(0);
        localMatrix.setM33(1);
        localMatrix.setM34(0);
        localMatrix.setM43(0);
    }

    // now apply it to our children

    TransformationMatrix childMatrix;
    childMatrix = localMatrix;
    childMatrix.translate3d(getScrollOffset().x(), getScrollOffset().y(), 0);
    if (!m_childrenTransform.isIdentity()) {
        childMatrix.translate(getSize().width() * 0.5f, getSize().height() * 0.5f);
        childMatrix.multiply(m_childrenTransform);
        childMatrix.translate(-getSize().width() * 0.5f, -getSize().height() * 0.5f);
    }
    for (int i = 0; i < countChildren(); i++)
        this->getChild(i)->updateGLPositionsAndScale(childMatrix, drawClip(),
                                                     opacity, scale, forceCalculation,
                                                     disableFixedElemUpdate);
}
Beispiel #3
0
void LayerAndroid::addDirtyArea()
{
    if (m_drawTransform.hasPerspective()) {
        state()->doFrameworkFullInval();
        return;
    }

    // TODO: rewrite this to handle partial invalidate, and to handle base
    // layer's large clip correctly

    IntSize layerSize(getSize().width(), getSize().height());

    FloatRect area =
        TilesManager::instance()->shader()->rectInViewCoord(m_drawTransform, layerSize);
    FloatRect clippingRect =
        TilesManager::instance()->shader()->rectInInvViewCoord(m_clippingRect);
    FloatRect clip =
        TilesManager::instance()->shader()->convertInvViewCoordToViewCoord(clippingRect);

    area.intersect(clip);
    IntRect dirtyArea(area.x(), area.y(), area.width(), area.height());

    state()->addDirtyArea(dirtyArea);

    for (int i = 0; i < countChildren(); i++)
        getChild(i)->addDirtyArea();
}
SkRect LayerAndroid::subtractLayers(const SkRect& visibleRect) const
{
    SkRect result;
    if (m_recordingPicture) {
        SkRect globalRect = bounds();
        globalRect.offset(-getPosition()); // localToGlobal adds in position
        SkMatrix globalMatrix;
        localToGlobal(&globalMatrix);
        globalMatrix.mapRect(&globalRect);
        SkIRect roundedGlobal;
        globalRect.round(&roundedGlobal);
        SkIRect iVisibleRect;
        visibleRect.round(&iVisibleRect);
        SkRegion visRegion(iVisibleRect);
        visRegion.op(roundedGlobal, SkRegion::kDifference_Op);
        result.set(visRegion.getBounds());
#if DEBUG_NAV_UI
        SkDebugf("%s visibleRect=(%g,%g,r=%g,b=%g) globalRect=(%g,%g,r=%g,b=%g)"
            "result=(%g,%g,r=%g,b=%g)", __FUNCTION__,
            visibleRect.fLeft, visibleRect.fTop,
            visibleRect.fRight, visibleRect.fBottom,
            globalRect.fLeft, globalRect.fTop,
            globalRect.fRight, globalRect.fBottom,
            result.fLeft, result.fTop, result.fRight, result.fBottom);
#endif
    } else
        result = visibleRect;
    for (int i = 0; i < countChildren(); i++)
        result = getChild(i)->subtractLayers(result);
    return result;
}
Beispiel #5
0
void LayerAndroid::dumpLayers(FILE* file, int indentLevel) const
{
    writeln(file, indentLevel, "{");

    dumpLayer(file, indentLevel);

    if (countChildren()) {
        writeln(file, indentLevel + 1, "children = [");
        for (int i = 0; i < countChildren(); i++) {
            if (i > 0)
                writeln(file, indentLevel + 1, ", ");
            getChild(i)->dumpLayers(file, indentLevel + 1);
        }
        writeln(file, indentLevel + 1, "];");
    }
    writeln(file, indentLevel, "}");
}
bool LayerAndroid::hasAnimations() const
{
    for (int i = 0; i < countChildren(); i++) {
        if (getChild(i)->hasAnimations())
            return true;
    }
    return !!m_animations.size();
}
Beispiel #7
0
void LayerAndroid::initAnimations() {
    // tell auto-initializing animations to start now
    for (int i = 0; i < countChildren(); i++)
        getChild(i)->initAnimations();

    KeyframesMap::const_iterator localBegin = m_animations.begin();
    KeyframesMap::const_iterator localEnd = m_animations.end();
    for (KeyframesMap::const_iterator localIt = localBegin; localIt != localEnd; ++localIt)
        (localIt->second)->suggestBeginTime(WTF::currentTime());
}
const LayerAndroid* LayerAndroid::findById(int match) const
{
    if (m_uniqueId == match)
        return this;
    for (int i = 0; i < countChildren(); i++) {
        const LayerAndroid* result = getChild(i)->findById(match);
        if (result)
            return result;
    }
    return 0;
}
Beispiel #9
0
bool LayerAndroid::hasAnimations() const
{
    if (state() && state()->isScrolling()) {
        return false;
    }
    
    for (int i = 0; i < countChildren(); i++) {
        if (getChild(i)->hasAnimations())
            return true;
    }
    return !!m_animations.size();
}
Beispiel #10
0
void Layer::draw(SkCanvas* canvas, SkScalar opacity) {
#if 0
    SkString str1, str2;
 //   getMatrix().toDumpString(&str1);
 //   getChildrenMatrix().toDumpString(&str2);
    SkDebugf("--- drawlayer %p opacity %g size [%g %g] pos [%g %g] matrix %s children %s\n",
             this, opacity * getOpacity(), m_size.width(), m_size.height(),
             m_position.fX, m_position.fY, str1.c_str(), str2.c_str());
#endif

    opacity = SkScalarMul(opacity, getOpacity());
    if (opacity <= 0) {
//        SkDebugf("---- abort drawing %p opacity %g\n", this, opacity);
        return;
    }

    SkAutoCanvasRestore acr(canvas, true);

    // apply our local transform
    {
        SkMatrix tmp;
        getLocalTransform(&tmp);
        if (shouldInheritFromRootTransform()) {
            // should we also apply the root's childrenMatrix?
            canvas->setMatrix(getRootLayer()->getMatrix());
        }
        canvas->concat(tmp);
    }

    onDraw(canvas, opacity);

#ifdef DEBUG_DRAW_LAYER_BOUNDS
    {
        SkRect r = SkRect::MakeSize(getSize());
        SkPaint p;
        p.setAntiAlias(true);
        p.setStyle(SkPaint::kStroke_Style);
        p.setStrokeWidth(SkIntToScalar(2));
        p.setColor(0xFFFF44DD);
        canvas->drawRect(r, p);
        canvas->drawLine(r.fLeft, r.fTop, r.fRight, r.fBottom, p);
        canvas->drawLine(r.fLeft, r.fBottom, r.fRight, r.fTop, p);
    }
#endif

    int count = countChildren();
    if (count > 0) {
        canvas->concat(getChildrenMatrix());
        for (int i = 0; i < count; i++) {
            getChild(i)->draw(canvas, opacity);
        }
    }
}
Beispiel #11
0
void PMTextureMapBase::childAdded( PMObject* ao )
{
   if( ( unsigned ) countChildren( ) <= m_mapValues.count( ) )
      return;

   if( m_pMemento )
      ( ( PMMapMemento* ) m_pMemento )->setMapValues( m_mapValues );
   if( m_removedValues.isEmpty( ) )
   {
      QValueList<double>::Iterator it = valueForChild( ao );
      if( it == m_mapValues.end( ) )
      {
         --it;
         if( it == m_mapValues.end( ) )
            m_mapValues.append( 0.0 );
         else
         {
            double v = *it + 0.1;
            if( v > 1.0 )
               v = 1.0;
            m_mapValues.append( v );
         }
      }
      else if( it == m_mapValues.begin( ) )
         m_mapValues.prepend( 0.0 );
      else
      {
         double va = *it;
         double vb = *( --it );
         m_mapValues.insert( ++it, ( va + vb ) / 2.0 );
      }
   }
   else
   {
      if( m_pMemento )
         ( ( PMMapMemento* ) m_pMemento )->setRemovedValues( m_removedValues );

      QValueList<double>::Iterator it = m_mapValues.begin( );
      bool stop = false;
      double v = m_removedValues.last( );
      m_removedValues.remove( m_removedValues.fromLast( ) );

      while( ( it != m_mapValues.end( ) ) && !stop )
      {
         if( ( *it ) > v )
            stop = true;
         else
            ++it;
      }
      m_mapValues.insert( it, v );
   }
}
Beispiel #12
0
LayerAndroid* LayerAndroid::findById(int match)
{
    if (m_uniqueId == match)
        return this;
    for (int i = 0; i < countChildren(); i++) {
		if(getChild(i)) {	// SAMSUNG CHANGE : null check.
			LayerAndroid* result = getChild(i)->findById(match);
			if (result)
				return result;
		}
    }
    return 0;
}
Beispiel #13
0
/**
 * countChildren()
 *
 * Returns the number of children this item has.  Calls itself
 * recursively to count its children's children.
 */
int PrintTreeWidget::countChildren(QTreeWidgetItem *item)
{
    int retVal = 0;

    if (item->childCount()) {
        retVal += item->childCount();
        for (int i = 0; i < item->childCount(); ++i) {
            retVal += countChildren(item->child(i));
        }
    }

    return retVal;
}
const LayerAndroid* LayerAndroid::find(int x, int y) const
{
    for (int i = 0; i < countChildren(); i++) {
        const LayerAndroid* found = getChild(i)->find(x, y);
        if (found)
            return found;
    }
    SkRect localBounds;
    bounds(&localBounds);
    if (localBounds.contains(x, y))
        return this;
    return 0;
}
void LayerAndroid::clipInner(SkTDArray<SkRect>* region,
                             const SkRect& local) const
{
    SkRect localBounds;
    bounds(&localBounds);
    localBounds.intersect(local);
    if (localBounds.isEmpty())
        return;
    if (m_recordingPicture && boundsIsUnique(*region, localBounds))
        *region->append() = localBounds;
    for (int i = 0; i < countChildren(); i++)
        getChild(i)->clipInner(region, m_haveClip ? localBounds : local);
}
Beispiel #16
0
/**
 * print()
 *
 * Initiates the actual printing of the list.
 */
void PrintTreeWidget::print()
{
    QPrinter        prn(QPrinter::PrinterResolution);
    QPainter        *p;
    QBrush          bbrush;
    
    int         pageNo = 1;
    int         totPages = 1;
    int         totLines = 0;
    
    prn.setPageSize(QPrinter::Letter);
    prn.setDocName("List Print");
    prn.setCreator("Total Accountability");
    
    // Initialize the printer device.
    if (!prn.setup()) return;
    // prn.setOutputFileName("/tmp/Report.ps");
    // prn.setOutputToFile(TRUE);
    QApplication::setOverrideCursor(Qt::waitCursor);
    
    p = new QPainter();
    p->begin(&prn);
    
    // Count the children.
    totLines = myTree->topLevelItemCount();
    for (int i = 0; i < myTree->topLevelItemCount(); ++i) {
        totLines += countChildren(myTree->topLevelItem(i));
    }
    totPages = (totLines / 50) + 1;
    // fprintf(stderr, "The total number of pages is: %d\n", totPages);

    // Print the report...
    // FIXME:  This should print children as well, but it doesn't.
    for (pageNo = 1; pageNo < totPages + 1; pageNo++) {
        int sItem = ((pageNo -1) * 50);
        int eItem = sItem + 50;
        if (eItem > myTree->topLevelItemCount()) eItem = myTree->topLevelItemCount();
        printHeader(p);
        printRows(p, sItem, eItem);
        printFooter(p, pageNo, totPages);
        if (pageNo < totPages) prn.newPage();
        //progress.setProgress(pageNo);
        //if (progress.wasCancelled()) pageNo = totPages + 1;
    }
    //progress.setProgress(totPages);
    
    // We're all done.  Close the printer device.
    p->end();
    delete(p);
    QApplication::restoreOverrideCursor();
}
Beispiel #17
0
/**
 * Performs the conversion from the XML file format to the G3D binary format.
 *
 * @param doc:     XML DOM document for input.
 * @param outfile: Binary file, opened as "wb", for output.
 */
int xml2g3d(xmlDocPtr doc, FILE *outfile)
{	
	struct FileHeader fh;
	struct ModelHeader mh;
	xmlNode *root_element;
	xmlNode *curNode;
	xmlChar version[] = "version";

	/* fetch the root element and check it */
	root_element = xmlDocGetRootElement(doc);
	assert(root_element->type == XML_ELEMENT_NODE);
	if (strcmp((char*)root_element->name, "G3D") != 0)
	{
		printf("G3D document not found!\n");
		return FALSE;
	}
	if (strcmp((char*)xmlGetProp(root_element, version), "4") != 0)
	{
		printf("Only version 4 G3D documents can be handled!\n");
		return FALSE;
	}

	/* write out the file header */
	memset(&fh, 0, sizeof(struct FileHeader));
	fh.id[0] = 'G'; fh.id[1] = '3'; fh.id[2] = 'D'; fh.version=4;
	fwrite(&fh, sizeof(struct FileHeader), 1, outfile);

	/* write out the model header */
	memset(&mh, 0, sizeof(struct ModelHeader));
	mh.meshCount = (uint16)countChildren(root_element, (xmlChar*)"Mesh");
	mh.type = 0;
	fwrite(&mh, sizeof(struct ModelHeader), 1, outfile);

	/* process each mesh in the file */
	curNode = root_element->children;
	for (; curNode; curNode = curNode->next)
	{
		if (curNode->type == XML_ELEMENT_NODE)
		{
			if (strcmp((char*)curNode->name, "Mesh") == 0)
			{
				if (processMesh(curNode, outfile) == FALSE)
					return FALSE;
			}
		}
	}
	
	return TRUE;
}
bool LayerAndroid::evaluateAnimations(double time) const
{
    bool hasRunningAnimations = false;
    for (int i = 0; i < countChildren(); i++) {
        if (getChild(i)->evaluateAnimations(time))
            hasRunningAnimations = true;
    }
    KeyframesMap::const_iterator end = m_animations.end();
    for (KeyframesMap::const_iterator it = m_animations.begin(); it != end; ++it) {
        gDebugNbAnims++;
        LayerAndroid* currentLayer = const_cast<LayerAndroid*>(this);
        if ((it->second)->evaluate(currentLayer, time)) {
            hasRunningAnimations = true;
        }
    }

    return hasRunningAnimations;
}
Beispiel #19
0
bool LayerAndroid::evaluateAnimations(double time)
{
    if (state() && state()->isScrolling()) {
        return false;
    }
    
    bool hasRunningAnimations = false;
    for (int i = 0; i < countChildren(); i++) {
        if (getChild(i)->evaluateAnimations(time))
            hasRunningAnimations = true;
    }

    m_hasRunningAnimations = false;
    int nbAnims = 0;
    KeyframesMap::const_iterator end = m_animations.end();
    for (KeyframesMap::const_iterator it = m_animations.begin(); it != end; ++it) {
        gDebugNbAnims++;
        nbAnims++;
        LayerAndroid* currentLayer = const_cast<LayerAndroid*>(this);
        m_hasRunningAnimations |= (it->second)->evaluate(currentLayer, time);
    }

    return hasRunningAnimations || m_hasRunningAnimations;
}
void LayerAndroid::setExtra(DrawExtra* extra)
{
    m_extra = extra;
    for (int i = 0; i < countChildren(); i++)
        getChild(i)->setExtra(extra);
}
Beispiel #21
0
/*!
 * \brief Check if the card can be moved from its current spot
 * \return boolean
 */
bool Card::isMovable()
{
    if (mIsOnAceSpot) {
        return false;
    }
    if (mChild == 0) {
        return true;
    }
    return isValidParentOf(mChild) && mChild->isMovable() && mBoard->hasEnoughFreecells(countChildren() + 1);
}
Beispiel #22
0
void Layer::setState(WebCore::GLWebViewState* state) {
    m_state = state;
    int count = countChildren();
    for (int i = 0; i < count; i++)
        m_children[i]->setState(state);
}