예제 #1
0
void RenderDoc::ReleaseLayout(LayoutResult* layout) {
	if (layout == nullptr)
		return;
	std::lock_guard<std::mutex> lock(LayoutLock);
	XO_ASSERT(layout->IsLocked);
	layout->IsLocked = false;
	PurgeOldLayouts();
}
예제 #2
0
void xoImageTester::DoDirectory(const char* dir)
{
	struct Item
	{
		xo::String	Path;
		int			ImageSize;
	};
	xo::cheapvec<Item> files;
	auto found = [&files](const xo::FilesystemItem& item)
	{
		if (xo::TempString(item.Name).EndsWith(".xoml"))
		{
			int imageSize = 256;
			xo::String root = item.Root;
			xo::String fullName = xo::String(item.Root) + XO_DIR_SEP_STR + item.Name;
			// interpret example-32px.xoml to mean the output image is 32 x 32 pixels
			if (fullName.EndsWith("px.xoml"))
			{
				size_t slash = fullName.RIndex("-");
				XO_ASSERT(slash != -1);
				imageSize = atoi(fullName.SubStr(slash + 1, fullName.Length() - 7).Z); // 7 = length of "px.xoml"
			}
			files += Item{ fullName, imageSize };
		}
		return true;
	};
	xo::FindFiles(PathRelativeToTestData(dir).Z, found);

	xoImageTester tester;

	for (size_t i = 0; i < files.size(); i++)
	{
		Item& item = files[i];
		printf("Test %3d %30s\n", (int) i, item.Path.Z);
		auto setup = [&item](xo::DomNode& root)
		{
			xo::String err = root.Parse(LoadFileAsString(item.Path.Z).Z);
			XO_ASSERT(err == "");
		};
		tester.SetSize(item.ImageSize, item.ImageSize);
		tester.TruthImage(item.Path.Z, setup);
	}
}
예제 #3
0
void DomNode::RemoveChild(DomEl* c) {
	if (!c)
		return;
	IncVersion();
	size_t ix = Children.find(c);
	XO_ASSERT(ix != -1);
	Children.erase(ix);
	Doc->ChildRemoved(c);
	Doc->FreeChild(c);
}
예제 #4
0
// Returns our fastest ticking timer event handler (or zero if none)
uint32_t DomNode::FastestTimerMS() const {
	uint32_t f = UINT32_MAX - 1;
	for (const auto& h : Handlers) {
		if (h.TimerPeriodMS != 0) {
			XO_ASSERT(!!(h.Mask & EventTimer));
			f = Min(f, h.TimerPeriodMS);
		}
	}
	return f != UINT32_MAX - 1 ? f : 0;
}
예제 #5
0
LayoutResult* RenderDoc::AcquireLatestLayout() {
	std::lock_guard<std::mutex> lock(LayoutLock);

	if (LatestLayout == nullptr)
		return nullptr;

	XO_ASSERT(!LatestLayout->IsLocked);
	LatestLayout->IsLocked = true;

	return LatestLayout;
}
예제 #6
0
void DomNode::AddHandler(Events ev, EventHandlerF func, bool isLambda, void* context, uint32_t timerPeriodMS) {
	for (size_t i = 0; i < Handlers.size(); i++) {
		if (Handlers[i].Context == context && Handlers[i].Func == func) {
			XO_ASSERT(isLambda == Handlers[i].IsLambda());
			Handlers[i].Mask |= ev;
			Handlers[i].TimerPeriodMS = timerPeriodMS;
			RecalcAllEventMask();
			return;
		}
	}
	auto& h         = Handlers.add();
	h.Context       = context;
	h.Func          = func;
	h.Mask          = ev;
	h.TimerPeriodMS = timerPeriodMS;
	if (isLambda)
		h.SetLambda();
	RecalcAllEventMask();
}
예제 #7
0
void StyleSet::Grow(Pool* pool) {
	XO_ASSERT(BitsPerSlot != 8);
	uint32_t     newbits    = BitsPerSlot == 0 ? InitialBitsPerSlot : BitsPerSlot * 2;
	uint32_t     totalBits  = newbits * CatEND;
	void*        newlookup  = pool->Alloc((totalBits + 7) / 8, true);
	StyleAttrib* newattribs = pool->AllocNT<StyleAttrib>(CapacityAt(newbits), false);
	if (BitsPerSlot) {
		if (newbits == 4)
			MigrateLookup(Lookup, newlookup, &GetSlot2, &SetSlot4);
		else if (newbits == 8)
			MigrateLookup(Lookup, newlookup, &GetSlot4, &SetSlot8);

		memcpy(newattribs, Attribs, CapacityAt(BitsPerSlot) * sizeof(StyleAttrib));
	}
	Capacity    = CapacityAt(newbits);
	Lookup      = newlookup;
	Attribs     = newattribs;
	BitsPerSlot = newbits;
	//if (newbits == 2)		{ SetSlotF = &SetSlot2; GetSlotF = &GetSlot2; }
	//else if (newbits == 4)	{ SetSlotF = &SetSlot4; GetSlotF = &GetSlot4; }
	//else if (newbits == 8)	{ SetSlotF = &SetSlot8; GetSlotF = &GetSlot8; }
}
예제 #8
0
DomEl* DomNode::ChildByIndex(size_t index) {
	XO_ASSERT(index < Children.size());
	return Children[index];
}
예제 #9
0
DomNode* DomNode::AddNode(xo::Tag tag) {
	XO_ASSERT(tag != TagText);
	return static_cast<DomNode*>(AddChild(tag));
}
예제 #10
0
void Style::SetBox(StyleCategories cat, StyleBox val) {
	if (cat >= CatMargin_Left && cat <= CatBorder_Bottom) {
		SetBoxInternal(CatMakeBaseBox(cat), val);
	} else
		XO_ASSERT(false);
}
예제 #11
0
const RenderDomNode* LayoutResult::Body() const {
	if (Root.Children.size() == 0)
		return nullptr;
	XO_ASSERT(Root.Children[0]->IsNode());
	return static_cast<const RenderDomNode*>(Root.Children[0]);
}