GFXBitmap *GFXFontEdit::getBitmapAbsolute(int charTableIndex)
{
	// pluck a bitmap (based on index in charTable, not ascii code)

	GFXCharInfo *cInfo;
	GFXBitmap       *bitmap0, *bitmap1, *bitmapSheet;

	cInfo = &(charTable[charTableIndex]);

	RectI bound(cInfo->x, 
            cInfo->y, 
            cInfo->x + cInfo->width  - 1,
			cInfo->y + cInfo->height - 1);

	// get a pointer to the sheet containing the char we're grabbing
	bitmapSheet = bma.array[cInfo->bitmapNo];

	// get a sub bitmap, note this uses shared memory
	bitmap0 = bitmapSheet->createSubBitmap(&bound);

	// from the sub bitmap create a new stand-alone bitmap
    bitmap1 = GFXBitmap::create(cInfo->width, cInfo->height);
	bitmap1->attribute = bitmapSheet->attribute;
	copyBits(bitmap1, bitmap0);

	// delete the temporary sub bitmap (won't delete pBits data since
	// it shares with original sheet	
	delete bitmap0;
	return(bitmap1);
}
Beispiel #2
0
/**
 * calculates the 12 bit CRC on a 128 bit word
 */
bitset<12> CRC12Calc::getCRC12(bitset<128> &dataSet128)
{
	bitset<12> crc;

	bitset<32> dataset32;
	bool crc_valid = false;
	bitset<12> p5;

	for (int i=3;i>=0;i--)
	{
		copyBits(dataset32, dataSet128, 0, i*32, 32);
		crc = getCRC12_part(dataset32, i, crc_valid, p5);
	}



	return crc;
}
Error Context::livenessAnalysis() {
  FuncNode* func = getFunc();
  JumpNode* from = NULL;

  Node* node = func->getEnd();
  uint32_t bLen = static_cast<uint32_t>(
    ((_contextVd.getLength() + VarBits::kEntityBits - 1) / VarBits::kEntityBits));

  LivenessTarget* ltCur = NULL;
  LivenessTarget* ltUnused = NULL;

  size_t varMapToVaListOffset = _varMapToVaListOffset;

  // No variables.
  if (bLen == 0)
    return kErrorOk;

  VarBits* bCur = newBits(bLen);
  if (bCur == NULL)
    goto _NoMemory;

  // Allocate bits for code visited first time.
_OnVisit:
  for (;;) {
    if (node->hasLiveness()) {
      if (bCur->_addBitsDelSource(node->getLiveness(), bCur, bLen))
        goto _OnPatch;
      else
        goto _OnDone;
    }

    VarBits* bTmp = copyBits(bCur, bLen);
    if (bTmp == NULL)
      goto _NoMemory;

    node->setLiveness(bTmp);
    VarMap* map = node->getMap();

    if (map != NULL) {
      uint32_t vaCount = map->getVaCount();
      VarAttr* vaList = reinterpret_cast<VarAttr*>(((uint8_t*)map) + varMapToVaListOffset);

      for (uint32_t i = 0; i < vaCount; i++) {
        VarAttr* va = &vaList[i];
        VarData* vd = va->getVd();

        uint32_t flags = va->getFlags();
        uint32_t ctxId = vd->getContextId();

        if ((flags & kVarAttrOutAll) && !(flags & kVarAttrInAll)) {
          // Write-Only.
          bTmp->setBit(ctxId);
          bCur->delBit(ctxId);
        }
        else {
          // Read-Only or Read/Write.
          bTmp->setBit(ctxId);
          bCur->setBit(ctxId);
        }
      }
    }

    if (node->getType() == kNodeTypeTarget)
      goto _OnTarget;

    if (node == func)
      goto _OnDone;

    ASMJIT_ASSERT(node->getPrev());
    node = node->getPrev();
  }

  // Patch already generated liveness bits.
_OnPatch:
  for (;;) {
    ASMJIT_ASSERT(node->hasLiveness());
    VarBits* bNode = node->getLiveness();

    if (!bNode->_addBitsDelSource(bCur, bLen))
      goto _OnDone;

    if (node->getType() == kNodeTypeTarget)
      goto _OnTarget;

    if (node == func)
      goto _OnDone;

    node = node->getPrev();
  }

_OnTarget:
  if (static_cast<TargetNode*>(node)->getNumRefs() != 0) {
    // Push a new LivenessTarget onto the stack if needed.
    if (ltCur == NULL || ltCur->node != node) {
      // Allocate a new LivenessTarget object (from pool or zone).
      LivenessTarget* ltTmp = ltUnused;

      if (ltTmp != NULL) {
        ltUnused = ltUnused->prev;
      }
      else {
        ltTmp = _baseZone.allocT<LivenessTarget>(
          sizeof(LivenessTarget) - sizeof(VarBits) + bLen * sizeof(uintptr_t));

        if (ltTmp == NULL)
          goto _NoMemory;
      }

      // Initialize and make current - ltTmp->from will be set later on.
      ltTmp->prev = ltCur;
      ltTmp->node = static_cast<TargetNode*>(node);
      ltCur = ltTmp;

      from = static_cast<TargetNode*>(node)->getFrom();
      ASMJIT_ASSERT(from != NULL);
    }
    else {
      from = ltCur->from;
      goto _OnJumpNext;
    }

    // Visit/Patch.
    do {
      ltCur->from = from;
      bCur->copyBits(node->getLiveness(), bLen);

      if (!from->hasLiveness()) {
        node = from;
        goto _OnVisit;
      }

      // Issue #25: Moved '_OnJumpNext' here since it's important to patch
      // code again if there are more live variables than before.
_OnJumpNext:
      if (bCur->delBits(from->getLiveness(), bLen)) {
        node = from;
        goto _OnPatch;
      }

      from = from->getJumpNext();
    } while (from != NULL);

    // Pop the current LivenessTarget from the stack.
    {
      LivenessTarget* ltTmp = ltCur;

      ltCur = ltCur->prev;
      ltTmp->prev = ltUnused;
      ltUnused = ltTmp;
    }
  }

  bCur->copyBits(node->getLiveness(), bLen);
  node = node->getPrev();

  if (node->isJmp() || !node->isFetched())
    goto _OnDone;

  if (!node->hasLiveness())
    goto _OnVisit;

  if (bCur->delBits(node->getLiveness(), bLen))
    goto _OnPatch;

_OnDone:
  if (ltCur != NULL) {
    node = ltCur->node;
    from = ltCur->from;

    goto _OnJumpNext;
  }
  return kErrorOk;

_NoMemory:
  return setError(kErrorNoHeapMemory);
}
Beispiel #4
0
/**
 * calculates a part of the CRC; used by getCRC12()
 */
bitset<12> CRC12Calc::getCRC12_part(bitset<32> DATA_in, int subtick_counter, bool &crc_valid, bitset<12> &p5)
{
	bitset<8> b0, b1, d0, d1;
	bitset<12> r0, r1, r2, r3, r4, r5, r6, r4_reg, r5_reg,p0,p1,p2,p3,p4,p3_reg,p4_reg;
	bitset<3> subtick_counter_reg;

	if (subtick_counter == 3)
	{
		r0 = 0;
	} else
	{
		r0 = p5;
	}

	if (subtick_counter == 0)
	{
		crc_valid = true;
	} else
	{
		crc_valid = false;
	}


	copyBits(b1, DATA_in, 0, 24, 8);
	copyBits(b0, DATA_in, 0, 16, 8);
	copyBits(d1, DATA_in, 0, 8, 8);
	copyBits(d0, DATA_in, 0, 0, 8);

	copyBits(r1, r0, 8, 0, 4);
	copyBits(r1, b1, 0, 0, 8);

	bitset<8> tmpr0;
	copyBits(tmpr0, r0, 0, 4, 8);
	r2 = lookupCRC(tmpr0);

	r3 = r1 ^ r2;

	copyBits(r4, r3, 8, 0, 4);
	copyBits(r4, b0, 0, 0, 8);

	bitset<8> tmpr3;
	copyBits(tmpr3, r3, 0, 4, 8);
	r5 = lookupCRC(tmpr3);

	r6 = r5 ^ r4;

	bitset<8> tmpr6;
	copyBits(tmpr6, r6, 0, 4, 8);
	p0 = lookupCRC(tmpr6);

	copyBits(p1, r6, 8, 0, 4);
	copyBits(p1, d1, 0, 0, 8);

	p2 = p0 ^ p1;

	bitset<8> tmpp2;
	copyBits(tmpp2, p2, 0, 4, 8);
	p3 = lookupCRC(tmpp2);

	copyBits(p4, p2, 8, 0, 4);
	copyBits(p4, d0, 0, 0, 8);

	p5 = p3 ^ p4;

	return p5;
}