Ticket #8428: drawLine.diff

File drawLine.diff, 1.6 KB (added by eriktorbjorn, 19 years ago)

Patch against a May 2 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 plotPoint(int x, int y, int color, void *data) {
     29        Surface *s = (Surface *)data;
     30
     31        if (s->bytesPerPixel == 1) {
     32                byte *ptr = (byte *)s->getBasePtr(x, y);
     33                *ptr = (byte)color;
     34        } else if (s->bytesPerPixel == 2) {
     35                uint16 *ptr = (uint16 *)s->getBasePtr(x, y);
     36                *ptr = (uint16)color;
     37        } else {
     38                error("plotPoint: bytesPerPixel must be 1 or 2");
     39        }
     40}
     41
     42void Surface::drawLine(int x0, int y0, int x1, int y1, uint32 color) const {
     43        Graphics::drawLine(x0, y0, x1, y1, color, &plotPoint, const_cast<Surface *>(this));
     44}
     45
    2746void Surface::hLine(int x, int y, int x2, uint32 color) const {
    2847        // Clipping
    2948        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  
    4242        inline void *getBasePtr(int x, int y) const {
    4343                return (void *)((byte *)pixels + y * pitch + x * bytesPerPixel);
    4444        }
    45        
     45
     46        void drawLine(int x0, int y0, int x1, int y1, uint32 color) const;
    4647        void hLine(int x, int y, int x2, uint32 color) const;
    4748        void vLine(int x, int y, int y2, uint32 color) const;
    4849        void fillRect(const Common::Rect &r, uint32 color) const;