Exemplo n.º 1
0
void
Shape::fixupShapeTreeAfterMovingGC()
{
    if (kids.isNull())
        return;

    if (kids.isShape()) {
        if (gc::IsForwarded(kids.toShape()))
            kids.setShape(gc::Forwarded(kids.toShape()));
        return;
    }

    JS_ASSERT(kids.isHash());
    KidsHash *kh = kids.toHash();
    for (KidsHash::Enum e(*kh); !e.empty(); e.popFront()) {
        Shape *key = e.front();
        if (!IsForwarded(key))
            continue;

        key = Forwarded(key);
        BaseShape *base = key->base();
        if (IsForwarded(base))
            base = Forwarded(base);
        UnownedBaseShape *unowned = base->unowned();
        if (IsForwarded(unowned))
            unowned = Forwarded(unowned);
        StackShape lookup(unowned,
                          const_cast<Shape *>(key)->propidRef(),
                          key->slotInfo & Shape::SLOT_MASK,
                          key->attrs,
                          key->flags);
        e.rekeyFront(lookup, key);
    }
}
Exemplo n.º 2
0
void sgw::BaseRenderer::CheckFlushList(const BaseShape& shape)
{
    if (m_flushListCollection.empty() || 
        m_flushListCollection.back().type != shape.GetFlushListType())
    {
        FlushList flushList;
        flushList.type = shape.GetFlushListType();
        m_flushListCollection.push_back(flushList);
    }
}
Exemplo n.º 3
0
bool ShapeEqual(const BaseShape& a,const BaseShape& b)
{
	if (a.get_x()!=b.get_x())	return false;
	if (a.get_y()!=b.get_y())	return false;
	if (a.get_color()!=b.get_color())	return false;
	if (a.get_dir()!=b.get_dir())	return false;
	return true;
}
Exemplo n.º 4
0
void
Shape::fixupShapeTreeAfterMovingGC()
{
    if (kids.isNull())
        return;

    if (kids.isShape()) {
        if (gc::IsForwarded(kids.toShape()))
            kids.setShape(gc::Forwarded(kids.toShape()));
        return;
    }

    MOZ_ASSERT(kids.isHash());
    KidsHash *kh = kids.toHash();
    for (KidsHash::Enum e(*kh); !e.empty(); e.popFront()) {
        Shape *key = e.front();
        if (IsForwarded(key))
            key = Forwarded(key);

        BaseShape *base = key->base();
        if (IsForwarded(base))
            base = Forwarded(base);
        UnownedBaseShape *unowned = base->unowned();
        if (IsForwarded(unowned))
            unowned = Forwarded(unowned);

        PropertyOp getter = key->getter();
        if (key->hasGetterObject())
            getter = PropertyOp(MaybeForwarded(key->getterObject()));

        StrictPropertyOp setter = key->setter();
        if (key->hasSetterObject())
            setter = StrictPropertyOp(MaybeForwarded(key->setterObject()));

        StackShape lookup(unowned,
                          const_cast<Shape *>(key)->propidRef(),
                          key->slotInfo & Shape::SLOT_MASK,
                          key->attrs,
                          key->flags);
        lookup.updateGetterSetter(getter, setter);
        e.rekeyFront(lookup, key);
    }
}
Exemplo n.º 5
0
		void BaseShapeUI::draw( const MDrawRequest & request, M3dView & view ) const {
			if (s_drawData.failure)
				return;

			MStatus status;

			view.beginGL();

			if (!s_drawData.initialized)
				initializeDraw();

			BaseShape *shape = (BaseShape *) surfaceShape();

			Model::Base base(MFnDagNode(shape->thisMObject()).parent(0, &status));

			if (!status) {
				status.perror("MFnDagNode::parent");
				return;
			}

			//MDagPath path = request.multiPath();
			MMaterial material = request.material();
			MColor color, borderColor;

			if (!(status = material.getDiffuse(color))) {
				status.perror("MMaterial::getDiffuse");
				return;
			}

			bool wireframe = (M3dView::DisplayStyle) request.token() == M3dView::kWireFrame;

			if (wireframe) {
				glPushAttrib(GL_POLYGON_BIT);

				glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
			}

			glUseProgram(s_drawData.program);
			
			switch (request.displayStatus())
            {
            case M3dView::kLead :
				borderColor = view.colorAtIndex( LEAD_COLOR);
				//glUniform1f(s_drawData.border_uniform, 1.0f);
				s_drawData.updateBorderUniform(1.0f);
				//glUniform3f(s_drawData.borderColor_uniform, borderColor.r, borderColor.g, borderColor.b);
				s_drawData.updateBorderColorUniform(borderColor.r, borderColor.g, borderColor.b);
				break;
            case M3dView::kActive :
                borderColor = view.colorAtIndex( ACTIVE_COLOR);
				//glUniform1f(s_drawData.border_uniform, 1.0f);
				s_drawData.updateBorderUniform(1.0f);
				//glUniform3f(s_drawData.borderColor_uniform, borderColor.r, borderColor.g, borderColor.b);
				s_drawData.updateBorderColorUniform(borderColor.r, borderColor.g, borderColor.b);
                break;
            case M3dView::kActiveAffected :
                borderColor = view.colorAtIndex( ACTIVE_AFFECTED_COLOR);
				//glUniform1f(s_drawData.border_uniform, 0.0f);
				s_drawData.updateBorderUniform(0.0f);
                break;
            case M3dView::kDormant :
				borderColor = view.colorAtIndex( DORMANT_COLOR, M3dView::kDormantColors);
				//glUniform1f(s_drawData.border_uniform, 0.0f);
				s_drawData.updateBorderUniform(0.0f);
                break;
            case M3dView::kHilite :
                borderColor = view.colorAtIndex( HILITE_COLOR);
				//glUniform1f(s_drawData.border_uniform, 1.0f);
				s_drawData.updateBorderUniform(1.0f);
				//glUniform3f(s_drawData.borderColor_uniform, borderColor.r, borderColor.g, borderColor.b);
				s_drawData.updateBorderColorUniform(borderColor.r, borderColor.g, borderColor.b);
                break;
            }

			//glUniform3f(s_drawData.color_uniform, color.r, color.g, color.b);
			s_drawData.updateColorUniform(color.r, color.g, color.b);

			glCallList(s_drawData.display_list);

			if (wireframe)
				glPopAttrib();

			view.endGL();
		}
Exemplo n.º 6
0
static void
StatsCellCallback(JSRuntime *rt, void *data, void *thing, JSGCTraceKind traceKind,
                  size_t thingSize)
{
    IteratorClosure *closure = static_cast<IteratorClosure *>(data);
    RuntimeStats *rtStats = closure->rtStats;
    ZoneStats *zStats = rtStats->currZoneStats;
    switch (traceKind) {
      case JSTRACE_OBJECT: {
        JSObject *obj = static_cast<JSObject *>(thing);
        CompartmentStats *cStats = GetCompartmentStats(obj->compartment());
        if (obj->is<JSFunction>())
            cStats->gcHeapObjectsFunction += thingSize;
        else if (obj->is<ArrayObject>())
            cStats->gcHeapObjectsDenseArray += thingSize;
        else if (obj->isCrossCompartmentWrapper())
            cStats->gcHeapObjectsCrossCompartmentWrapper += thingSize;
        else
            cStats->gcHeapObjectsOrdinary += thingSize;

        JS::ObjectsExtraSizes objectsExtra;
        obj->sizeOfExcludingThis(rtStats->mallocSizeOf_, &objectsExtra);
        cStats->objectsExtra.add(objectsExtra);

        // JSObject::sizeOfExcludingThis() doesn't measure objectsExtraPrivate,
        // so we do it here.
        if (ObjectPrivateVisitor *opv = closure->opv) {
            nsISupports *iface;
            if (opv->getISupports_(obj, &iface) && iface) {
                cStats->objectsExtra.private_ += opv->sizeOfIncludingThis(iface);
            }
        }
        break;
      }

      case JSTRACE_STRING: {
        JSString *str = static_cast<JSString *>(thing);

        size_t strSize = str->sizeOfExcludingThis(rtStats->mallocSizeOf_);

        // If we can't grow hugeStrings, let's just call this string non-huge.
        // We're probably about to OOM anyway.
        if (strSize >= JS::HugeStringInfo::MinSize() && zStats->hugeStrings.growBy(1)) {
            zStats->gcHeapStringsNormal += thingSize;
            JS::HugeStringInfo &info = zStats->hugeStrings.back();
            info.length = str->length();
            info.size = strSize;
            PutEscapedString(info.buffer, sizeof(info.buffer), &str->asLinear(), 0);
        } else if (str->isShort()) {
            MOZ_ASSERT(strSize == 0);
            zStats->gcHeapStringsShort += thingSize;
        } else {
            zStats->gcHeapStringsNormal += thingSize;
            zStats->stringCharsNonHuge += strSize;
        }
        break;
      }

      case JSTRACE_SHAPE: {
        Shape *shape = static_cast<Shape *>(thing);
        CompartmentStats *cStats = GetCompartmentStats(shape->compartment());
        size_t propTableSize, kidsSize;
        shape->sizeOfExcludingThis(rtStats->mallocSizeOf_, &propTableSize, &kidsSize);
        if (shape->inDictionary()) {
            cStats->gcHeapShapesDict += thingSize;
            cStats->shapesExtraDictTables += propTableSize;
            JS_ASSERT(kidsSize == 0);
        } else {
            if (shape->base()->getObjectParent() == shape->compartment()->maybeGlobal()) {
                cStats->gcHeapShapesTreeGlobalParented += thingSize;
            } else {
                cStats->gcHeapShapesTreeNonGlobalParented += thingSize;
            }
            cStats->shapesExtraTreeTables += propTableSize;
            cStats->shapesExtraTreeShapeKids += kidsSize;
        }
        break;
      }

      case JSTRACE_BASE_SHAPE: {
        BaseShape *base = static_cast<BaseShape *>(thing);
        CompartmentStats *cStats = GetCompartmentStats(base->compartment());
        cStats->gcHeapShapesBase += thingSize;
        break;
      }

      case JSTRACE_SCRIPT: {
        JSScript *script = static_cast<JSScript *>(thing);
        CompartmentStats *cStats = GetCompartmentStats(script->compartment());
        cStats->gcHeapScripts += thingSize;
        cStats->scriptData += script->sizeOfData(rtStats->mallocSizeOf_);
#ifdef JS_ION
        size_t baselineData = 0, baselineStubsFallback = 0;
        ion::SizeOfBaselineData(script, rtStats->mallocSizeOf_, &baselineData,
                                &baselineStubsFallback);
        cStats->baselineData += baselineData;
        cStats->baselineStubsFallback += baselineStubsFallback;
        cStats->ionData += ion::SizeOfIonData(script, rtStats->mallocSizeOf_);
#endif

        ScriptSource *ss = script->scriptSource();
        SourceSet::AddPtr entry = closure->seenSources.lookupForAdd(ss);
        if (!entry) {
            closure->seenSources.add(entry, ss); // Not much to be done on failure.
            rtStats->runtime.scriptSources += ss->sizeOfIncludingThis(rtStats->mallocSizeOf_);
        }
        break;
      }

      case JSTRACE_LAZY_SCRIPT: {
        LazyScript *lazy = static_cast<LazyScript *>(thing);
        zStats->gcHeapLazyScripts += thingSize;
        zStats->lazyScripts += lazy->sizeOfExcludingThis(rtStats->mallocSizeOf_);
        break;
      }

      case JSTRACE_IONCODE: {
#ifdef JS_ION
        zStats->gcHeapIonCodes += thingSize;
        // The code for a script is counted in ExecutableAllocator::sizeOfCode().
#endif
        break;
      }

      case JSTRACE_TYPE_OBJECT: {
        types::TypeObject *obj = static_cast<types::TypeObject *>(thing);
        zStats->gcHeapTypeObjects += thingSize;
        zStats->typeObjects += obj->sizeOfExcludingThis(rtStats->mallocSizeOf_);
        break;
      }

    }

    // Yes, this is a subtraction:  see StatsArenaCallback() for details.
    zStats->gcHeapUnusedGcThings -= thingSize;
}