comparison src/video/SDL_video.c @ 1684:c4aa1a2f48f1 SDL-1.3

Software YUV texture support in progress...
author Sam Lantinga <slouken@libsdl.org>
date Sun, 18 Jun 2006 06:35:41 +0000
parents 396a35389351
children 1577404809f0
comparison
equal deleted inserted replaced
1683:396a35389351 1684:c4aa1a2f48f1
565 ncolors = (1 << SDL_BITSPERPIXEL(display_mode.format)); 565 ncolors = (1 << SDL_BITSPERPIXEL(display_mode.format));
566 } else { 566 } else {
567 ncolors = 0; 567 ncolors = 0;
568 } 568 }
569 if ((!ncolors && display->palette) || (ncolors && !display->palette) 569 if ((!ncolors && display->palette) || (ncolors && !display->palette)
570 || (ncolors != display->palette->ncolors)) { 570 || (ncolors && ncolors != display->palette->ncolors)) {
571 if (display->palette) { 571 if (display->palette) {
572 SDL_FreePalette(display->palette); 572 SDL_FreePalette(display->palette);
573 display->palette = NULL; 573 display->palette = NULL;
574 } 574 }
575 if (ncolors) { 575 if (ncolors) {
1432 SDL_UpdateTexture(SDL_TextureID textureID, const SDL_Rect * rect, 1432 SDL_UpdateTexture(SDL_TextureID textureID, const SDL_Rect * rect,
1433 const void *pixels, int pitch) 1433 const void *pixels, int pitch)
1434 { 1434 {
1435 SDL_Texture *texture = SDL_GetTextureFromID(textureID); 1435 SDL_Texture *texture = SDL_GetTextureFromID(textureID);
1436 SDL_Renderer *renderer; 1436 SDL_Renderer *renderer;
1437 SDL_Rect full_rect;
1437 1438
1438 if (!texture) { 1439 if (!texture) {
1439 return -1; 1440 return -1;
1440 } 1441 }
1441 1442
1442 renderer = texture->renderer; 1443 renderer = texture->renderer;
1443 if (!renderer->UpdateTexture) { 1444 if (!renderer->UpdateTexture) {
1444 return -1; 1445 return -1;
1445 } 1446 }
1447
1448 if (!rect) {
1449 full_rect.x = 0;
1450 full_rect.y = 0;
1451 full_rect.w = texture->w;
1452 full_rect.h = texture->h;
1453 rect = &full_rect;
1454 }
1455
1446 return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch); 1456 return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch);
1447 } 1457 }
1448 1458
1449 int 1459 int
1450 SDL_LockTexture(SDL_TextureID textureID, const SDL_Rect * rect, int markDirty, 1460 SDL_LockTexture(SDL_TextureID textureID, const SDL_Rect * rect, int markDirty,
1451 void **pixels, int *pitch) 1461 void **pixels, int *pitch)
1452 { 1462 {
1453 SDL_Texture *texture = SDL_GetTextureFromID(textureID); 1463 SDL_Texture *texture = SDL_GetTextureFromID(textureID);
1454 SDL_Renderer *renderer; 1464 SDL_Renderer *renderer;
1465 SDL_Rect full_rect;
1455 1466
1456 if (!texture) { 1467 if (!texture) {
1457 return -1; 1468 return -1;
1458 } 1469 }
1459 1470
1460 renderer = texture->renderer; 1471 renderer = texture->renderer;
1461 if (!renderer->LockTexture) { 1472 if (!renderer->LockTexture) {
1462 return -1; 1473 return -1;
1463 } 1474 }
1475
1476 if (!rect) {
1477 full_rect.x = 0;
1478 full_rect.y = 0;
1479 full_rect.w = texture->w;
1480 full_rect.h = texture->h;
1481 rect = &full_rect;
1482 }
1483
1464 return renderer->LockTexture(renderer, texture, rect, markDirty, pixels, 1484 return renderer->LockTexture(renderer, texture, rect, markDirty, pixels,
1465 pitch); 1485 pitch);
1466 } 1486 }
1467 1487
1468 void 1488 void
1518 1538
1519 int 1539 int
1520 SDL_RenderFill(const SDL_Rect * rect, Uint32 color) 1540 SDL_RenderFill(const SDL_Rect * rect, Uint32 color)
1521 { 1541 {
1522 SDL_Renderer *renderer; 1542 SDL_Renderer *renderer;
1543 SDL_Rect full_rect;
1523 1544
1524 if (!_this) { 1545 if (!_this) {
1525 return -1; 1546 return -1;
1526 } 1547 }
1527 1548
1528 renderer = SDL_CurrentDisplay.current_renderer; 1549 renderer = SDL_CurrentDisplay.current_renderer;
1529 if (!renderer || !renderer->RenderFill) { 1550 if (!renderer || !renderer->RenderFill) {
1530 return -1; 1551 return -1;
1531 } 1552 }
1532 1553
1554 if (!rect) {
1555 full_rect.x = 0;
1556 full_rect.y = 0;
1557 full_rect.w = renderer->window->w;
1558 full_rect.h = renderer->window->h;
1559 rect = &full_rect;
1560 }
1561
1533 renderer->RenderFill(renderer, rect, color); 1562 renderer->RenderFill(renderer, rect, color);
1534 } 1563 }
1535 1564
1536 int 1565 int
1537 SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect * srcrect, 1566 SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect * srcrect,
1538 const SDL_Rect * dstrect, int blendMode, int scaleMode) 1567 const SDL_Rect * dstrect, int blendMode, int scaleMode)
1539 { 1568 {
1540 SDL_Texture *texture = SDL_GetTextureFromID(textureID); 1569 SDL_Texture *texture = SDL_GetTextureFromID(textureID);
1541 SDL_Renderer *renderer; 1570 SDL_Renderer *renderer;
1571 SDL_Rect full_srcrect;
1572 SDL_Rect full_dstrect;
1542 1573
1543 if (!texture || texture->renderer != SDL_CurrentDisplay.current_renderer) { 1574 if (!texture || texture->renderer != SDL_CurrentDisplay.current_renderer) {
1544 return; 1575 return;
1545 } 1576 }
1546 1577
1547 renderer = SDL_CurrentDisplay.current_renderer; 1578 renderer = SDL_CurrentDisplay.current_renderer;
1548 if (!renderer || !renderer->RenderCopy) { 1579 if (!renderer || !renderer->RenderCopy) {
1549 return -1; 1580 return -1;
1550 } 1581 }
1551 1582
1583 if (!srcrect) {
1584 full_srcrect.x = 0;
1585 full_srcrect.y = 0;
1586 full_srcrect.w = texture->w;
1587 full_srcrect.h = texture->h;
1588 srcrect = &full_srcrect;
1589 }
1590 if (!dstrect) {
1591 full_dstrect.x = 0;
1592 full_dstrect.y = 0;
1593 full_dstrect.w = renderer->window->w;
1594 full_dstrect.h = renderer->window->h;
1595 dstrect = &full_dstrect;
1596 }
1597
1552 return renderer->RenderCopy(renderer, texture, srcrect, dstrect, 1598 return renderer->RenderCopy(renderer, texture, srcrect, dstrect,
1553 blendMode, scaleMode); 1599 blendMode, scaleMode);
1554 } 1600 }
1555 1601
1556 int 1602 int
1557 SDL_RenderReadPixels(const SDL_Rect * rect, void *pixels, int pitch) 1603 SDL_RenderReadPixels(const SDL_Rect * rect, void *pixels, int pitch)
1558 { 1604 {
1559 SDL_Renderer *renderer; 1605 SDL_Renderer *renderer;
1606 SDL_Rect full_rect;
1560 1607
1561 if (!_this) { 1608 if (!_this) {
1562 return -1; 1609 return -1;
1563 } 1610 }
1564 1611
1565 renderer = SDL_CurrentDisplay.current_renderer; 1612 renderer = SDL_CurrentDisplay.current_renderer;
1566 if (!renderer || !renderer->RenderReadPixels) { 1613 if (!renderer || !renderer->RenderReadPixels) {
1567 return -1; 1614 return -1;
1568 } 1615 }
1569 1616
1617 if (!rect) {
1618 full_rect.x = 0;
1619 full_rect.y = 0;
1620 full_rect.w = renderer->window->w;
1621 full_rect.h = renderer->window->h;
1622 rect = &full_rect;
1623 }
1624
1570 return renderer->RenderReadPixels(renderer, rect, pixels, pitch); 1625 return renderer->RenderReadPixels(renderer, rect, pixels, pitch);
1571 } 1626 }
1572 1627
1573 int 1628 int
1574 SDL_RenderWritePixels(const SDL_Rect * rect, const void *pixels, int pitch) 1629 SDL_RenderWritePixels(const SDL_Rect * rect, const void *pixels, int pitch)
1575 { 1630 {
1576 SDL_Renderer *renderer; 1631 SDL_Renderer *renderer;
1632 SDL_Rect full_rect;
1577 1633
1578 if (!_this) { 1634 if (!_this) {
1579 return -1; 1635 return -1;
1580 } 1636 }
1581 1637
1582 renderer = SDL_CurrentDisplay.current_renderer; 1638 renderer = SDL_CurrentDisplay.current_renderer;
1583 if (!renderer || !renderer->RenderWritePixels) { 1639 if (!renderer || !renderer->RenderWritePixels) {
1584 return -1; 1640 return -1;
1641 }
1642
1643 if (!rect) {
1644 full_rect.x = 0;
1645 full_rect.y = 0;
1646 full_rect.w = renderer->window->w;
1647 full_rect.h = renderer->window->h;
1648 rect = &full_rect;
1585 } 1649 }
1586 1650
1587 return renderer->RenderWritePixels(renderer, rect, pixels, pitch); 1651 return renderer->RenderWritePixels(renderer, rect, pixels, pitch);
1588 } 1652 }
1589 1653