Ejemplo n.º 1
0
static void *
TestThread( DirectThread *thread,
            void         *arg )
{
     DFBResult         ret;
     IDirectFBSurface *surface = arg;
     DFBRectangle      rect    = { 0, 0, 500, 1 };

     while (!quit) {
          void *data;
          int   pitch;

          ret = surface->Lock( surface, DSLF_WRITE, &data, &pitch );

          if (ret) {
               D_DERROR( ret, "DFBTest/Resize: Lock() failed!\n" );
               return NULL;
          }

          if (!data) {
               D_DERROR( ret, "DFBTest/Resize:invalid pointer!\n" );
               return NULL;
          }

          memset( data, 0, pitch * 400 );

          surface->Unlock( surface );

          data = malloc( pitch );

          ret = surface->Read( surface, &rect, data, pitch );

          if (ret) {
               D_DERROR( ret, "DFBTest/Resize: Read() failed!\n" );
               free (data);
               return NULL;
          }

          ret = surface->Write( surface, &rect, data, pitch );
          if (ret) {
               D_DERROR( ret, "DFBTest/Resize: Write() failed!\n" );
               free(data);
               return NULL;
          }

          free(data);
     }

     return NULL;
}
Ejemplo n.º 2
0
//Hardcore translateion
void glTexImage2D (GLenum target, GLint level, GLint internalformat, 
                   GLsizei width, GLsizei height, GLint border, GLenum format, 
                   GLenum type, const GLvoid *pixels)
{
#ifdef DEBUG
  printf("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
#endif

  IDirectFBSurface * surface = NULL;
  EGLSurface egl_surface = NULL;
  DFBResult err = 0;
  DFBSurfaceDescription dsc;
  CoreSurfaceBufferLock lock;

  dsc.flags  = (DFBSurfaceDescriptionFlags) (DSDESC_WIDTH | DSDESC_HEIGHT | 
                                             DSDESC_PIXELFORMAT | DSDESC_CAPS);
  dsc.caps   = DSCAPS_PREMULTIPLIED;
  dsc.width  = width;
  dsc.height = height;

  dsc.pixelformat = DSPF_ARGB;

  m_dfb->CreateSurface(
      m_dfb, 
      &dsc, 
      &surface);

#if 0
  surface->Lock (surface, DSLF_WRITE, &lock.addr, &lock.pitch);
  memcpy(lock.addr, pixels, width*height*4);
  surface->Unlock (surface);
#else
  DFBRectangle rect;
  rect.x = 0;
  rect.y = 0;
  rect.w = width;
  rect.h = height;

  surface->Write(surface, &rect, pixels, 4*width);
#endif
  egl_textures[m_bound_texture].surface = surface;
  
#ifdef DEBUG
  printf("%s:%s[%d] ---------------- texture=%d (%p)\n", __FILE__, __func__, __LINE__, texturesCurrent, egl_textures[texturesCurrent].surface);
#endif
}