ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/video_x.cpp
(Generate patch)

Comparing SheepShaver/src/Unix/video_x.cpp (file contents):
Revision 1.15 by gbeauche, 2004-04-13T22:22:21Z vs.
Revision 1.16 by gbeauche, 2004-04-18T23:03:51Z

# Line 195 | Line 195 | static int palette_size(int mode)
195          }
196   }
197  
198 + // Return bits per pixel for requested depth
199 + static inline int bytes_per_pixel(int depth)
200 + {
201 +        int bpp;
202 +        switch (depth) {
203 +        case 8:
204 +                bpp = 1;
205 +                break;
206 +        case 15: case 16:
207 +                bpp = 2;
208 +                break;
209 +        case 24: case 32:
210 +                bpp = 4;
211 +                break;
212 +        default:
213 +                abort();
214 +        }
215 +        return bpp;
216 + }
217 +
218   // Map video_mode depth ID to numerical depth value
219   static inline int depth_of_video_mode(int mode)
220   {
221 <        int depth = -1;
221 >        int depth;
222          switch (mode) {
223          case APPLE_1_BIT:
224                  depth = 1;
# Line 1592 | Line 1612 | void VideoVBL(void)
1612   */
1613  
1614   #if 0
1595 // Rectangle blitting
1596 static void accl_bitblt(accl_params *p)
1597 {
1598        D(bug("accl_bitblt\n"));
1599
1600        // Get blitting parameters
1601        int16 src_X = p->src_rect[1] - p->src_bounds[1];
1602        int16 src_Y = p->src_rect[0] - p->src_bounds[0];
1603        int16 dest_X = p->dest_rect[1] - p->dest_bounds[1];
1604        int16 dest_Y = p->dest_rect[0] - p->dest_bounds[0];
1605        int16 width = p->dest_rect[3] - p->dest_rect[1] - 1;
1606        int16 height = p->dest_rect[2] - p->dest_rect[0] - 1;
1607        D(bug(" src X %d, src Y %d, dest X %d, dest Y %d\n", src_X, src_Y, dest_X, dest_Y));
1608        D(bug(" width %d, height %d\n", width, height));
1609
1610        // And perform the blit
1611        bitblt_hook(src_X, src_Y, dest_X, dest_Y, width, height);
1612 }
1613
1614 static bool accl_bitblt_hook(accl_params *p)
1615 {
1616        D(bug("accl_draw_hook %p\n", p));
1617
1618        // Check if we can accelerate this bitblt
1619        if (p->src_base_addr == screen_base && p->dest_base_addr == screen_base &&
1620                display_type == DIS_SCREEN && bitblt_hook != NULL &&
1621                ((uint32 *)p)[0x18 >> 2] + ((uint32 *)p)[0x128 >> 2] == 0 &&
1622                ((uint32 *)p)[0x130 >> 2] == 0 &&
1623                p->transfer_mode == 0 &&
1624                p->src_row_bytes > 0 && ((uint32 *)p)[0x15c >> 2] > 0) {
1625
1626                // Yes, set function pointer
1627                p->draw_proc = accl_bitblt;
1628                return true;
1629        }
1630        return false;
1631 }
1632
1615   // Rectangle filling/inversion
1616   static void accl_fillrect8(accl_params *p)
1617   {
# Line 1707 | Line 1689 | static bool accl_fillrect_hook(accl_para
1689          return false;
1690   }
1691  
1692 + static struct accl_hook_info fillrect_hook_info = {accl_fillrect_hook, accl_sync_hook, ACCL_FILLRECT};
1693 + #endif
1694 +
1695 + // Rectangle blitting
1696 + // TODO: optimize for VOSF and target pixmap == screen
1697 + void NQD_bitblt(uint32 arg)
1698 + {
1699 +        D(bug("accl_bitblt %08x\n", arg));
1700 +        accl_params *p = (accl_params *)arg;
1701 +
1702 +        // Get blitting parameters
1703 +        int16 src_X = p->src_rect[1] - p->src_bounds[1];
1704 +        int16 src_Y = p->src_rect[0] - p->src_bounds[0];
1705 +        int16 dest_X = p->dest_rect[1] - p->dest_bounds[1];
1706 +        int16 dest_Y = p->dest_rect[0] - p->dest_bounds[0];
1707 +        int16 width = p->dest_rect[3] - p->dest_rect[1];
1708 +        int16 height = p->dest_rect[2] - p->dest_rect[0];
1709 +        D(bug(" src addr %08x, dest addr %08x\n", p->src_base_addr, p->dest_base_addr));
1710 +        D(bug(" src X %d, src Y %d, dest X %d, dest Y %d\n", src_X, src_Y, dest_X, dest_Y));
1711 +        D(bug(" width %d, height %d\n", width, height));
1712 +
1713 +        // And perform the blit
1714 +        const int bpp = bytes_per_pixel(p->src_pixel_size);
1715 +        width *= bpp;
1716 +        if (p->src_row_bytes > 0) {
1717 +                const int src_row_bytes = p->src_row_bytes;
1718 +                const int dst_row_bytes = p->dest_row_bytes;
1719 +                uint8 *src = (uint8 *)p->src_base_addr + (src_Y * src_row_bytes) + (src_X * bpp);
1720 +                uint8 *dst = (uint8 *)p->dest_base_addr + (dest_Y * dst_row_bytes) + (dest_X * bpp);
1721 +                for (int i = 0; i < height; i++) {
1722 +                        memcpy(dst, src, width);
1723 +                        src += src_row_bytes;
1724 +                        dst += dst_row_bytes;
1725 +                }
1726 +        }
1727 +        else {
1728 +                const int src_row_bytes = -p->src_row_bytes;
1729 +                const int dst_row_bytes = -p->dest_row_bytes;
1730 +                uint8 *src = (uint8 *)p->src_base_addr + ((src_Y + height - 1) * src_row_bytes) + (src_X * bpp);
1731 +                uint8 *dst = (uint8 *)p->dest_base_addr + ((dest_Y + height - 1) * dst_row_bytes) + (dest_X * bpp);
1732 +                for (int i = height - 1; i >= 0; i--) {
1733 +                        memcpy(dst, src, width);
1734 +                        src -= src_row_bytes;
1735 +                        dst -= dst_row_bytes;
1736 +                }
1737 +        }
1738 + }
1739 +
1740 + bool NQD_bitblt_hook(uint32 arg)
1741 + {
1742 +        D(bug("accl_draw_hook %08x\n", arg));
1743 +        accl_params *p = (accl_params *)arg;
1744 +
1745 +        // Check if we can accelerate this bitblt
1746 +        if (((uint32 *)p)[0x18 >> 2] + ((uint32 *)p)[0x128 >> 2] == 0 &&
1747 +                ((uint32 *)p)[0x130 >> 2] == 0 &&
1748 +                p->src_pixel_size >= 8 && p->src_pixel_size == p->dest_pixel_size &&
1749 +                ((p->src_row_bytes ^ p->dest_row_bytes) >> 31) == 0 &&
1750 +                p->transfer_mode == 0 &&
1751 +                ((uint32 *)p)[0x15c >> 2] > 0) {
1752 +
1753 +                // Yes, set function pointer
1754 +                p->draw_proc = NativeTVECT(NATIVE_BITBLT);
1755 +                return true;
1756 +        }
1757 +        return false;
1758 + }
1759 +
1760   // Wait for graphics operation to finish
1761 < static bool accl_sync_hook(void *arg)
1761 > bool NQD_sync_hook(uint32 arg)
1762   {
1763 <        D(bug("accl_sync_hook %p\n", arg));
1714 <        if (sync_hook != NULL)
1715 <                sync_hook();
1763 >        D(bug("accl_sync_hook %08x\n", arg));
1764          return true;
1765   }
1766  
1719 static struct accl_hook_info bitblt_hook_info = {accl_bitblt_hook, accl_sync_hook, ACCL_BITBLT};
1720 static struct accl_hook_info fillrect_hook_info = {accl_fillrect_hook, accl_sync_hook, ACCL_FILLRECT};
1721 #endif
1722
1767   void VideoInstallAccel(void)
1768   {
1769          // Install acceleration hooks
1770          if (PrefsFindBool("gfxaccel")) {
1771                  D(bug("Video: Installing acceleration hooks\n"));
1772 < //!!    NQDMisc(6, &bitblt_hook_info);
1772 >                uint32 base;
1773 >
1774 >                SheepVar bitblt_hook_info(sizeof(accl_hook_info));
1775 >                base = bitblt_hook_info.addr();
1776 >                WriteMacInt32(base + 0, NativeTVECT(NATIVE_BITBLT_HOOK));
1777 >                WriteMacInt32(base + 4, NativeTVECT(NATIVE_SYNC_HOOK));
1778 >                WriteMacInt32(base + 8, ACCL_BITBLT);
1779 >                NQDMisc(6, bitblt_hook_info.ptr());
1780 >
1781   //              NQDMisc(6, &fillrect_hook_info);
1782          }
1783   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines