示例#1
0
/** Optimised 8-bit tone fill for the most common cases. */
static void imageblt8(render_blit_t *rb, imgblt_params_t *params,
                      imgblt_callback_fn *callback,
                      Bool *result)
{
#ifdef BLIT_CONTONE_8
  /* Added code size for optimised images only if we're using this for an
     output surface. */
  const blit_colormap_t *map ;

  HQASSERT(rb != NULL, "No image blit render state") ;
  HQASSERT(callback, "No image blit callback") ;
  VERIFY_OBJECT(params, IMGBLT_PARAMS_NAME) ;

  VERIFY_OBJECT(rb->color, BLIT_COLOR_NAME) ;
  map = rb->color->map ;
  VERIFY_OBJECT(map, BLIT_MAP_NAME) ;

  ASSERT_BASE_OR_FORWARD_ONLY(rb, imagefn, &next_imgblt,
                              "Tone 8 image function called after other blits") ;

  /* Very specialised fully expanded blit stack for unclipped/rectclipped
     images. The combinations we probably want for this are forward/backward,
     subtractive/additive. */
  if ( params->type == IM_BLIT_IMAGE && !params->out16 &&
       params->one_color_channel && !params->on_the_fly &&
       !map->apply_properties && channel_is_negative8(map, 0) ) {
    if ( params->orthogonal ) {
      HQASSERT(!params->wflip && !params->hflip,
               "Tone8 surface should not be X or Y flipped") ;
      if ( rb->clipmode != BLT_CLP_COMPLEX ) {
        if ( params->geometry->wx != 0 ) {
          *result = orth_subtractive_1x8_rows(rb, params) ;
        } else {
          *result = orth_subtractive_1x8_cols(rb, params) ;
        }
        return ;
      }
    } else { /* rotated, 8-bit, one subtractive color channel image. */
      if ( params->tiles ) {
        if ( params->dcol < 0 ) {
          *result = rot_subtractive_1x8_backward(rb, params) ;
        } else {
          *result = rot_subtractive_1x8_forward(rb, params) ;
        }
        return ;
      }
    }
  }
#endif /* BLIT_CONTONE_8 */

  imagebltn(rb, params, callback, result) ;
}
示例#2
0
/** Expanding the color is a no-op because the pack routine already did
    it. */
static void tone8_color_expand(blit_color_t *color)
{
  UNUSED_PARAM(blit_color_t *, color) ;
  VERIFY_OBJECT(color, BLIT_COLOR_NAME) ;
  HQASSERT(color->valid & blit_color_packed, "Blit color not packed") ;
  HQASSERT(color->valid & blit_color_expanded, "Blit color not expanded") ;
}
示例#3
0
static void cid0_end_char(FONTinfo *fontInfo,
                          charcontext_t *context)
{
  CID0_CACHE *cid_font ;
  charstring_methods_t *cid0methods ;

  UNUSED_PARAM(FONTinfo *, fontInfo) ;

  HQASSERT(context, "No context object") ;

  cid0methods = context->methods ;
  HQASSERT(cid0methods, "CID Type 0 charstring methods lost") ;

  cid_font = cid0methods->data ;
  VERIFY_OBJECT(cid_font, CID0_CACHE_NAME) ;
  HQASSERT(cid0methods == &cid_font->cid0methods,
           "CID charstring methods inconsistent with font structure") ;

  fontdata_close(&cid_font->font_data) ;

  HQASSERT(fontInfo == cid_font->fontInfo,
           "Font info does not match at end of CID0 character") ;
  cid_font->fontInfo = NULL ;

  object_store_null(&context->definition) ;
}
示例#4
0
void corejob_begin(DL_STATE *page)
{
  corejob_t *job ;
  job = page->job ;

  VERIFY_OBJECT(job, CORE_JOB_NAME) ;
  HQASSERT(job->first_dl == page && job->last_dl == page,
           "Job tracker out of sync with DL page") ;
  HQASSERT(job->state == CORE_JOB_NONE, "Unexpected core job state") ;

  page->pageno = 0 ;

  mps_telemetry_label(0, jobStart);

  job->state = CORE_JOB_CONFIG ;
  job->has_output = FALSE ;
  job->pages_output = 0 ;
  job->failed = FALSE ;

  probe_begin(SW_TRACE_JOB_CONFIG, (intptr_t)job);

  if ( (page->timeline = timeline_push(&job->timeline, SWTLT_JOB_CONFIG,
                                       0 /*end*/, SW_TL_UNIT_NONE,
                                       job, job->name.string, job->name.length))
       == SW_TL_REF_INVALID ) {
    job->failed = TRUE ;
    /** \todo ajcd 2011-07-20: Decide how to clean up */
    HQFAIL("Job config timeline start failed") ;
  }

  mps_telemetry_label(0, configStart);
}
示例#5
0
/** \brief Clear a given quantity of data from the CID cache.

    \param purge  The amount to purge.
    \return  The amount purged.

  This won't touch data currently in use, so it may fail to clear as
  much as requested.
 */
static size_t cid0_purge(size_t purge)
{
  CID0_CACHE *cid_font, **cid_prev = &cid0_font_cache ;
  size_t orig_size = cid0_cache_size, level;

  level = orig_size - purge;
  cid0_cache_size = 0 ;

  /** \todo The CID font list is an MRU list, so it'd be best to purge
      starting from the tail. */
  while ( (cid_font = *cid_prev) != NULL ) {
    VERIFY_OBJECT(cid_font, CID0_CACHE_NAME) ;

    /* Purge fonts that are not in use, have been garbage collected, and
       are superfluous to our needs. */
    if ( cid_font->font_data == NULL &&
         (cid0_cache_size >= level || cid_font->source == NULL) ) {
      *cid_prev = cid_font->next ;

      UNNAME_OBJECT(cid_font) ;
      mm_free(mm_pool_temp, (mm_addr_t)cid_font, sizeof(CID0_CACHE)) ;
    } else {
      cid0_cache_size += sizeof(CID0_CACHE) ;
      cid_prev = &cid_font->next ;
    }
  }
  HQASSERT((cid0_cache_size == 0) == (cid0_font_cache == NULL) &&
           orig_size >= cid0_cache_size,
           "Inconsistent CID Type 0 cache size") ;
  return orig_size - cid0_cache_size ;
}
示例#6
0
static sw_blob_result blobdata_file_length(const OBJECT *file,
                                           blobdata_private_t *data,
                                           Hq32x2 *length)
{
  HQASSERT(file, "No file object") ;
  HQASSERT(oType(*file) == OFILE || oType(*file) == OSTRING,
           "Blob data source is not a file or a filename") ;
  HQASSERT(length != NULL, "No where to put length") ;
  VERIFY_OBJECT(data, BLOBDATA_PRIVATE_NAME) ;

  /* If we marked the file for lazy opening, then open it now. */
  if ( !data->isopen && !blobdata_file_lazy(file, data) )
    return FAILURE(SW_BLOB_ERROR_EXPIRED) ;

  /* If the length stored is valid, return it. */
  if ( !data->length_ok ) {
    if ( data->fhandle >= 0 ) {
      /* Getting the length of a device file is a *very* expensive
         operation. */
      if ( !(*theIBytesFile(data->dev))(data->dev, data->fhandle,
                                        &data->length, SW_BYTES_TOTAL_ABS) ) {
        (void)device_error_handler(data->dev);
        return FAILURE(SW_BLOB_ERROR_EOF) ;
      }

      if ( data->encrypted ) {
        /* Reduce length by size of initialisation and tail data */
        Hq32x2SubtractInt32(&data->length, &data->length,
                            data->hqxoffset + data->hqxtail) ;
        HQASSERT(Hq32x2Sign(&data->length) >= 0,
                 "HQX leader/trailer exceed length of file") ;
      }
    } else {
      /* File/filter bytes available is likely to fail. */
      Hq32x2 start = HQ32X2_INIT_ZERO ;
      FILELIST *flptr ;

      HQASSERT(oType(*file) == OFILE, "Blob data source is not a file") ;

      flptr = oFile(*file) ;
      HQASSERT(isIOpenFile(flptr), "Blob data file is not open") ;

      /* There isn't a good way of getting a file's length. Reset the file
         position to the start, because RSDs give the bytes available from
         the (unspecified) current position. Ignore it if this fails, in the
         vain hope that other bytes available will do something useful. */
      (void)(*theIMySetFilePos(flptr))(flptr, &start) ;

      if ( (*theIMyBytesAvailable(flptr))(flptr, &data->length) == EOF )
        return FAILURE(SW_BLOB_ERROR_EOF) ;

      HQASSERT(!data->encrypted, "FILELIST should not be hqx encrypted") ;
    }
  }

  data->length_ok = TRUE ;
  *length = data->length ;

  return SW_BLOB_OK ;
}
示例#7
0
/* GC scanning for CID cache. I would prefer to have a hook to finalisation,
   so we can delete the cache entry when the object is GC'ed. */
static mps_res_t MPS_CALL cid0_scan(mps_ss_t ss, void *p, size_t s)
{
  CID0_CACHE *cid_font ;

  UNUSED_PARAM(void *, p);
  UNUSED_PARAM(size_t, s);

  MPS_SCAN_BEGIN( ss )
    for ( cid_font = cid0_font_cache ; cid_font ; cid_font = cid_font->next ) {
      VERIFY_OBJECT(cid_font, CID0_CACHE_NAME) ;

      /* If we're GC scanning, we are probably in a low-memory situation.
         Mark this font entry as freeable if it's not in use, fix the source
         pointer if it is. The MPS is not reentrant, so we can't actually
         free it now. */
      if ( cid_font->font_data == NULL )
        MPS_SCAN_UPDATE( cid_font->source, NULL );
      else
        /* Fix the font data source objects, so they won't be collected. */
        MPS_RETAIN( &cid_font->source, TRUE );
    }
  MPS_SCAN_END( ss );

  return MPS_RES_OK ;
}
示例#8
0
文件: fsm.c 项目: Graynomad/LARD
void fsmHandleEvents (Fsm * fsm) {
	uint32 		event;
	uint32		offset;
	fsmEvent 	e;
	uint32		returned_state;

	VERIFY_OBJECT(fsm, OBJID_FSM);

	while (fsm->q_events->nItems) {
		event = fifo32Read (fsm->q_events, NULL);

		e.val = event >> 8;
		e.event = event &= 0xFF;

		offset = (fsm->state * fsm->n_events) + e.event;

		fsmFuncPtr f = *(fsm->actions+offset);
		if (f != NULL) returned_state = f(e);
//		returned_state = (*(fsm->actions+offset))(e);

		if (returned_state >= fsm->n_states) {
			SYS_ERROR (ERR_BAD_FSM_STATE | returned_state);
		} else {
			fsm->state = returned_state;
		}
	}
}
示例#9
0
corejob_t *corejob_acquire(corejob_t *job)
{
  hq_atomic_counter_t before ;

  VERIFY_OBJECT(job, CORE_JOB_NAME) ;

  HqAtomicIncrement(&job->refcount, before) ;
  HQASSERT(before > 0, "Job was previously released") ;

  return job ;
}
示例#10
0
/* If a character is on disk, pull it into the CID data cache. */
static Bool cid0_begin_char(FONTinfo *fontInfo,
                            charcontext_t *context)
{
  CID0_CACHE *cid_font ;

  HQASSERT(fontInfo, "No font info") ;
  HQASSERT(context, "No character context") ;

  HQASSERT(theIFontType(fontInfo) == CIDFONTTYPE0, "Not in a CID Type 0") ;
  HQASSERT(context->chartype == CHAR_Type1 ||
           context->chartype == CHAR_Type2, "Not a Type 1/2 charstring") ;

  if ( (cid_font = cid0_set_font(fontInfo)) == NULL )
    return FALSE ;

  VERIFY_OBJECT(cid_font, CID0_CACHE_NAME) ;

  if ( (cid_font->font_data = fontdata_open(cid_font->source,
                                            cid_font->fdmethods)) == NULL )
    return FALSE ;

  if ( oType(context->definition) == ONULL ) {
    /* cid0_lookup_char creates a special ONULL object containing an integer
       offset and a length. This is now converted into a string by opening a
       fontdata frame. */
    if ( (oString(context->definition) =
          fontdata_frame(cid_font->font_data,
                         cid_font->offset + oInteger(context->definition),
                         theLen(context->definition),
                         sizeof(uint8))) == NULL ) {
      fontdata_close(&cid_font->font_data) ;
      return FALSE ;
    }

    theTags(context->definition) = OSTRING | LITERAL | READ_ONLY ;
  }

  HQASSERT(oType(context->definition) == OSTRING,
           "Definition of CID character is wrong type") ;

  context->methods = &cid_font->cid0methods ;

  /* cid0_get_info is based on ps1_get_info, which uses the fontInfo to
     extract information. Save the current font info between begin_char and
     end_char; this means we cannot call CID0 fonts recursively. */
  HQASSERT(cid_font->fontInfo == NULL, "Should not call CID0 recursively.") ;
  cid_font->fontInfo = fontInfo ;

  return TRUE ;
}
示例#11
0
文件: fsm.c 项目: Graynomad/LARD
uint32 fsmRaiseEvent (Fsm * fsm, uint32 event, uint32 val) {

	VERIFY_OBJECT(fsm, OBJID_FSM);

	if (event >= fsm->n_events) {
		SYS_ERROR (ERR_BAD_FSM_EVENT | event);
		return ERROR;
	}

	fifo32Write (fsm->q_events, (val << 8) | event);

	return NOERROR;

}
示例#12
0
static uint8 blobdata_file_protection(const OBJECT *file,
                                      blobdata_private_t *data)
{
  VERIFY_OBJECT(data, BLOBDATA_PRIVATE_NAME) ;

  /* If we marked the file for lazy opening, then open it now. */
  if ( !data->isopen && !blobdata_file_lazy(file, data) )
    return FAILURE(PROTECTED_NONE) ;

  if ( data->encrypted )
    return PROTECTED_HQXRUN ;

  return PROTECTED_NONE ;
}
示例#13
0
文件: lstring.c 项目: LORDofDOOM/LARD
/////////////////////////////////////////////////////////////////////
//
// Function name:		stringCopyToArray
//
// Description:
//
// Parameters:
//
// Returned value:
//
// Errors raised:
//
// Example:
//
// Notes:
//
uint32 stringCopyToArray(string * s, char * c) {

	VERIFY_OBJECT(s, OBJID_STRING)

	uint8 * from = s->str;
	uint8 * to = (uint8 *)c;

	while (*from) {
		*to++ = *from++;
	}
	*to = NULLCHAR;

	return NOERROR;
}
示例#14
0
/** Blit color packing for 1 channel of 8 bit, negative. */
static inline void tone8_pack_negative(blit_color_t *color)
{
  blit_t v ;

  VERIFY_OBJECT(color, BLIT_COLOR_NAME) ;
  HQASSERT(color->valid & blit_color_quantised, "Blit color is not quantised") ;
#if 0
  /* Would be nice to assert that we're not wasting work, but the erase
     color is quantised and packed when it is set up, so this won't work. */
  HQASSERT(!(color->valid & blit_color_packed), "Blit color already packed") ;
#endif

  VERIFY_OBJECT(color->map, BLIT_MAP_NAME) ;
  HQASSERT(color->map->nchannels == 1 &&
           color->map->rendered[0] == 1 &&
           color->map->nrendered == 1 &&
           color->map->packed_bits == 8 &&
           color->map->expanded_bytes == sizeof(blit_t) &&
           !color->map->apply_properties &&
           channel_is_8bit(color->map, 0) &&
           channel_is_negative8(color->map, 0),
           "Not a 1x8 bit negative colormap") ;

  /* Quicker to re-pack and expand in one go. */
  HQASSERT(color->quantised.qcv[0] <= 255,
           "Quantised colorvalue doesn't fit in a byte") ;
  v = color->quantised.qcv[0] ;
  v |= v << 8 ;
  v |= v << 16 ;
#if BLIT_WIDTH_BYTES > 4
  v |= v << 32 ;
#endif
  color->packed.channels.blits[0] = ~v ;
#ifdef ASSERT_BUILD
  color->valid |= blit_color_packed|blit_color_expanded ;
#endif
}
示例#15
0
/** Preserve the blob data if possible by storing the filename in a global
   string. */
static OBJECT *blobdata_file_restored(const OBJECT *file,
                                      blobdata_private_t *data,
                                      int32 savelevel)
{
  DEVICELIST *dev ;
  FILELIST *flptr ;

  UNUSED_PARAM(blobdata_private_t *, data) ;

  HQASSERT(file, "No blob data source") ;
  VERIFY_OBJECT(data, BLOBDATA_PRIVATE_NAME) ;

  if ( NUMBERSAVES(savelevel) > MAXGLOBALSAVELEVEL &&
       oType(*file) == OFILE &&
       (flptr = oFile(*file)) != NULL &&
       (dev = theIDeviceList(flptr)) != NULL ) {
    int32 devlen = strlen_int32((char *)theIDevName(dev)) ;
    int32 length = devlen + theINLen(flptr) + 2 ;
    OBJECT *string ;

    /* We're in a local save levels. We can re-use the file if it is a real
       device file. Store the full filename (including device name) in
       global memory. */
    if ( (string = get_gomemory(1)) != NULL ) {
      uint8 *smem ;
      if ( (smem = get_gsmemory(length)) != NULL ) {
        smem[0] = '%' ;
        HqMemCpy(smem + 1, theIDevName(dev), devlen) ;
        smem[devlen + 1] = '%' ;
        if ( theINLen(flptr) )
          HqMemCpy(smem + devlen + 2, theICList(flptr), theINLen(flptr)) ;

        oString(*string) = smem ;
        theTags(*string) = OSTRING | LITERAL | READ_ONLY ;
        theLen(*string) = CAST_UNSIGNED_TO_UINT16(length);
        SETGLOBJECTTO(*string, TRUE) ;

        return string ;
      }

      /* Got object memory, but no string memory. Forget the global object,
         it will get restored soon enough. */
      theTags(*string) = ONULL ;
    }
  }

  /* Forget about it, we can't save the data any more */
  return NULL ;
}
示例#16
0
/**
 * Set all the 8bit pixels in a given form to a given value
 */
static void areahalf8(render_blit_t *rb,  FORM *formptr )
{
  blit_color_t *color = rb->color ;

  HQASSERT(formptr->type == FORMTYPE_BANDBITMAP,
           "Output form is not tonemap") ;

  VERIFY_OBJECT(color, BLIT_COLOR_NAME) ;
  HQASSERT(color->map->packed_bits == 8, "Packed color size incorrect") ;
  HQASSERT(color->map->expanded_bytes != 0, "Expanded color size incorrect") ;

  blit_color_expand(color) ;

  BlitSet(theFormA(*formptr), color->packed.channels.blits[0],
          theFormS(*formptr) >> BLIT_SHIFT_BYTES);
}
示例#17
0
文件: spi.c 项目: Graynomad/LARD
void spiFlush (spiConnection * s) {

	VERIFY_OBJECT(s, OBJID_SPI_CONNECTION)

	uint8 x = 0;

	spiLoopbackOn(s);

	for (int i = 0; i < 8; i++)
		s->port->DR = 0;

	for (int i = 0; i < 8; i++)
		x = s->port->DR;

	spiLoopbackOff(s);
}
示例#18
0
void corejob_set_timeout(corejob_t *job, int32 timeout)
{
  VERIFY_OBJECT(job, CORE_JOB_NAME);

  /* Remove any existing timer */
  if (job->timeout_timer != NULL) {
    hqn_timer_destroy(job->timeout_timer);
    job->timeout_timer = NULL;
  }
  /* Set a new one if needed */
  if (timeout > 0) {
    sw_tl_ref ref ;
    CHECK_TL_VALID((ref = SwTimelineOfType(job->timeline, SWTLT_JOB_STREAM)));
    job->timeout_timer = hqn_timer_create(timeout*1000, 0, timeout_fire,
                                          (void *)((intptr_t)ref));
  }
}
示例#19
0
static void blobdata_file_destroy(OBJECT *file, blobdata_private_t **data)
{
  blobdata_private_t *state ;

  UNUSED_PARAM(OBJECT *, file) ;

  HQASSERT(oType(*file) == OFILE || oType(*file) == OSTRING,
           "Blob data source is not a file or a filename") ;
  HQASSERT(data, "Nowhere for private data") ;

  state = *data ;
  VERIFY_OBJECT(state, BLOBDATA_PRIVATE_NAME) ;

  UNNAME_OBJECT(state) ;
  mm_free(mm_pool_temp, (mm_addr_t)state, sizeof(blobdata_private_t)) ;
  *data = NULL ;
}
示例#20
0
static sw_event_result HQNCALL corejob_tl_ended(void *context, sw_event *evt)
{
  SWMSG_TIMELINE *msg = evt->message;

  UNUSED_PARAM(void *, context);

  HQASSERT(evt->type == EVENT_TIMELINE_ENDED ||
           evt->type == EVENT_TIMELINE_ABORTED, "Unexpected event type");
  if ( msg == NULL || evt->length < sizeof(SWMSG_TIMELINE) )
    return SW_EVENT_CONTINUE;

  if ( msg->type == SWTLT_JOB_STREAM) {
    corejob_t *job = msg->context ;

    VERIFY_OBJECT(job, CORE_JOB_NAME) ;

    /* Close the JobLog file [65510] */
    if (job->logfile >= 0) {
      /* Detach the default handler for the %progress%JobLog channel */
      (void)SwSafeDeregisterHandler(SWEVT_MONITOR, &prog_handler) ;
      prog_handler.context = NULL ;
      if (progressdev != NULL)
        (void)(*theICloseFile(progressdev))(progressdev, job->logfile) ;
      job->logfile = -1 ;
    }

    /* This is where we finally release the core job object. */
    HQASSERT(job->refcount == 0, "Live job object in ended timeline") ;
    HQASSERT(job->name.length == 0 &&
             job->join_group == NULL && job->task_group == NULL &&
             job->previous == NULL, "Job object not properly released") ;

#ifdef ASSERT_BUILD
    --corejob_allocs ;
#endif

    UNNAME_OBJECT(job) ;
    mm_free(mm_pool_temp, job, sizeof(corejob_t)) ;

    /* Since the context has now disappeared, it wouldn't be safe for any
       other handlers to run. */
    return SW_EVENT_HANDLED;
  }

  return SW_EVENT_CONTINUE;
}
示例#21
0
static sw_blob_result blobdata_file_open(OBJECT *file, blobdata_private_t *data, int mode)
{
  UNUSED_PARAM(OBJECT *, file) ;

  HQASSERT(file, "No blob data source") ;
  HQASSERT(oType(*file) == OFILE || oType(*file) == OSTRING,
           "Blob data source is not a file or a filename") ;
  VERIFY_OBJECT(data, BLOBDATA_PRIVATE_NAME) ;

  data->dev = NULL ;
  data->fhandle = -1 ;
  data->isopen = FALSE ;
  data->length_ok = FALSE ;
  data->mode = mode ;

  return SW_BLOB_OK ;
}
示例#22
0
static uint8 *blobdata_file_available(const OBJECT *file,
                                     blobdata_private_t *data,
                                     Hq32x2 start, size_t *length)
{
  UNUSED_PARAM(const OBJECT *, file) ;
  UNUSED_PARAM(blobdata_private_t *, data) ;
  UNUSED_PARAM(Hq32x2, start) ;
  UNUSED_PARAM(size_t *, length) ;

  HQASSERT(file, "No file object") ;
  HQASSERT(oType(*file) == OFILE || oType(*file) == OSTRING,
           "Blob data source is not a file or a filename") ;
  HQASSERT(length, "No available length") ;
  VERIFY_OBJECT(data, BLOBDATA_PRIVATE_NAME) ;

  /* Must always copy data from buffers */
  return NULL ;
}
示例#23
0
void corejob_running(DL_STATE *page)
{
  corejob_t *job = page->job ;

  VERIFY_OBJECT(job, CORE_JOB_NAME) ;
  HQASSERT(job->first_dl == page && job->last_dl == page,
           "Job tracker out of sync with DL page") ;
  HQASSERT(job->state == CORE_JOB_CONFIG, "Unexpected core job state") ;

  mps_telemetry_label(0, configEnd);
  timeline_pop(&job->timeline, SWTLT_JOB_CONFIG, !job->failed) ;
  probe_end(SW_TRACE_JOB_CONFIG, (intptr_t)job);

  job->state = CORE_JOB_RUNNING ;

  probe_begin(SW_TRACE_JOB, (intptr_t)job);
  if ( (page->timeline = timeline_push(&job->timeline, SWTLT_JOB,
                                       SW_TL_EXTENT_INDETERMINATE /*end*/,
                                       SW_TL_UNIT_PAGES,
                                       job, job->name.string, job->name.length))
       == SW_TL_REF_INVALID ) {
    job->failed = TRUE ;
    /** \todo ajcd 2011-07-20: Decide how to clean up */
    HQFAIL("Job timeline start failed") ;
  }

  /* Register user and timeout interrupt handlers for this job */
  job->interrupt_handler.context = job;
  if (SwRegisterHandler(SWEVT_INTERRUPT_USER, &job->interrupt_handler,
                        SW_EVENT_NORMAL) != SW_RDR_SUCCESS ||
      SwRegisterHandler(SWEVT_INTERRUPT_TIMEOUT, &job->interrupt_handler,
                        SW_EVENT_NORMAL) != SW_RDR_SUCCESS) {
    job->failed = TRUE;
    /* Deregister user interrupt event handler in case it succeeded. */
    (void)SwSafeDeregisterHandler(SWEVT_INTERRUPT_USER, &job->interrupt_handler);
    /** \todo mrw 2011-08-19: needs clean up along lines of what happens with
     * timeline. */
    HQFAIL("Job start interrupt handler register failed") ;
    job->interrupt_handler.context = NULL;
  }

  mps_telemetry_label(0, jobStart);
}
示例#24
0
static void tone8_blitmap_optimise(blit_colormap_t *map)
{
  VERIFY_OBJECT(map, BLIT_MAP_NAME) ;

  HQASSERT(map->packed_bits == 8 && map->nchannels == 1 &&
           channel_is_8bit(map, 0),
           "Not a suitable 8-bit blit map") ;

  /* We have several options for 8-bit. We only use these if not applying
     properties, because properties may affect the rendered state of
     channels. */
  if ( !map->apply_properties && map->nrendered == 1 ) {
    /* One 8-bit rendered channel. Is it positive or negative? */
    if ( channel_is_positive(map, 0) ) { /* Additive */
      map->pack_quantised_color = tone8_pack_positive ;
    } else if ( channel_is_negative8(map, 0) ) { /* Subtractive */
      map->pack_quantised_color = tone8_pack_negative ;
    }
    map->expand_packed_color = tone8_color_expand ;
  }
}
示例#25
0
文件: lstring.c 项目: LORDofDOOM/LARD
// Notes:				In the case of a ERR_STRING_ARRAY_TOO_LONG error the
//						copy will be truncated.
//
uint32 stringLoadFromArray(string * s, char * c) {

	VERIFY_OBJECT(s, OBJID_STRING)

	uint8 * to = s->str;
	uint8 * from = (uint8 *)c;
	uint32 len = s->max_len;

	while (len && *from) {
		*to++ = *from++;
		len--;
		s->cur_len++;
	}
	*to = NULLCHAR;

	if (len == 0 && (*from != 0)) {
		SYS_ERROR (ERR_STRING_ARRAY_TOO_LONG);
		return ERROR;
	}

	return NOERROR;
}
示例#26
0
static void blobdata_file_close(OBJECT *file, blobdata_private_t *data)
{
  UNUSED_PARAM(OBJECT *, file) ;

  HQASSERT(oType(*file) == OFILE || oType(*file) == OSTRING,
           "Blob data source is not a file or a filename") ;
  VERIFY_OBJECT(data, BLOBDATA_PRIVATE_NAME) ;

  /* Either both or neither of the file handle and device should be set */
  HQASSERT((data->fhandle < 0) == (data->dev == NULL),
           "Blob file handle and device inconsistent") ;

  /* Ignore errors on closing; we got all the data we came for anyway. */
  if ( data->fhandle >= 0 ) {
    (void)(*theICloseFile(data->dev))(data->dev, data->fhandle) ;

    data->dev = NULL ;
    data->fhandle = -1 ;
  }

  data->isopen = FALSE ;
}
示例#27
0
/* Clean out cache of CID fonts */
void cid0_restore(int32 savelevel)
{
  CID0_CACHE *cid_font, **cid_prev = &cid0_font_cache ;
  int32 numsaves = NUMBERSAVES(savelevel) ;

  while ( (cid_font = *cid_prev) != NULL ) {
    VERIFY_OBJECT(cid_font, CID0_CACHE_NAME) ;

    /* Test if the data source will be restored */
    if ( cid_font->source == NULL ||
         mm_ps_check(numsaves, cid_font->source) != MM_SUCCESS ) {
      *cid_prev = cid_font->next ;

      HQASSERT(cid_font->font_data == NULL,
               "Font data open when purging CID font") ;
      mm_free(mm_pool_temp, (mm_addr_t)cid_font, sizeof(CID0_CACHE)) ;
      cid0_cache_size -= sizeof(CID0_CACHE) ;
    } else {
      cid_prev = &cid_font->next ;
    }
  }
}
示例#28
0
文件: fifo.c 项目: LORDofDOOM/LARD
uint32 fifo32Read (fifo32 * buf, uint8 * result) {

    uint32 val;

    VERIFY_OBJECT (buf, OBJID_FIFO)

    CLEAR_RESULT;

    if (buf->nItems == 0) {
        SET_RESULT (RSLT_BUFFER_EMPTY);
        return ERROR;
    }

    val = * buf->rd_ptr;
    buf->rd_ptr++;
    ATOMIC(buf->nItems--);

    if (buf->rd_ptr == buf->end)
        buf->rd_ptr = buf->start;

    return val;
}
示例#29
0
文件: fifo.c 项目: LORDofDOOM/LARD
uint16 fifo16Read (fifo16 * buf, uint8 * result) {

    uint32 val;

    VERIFY_OBJECT (buf, OBJID_FIFO)

    CLEAR_RESULT;

    if (buf->nItems == 0) {
        SET_RESULT (RSLT_BUFFER_EMPTY);
        return ERROR;
    }

    val = * buf->rd_ptr;
    buf->rd_ptr++;
    ATOMIC(buf->nItems--);

    if (buf->rd_ptr == buf->end)
        buf->rd_ptr = buf->start;
//   _rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) % SERIAL_BUFFER_SIZE;

    return val;
}
示例#30
0
static sw_event_result HQNCALL corejob_name_handler(void *context, sw_event *ev)
{
  SWMSG_TIMELINE *msg = ev->message;

  UNUSED_PARAM(void *, context);

  if (msg == NULL || ev->length < sizeof(SWMSG_TIMELINE))
    return SW_EVENT_CONTINUE;

  HQASSERT(ev->type == EVENT_TIMELINE_TITLE, "Unexpected event type");

  if ( msg->type == SWTLT_JOB ) {
    corejob_t *job = msg->context;

    VERIFY_OBJECT(job, CORE_JOB_NAME) ;

    if ( job->name.length > 0 ) {
      mm_free(mm_pool_temp, job->name.string, job->name.length) ;
      job->name.length = 0 ;
      job->name.string = (uint8 *)"" ;
    }

    if ( msg->length > 0 ) {
      uint8 *name = mm_alloc(mm_pool_temp, msg->length, MM_ALLOC_CLASS_JOB) ;

      if ( name == NULL )
        return SW_EVENT_ERROR ;

      HqMemCpy(name, msg->title, msg->length) ;
      job->name.string = name ;
      job->name.length = msg->length ;
    }
  }

  return SW_EVENT_CONTINUE;
}