src/video/photon/SDL_phyuv.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
equal deleted inserted replaced
1667:1fddae038bc8 1668:4da1ee79c9af
    42     ph_DisplayYUVOverlay,
    42     ph_DisplayYUVOverlay,
    43     ph_FreeYUVOverlay
    43     ph_FreeYUVOverlay
    44 };
    44 };
    45 
    45 
    46 int
    46 int
    47 grab_ptrs2 (PgVideoChannel_t * channel, FRAMEDATA * Frame0,
    47 grab_ptrs2(PgVideoChannel_t * channel, FRAMEDATA * Frame0, FRAMEDATA * Frame1)
    48             FRAMEDATA * Frame1)
       
    49 {
    48 {
    50     int planes = 0;
    49     int planes = 0;
    51 
    50 
    52     /* Buffers have moved; re-obtain the pointers */
    51     /* Buffers have moved; re-obtain the pointers */
    53     Frame0->Y = (unsigned char *) PdGetOffscreenContextPtr (channel->yplane1);
    52     Frame0->Y = (unsigned char *) PdGetOffscreenContextPtr(channel->yplane1);
    54     Frame1->Y = (unsigned char *) PdGetOffscreenContextPtr (channel->yplane2);
    53     Frame1->Y = (unsigned char *) PdGetOffscreenContextPtr(channel->yplane2);
    55     Frame0->U = (unsigned char *) PdGetOffscreenContextPtr (channel->vplane1);
    54     Frame0->U = (unsigned char *) PdGetOffscreenContextPtr(channel->vplane1);
    56     Frame1->U = (unsigned char *) PdGetOffscreenContextPtr (channel->vplane2);
    55     Frame1->U = (unsigned char *) PdGetOffscreenContextPtr(channel->vplane2);
    57     Frame0->V = (unsigned char *) PdGetOffscreenContextPtr (channel->uplane1);
    56     Frame0->V = (unsigned char *) PdGetOffscreenContextPtr(channel->uplane1);
    58     Frame1->V = (unsigned char *) PdGetOffscreenContextPtr (channel->uplane2);
    57     Frame1->V = (unsigned char *) PdGetOffscreenContextPtr(channel->uplane2);
    59 
    58 
    60     if (Frame0->Y)
    59     if (Frame0->Y)
    61         planes++;
    60         planes++;
    62 
    61 
    63     if (Frame0->U)
    62     if (Frame0->U)
    68 
    67 
    69     return planes;
    68     return planes;
    70 }
    69 }
    71 
    70 
    72 SDL_Overlay *
    71 SDL_Overlay *
    73 ph_CreateYUVOverlay (_THIS, int width, int height, Uint32 format,
    72 ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format,
    74                      SDL_Surface * display)
    73                     SDL_Surface * display)
    75 {
    74 {
    76     SDL_Overlay *overlay;
    75     SDL_Overlay *overlay;
    77     struct private_yuvhwdata *hwdata;
    76     struct private_yuvhwdata *hwdata;
    78     int vidport;
    77     int vidport;
    79     int rtncode;
    78     int rtncode;
    80     int planes;
    79     int planes;
    81     int i = 0;
    80     int i = 0;
    82     PhPoint_t pos;
    81     PhPoint_t pos;
    83 
    82 
    84     /* Create the overlay structure */
    83     /* Create the overlay structure */
    85     overlay = SDL_calloc (1, sizeof (SDL_Overlay));
    84     overlay = SDL_calloc(1, sizeof(SDL_Overlay));
    86 
    85 
    87     if (overlay == NULL) {
    86     if (overlay == NULL) {
    88         SDL_OutOfMemory ();
    87         SDL_OutOfMemory();
    89         return NULL;
    88         return NULL;
    90     }
    89     }
    91 
    90 
    92     /* Fill in the basic members */
    91     /* Fill in the basic members */
    93     overlay->format = format;
    92     overlay->format = format;
    97 
    96 
    98     /* Set up the YUV surface function structure */
    97     /* Set up the YUV surface function structure */
    99     overlay->hwfuncs = &ph_yuvfuncs;
    98     overlay->hwfuncs = &ph_yuvfuncs;
   100 
    99 
   101     /* Create the pixel data and lookup tables */
   100     /* Create the pixel data and lookup tables */
   102     hwdata = SDL_calloc (1, sizeof (struct private_yuvhwdata));
   101     hwdata = SDL_calloc(1, sizeof(struct private_yuvhwdata));
   103 
   102 
   104     if (hwdata == NULL) {
   103     if (hwdata == NULL) {
   105         SDL_OutOfMemory ();
   104         SDL_OutOfMemory();
   106         SDL_FreeYUVOverlay (overlay);
   105         SDL_FreeYUVOverlay(overlay);
   107         return NULL;
   106         return NULL;
   108     }
   107     }
   109 
   108 
   110     overlay->hwdata = hwdata;
   109     overlay->hwdata = hwdata;
   111 
   110 
   112     PhDCSetCurrent (0);
   111     PhDCSetCurrent(0);
   113     if (overlay->hwdata->channel == NULL) {
   112     if (overlay->hwdata->channel == NULL) {
   114         if ((overlay->hwdata->channel =
   113         if ((overlay->hwdata->channel =
   115              PgCreateVideoChannel (Pg_VIDEO_CHANNEL_SCALER, 0)) == NULL) {
   114              PgCreateVideoChannel(Pg_VIDEO_CHANNEL_SCALER, 0)) == NULL) {
   116             SDL_SetError
   115             SDL_SetError
   117                 ("ph_CreateYUVOverlay(): Create channel failed: %s\n",
   116                 ("ph_CreateYUVOverlay(): Create channel failed: %s\n",
   118                  strerror (errno));
   117                  strerror(errno));
   119             SDL_FreeYUVOverlay (overlay);
   118             SDL_FreeYUVOverlay(overlay);
   120             return NULL;
   119             return NULL;
   121 
   120 
   122         }
   121         }
   123     }
   122     }
   124 
   123 
   125     overlay->hwdata->forcedredraw = 0;
   124     overlay->hwdata->forcedredraw = 0;
   126 
   125 
   127     PtGetAbsPosition (window, &pos.x, &pos.y);
   126     PtGetAbsPosition(window, &pos.x, &pos.y);
   128     overlay->hwdata->CurrentWindowPos.x = pos.x;
   127     overlay->hwdata->CurrentWindowPos.x = pos.x;
   129     overlay->hwdata->CurrentWindowPos.y = pos.y;
   128     overlay->hwdata->CurrentWindowPos.y = pos.y;
   130     overlay->hwdata->CurrentViewPort.pos.x = 0;
   129     overlay->hwdata->CurrentViewPort.pos.x = 0;
   131     overlay->hwdata->CurrentViewPort.pos.y = 0;
   130     overlay->hwdata->CurrentViewPort.pos.y = 0;
   132     overlay->hwdata->CurrentViewPort.size.w = width;
   131     overlay->hwdata->CurrentViewPort.size.w = width;
   133     overlay->hwdata->CurrentViewPort.size.h = height;
   132     overlay->hwdata->CurrentViewPort.size.h = height;
   134     overlay->hwdata->State = OVERLAY_STATE_UNINIT;
   133     overlay->hwdata->State = OVERLAY_STATE_UNINIT;
   135     overlay->hwdata->FrameData0 =
   134     overlay->hwdata->FrameData0 =
   136         (FRAMEDATA *) SDL_calloc (1, sizeof (FRAMEDATA));
   135         (FRAMEDATA *) SDL_calloc(1, sizeof(FRAMEDATA));
   137     overlay->hwdata->FrameData1 =
   136     overlay->hwdata->FrameData1 =
   138         (FRAMEDATA *) SDL_calloc (1, sizeof (FRAMEDATA));
   137         (FRAMEDATA *) SDL_calloc(1, sizeof(FRAMEDATA));
   139 
   138 
   140     vidport = -1;
   139     vidport = -1;
   141     i = 0;
   140     i = 0;
   142 
   141 
   143     overlay->hwdata->ischromakey = 0;
   142     overlay->hwdata->ischromakey = 0;
   144 
   143 
   145     do {
   144     do {
   146         SDL_memset (&overlay->hwdata->caps, 0x00, sizeof (PgScalerCaps_t));
   145         SDL_memset(&overlay->hwdata->caps, 0x00, sizeof(PgScalerCaps_t));
   147         overlay->hwdata->caps.size = sizeof (PgScalerCaps_t);
   146         overlay->hwdata->caps.size = sizeof(PgScalerCaps_t);
   148         rtncode =
   147         rtncode =
   149             PgGetScalerCapabilities (overlay->hwdata->channel, i,
   148             PgGetScalerCapabilities(overlay->hwdata->channel, i,
   150                                      &overlay->hwdata->caps);
   149                                     &overlay->hwdata->caps);
   151         if (rtncode == 0) {
   150         if (rtncode == 0) {
   152             if (overlay->hwdata->caps.format == format) {
   151             if (overlay->hwdata->caps.format == format) {
   153                 if ((overlay->hwdata->caps.
   152                 if ((overlay->hwdata->caps.
   154                      flags & Pg_SCALER_CAP_DST_CHROMA_KEY) ==
   153                      flags & Pg_SCALER_CAP_DST_CHROMA_KEY) ==
   155                     Pg_SCALER_CAP_DST_CHROMA_KEY) {
   154                     Pg_SCALER_CAP_DST_CHROMA_KEY) {
   165     }
   164     }
   166     while (1);
   165     while (1);
   167 
   166 
   168 
   167 
   169     if (vidport == -1) {
   168     if (vidport == -1) {
   170         SDL_SetError ("No available video ports for requested format\n");
   169         SDL_SetError("No available video ports for requested format\n");
   171         SDL_FreeYUVOverlay (overlay);
   170         SDL_FreeYUVOverlay(overlay);
   172         return NULL;
   171         return NULL;
   173     }
   172     }
   174 
   173 
   175     overlay->hwdata->format = format;
   174     overlay->hwdata->format = format;
   176     overlay->hwdata->props.format = format;
   175     overlay->hwdata->props.format = format;
   177     overlay->hwdata->props.size = sizeof (PgScalerProps_t);
   176     overlay->hwdata->props.size = sizeof(PgScalerProps_t);
   178     overlay->hwdata->props.src_dim.w = width;
   177     overlay->hwdata->props.src_dim.w = width;
   179     overlay->hwdata->props.src_dim.h = height;
   178     overlay->hwdata->props.src_dim.h = height;
   180 
   179 
   181     /* overlay->hwdata->chromakey = PgGetOverlayChromaColor(); */
   180     /* overlay->hwdata->chromakey = PgGetOverlayChromaColor(); */
   182     overlay->hwdata->chromakey = PgRGB (12, 6, 12);     /* very dark pink color */
   181     overlay->hwdata->chromakey = PgRGB(12, 6, 12);      /* very dark pink color */
   183     overlay->hwdata->props.color_key = overlay->hwdata->chromakey;
   182     overlay->hwdata->props.color_key = overlay->hwdata->chromakey;
   184 
   183 
   185     PhAreaToRect (&overlay->hwdata->CurrentViewPort,
   184     PhAreaToRect(&overlay->hwdata->CurrentViewPort,
   186                   &overlay->hwdata->props.viewport);
   185                  &overlay->hwdata->props.viewport);
   187 
   186 
   188     overlay->hwdata->props.flags = Pg_SCALER_PROP_DOUBLE_BUFFER;
   187     overlay->hwdata->props.flags = Pg_SCALER_PROP_DOUBLE_BUFFER;
   189 
   188 
   190     if ((overlay->hwdata->ischromakey) && (overlay->hwdata->chromakey)) {
   189     if ((overlay->hwdata->ischromakey) && (overlay->hwdata->chromakey)) {
   191         overlay->hwdata->props.flags |= Pg_SCALER_PROP_CHROMA_ENABLE;
   190         overlay->hwdata->props.flags |= Pg_SCALER_PROP_CHROMA_ENABLE;
   194     } else {
   193     } else {
   195         overlay->hwdata->props.flags &= ~Pg_SCALER_PROP_CHROMA_ENABLE;
   194         overlay->hwdata->props.flags &= ~Pg_SCALER_PROP_CHROMA_ENABLE;
   196     }
   195     }
   197 
   196 
   198     rtncode =
   197     rtncode =
   199         PgConfigScalerChannel (overlay->hwdata->channel,
   198         PgConfigScalerChannel(overlay->hwdata->channel,
   200                                &overlay->hwdata->props);
   199                               &overlay->hwdata->props);
   201 
   200 
   202     switch (rtncode) {
   201     switch (rtncode) {
   203     case -1:
   202     case -1:
   204         SDL_SetError ("PgConfigScalerChannel failed\n");
   203         SDL_SetError("PgConfigScalerChannel failed\n");
   205         SDL_FreeYUVOverlay (overlay);
   204         SDL_FreeYUVOverlay(overlay);
   206         return NULL;
   205         return NULL;
   207     case 1:
   206     case 1:
   208     case 0:
   207     case 0:
   209     default:
   208     default:
   210         break;
   209         break;
   211     }
   210     }
   212 
   211 
   213     planes =
   212     planes =
   214         grab_ptrs2 (overlay->hwdata->channel, overlay->hwdata->FrameData0,
   213         grab_ptrs2(overlay->hwdata->channel, overlay->hwdata->FrameData0,
   215                     overlay->hwdata->FrameData1);
   214                    overlay->hwdata->FrameData1);
   216 
   215 
   217     if (overlay->hwdata->channel->yplane1 != NULL)
   216     if (overlay->hwdata->channel->yplane1 != NULL)
   218         overlay->hwdata->YStride = overlay->hwdata->channel->yplane1->pitch;
   217         overlay->hwdata->YStride = overlay->hwdata->channel->yplane1->pitch;
   219     if (overlay->hwdata->channel->vplane1 != NULL)
   218     if (overlay->hwdata->channel->vplane1 != NULL)
   220         overlay->hwdata->UStride = overlay->hwdata->channel->vplane1->pitch;
   219         overlay->hwdata->UStride = overlay->hwdata->channel->vplane1->pitch;
   223 
   222 
   224     /* check for the validness of all planes */
   223     /* check for the validness of all planes */
   225     if ((overlay->hwdata->channel->yplane1 == NULL) &&
   224     if ((overlay->hwdata->channel->yplane1 == NULL) &&
   226         (overlay->hwdata->channel->uplane1 == NULL) &&
   225         (overlay->hwdata->channel->uplane1 == NULL) &&
   227         (overlay->hwdata->channel->vplane1 == NULL)) {
   226         (overlay->hwdata->channel->vplane1 == NULL)) {
   228         SDL_FreeYUVOverlay (overlay);
   227         SDL_FreeYUVOverlay(overlay);
   229         SDL_SetError ("PgConfigScaler() returns all planes equal NULL\n");
   228         SDL_SetError("PgConfigScaler() returns all planes equal NULL\n");
   230         return NULL;
   229         return NULL;
   231     }
   230     }
   232 /*
   231 /*
   233     overlay->hwdata->current = PgNextVideoFrame(overlay->hwdata->channel);
   232     overlay->hwdata->current = PgNextVideoFrame(overlay->hwdata->channel);
   234 
   233 
   247     overlay->hwdata->locked = 1;
   246     overlay->hwdata->locked = 1;
   248 */
   247 */
   249 
   248 
   250     /* Find the pitch and offset values for the overlay */
   249     /* Find the pitch and offset values for the overlay */
   251     overlay->planes = planes;
   250     overlay->planes = planes;
   252     overlay->pitches = SDL_calloc (overlay->planes, sizeof (Uint16));
   251     overlay->pitches = SDL_calloc(overlay->planes, sizeof(Uint16));
   253     overlay->pixels = SDL_calloc (overlay->planes, sizeof (Uint8 *));
   252     overlay->pixels = SDL_calloc(overlay->planes, sizeof(Uint8 *));
   254     if (!overlay->pitches || !overlay->pixels) {
   253     if (!overlay->pitches || !overlay->pixels) {
   255         SDL_OutOfMemory ();
   254         SDL_OutOfMemory();
   256         SDL_FreeYUVOverlay (overlay);
   255         SDL_FreeYUVOverlay(overlay);
   257         return (NULL);
   256         return (NULL);
   258     }
   257     }
   259 
   258 
   260     if (overlay->planes > 0) {
   259     if (overlay->planes > 0) {
   261         overlay->pitches[0] = overlay->hwdata->channel->yplane1->pitch;
   260         overlay->pitches[0] = overlay->hwdata->channel->yplane1->pitch;
   278 
   277 
   279     return overlay;
   278     return overlay;
   280 }
   279 }
   281 
   280 
   282 int
   281 int
   283 ph_LockYUVOverlay (_THIS, SDL_Overlay * overlay)
   282 ph_LockYUVOverlay(_THIS, SDL_Overlay * overlay)
   284 {
   283 {
   285     if (overlay == NULL) {
   284     if (overlay == NULL) {
   286         return -1;
   285         return -1;
   287     }
   286     }
   288 
   287 
   324 
   323 
   325     return (0);
   324     return (0);
   326 }
   325 }
   327 
   326 
   328 void
   327 void
   329 ph_UnlockYUVOverlay (_THIS, SDL_Overlay * overlay)
   328 ph_UnlockYUVOverlay(_THIS, SDL_Overlay * overlay)
   330 {
   329 {
   331     if (overlay == NULL) {
   330     if (overlay == NULL) {
   332         return;
   331         return;
   333     }
   332     }
   334 
   333 
   335     overlay->hwdata->locked = 0;
   334     overlay->hwdata->locked = 0;
   336 }
   335 }
   337 
   336 
   338 int
   337 int
   339 ph_DisplayYUVOverlay (_THIS, SDL_Overlay * overlay, SDL_Rect * src,
   338 ph_DisplayYUVOverlay(_THIS, SDL_Overlay * overlay, SDL_Rect * src,
   340                       SDL_Rect * dst)
   339                      SDL_Rect * dst)
   341 {
   340 {
   342     int rtncode;
   341     int rtncode;
   343     PhPoint_t pos;
   342     PhPoint_t pos;
   344     SDL_Rect backrect;
   343     SDL_Rect backrect;
   345     PhRect_t windowextent;
   344     PhRect_t windowextent;
   351 
   350 
   352     if (overlay->hwdata->State == OVERLAY_STATE_UNINIT) {
   351     if (overlay->hwdata->State == OVERLAY_STATE_UNINIT) {
   353         return -1;
   352         return -1;
   354     }
   353     }
   355 
   354 
   356     PtGetAbsPosition (window, &pos.x, &pos.y);
   355     PtGetAbsPosition(window, &pos.x, &pos.y);
   357     if ((pos.x != overlay->hwdata->CurrentWindowPos.x) ||
   356     if ((pos.x != overlay->hwdata->CurrentWindowPos.x) ||
   358         (pos.y != overlay->hwdata->CurrentWindowPos.y)) {
   357         (pos.y != overlay->hwdata->CurrentWindowPos.y)) {
   359         winchanged = 1;
   358         winchanged = 1;
   360         overlay->hwdata->CurrentWindowPos.x = pos.x;
   359         overlay->hwdata->CurrentWindowPos.x = pos.x;
   361         overlay->hwdata->CurrentWindowPos.y = pos.y;
   360         overlay->hwdata->CurrentWindowPos.y = pos.y;
   373             /* restore screen behind the overlay/chroma color. */
   372             /* restore screen behind the overlay/chroma color. */
   374             backrect.x = overlay->hwdata->CurrentViewPort.pos.x;
   373             backrect.x = overlay->hwdata->CurrentViewPort.pos.x;
   375             backrect.y = overlay->hwdata->CurrentViewPort.pos.y;
   374             backrect.y = overlay->hwdata->CurrentViewPort.pos.y;
   376             backrect.w = overlay->hwdata->CurrentViewPort.size.w;
   375             backrect.w = overlay->hwdata->CurrentViewPort.size.w;
   377             backrect.h = overlay->hwdata->CurrentViewPort.size.h;
   376             backrect.h = overlay->hwdata->CurrentViewPort.size.h;
   378             this->UpdateRects (this, 1, &backrect);
   377             this->UpdateRects(this, 1, &backrect);
   379 
   378 
   380             /* Draw the new rectangle of the chroma color at the viewport position */
   379             /* Draw the new rectangle of the chroma color at the viewport position */
   381             PgSetFillColor (overlay->hwdata->chromakey);
   380             PgSetFillColor(overlay->hwdata->chromakey);
   382             PgDrawIRect (dst->x, dst->y, dst->x + dst->w - 1,
   381             PgDrawIRect(dst->x, dst->y, dst->x + dst->w - 1,
   383                          dst->y + dst->h - 1, Pg_DRAW_FILL);
   382                         dst->y + dst->h - 1, Pg_DRAW_FILL);
   384             PgFlush ();
   383             PgFlush();
   385         }
   384         }
   386 
   385 
   387         overlay->hwdata->props.flags |= Pg_SCALER_PROP_SCALER_ENABLE;
   386         overlay->hwdata->props.flags |= Pg_SCALER_PROP_SCALER_ENABLE;
   388         overlay->hwdata->scaler_on = 1;
   387         overlay->hwdata->scaler_on = 1;
   389 
   388 
   390         PhWindowQueryVisible (Ph_QUERY_CONSOLE, 0, PtWidgetRid (window),
   389         PhWindowQueryVisible(Ph_QUERY_CONSOLE, 0, PtWidgetRid(window),
   391                               &windowextent);
   390                              &windowextent);
   392         overlay->hwdata->CurrentViewPort.pos.x =
   391         overlay->hwdata->CurrentViewPort.pos.x =
   393             pos.x - windowextent.ul.x + dst->x;
   392             pos.x - windowextent.ul.x + dst->x;
   394         overlay->hwdata->CurrentViewPort.pos.y =
   393         overlay->hwdata->CurrentViewPort.pos.y =
   395             pos.y - windowextent.ul.y + dst->y;
   394             pos.y - windowextent.ul.y + dst->y;
   396         overlay->hwdata->CurrentViewPort.size.w = dst->w;
   395         overlay->hwdata->CurrentViewPort.size.w = dst->w;
   397         overlay->hwdata->CurrentViewPort.size.h = dst->h;
   396         overlay->hwdata->CurrentViewPort.size.h = dst->h;
   398         PhAreaToRect (&overlay->hwdata->CurrentViewPort,
   397         PhAreaToRect(&overlay->hwdata->CurrentViewPort,
   399                       &overlay->hwdata->props.viewport);
   398                      &overlay->hwdata->props.viewport);
   400         overlay->hwdata->CurrentViewPort.pos.x = dst->x;
   399         overlay->hwdata->CurrentViewPort.pos.x = dst->x;
   401         overlay->hwdata->CurrentViewPort.pos.y = dst->y;
   400         overlay->hwdata->CurrentViewPort.pos.y = dst->y;
   402 
   401 
   403         rtncode =
   402         rtncode =
   404             PgConfigScalerChannel (overlay->hwdata->channel,
   403             PgConfigScalerChannel(overlay->hwdata->channel,
   405                                    &(overlay->hwdata->props));
   404                                   &(overlay->hwdata->props));
   406 
   405 
   407         switch (rtncode) {
   406         switch (rtncode) {
   408         case -1:
   407         case -1:
   409             SDL_SetError ("PgConfigScalerChannel() function failed\n");
   408             SDL_SetError("PgConfigScalerChannel() function failed\n");
   410             SDL_FreeYUVOverlay (overlay);
   409             SDL_FreeYUVOverlay(overlay);
   411             return -1;
   410             return -1;
   412         case 1:
   411         case 1:
   413             grab_ptrs2 (overlay->hwdata->channel,
   412             grab_ptrs2(overlay->hwdata->channel,
   414                         overlay->hwdata->FrameData0,
   413                        overlay->hwdata->FrameData0,
   415                         overlay->hwdata->FrameData1);
   414                        overlay->hwdata->FrameData1);
   416             break;
   415             break;
   417         case 0:
   416         case 0:
   418         default:
   417         default:
   419             break;
   418             break;
   420         }
   419         }
   461 
   460 
   462     return 0;
   461     return 0;
   463 }
   462 }
   464 
   463 
   465 void
   464 void
   466 ph_FreeYUVOverlay (_THIS, SDL_Overlay * overlay)
   465 ph_FreeYUVOverlay(_THIS, SDL_Overlay * overlay)
   467 {
   466 {
   468     SDL_Rect backrect;
   467     SDL_Rect backrect;
   469 
   468 
   470     if (overlay == NULL) {
   469     if (overlay == NULL) {
   471         return;
   470         return;
   480     /* restore screen behind the overlay/chroma color. */
   479     /* restore screen behind the overlay/chroma color. */
   481     backrect.x = overlay->hwdata->CurrentViewPort.pos.x;
   480     backrect.x = overlay->hwdata->CurrentViewPort.pos.x;
   482     backrect.y = overlay->hwdata->CurrentViewPort.pos.y;
   481     backrect.y = overlay->hwdata->CurrentViewPort.pos.y;
   483     backrect.w = overlay->hwdata->CurrentViewPort.size.w;
   482     backrect.w = overlay->hwdata->CurrentViewPort.size.w;
   484     backrect.h = overlay->hwdata->CurrentViewPort.size.h;
   483     backrect.h = overlay->hwdata->CurrentViewPort.size.h;
   485     this->UpdateRects (this, 1, &backrect);
   484     this->UpdateRects(this, 1, &backrect);
   486 
   485 
   487     /* it is need for some buggy drivers, that can't hide overlay before */
   486     /* it is need for some buggy drivers, that can't hide overlay before */
   488     /* freeing buffer, so we got trash on the srceen                     */
   487     /* freeing buffer, so we got trash on the srceen                     */
   489     overlay->hwdata->props.flags &= ~Pg_SCALER_PROP_SCALER_ENABLE;
   488     overlay->hwdata->props.flags &= ~Pg_SCALER_PROP_SCALER_ENABLE;
   490     PgConfigScalerChannel (overlay->hwdata->channel,
   489     PgConfigScalerChannel(overlay->hwdata->channel,
   491                            &(overlay->hwdata->props));
   490                           &(overlay->hwdata->props));
   492 
   491 
   493     overlay->hwdata->scaler_on = 0;
   492     overlay->hwdata->scaler_on = 0;
   494     overlay->hwdata->State = OVERLAY_STATE_UNINIT;
   493     overlay->hwdata->State = OVERLAY_STATE_UNINIT;
   495 
   494 
   496     if (overlay->hwdata->channel != NULL) {
   495     if (overlay->hwdata->channel != NULL) {
   497         PgDestroyVideoChannel (overlay->hwdata->channel);
   496         PgDestroyVideoChannel(overlay->hwdata->channel);
   498         overlay->hwdata->channel = NULL;
   497         overlay->hwdata->channel = NULL;
   499         return;
   498         return;
   500     }
   499     }
   501 
   500 
   502     overlay->hwdata->CurrentFrameData = NULL;
   501     overlay->hwdata->CurrentFrameData = NULL;
   503 
   502 
   504     SDL_free (overlay->hwdata->FrameData0);
   503     SDL_free(overlay->hwdata->FrameData0);
   505     SDL_free (overlay->hwdata->FrameData1);
   504     SDL_free(overlay->hwdata->FrameData1);
   506     overlay->hwdata->FrameData0 = NULL;
   505     overlay->hwdata->FrameData0 = NULL;
   507     overlay->hwdata->FrameData1 = NULL;
   506     overlay->hwdata->FrameData1 = NULL;
   508     SDL_free (overlay->hwdata);
   507     SDL_free(overlay->hwdata);
   509 }
   508 }
   510 
   509 
   511 /* vi: set ts=4 sw=4 expandtab: */
   510 /* vi: set ts=4 sw=4 expandtab: */