本文整理汇总了C++中IDirectFBSurface::Lock方法的典型用法代码示例。如果您正苦于以下问题:C++ IDirectFBSurface::Lock方法的具体用法?C++ IDirectFBSurface::Lock怎么用?C++ IDirectFBSurface::Lock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirectFBSurface
的用法示例。
在下文中一共展示了IDirectFBSurface::Lock方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static int
DirectFB_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
Uint32 format, void * pixels, int pitch)
{
Uint32 sdl_format;
unsigned char* laypixels;
int laypitch;
DFBSurfacePixelFormat dfb_format;
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
IDirectFBSurface *winsurf = data->target;
DirectFB_ActivateRenderer(renderer);
winsurf->GetPixelFormat(winsurf, &dfb_format);
sdl_format = DirectFB_DFBToSDLPixelFormat(dfb_format);
winsurf->Lock(winsurf, DSLF_READ, (void **) &laypixels, &laypitch);
laypixels += (rect->y * laypitch + rect->x * SDL_BYTESPERPIXEL(sdl_format) );
SDL_ConvertPixels(rect->w, rect->h,
sdl_format, laypixels, laypitch,
format, pixels, pitch);
winsurf->Unlock(winsurf);
return 0;
}
示例2: Display
static void Display(vout_display_t *vd, picture_t *picture)
{
vout_display_sys_t *sys = vd->sys;
IDirectFBSurface *primary = sys->primary;
void *pixels;
int pitch;
if (primary->Lock(primary, DSLF_WRITE, &pixels, &pitch) == DFB_OK) {
picture_resource_t rsc;
memset(&rsc, 0, sizeof(rsc));
rsc.p[0].p_pixels = pixels;
rsc.p[0].i_lines = sys->height;
rsc.p[0].i_pitch = pitch;
picture_t *direct = picture_NewFromResource(&vd->fmt, &rsc);
if (direct) {
picture_Copy(direct, picture);
picture_Release(direct);
}
if (primary->Unlock(primary) == DFB_OK)
primary->Flip(primary, NULL, 0);
}
picture_Release(picture);
}
示例3:
static int
directfb_get_empty_bitmap (struct bitmap *bmp)
{
IDirectFBSurface *surface;
DFBSurfaceDescription desc;
bmp->data = bmp->flags = NULL;
desc.flags = (DFBSurfaceDescriptionFlags)(DSDESC_WIDTH | DSDESC_HEIGHT);
desc.width = bmp->x;
desc.height = bmp->y;
retry:
if (dfb->CreateSurface (dfb, &desc, &surface) != DFB_OK) {
if (out_of_memory(MF_GPI, NULL, 0))
goto retry;
return -1;
}
surface->Lock (surface, (DFBSurfaceLockFlags)(DSLF_READ | DSLF_WRITE), &bmp->data, &bmp->skip);
bmp->flags = surface;
return 0;
}
示例4: DirectFB_LockYUVOverlay
int DirectFB_LockYUVOverlay(_THIS, SDL_Overlay *overlay)
{
DFBResult ret;
void *data;
int pitch;
IDirectFBSurface *surface = overlay->hwdata->surface;
ret = surface->Lock (surface, DSLF_READ | DSLF_WRITE, &data, &pitch);
if (ret)
{
SetDirectFBerror("IDirectFBSurface::Lock", ret);
return -1;
}
/* Find the pitch and offset values for the overlay */
overlay->pitches[0] = (Uint16) pitch;
overlay->pixels[0] = (Uint8*) data;
switch (overlay->format)
{
case SDL_YV12_OVERLAY:
case SDL_IYUV_OVERLAY:
/* Add the two extra planes */
overlay->pitches[1] = overlay->pitches[0] / 2;
overlay->pitches[2] = overlay->pitches[0] / 2;
overlay->pixels[1] = overlay->pixels[0] + overlay->pitches[0] * overlay->h;
overlay->pixels[2] = overlay->pixels[1] + overlay->pitches[1] * overlay->h / 2;
break;
default:
/* Only one plane, no worries */
break;
}
return 0;
}
示例5: return
static void *
directfb_prepare_strip (struct bitmap *bmp, int top, int lines)
{
IDirectFBSurface *surface = bmp->flags;
surface->Lock (surface, DSLF_READ | DSLF_WRITE, &bmp->data, &bmp->skip);
return ((unsigned char *) bmp->data + top * bmp->skip);
}
示例6: while
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;
}
示例7: glTexImage2D
//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
}
示例8: surface_lock
static mrb_value surface_lock(mrb_state *mrb, mrb_value self)
{
IDirectFBSurface* surface = mrb_directfb_surface(mrb, self);
if (surface != NULL) {
void* p = NULL;
int pitch;
DFBResult ret;
mrb_int flags = 0;
mrb_get_args(mrb, "i", &flags);
pitch = 0;
ret = surface->Lock(surface, flags, &p, &pitch);
if (!ret) {
mrb_value a[2];
a[0] = mrb_cptr_value(mrb, p);
a[1] = mrb_fixnum_value(pitch);
return mrb_ary_new_from_values(mrb, 2, a);
}
}
return mrb_nil_value();
}
示例9:
static int
directfb_get_empty_bitmap (struct bitmap *bmp)
{
IDirectFBSurface *surface;
DFBSurfaceDescription desc;
bmp->data = bmp->flags = NULL;
desc.flags = DSDESC_WIDTH | DSDESC_HEIGHT;
desc.width = bmp->x;
desc.height = bmp->y;
if (dfb->CreateSurface (dfb, &desc, &surface) != DFB_OK)
return 0;
surface->Lock (surface, DSLF_READ | DSLF_WRITE, &bmp->data, &bmp->skip);
bmp->flags = surface;
return 0;
}
示例10: main
int
main( int argc, char *argv[] )
{
DFBResult ret;
/* Initialize DirectFB including command line parsing. */
ret = DirectFBInit( &argc, &argv );
if (ret) {
DirectFBError( "DirectFBInit() failed", ret );
return -1;
}
/* Parse the command line. */
if (!parse_command_line( argc, argv ))
return -2;
/* Create the super interface. */
ret = DirectFBCreate( &dfb );
if (ret) {
DirectFBError( "DirectFBCreate() failed", ret );
return -3;
}
/* Get the primary display layer. */
ret = dfb->GetDisplayLayer( dfb, id, &layer );
if (ret) {
if (ret == DFB_IDNOTFOUND)
fprintf (stderr, "\nUnknown layer id, check 'dfbinfo' for valid values.\n\n");
else
DirectFBError( "IDirectFB::GetDisplayLayer() failed", ret );
dfb->Release( dfb );
return -4;
}
/* Get a description of the layer. */
ret = layer->GetDescription( layer, &desc );
if (ret) {
DirectFBError( "IDirectFBDisplayLayer::GetDescription() failed", ret );
layer->Release( layer );
dfb->Release( dfb );
return -5;
}
/* Acquire administrative cooperative level. */
ret = layer->SetCooperativeLevel( layer, DLSCL_ADMINISTRATIVE );
if (ret) {
DirectFBError( "IDirectFBDisplayLayer::SetCooperativeLevel() failed", ret );
layer->Release( layer );
dfb->Release( dfb );
return -6;
}
/* Show/change the configuration. */
set_configuration();
/* Test Lock() on layer surface? */
if (test_lock) {
IDirectFBSurface *surface;
fprintf( stderr, "\nGetting layer surface...\n" );
ret = layer->GetSurface( layer, &surface );
if (ret)
DirectFBError( "IDirectFBDisplayLayer::GetSurface() failed", ret );
else {
void *data;
int pitch;
fprintf( stderr, "\nTesting Lock( %s ) on layer surface...\n",
test_lock == DSLF_READ ? "read only" : test_lock == DSLF_WRITE ? "write only" : "read/write" );
ret = surface->Lock( surface, test_lock, &data, &pitch );
if (ret)
DirectFBError( "IDirectFBSurface::Lock() failed", ret );
else
fprintf( stderr, " => OK\n\n" );
surface->Release( surface );
}
}
/* Release the display layer. */
layer->Release( layer );
/* Release the super interface. */
dfb->Release( dfb );
return EXIT_SUCCESS;
}
示例11: main
//.........这里部分代码省略.........
// Red
if (is_lut8) SurfaceHandle->SetColorIndex (SurfaceHandle, 0x1);
else SurfaceHandle->SetColor (SurfaceHandle, 0xff, 0x00, 0x00, 0xff);
SurfaceHandle->FillRectangle (SurfaceHandle, coords, coords, size, size);
coords += size;
// Green
if (is_lut8) SurfaceHandle->SetColorIndex (SurfaceHandle, 0x2);
else SurfaceHandle->SetColor (SurfaceHandle, 0x00, 0xff, 0x00, 0xff);
SurfaceHandle->FillRectangle (SurfaceHandle, coords, coords, size, size);
coords += size;
// Blue
if (is_lut8) SurfaceHandle->SetColorIndex (SurfaceHandle, 0x3);
else SurfaceHandle->SetColor (SurfaceHandle, 0x00, 0x00, 0xff, 0xff);
SurfaceHandle->FillRectangle (SurfaceHandle, coords, coords, size, size);
coords += size;
// half transp yellow
if (is_lut8) SurfaceHandle->SetColorIndex (SurfaceHandle, 0x5);
else SurfaceHandle->SetColor (SurfaceHandle, 0x80, 0x80, 0x00, 0x80);
SurfaceHandle->FillRectangle (SurfaceHandle, coords, coords, size, size);
coords += size;
// transp
if (is_lut8) SurfaceHandle->SetColorIndex (SurfaceHandle, 0x6);
else SurfaceHandle->SetColor (SurfaceHandle, 0x00, 0x00, 0x00, 0x00);
SurfaceHandle->FillRectangle (SurfaceHandle, coords, coords, size, size);
coords += size;
}
{
int xcoords = 60 + (100 * 6), ycoords = 60;
int size = 100;
// clear
SurfaceHandle2->SetColorIndex (SurfaceHandle2, 0x6);
SurfaceHandle2->FillRectangle (SurfaceHandle2, 220, 220, 440, 440);
// transp
SurfaceHandle2->SetColorIndex (SurfaceHandle2, 0x6);
SurfaceHandle2->FillRectangle (SurfaceHandle2, xcoords, ycoords, size, size);
xcoords -= size; ycoords += size;
// half transp yellow
SurfaceHandle2->SetColorIndex (SurfaceHandle2, 0x5);
SurfaceHandle2->FillRectangle (SurfaceHandle2, xcoords, ycoords, size, size);
xcoords -= size; ycoords += size;
// Blue
SurfaceHandle2->SetColorIndex (SurfaceHandle2, 0x3);
SurfaceHandle2->FillRectangle (SurfaceHandle2, xcoords, ycoords, size, size);
xcoords -= size; ycoords += size;
// Green
SurfaceHandle2->SetColorIndex (SurfaceHandle2, 0x2);
SurfaceHandle2->FillRectangle (SurfaceHandle2, xcoords, ycoords, size, size);
xcoords -= size; ycoords += size;
// Red
SurfaceHandle2->SetColorIndex (SurfaceHandle2, 0x1);
SurfaceHandle2->FillRectangle (SurfaceHandle2, xcoords, ycoords, size, size);
xcoords -= size; ycoords += size;
// White
SurfaceHandle2->SetColorIndex (SurfaceHandle2, 0x4);
SurfaceHandle2->FillRectangle (SurfaceHandle2, xcoords, ycoords, size, size);
xcoords -= size; ycoords += size;
}
DFBCHECK (SurfaceHandle->Lock (SurfaceHandle, DSLF_READ, &ptr, &pitch));
DFBCHECK (SurfaceHandle2->Lock (SurfaceHandle2, DSLF_READ, &ptr2, &pitch2));
printf("%s:%d\n",__FUNCTION__,__LINE__);
zorder(videofd2,V4L2_CID_STM_Z_ORDER_RGB2,1);
zorder(videofd1,V4L2_CID_STM_Z_ORDER_RGB1,2);
queue_buffer( videofd1, ptr, (is_lut8 ? colour_palette : 0), 0ULL);
stream_on( videofd1 );
getchar();
queue_buffer( videofd2, ptr2, colour_palette2, 0ULL);
printf("%s:%d\n",__FUNCTION__,__LINE__);
stream_on( videofd2 );
printf("%s:%d\n",__FUNCTION__,__LINE__);
getchar();
zorder(videofd2,V4L2_CID_STM_Z_ORDER_RGB2,2);
zorder(videofd1,V4L2_CID_STM_Z_ORDER_RGB1,1);
fprintf(stderr,"Press Return/Enter to quit\n");
getchar();
// This seems to dequeue all buffers too, but that's what the spec says
// so this is ok.
stream_off( videofd1 );
stream_off( videofd2 );
deinit_dfb();
close(videofd1);
return 0;
}
示例12: print_usage
//.........这里部分代码省略.........
goto out;
}
dest->GetSize( dest, &desc.width, &desc.height );
dest->GetPixelFormat( dest, &desc.pixelformat );
D_INFO( "DFBTest/PreAlloc: Destination is %dx%d using %s\n",
desc.width, desc.height, dfb_pixelformat_name(desc.pixelformat) );
/* Create a preallocated surface. */
desc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS | DSDESC_PREALLOCATED;
desc.width = 100;
desc.height = 100;
desc.pixelformat = DSPF_ARGB;
desc.caps = static_caps;
desc.preallocated[0].data = pixel_buffer;
desc.preallocated[0].pitch = 100 * 4;
ret = dfb->CreateSurface( dfb, &desc, &source );
if (ret) {
D_DERROR( ret, "DFBTest/PreAlloc: IDirectFB::CreateSurface() for the preallocated source failed!\n" );
goto out;
}
/* Before any other operation the pixel data can be written to without locking */
gen_pixels( pixel_buffer, 100 * 4, 100 );
while (!quit) {
void *ptr;
int pitch;
/* Lock source surface for writing before making updates to the pixel buffer */
source->Lock( source, DSLF_WRITE, &ptr, &pitch );
if (ptr == pixel_buffer)
D_INFO( "DFBTest/PreAlloc: Locking preallocated source gave original preallocated pixel buffer :-)\n" );
else {
if (static_caps)
D_INFO( "DFBTest/PreAlloc: Locking preallocated source gave different pixel buffer, ERROR with static alloc!\n" );
else
D_INFO( "DFBTest/PreAlloc: Locking preallocated source gave different pixel buffer, but OK (no static alloc)\n" );
}
update_pixels( ptr, pitch, 100 );
/* Unlock source surface after writing, before making further Blits,
to have the buffer be transfered to master again */
source->Unlock( source );
dest->Clear( dest, 0, 0, 0, 0xff );
/* First Blit from preallocated source, data will be transfered to master */
dest->Blit( dest, source, NULL, 50, 50 );
/* Second Blit from preallocated source, data is already master */
dest->Blit( dest, source, NULL, 150, 150 );
dest->Flip( dest, NULL, DSFLIP_NONE );
/* This will upload again the preallocated buffer to the master, where it is
modified and outdates the preallocated buffer. Now it depends on the static
alloc flag whether the next Lock will directly go into the shared memory
allocation or the preallocated buffer again (with a transfer back from master
to us). */