Example #1
0
static void vc_image_to_tga_memory(
	VC_IMAGE_T*			image)
{
	uint16_t			width, height;
	uint16_t			x, y;
	KHRN_IMAGE_WRAP_T	src, dst;
	uint8_t*			src_ptr				= (image->mem_handle != MEM_INVALID_HANDLE) ? (uint8_t*)mem_lock(image->mem_handle) : (uint8_t*)image->image_data;
	bool				tformat				= (image->type == VC_IMAGE_TF_RGBA32 || image->type == VC_IMAGE_TF_RGBX32);
	uint8_t				twelve_bytes[12]	= {0,0,2,0,0,0,0,0,0,0,0,0};
	uint32_t			tga_mempos			= 0;
	
	assert(tga_mem_size >= 18 + 4*image->height*image->width);
	
	/* 0-length image id, no colour map, uncompressed true-color image, (0,0) origin. */
	memcpy(tga_memory, twelve_bytes, 12);
	tga_mempos += 12;
	
	/* Width and height, 16-bit little endian */
	*(tga_memory+tga_mempos++) = image->width & 0xFF;
	*(tga_memory+tga_mempos++) = (image->width & 0xFF00) >> 8;
	*(tga_memory+tga_mempos++) = image->height & 0xFF;
	*(tga_memory+tga_mempos++) = (image->height & 0xFF00) >> 8;
	*(tga_memory+tga_mempos++) = '\x20';
	*(tga_memory+tga_mempos++) = '\x20';
	
	// Swap red and blue. Do t-format conversion if necessary.
	khrn_image_wrap(&src, tformat ? ABGR_8888_TF : ABGR_8888_RSO, image->width, image->height, image->pitch, src_ptr);
	khrn_image_wrap(&dst, ARGB_8888_RSO, image->width, image->height, image->pitch, tga_memory + tga_mempos);
	khrn_image_wrap_convert(&dst, &src, IMAGE_CONV_GL);

	if (image->mem_handle != MEM_INVALID_HANDLE) mem_unlock(image->mem_handle);
}
Example #2
0
static void vg_scissor_gen(
    void *data, uint32_t stride, int32_t *bounds,
    KHRN_IMAGE_FORMAT_T format, uint32_t width, uint32_t height,
    const int32_t *rects, uint32_t rects_count)
{
    KHRN_IMAGE_WRAP_T wrap;
    uint32_t i;

    /* data already initialised to 0 by virtue of MEM_FLAG_ZERO and MEM_FLAG_INIT */
    bounds[0] = width;
    bounds[1] = height;
    bounds[2] = 0;
    bounds[3] = 0;

    khrn_image_wrap(&wrap, format, width, height, stride, data);
    for (i = 0; i != rects_count; i += 4) {
        int32_t rect_x      = rects[i];
        int32_t rect_y      = rects[i + 1];
        int32_t rect_width  = rects[i + 2];
        int32_t rect_height = rects[i + 3];
        khrn_clip_rect(
            &rect_x, &rect_y, &rect_width, &rect_height,
            0, 0, width, height);
        khrn_image_wrap_clear_region(&wrap, rect_x, rect_y, rect_width, rect_height, 0xffffffff, IMAGE_CONV_GL);
        bounds[0] = _min(bounds[0], rect_x);
        bounds[1] = _min(bounds[1], rect_y);
        bounds[2] = _max(bounds[2], rect_x + rect_width);
        bounds[3] = _max(bounds[3], rect_y + rect_height);
    }
}
static bool brcm_egl_convert_anative_buf_to_khrn_image( android_native_buffer_t *abuffer, KHRN_IMAGE_WRAP_T *khr_image ,bool isTiled)
{
   bool ret = false;

   if( NULL != khr_image )
   {

      KHRN_IMAGE_FORMAT_T format = convert_android_format( abuffer->format ,isTiled) ; //get the format from the gralloc image
#ifdef BRCM_V3D_OPT
      uint32_t width = abuffer->stride; //get the width from the gralloc image
#else
      uint32_t width = abuffer->width; //get the width from the gralloc image
#endif
      uint32_t height = abuffer->height; //get the width from the gralloc image
      int32_t stride = calculate_pitch( format, width );

      // native_buffer *nbuffer = (native_buffer *)abuffer->handle;
      struct private_handle_t* nbuffer = (struct private_handle_t*)abuffer->handle;
      void *storage = nbuffer->p_addr + nbuffer->offset; //get the buffer pointer from the gralloc image - its the 7th item in the structure

      memset( khr_image, 0, sizeof( KHRN_IMAGE_WRAP_T ) );

      if( format != IMAGE_FORMAT_INVALID )
      {
         LOGV("brcm_egl_convert_anative_buf_to_khrn_image - 3" );

         khrn_image_wrap( khr_image, format, width, height, stride, storage );
#ifdef BRCM_V3D_OPT
		 khr_image->aux = nbuffer->base; //get the buffer pointer from the gralloc image - its the 7th item in the structure
#endif
         ret = true;
      }
      else
         LOGE("brcm_egl_convert_anative_buf_to_khrn_image - 3" );
   }

   return ret;
}
Example #4
0
static void vc_image_to_RSO_memory(VC_IMAGE_T *image, android_native_buffer_t *buffer, void *bits)
{
    KHRN_IMAGE_FORMAT_T src_format, dst_format;
    KHRN_IMAGE_WRAP_T src, dst;
    uint8_t* src_ptr;
    int conv_width, conv_height;

    dst_format = convert_color_format(buffer->format);

    if (!dst_format)
        return;

    // Swap red and blue. Do t-format conversion if necessary.
    switch (image->type) {
    case VC_IMAGE_TF_RGBA32:
        src_format = ABGR_8888_TF;
        break;
    case VC_IMAGE_TF_RGBX32:
        src_format = XBGR_8888_TF;
        break;
    case VC_IMAGE_TF_RGB565:
        src_format = RGB_565_TF;
        break;
    case VC_IMAGE_TF_RGBA5551:
        src_format = RGBA_5551_TF;
        break;
    case VC_IMAGE_TF_RGBA16:
        src_format = RGBA_4444_TF;
        break;
    case VC_IMAGE_RGBA32:
        src_format = ABGR_8888_RSO;
        break;
    case VC_IMAGE_RGBX32:
        src_format = XBGR_8888_RSO;
        break;
    case VC_IMAGE_RGB565:
        src_format = RGB_565_RSO;
        break;
    default:
        UNREACHABLE();
        src_format = 0;
        break;
    }

    if (!src_format)
        return;

    src_ptr = (image->mem_handle != MEM_INVALID_HANDLE) ? (uint8_t*)mem_lock(image->mem_handle) : (uint8_t*)image->image_data;

    conv_width = (image->width <= buffer->width) ? image->width : buffer->width;
    conv_height = (image->height <= buffer->height) ? image->height : buffer->height;

    khrn_image_wrap(&src, src_format, conv_width, conv_height, image->pitch, src_ptr);
    khrn_image_wrap(&dst, dst_format, conv_width, conv_height, buffer->width * bpp, bits);

    if (src.format == dst.format)
        khrn_image_copy(&dst, &src);
    else
        khrn_image_wrap_convert(&dst, &src, IMAGE_CONV_GL);

    if (image->mem_handle != MEM_INVALID_HANDLE)
        mem_unlock(image->mem_handle);
}