Loading

Paste #pyppjeqdj

  1. Index: src/blitter/32bpp_anim.cpp
  2. ===================================================================
  3. --- src/blitter/32bpp_anim.cpp  (revision 27795)
  4. +++ src/blitter/32bpp_anim.cpp  (working copy)
  5. @@ -39,6 +39,7 @@
  6.     }
  7.  
  8.     Colour *dst = (Colour *)bp->dst + bp->top * bp->pitch + bp->left;
  9. +   assert(_screen.pitch == this->anim_buf_pitch); // precondition for translating 'bp->dst' into an 'anim_buf' offset below.
  10.     uint16 *anim = this->anim_buf + ((uint32 *)bp->dst - (uint32 *)_screen.dst_ptr) + bp->top * this->anim_buf_width + bp->left;
  11.  
  12.     const byte *remap = bp->remap; // store so we don't have to access it via bp everytime
  13. @@ -45,7 +46,7 @@
  14.  
  15.     for (int y = 0; y < bp->height; y++) {
  16.         Colour *dst_ln = dst + bp->pitch;
  17. -       uint16 *anim_ln = anim + this->anim_buf_width;
  18. +       uint16 *anim_ln = anim + this->anim_buf_pitch;
  19.  
  20.         const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px);
  21.         src_px++;
  22. @@ -279,10 +280,9 @@
  23.     }
  24.  
  25.     Colour *udst = (Colour *)dst;
  26. -   uint16 *anim;
  27. +   assert(_screen.pitch == this->anim_buf_pitch); // precondition for translating 'dst' into an 'anim_buf' offset below.
  28. +   uint16 *anim = this->anim_buf + ((uint32 *)dst - (uint32 *)_screen.dst_ptr);
  29.  
  30. -   anim = this->anim_buf + ((uint32 *)dst - (uint32 *)_screen.dst_ptr);
  31. -
  32.     if (pal == PALETTE_TO_TRANSPARENT) {
  33.         do {
  34.             for (int i = 0; i != width; i++) {
  35. @@ -292,7 +292,7 @@
  36.                 anim++;
  37.             }
  38.             udst = udst - width + _screen.pitch;
  39. -           anim = anim - width + this->anim_buf_width;
  40. +           anim = anim - width + this->anim_buf_pitch;
  41.         } while (--height);
  42.         return;
  43.     }
  44. @@ -305,7 +305,7 @@
  45.                 anim++;
  46.             }
  47.             udst = udst - width + _screen.pitch;
  48. -           anim = anim - width + this->anim_buf_width;
  49. +           anim = anim - width + this->anim_buf_pitch;
  50.         } while (--height);
  51.         return;
  52.     }
  53. @@ -319,7 +319,8 @@
  54.  
  55.     /* Set the colour in the anim-buffer too, if we are rendering to the screen */
  56.     if (_screen_disable_anim) return;
  57. -   this->anim_buf[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y * this->anim_buf_width] = colour | (DEFAULT_BRIGHTNESS << 8);
  58. +   assert(_screen.pitch == this->anim_buf_pitch); // precondition for translating 'video' into an 'anim_buf' offset below.
  59. +   this->anim_buf[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y * this->anim_buf_pitch] = colour | (DEFAULT_BRIGHTNESS << 8);
  60.  }
  61.  
  62.  void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 colour)
  63. @@ -331,10 +332,9 @@
  64.     }
  65.  
  66.     Colour colour32 = LookupColourInPalette(colour);
  67. -   uint16 *anim_line;
  68. +   assert(_screen.pitch == this->anim_buf_pitch); // precondition for translating 'video' into an 'anim_buf' offset below.
  69. +   uint16 *anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf;
  70.  
  71. -   anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf;
  72. -
  73.     do {
  74.         Colour *dst = (Colour *)video;
  75.         uint16 *anim = anim_line;
  76. @@ -347,7 +347,7 @@
  77.             anim++;
  78.         }
  79.         video = (uint32 *)video + _screen.pitch;
  80. -       anim_line += this->anim_buf_width;
  81. +       anim_line += this->anim_buf_pitch;
  82.     } while (--height);
  83.  }
  84.  
  85. @@ -357,6 +357,7 @@
  86.     assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
  87.     Colour *dst = (Colour *)video;
  88.     const uint32 *usrc = (const uint32 *)src;
  89. +   assert(_screen.pitch == this->anim_buf_pitch); // precondition for translating 'video' into an 'anim_buf' offset below.
  90.     uint16 *anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf;
  91.  
  92.     for (; height > 0; height--) {
  93. @@ -370,7 +371,7 @@
  94.         /* Copy back the anim-buffer */
  95.         memcpy(anim_line, usrc, width * sizeof(uint16));
  96.         usrc = (const uint32 *)((const uint16 *)usrc + width);
  97. -       anim_line += this->anim_buf_width;
  98. +       anim_line += this->anim_buf_pitch;
  99.  
  100.         /* Okay, it is *very* likely that the image we stored is using
  101.          * the wrong palette animated colours. There are two things we
  102. @@ -397,11 +398,11 @@
  103.     assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
  104.     uint32 *udst = (uint32 *)dst;
  105.     const uint32 *src = (const uint32 *)video;
  106. -   const uint16 *anim_line;
  107.  
  108.     if (this->anim_buf == NULL) return;
  109.  
  110. -   anim_line = ((const uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf;
  111. +   assert(_screen.pitch == this->anim_buf_pitch); // precondition for translating 'video' into an 'anim_buf' offset below.
  112. +   const uint16 *anim_line = ((const uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf;
  113.  
  114.     for (; height > 0; height--) {
  115.         memcpy(udst, src, width * sizeof(uint32));
  116. @@ -410,7 +411,7 @@
  117.         /* Copy the anim-buffer */
  118.         memcpy(udst, anim_line, width * sizeof(uint16));
  119.         udst = (uint32 *)((uint16 *)udst + width);
  120. -       anim_line += this->anim_buf_width;
  121. +       anim_line += this->anim_buf_pitch;
  122.     }
  123.  }
  124.  
  125. @@ -422,8 +423,8 @@
  126.  
  127.     /* We need to scroll the anim-buffer too */
  128.     if (scroll_y > 0) {
  129. -       dst = this->anim_buf + left + (top + height - 1) * this->anim_buf_width;
  130. -       src = dst - scroll_y * this->anim_buf_width;
  131. +       dst = this->anim_buf + left + (top + height - 1) * this->anim_buf_pitch;
  132. +       src = dst - scroll_y * this->anim_buf_pitch;
  133.  
  134.         /* Adjust left & width */
  135.         if (scroll_x >= 0) {
  136. @@ -436,13 +437,13 @@
  137.         uint th = height - scroll_y;
  138.         for (; th > 0; th--) {
  139.             memcpy(dst, src, tw * sizeof(uint16));
  140. -           src -= this->anim_buf_width;
  141. -           dst -= this->anim_buf_width;
  142. +           src -= this->anim_buf_pitch;
  143. +           dst -= this->anim_buf_pitch;
  144.         }
  145.     } else {
  146.         /* Calculate pointers */
  147. -       dst = this->anim_buf + left + top * this->anim_buf_width;
  148. -       src = dst - scroll_y * this->anim_buf_width;
  149. +       dst = this->anim_buf + left + top * this->anim_buf_pitch;
  150. +       src = dst - scroll_y * this->anim_buf_pitch;
  151.  
  152.         /* Adjust left & width */
  153.         if (scroll_x >= 0) {
  154. @@ -457,8 +458,8 @@
  155.         uint th = height + scroll_y;
  156.         for (; th > 0; th--) {
  157.             memmove(dst, src, tw * sizeof(uint16));
  158. -           src += this->anim_buf_width;
  159. -           dst += this->anim_buf_width;
  160. +           src += this->anim_buf_pitch;
  161. +           dst += this->anim_buf_pitch;
  162.         }
  163.     }
  164.  
  165. @@ -495,6 +496,7 @@
  166.             anim++;
  167.         }
  168.         dst += _screen.pitch - this->anim_buf_width;
  169. +       anim += this->anim_buf_pitch - this->anim_buf_width;
  170.     }
  171.  
  172.     /* Make sure the backend redraws the whole screen */
  173. @@ -508,11 +510,13 @@
  174.  
  175.  void Blitter_32bppAnim::PostResize()
  176.  {
  177. -   if (_screen.width != this->anim_buf_width || _screen.height != this->anim_buf_height) {
  178. +   if (_screen.width != this->anim_buf_width || _screen.height != this->anim_buf_height ||
  179. +           _screen.pitch != this->anim_buf_pitch) {
  180.         /* The size of the screen changed; we can assume we can wipe all data from our buffer */
  181.         free(this->anim_buf);
  182. -       this->anim_buf = CallocT<uint16>(_screen.width * _screen.height);
  183.         this->anim_buf_width = _screen.width;
  184.         this->anim_buf_height = _screen.height;
  185. +       this->anim_buf_pitch = _screen.pitch;
  186. +       this->anim_buf = CallocT<uint16>(this->anim_buf_height * this->anim_buf_pitch);
  187.     }
  188.  }
  189. Index: src/blitter/32bpp_anim.hpp
  190. ===================================================================
  191. --- src/blitter/32bpp_anim.hpp  (revision 27795)
  192. +++ src/blitter/32bpp_anim.hpp  (working copy)
  193. @@ -20,6 +20,7 @@
  194.     uint16 *anim_buf;    ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation
  195.     int anim_buf_width;  ///< The width of the animation buffer.
  196.     int anim_buf_height; ///< The height of the animation buffer.
  197. +   int anim_buf_pitch;  ///< The pitch of the animation buffer.
  198.     Palette palette;     ///< The current palette.
  199.  
  200.  public:
  201. @@ -26,7 +27,8 @@
  202.     Blitter_32bppAnim() :
  203.         anim_buf(NULL),
  204.         anim_buf_width(0),
  205. -       anim_buf_height(0)
  206. +       anim_buf_height(0),
  207. +       anim_buf_pitch(0)
  208.     {
  209.         this->palette = _cur_palette;
  210.     }
  211. Index: src/blitter/32bpp_anim_sse4.cpp
  212. ===================================================================
  213. --- src/blitter/32bpp_anim_sse4.cpp (revision 27795)
  214. +++ src/blitter/32bpp_anim_sse4.cpp (working copy)
  215. @@ -35,7 +35,8 @@
  216.  {
  217.     const byte * const remap = bp->remap;
  218.     Colour *dst_line = (Colour *) bp->dst + bp->top * bp->pitch + bp->left;
  219. -   uint16 *anim_line = this->anim_buf + ((uint32 *)bp->dst - (uint32 *)_screen.dst_ptr) + bp->top * this->anim_buf_width + bp->left;
  220. +   assert(_screen.pitch == this->anim_buf_pitch); // precondition for translating 'bp->dst' into an 'anim_buf' offset below.
  221. +   uint16 *anim_line = this->anim_buf + ((uint32 *)bp->dst - (uint32 *)_screen.dst_ptr) + bp->top * this->anim_buf_pitch + bp->left;
  222.     int effective_width = bp->width;
  223.  
  224.     /* Find where to start reading in the source sprite. */
  225. @@ -353,7 +354,7 @@
  226.         if (mode != BM_TRANSPARENT) src_mv_line += si->sprite_width;
  227.         src_rgba_line = (const Colour*) ((const byte*) src_rgba_line + si->sprite_line_size);
  228.         dst_line += bp->pitch;
  229. -       anim_line += this->anim_buf_width;
  230. +       anim_line += this->anim_buf_pitch;
  231.     }
  232.  }
  233.  IGNORE_UNINITIALIZED_WARNING_STOP
  234.  

Comments