本文整理汇总了C++中IDirectFBSurface::FillRectangle方法的典型用法代码示例。如果您正苦于以下问题:C++ IDirectFBSurface::FillRectangle方法的具体用法?C++ IDirectFBSurface::FillRectangle怎么用?C++ IDirectFBSurface::FillRectangle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirectFBSurface
的用法示例。
在下文中一共展示了IDirectFBSurface::FillRectangle方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrepareDraw
static int
DirectFB_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, int count)
{
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
IDirectFBSurface *destsurf = data->target;
DFBRegion clip_region;
int i;
DirectFB_ActivateRenderer(renderer);
PrepareDraw(renderer);
destsurf->GetClip(destsurf, &clip_region);
for (i=0; i<count; i++) {
SDL_Rect dst = {rects[i].x, rects[i].y, rects[i].w, rects[i].h};
dst.x += clip_region.x1;
dst.y += clip_region.y1;
SDL_DFB_CHECKERR(destsurf->FillRectangle(destsurf, dst.x, dst.y,
dst.w, dst.h));
}
return 0;
error:
return -1;
}
示例2: OpenDisplay
static int OpenDisplay(vout_display_t *vd)
{
vout_display_sys_t *sys = vd->sys;
DFBSurfaceDescription dsc;
/*dsc.flags = DSDESC_CAPS | DSDESC_HEIGHT | DSDESC_WIDTH;*/
dsc.flags = DSDESC_CAPS;
dsc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
/*dsc.width = 352;*/
/*dsc.height = 240;*/
IDirectFB *directfb = NULL;
if (DirectFBCreate(&directfb) != DFB_OK || !directfb)
return VLC_EGENERIC;
sys->directfb = directfb;
IDirectFBSurface *primary = NULL;
if (directfb->CreateSurface(directfb, &dsc, &primary) || !primary)
return VLC_EGENERIC;
sys->primary = primary;
primary->GetSize(primary, &sys->width, &sys->height);
primary->GetPixelFormat(primary, &sys->pixel_format);
primary->FillRectangle(primary, 0, 0, sys->width, sys->height);
primary->Flip(primary, NULL, 0);
return VLC_SUCCESS;
}
示例3: l_FillRectangle
static int l_FillRectangle (lua_State* L)
{
// [ sfc | x | y | w | h ]
IDirectFBSurface* sfc = * (IDirectFBSurface**) luaL_checkudata(L, 1, "ldirectfb.IDirectFBSurface");
DFBCHECK (sfc->FillRectangle(sfc, luaL_checknumber(L, 2), luaL_checknumber(L, 3), luaL_checknumber(L, 4), luaL_checknumber(L, 5)));
return 0;
}
示例4: if
static void
app_update( App *app )
{
static const DFBColor colors[3] = {
{ 0xff, 0x30, 0xc0, 0xff },
{ 0xff, 0xff, 0xff, 0x30 },
{ 0xff, 0x30, 0xff, 0xc0 }
};
IDirectFBSurface *surface = app->surface;
surface->Clear( surface, 0xff, 0xff, 0xff, 0x20 );
surface->SetColor( surface, colors[app->index].r, colors[app->index].g, colors[app->index].b, colors[app->index].a );
surface->FillRectangle( surface, app->anim_x, app->anim_y, 40, 300 );
surface->Flip( surface, NULL, DSFLIP_WAITFORSYNC );
app->anim_x += app->anim_dirx;
if (app->anim_x >= app->resolution.w - 40)
app->anim_dirx = -5;
else if (app->anim_x <= 0)
app->anim_dirx = 5;
app->anim_y += app->anim_diry;
if (app->anim_y >= app->resolution.h - 300)
app->anim_diry = -5;
else if (app->anim_y <= 0)
app->anim_diry = 5;
}
示例5: surface_fill_rectangle
static mrb_value surface_fill_rectangle(mrb_state *mrb, mrb_value self)
{
IDirectFBSurface* surface = mrb_directfb_surface(mrb, self);
DFBResult ret = -1;
if (surface != NULL) {
mrb_int x, y, width, height;
mrb_get_args(mrb, "iiii", &x, &y, &width, &height);
ret = surface->FillRectangle(surface, x, y, width, height);
}
return mrb_fixnum_value(ret);
}
示例6: PrepareDraw
static int
DirectFB_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect * rects, int count)
{
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
IDirectFBSurface *destsurf = get_dfb_surface(data->window);
int i;
DirectFB_ActivateRenderer(renderer);
PrepareDraw(renderer);
for (i=0; i<count; i++)
SDL_DFB_CHECKERR(destsurf->FillRectangle(destsurf, rects[i].x, rects[i].y,
rects[i].w, rects[i].h));
return 0;
error:
return -1;
}
示例7: render_loop
static void* render_loop (void *arg)
{
IDirectFBSurface *view = (IDirectFBSurface*)arg;
view->SetBlittingFlags( view, DSBLIT_SRC_COLORKEY | DSBLIT_COLORIZE );
while (started_rendering()) {
int i;
pthread_testcancel();
view->SetColor( view, 0, 0, 0, 0 );
view->FillRectangle( view, 0, 0, xres, yres );
for (i=0; i<STARFIELD_SIZE; i++) {
int map = (int)(t_starfield[i].pos.v[Z]) >> 8;
int light = 0xFF - ((int)(t_starfield[i].pos.v[Z] * t_starfield[i].pos.v[Z]) >> 12);
if (map >= 0 && light > 0) {
if (map >= NUM_STARS)
map = NUM_STARS - 1;
view->SetColor( view, light, light, light, 0xff );
view->Blit( view, stars[map], NULL,
(int)(t_starfield[i].pos.v[X]),
(int)(t_starfield[i].pos.v[Y]) );
}
}
view->Flip( view, NULL, DSFLIP_WAITFORSYNC );
finished_rendering();
}
pthread_testcancel();
return NULL;
}
示例8: LoadFont
void
DirectFB_WM_RedrawLayout(_THIS, SDL_Window * window)
{
SDL_DFB_WINDOWDATA(window);
IDirectFBSurface *s = windata->window_surface;
DFB_Theme *t = &windata->theme;
int i;
int d = (t->caption_size - t->font_size) / 2;
int x, y, w;
if (!windata->is_managed || (window->flags & SDL_WINDOW_FULLSCREEN))
return;
SDL_DFB_CHECK(s->SetSrcBlendFunction(s, DSBF_ONE));
SDL_DFB_CHECK(s->SetDstBlendFunction(s, DSBF_ZERO));
SDL_DFB_CHECK(s->SetDrawingFlags(s, DSDRAW_NOFX));
SDL_DFB_CHECK(s->SetBlittingFlags(s, DSBLIT_NOFX));
LoadFont(_this, window);
/* s->SetDrawingFlags(s, DSDRAW_BLEND); */
s->SetColor(s, COLOR_EXPAND(t->frame_color));
/* top */
for (i = 0; i < t->top_size; i++)
s->DrawLine(s, 0, i, windata->size.w, i);
/* bottom */
for (i = windata->size.h - t->bottom_size; i < windata->size.h; i++)
s->DrawLine(s, 0, i, windata->size.w, i);
/* left */
for (i = 0; i < t->left_size; i++)
s->DrawLine(s, i, 0, i, windata->size.h);
/* right */
for (i = windata->size.w - t->right_size; i < windata->size.w; i++)
s->DrawLine(s, i, 0, i, windata->size.h);
/* Caption */
s->SetColor(s, COLOR_EXPAND(t->caption_color));
s->FillRectangle(s, t->left_size, t->top_size, windata->client.w,
t->caption_size);
/* Close Button */
w = t->caption_size;
x = windata->size.w - t->right_size - w + d;
y = t->top_size + d;
s->SetColor(s, COLOR_EXPAND(t->close_color));
DrawTriangle(s, 1, x, y, w - 2 * d);
/* Max Button */
s->SetColor(s, COLOR_EXPAND(t->max_color));
DrawTriangle(s, window->flags & SDL_WINDOW_MAXIMIZED ? 1 : 0, x - w,
y, w - 2 * d);
/* Caption */
if (*window->title) {
s->SetColor(s, COLOR_EXPAND(t->font_color));
DrawCraption(_this, s, (x - w) / 2, t->top_size + d, window->title);
}
/* Icon */
if (windata->icon) {
DFBRectangle dr;
dr.x = t->left_size + d;
dr.y = t->top_size + d;
dr.w = w - 2 * d;
dr.h = w - 2 * d;
s->SetBlittingFlags(s, DSBLIT_BLEND_ALPHACHANNEL);
s->StretchBlit(s, windata->icon, NULL, &dr);
}
windata->wm_needs_redraw = 0;
}
示例9: main
int main (int argc,char *argv[])
{
int videofd1 = open("/dev/video0",O_RDWR);
int videofd2 = open("/dev/video0",O_RDWR);
IDirectFBSurface *SurfaceHandle;
IDirectFBSurface *SurfaceHandle2;
void *ptr,*ptr2;
int pitch,pitch2;
int colour_palette[256];
int colour_palette2_real[256]; /* random... */
int *colour_palette2 = colour_palette2_real;
int is_lut8;
is_lut8 = (argc > 1 && !strcmp (argv[1], "both"));
memset(&colour_palette,0x0,4*256);
//memset(&colour_palette[1],0xff,255*4);
colour_palette[0] = 0xff000000; // black
colour_palette[1] = 0xffff0000; // red
colour_palette[2] = 0xff00ff00; // green
colour_palette[3] = 0xff0000ff; // blue
colour_palette[4] = 0xffffffff; // white
colour_palette[5] = 0x80808000; // half-transp yellow
colour_palette[6] = 0x00000000; // transp black
if (videofd1 < 0)
perror("Couldn't open video device 1\n");
if (videofd2 < 0)
perror("Couldn't open video device 2\n");
v4l2_list_outputs (videofd1);
fb_make_transparent();
init_dfb(&SurfaceHandle,is_lut8);
init_dfb(&SurfaceHandle2,1);
v4l2_set_output_by_name (videofd1, "RGB1");
v4l2_set_output_by_name (videofd2, "RGB2");
init_v4l(videofd1,0,0,1280,720,is_lut8);
init_v4l(videofd2,0,0,1280,720,1);
printf("%s:%d\n",__FUNCTION__,__LINE__);
// memcpy (colour_palette, colour_palette2, sizeof (colour_palette));
colour_palette2 = colour_palette;
{
int coords = 60;
int size = 100;
// clear
if (!is_lut8) SurfaceHandle->Clear (SurfaceHandle, 0x00, 0x00, 0x00, 0x00);
else {
SurfaceHandle->SetColorIndex (SurfaceHandle, 0x6);
SurfaceHandle->FillRectangle (SurfaceHandle, 0, 0, 600, 600);
}
// White
if (is_lut8) SurfaceHandle->SetColorIndex (SurfaceHandle, 0x4);
else SurfaceHandle->SetColor (SurfaceHandle, 0xff, 0xff, 0xff, 0xff);
SurfaceHandle->FillRectangle (SurfaceHandle, coords, coords, size, size);
coords += size;
// 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
//.........这里部分代码省略.........
示例10:
static void *handle_record_button(DirectThread *thread, void *arg)
{
IDirectFBSurface *surface = arg;
IDirectFBFont *font, *font_s;
DFBFontDescription font_desc;
bool local_flg = false;
int width, height;
int font_big_height, font_little_height;
char font_file[50] = "/misc/font/wqy-zenhei.ttc";
DFBCHECK(surface->GetSize(surface, &width, &height));
font_big_height = 48;
while(font_big_height > (height / 2))
{
font_big_height -= 4;
}
font_desc.flags = DFDESC_HEIGHT;
font_desc.height = font_big_height;
DFBCHECK(dfb->CreateFont( dfb, font_file, &font_desc, &font));
font_little_height = 32;
while(font_little_height > (height / 4))
{
font_little_height -= 4;
}
font_desc.height = font_little_height;
DFBCHECK(dfb->CreateFont( dfb, font_file, &font_desc, &font_s));
printf("font size is %d %d\n", font_big_height, font_little_height);
DFBCHECK(surface->SetFont(surface, font_s));
DFBCHECK(surface->SetColor(surface, 0x8C, 0x8C, 0x8C, 0xff));
DFBCHECK(surface->DrawString(surface, "点击录音", -1, width / 2, 0, DSTF_TOPCENTER));
DFBCHECK(surface->SetColor(surface, 0x41, 0x41, 0x41, 0xff));
DFBCHECK(surface->DrawString(surface, "测试TP请避开此区域", -1, width / 2, height / 4, DSTF_TOPCENTER));
DFBCHECK(surface->SetFont(surface, font));
DFBCHECK(surface->SetColor(surface, 0xE3, 0x6C, 0x4C, 0xff));
DFBCHECK(surface->DrawString(surface, "状态:停止录音", -1, width / 2, height / 2, DSTF_TOPCENTER));
DFBCHECK(surface->Flip(surface, NULL, 0));
while(true)
{
if(record_flg != local_flg)
{
local_flg = record_flg;
DFBCHECK(surface->SetColor(surface, 0xff, 0xff, 0xff, 0xff));
DFBCHECK(surface->FillRectangle(surface, 0 , height / 2, width, font_big_height + 4)); //need fix
DFBCHECK(surface->SetColor(surface, 0xE3, 0x6C, 0x4C, 0xff));
if(local_flg)
{
DFBCHECK(surface->DrawString(surface, "状态:正在录音", -1, width / 2, height / 2, DSTF_TOPCENTER));
}
else
{
DFBCHECK(surface->DrawString(surface, "状态:停止录音", -1, width / 2, height / 2, DSTF_TOPCENTER));
}
DFBCHECK(surface->Flip(surface, NULL, 0));
}
direct_thread_sleep(100000);
}
font->Release(font);
font_s->Release(font_s);
}
示例11: print_usage
//.........这里部分代码省略.........
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). */
source->FillRectangle( source, 0, 0, 10, 10 );
/* Process keybuffer */
while (keybuffer->GetEvent( keybuffer, DFB_EVENT(&evt)) == DFB_OK)
{
if (evt.type == DIET_KEYPRESS) {
switch (DFB_LOWER_CASE(evt.key_symbol)) {
case DIKS_ESCAPE:
case DIKS_SMALL_Q:
case DIKS_BACK:
case DIKS_STOP:
case DIKS_EXIT:
/* Quit main loop & test thread */
quit = true;
break;
default:
break;
}
}
}
if (!quit)
sleep( 5 );
}
out:
if (source)
source->Release( source );
if (dest)
dest->Release( dest );
keybuffer->Release( keybuffer );
/* Shutdown DirectFB. */
dfb->Release( dfb );
return ret;
}
示例12: main
//.........这里部分代码省略.........
// We want to create an Image Provider tied to a directfb data buffer.
// DirectFB will find (or not) an Image Provider for the data type
// depending on Image Providers probe method (sniffing data headers)
DFBCHECK (databuffer->CreateImageProvider (databuffer, &provider));
}
else {
# ifdef USE_PACKET_BUILDER_ONLY
DFBFAIL(rle_build_databuffer_err);
# else
// We could also create an Image Provider by passing a filename.
// DirectFB will find (or not) an Image Provider matching the file type.
DFBCHECK (dfb->CreateImageProvider (dfb, filename, &provider));
# endif
}
// Get a surface description from the provider. It will contain the width,
// height, bits per pixel and the flag for an alphachannel if the image
// has one. If the image has no alphachannel the bits per pixel is set to
// the bits per pixel of the primary layer to use simple blitting without
// pixel format conversion.
DFBCHECK (provider->GetSurfaceDescription (provider, &surface_dsc));
// Create a surface based on the description of the provider.
DFBCHECK (dfb->CreateSurface( dfb, &surface_dsc, &logo ));
// Let the provider render to our surface. Image providers are supposed
// to support every destination pixel format and size. If the size
// differs the image will be scaled (bilinear). The last parameter allows
// to specify an optional destination rectangle. We use NULL here so that
// our image covers the whole logo surface.
DFBCHECK (provider->RenderTo (provider, logo, NULL));
// Note: RLE Image Provider allows for direct non-scaled LUT-8 surface
// rendering without any attached colormap.
#ifdef CLEVER_APPROACH
// Let's setup our logo surface palette outside of the RLE Image
// Provider if we got a colormap from rle_build_databuffer ...
if (color_palette)
{
IDirectFBPalette *palette;
DFBCHECK (logo->GetPalette (logo, &palette));
palette->SetEntries (palette, color_palette, number_of_colors, 0);
palette->Release (palette);
}
#endif
//
// --- WE GET RID OF OUR IMAGE PROVIDER INSTANCE HERE
//
// Release the provider, we don't need it anymore.
provider->Release (provider); provider = NULL;
// Destroy the databuffer as well, we don't need it anymore.
rle_destroy_databuffer (databuffer); databuffer = NULL;
# ifndef SUBTITLES_MODE
// We want to let the logo slide in on the left and slide out on the
// right.
for (i = -surface_dsc.width; i < screen_width; i++)
# else
// We want to let the logo slide in on the right and slide out on the
// left.
for (i = screen_width-1; i >= -surface_dsc.width; i--)
# endif
{
// Clear the screen.
DFBCHECK (primary->FillRectangle (primary, 0, 0,
screen_width, screen_height));
// Blit the logo vertically centered with "i" as the X coordinate.
// NULL means that we want to blit the whole surface.
DFBCHECK (primary->Blit (primary, logo, NULL, i,
(screen_height - surface_dsc.height) / 2));
// Flip the front and back buffer, but wait for the vertical
// retrace to avoid tearing.
DFBCHECK (primary->Flip (primary, NULL, DSFLIP_WAITFORSYNC));
if (argc < 3)
{
usleep(1000*5);
}
}
// Release the image.
if (logo)
{
logo->Release (logo);
}
}
// Release everything else
primary->Release (primary);
dfb->Release (dfb);
return 0;
}
示例13: print_usage
//.........这里部分代码省略.........
ret = provider->GetSurfaceDescription( provider, &desc );
if (ret) {
D_DERROR( ret, "DFBTest/Blit: IDirectFBImageProvider::GetSurfaceDescription() failed!\n" );
goto out;
}
if (source_format != DSPF_UNKNOWN)
desc.pixelformat = source_format;
D_INFO( "DFBTest/Blit: Source is %dx%d using %s\n",
desc.width, desc.height, dfb_pixelformat_name(desc.pixelformat) );
/* Create a surface for the image. */
ret = dfb->CreateSurface( dfb, &desc, &source );
if (ret) {
D_DERROR( ret, "DFBTest/Blit: IDirectFB::CreateSurface() failed!\n" );
goto out;
}
ret = provider->RenderTo( provider, source, NULL );
if (ret) {
D_DERROR( ret, "DFBTest/Blit: IDirectFBImageProvider::RenderTo() failed!\n" );
goto out;
}
/* Fill description for a primary surface. */
desc.flags = DSDESC_CAPS;
desc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
if (dest_format != DSPF_UNKNOWN) {
desc.flags |= DSDESC_PIXELFORMAT;
desc.pixelformat = dest_format;
}
if (dest_resize)
desc.flags |= DSDESC_WIDTH | DSDESC_HEIGHT;
dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN );
/* Create a primary surface. */
ret = dfb->CreateSurface( dfb, &desc, &dest );
if (ret) {
D_DERROR( ret, "DFBTest/Blit: IDirectFB::CreateSurface() failed!\n" );
goto out;
}
dest->GetSize( dest, &desc.width, &desc.height );
dest->GetPixelFormat( dest, &desc.pixelformat );
D_INFO( "DFBTest/Blit: Destination is %dx%d using %s\n",
desc.width, desc.height, dfb_pixelformat_name(desc.pixelformat) );
for (i=0; i<100000; i++) {
int j,n = rand()%100;
for (j=0; j<n; j++) {
switch (rand()%3) {
case 0:
dest->SetDrawingFlags( dest, rand() & (DSDRAW_BLEND) );
dest->FillRectangle( dest, rand()%100, rand()%100, rand()%100, rand()%100 );
break;
case 1:
dest->SetBlittingFlags( dest, rand() & (DSBLIT_BLEND_ALPHACHANNEL |
DSBLIT_BLEND_COLORALPHA |
DSBLIT_COLORIZE |
DSBLIT_ROTATE90) );
dest->Blit( dest, source, NULL, rand()%100, rand()%100 );
break;
case 2:
dest->SetBlittingFlags( dest, rand() & (DSBLIT_BLEND_ALPHACHANNEL |
DSBLIT_BLEND_COLORALPHA |
DSBLIT_COLORIZE |
DSBLIT_ROTATE90) );
dest->StretchBlit( dest, source, NULL, NULL );
break;
}
}
dfb->WaitIdle( dfb );
dest->Flip( dest, NULL, DSFLIP_NONE );
}
out:
if (dest)
dest->Release( dest );
if (source)
source->Release( source );
if (provider)
provider->Release( provider );
/* Shutdown DirectFB. */
dfb->Release( dfb );
return ret;
}
示例14: if
int
main( int argc, char *argv[] )
{
DFBResult ret;
int i;
int x, y;
int dx, dy;
int sw3, sh3;
int opacity = 255;
int opacity_delta = -1;
IDirectFB *dfb;
IDirectFBDisplayLayer *layer;
IDirectFBSurface *surface;
DFBDisplayLayerConfig config;
DFBDimension size;
DFBInputEvent evt;
/* Initialize DirectFB. */
ret = DirectFBInit( &argc, &argv );
if (ret) {
D_DERROR( ret, "DFBTest/Layer: DirectFBInit() failed!\n" );
return ret;
}
/* Create super interface. */
ret = DirectFBCreate( &dfb );
if (ret) {
D_DERROR( ret, "DFBTest/Layer: DirectFBCreate() failed!\n" );
return ret;
}
dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer );
/* Create an input buffer for key events */
dfb->CreateInputEventBuffer( dfb, DICAPS_KEYS,
DFB_TRUE, &keybuffer);
layer->SetCooperativeLevel( layer, DFSCL_EXCLUSIVE );
layer->GetConfiguration( layer, &config );
config.options = DLOP_OPACITY | DLOP_SRC_COLORKEY;
config.buffermode = DLBM_FRONTONLY;
layer->SetConfiguration( layer, &config );
layer->SetSrcColorKey( layer, 0x00, 0xff, 0x00 );
ret = layer->GetSurface( layer, &surface );
if (ret) {
D_DERROR( ret, "DFBTest/Layer: GetSurface() failed!\n" );
dfb->Release( dfb );
return ret;
}
surface->GetSize( surface, &size.w, &size.h );
sw3 = ((size.w / 3) + 1) & ~1;
sh3 = ((size.h / 3) + 1) & ~1;
surface->Clear( surface, 0, 0, 0, 0xff );
for (i=0; i<10; i++) {
surface->SetColor( surface, 0xff - i*16, 0xff - i*16, 0xff - i*16, 0xff );
surface->DrawRectangle( surface, i, i, size.w - i*2, size.h - i*2 );
}
surface->FillRectangle( surface, 10, size.h/2, size.w - 20, 1 );
surface->FillRectangle( surface, size.w/2, 10, 1, size.h - 20 );
surface->SetColor( surface, 0xff, 0x00, 0x00, 0xff );
surface->FillRectangle( surface, size.w/3, size.h/3, size.w/3, size.h/3 );
surface->SetColor( surface, 0x00, 0xff, 0x00, 0xff );
surface->FillRectangle( surface, size.w/3 + size.w/9, size.h/3 + size.h/9, size.w/9, size.h/9 );
surface->Flip( surface, NULL, DSFLIP_NONE );
#ifdef BUILD_AUTOMATION
sleep( 2 );
#else
sleep( 12 );
#endif
layer->SetSourceRectangle( layer, 0, 0, size.w - sw3, size.h - sh3 );
layer->SetScreenPosition( layer, 100, 100 );
layer->SetScreenRectangle( layer, 100, 100, size.w - sw3, size.h - sh3 );
sleep( 2 );
#ifdef BUILD_AUTOMATION
sleep( 20 );
quit = 1;
#endif
for (x=0, y=0, dx=1, dy=1; !quit ; x+=dx, y+=dy) {
layer->SetOpacity( layer, opacity );
//.........这里部分代码省略.........