Ticket #8428: drawLine2.diff

File drawLine2.diff, 1.8 KB (added by eriktorbjorn, 20 years ago)

Patch against a May 3 CVS snapshot

  • graphics/surface.cpp

    diff -ur --exclude=CVS --exclude=Makefile ScummVM/graphics/surface.cpp ScummVM+hack/graphics/surface.cpp
    old new  
    2020
    2121#include "common/stdafx.h"
    2222#include "common/util.h"
     23#include "graphics/primitives.h"
    2324#include "graphics/surface.h"
    2425
    2526namespace Graphics {
    2627
     28static void plotPoint1(int x, int y, int color, void *data) {
     29        Surface *s = (Surface *)data;
     30        byte *ptr = (byte *)s->getBasePtr(x, y);
     31        *ptr = (byte)color;
     32}
     33
     34static void plotPoint2(int x, int y, int color, void *data) {
     35        Surface *s = (Surface *)data;
     36        uint16 *ptr = (uint16 *)s->getBasePtr(x, y);
     37        *ptr = (uint16)color;
     38}
     39
     40void Surface::drawLine(int x0, int y0, int x1, int y1, uint32 color) {
     41        if (bytesPerPixel == 1)
     42                Graphics::drawLine(x0, y0, x1, y1, color, &plotPoint1, this);
     43        else if (bytesPerPixel == 2)
     44                Graphics::drawLine(x0, y0, x1, y1, color, &plotPoint2, this);
     45        else
     46                error("Surface::drawLine: bytesPerPixel must be 1 or 2");
     47}
     48
    2749void Surface::hLine(int x, int y, int x2, uint32 color) {
    2850        // Clipping
    2951        if (y < 0 || y >= h)
  • graphics/surface.h

    diff -ur --exclude=CVS --exclude=Makefile ScummVM/graphics/surface.h ScummVM+hack/graphics/surface.h
    old new  
    4646        inline void *getBasePtr(int x, int y) {
    4747                return static_cast<void *>(static_cast<byte *>(pixels) + y * pitch + x * bytesPerPixel);
    4848        }
    49        
     49
     50        void drawLine(int x0, int y0, int x1, int y1, uint32 color);
    5051        void hLine(int x, int y, int x2, uint32 color);
    5152        void vLine(int x, int y, int y2, uint32 color);
    5253        void fillRect(const Common::Rect &r, uint32 color);