Sync with stippi's version of PatternHandler with integration tweaks

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10719 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm 2005-01-14 01:34:20 +00:00
parent 8a4cda2a9b
commit d9558e8396
4 changed files with 128 additions and 98 deletions

View File

@ -228,7 +228,7 @@ void AccelerantDriver::StrokeLineArray(const int32 &numlines, const LineArrayDat
Lock(); Lock();
fLineThickness = (int)d->pensize; fLineThickness = (int)d->pensize;
fDrawPattern.SetTarget((int8*)&B_SOLID_HIGH); fDrawPattern.SetPattern((int8*)&B_SOLID_HIGH);
for (i=0; i<numlines; i++) for (i=0; i<numlines; i++)
{ {
data=(const LineArrayData *)&(linedata[i]); data=(const LineArrayData *)&(linedata[i]);
@ -503,7 +503,7 @@ void AccelerantDriver::SetThickPatternPixel(int x, int y)
for (y=top; y<=bottom; y++) for (y=top; y<=bottom; y++)
{ {
for (x=left; x<=right; x++) for (x=left; x<=right; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor8();; fb[x] = fDrawPattern.ColorAt(x,y).GetColor8();;
fb += mFrameBufferConfig.bytes_per_row; fb += mFrameBufferConfig.bytes_per_row;
} }
} break; } break;
@ -517,7 +517,7 @@ void AccelerantDriver::SetThickPatternPixel(int x, int y)
for (y=top; y<=bottom; y++) for (y=top; y<=bottom; y++)
{ {
for (x=left; x<=right; x++) for (x=left; x<=right; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor15(); fb[x] = fDrawPattern.ColorAt(x,y).GetColor15();
fb = (uint16 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row); fb = (uint16 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row);
} }
} break; } break;
@ -529,7 +529,7 @@ void AccelerantDriver::SetThickPatternPixel(int x, int y)
for (y=top; y<=bottom; y++) for (y=top; y<=bottom; y++)
{ {
for (x=left; x<=right; x++) for (x=left; x<=right; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor16(); fb[x] = fDrawPattern.ColorAt(x,y).GetColor16();
fb = (uint16 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row); fb = (uint16 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row);
} }
} break; } break;
@ -545,7 +545,7 @@ void AccelerantDriver::SetThickPatternPixel(int x, int y)
{ {
for (x=left; x<=right; x++) for (x=left; x<=right; x++)
{ {
color = fDrawPattern.GetColor(x,y).GetColor32(); color = fDrawPattern.ColorAt(x,y).GetColor32();
fb[x] = (color.alpha << 24) | (color.red << 16) | (color.green << 8) | (color.blue); fb[x] = (color.alpha << 24) | (color.red << 16) | (color.green << 8) | (color.blue);
} }
fb = (uint32 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row); fb = (uint32 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row);
@ -580,7 +580,7 @@ void AccelerantDriver::HLine(int32 x1, int32 x2, int32 y, PatternHandler *pat)
{ {
uint8 *fb = (uint8 *)mFrameBufferConfig.frame_buffer + y*mFrameBufferConfig.bytes_per_row; uint8 *fb = (uint8 *)mFrameBufferConfig.frame_buffer + y*mFrameBufferConfig.bytes_per_row;
for (x=x1; x<=x2; x++) for (x=x1; x<=x2; x++)
fb[x] = pat->GetColor(x,y).GetColor8(); fb[x] = pat->ColorAt(x,y).GetColor8();
} break; } break;
case B_RGB15_BIG: case B_RGB15_BIG:
case B_RGBA15_BIG: case B_RGBA15_BIG:
@ -589,14 +589,14 @@ void AccelerantDriver::HLine(int32 x1, int32 x2, int32 y, PatternHandler *pat)
{ {
uint16 *fb = (uint16 *)((uint8 *)mFrameBufferConfig.frame_buffer + y*mFrameBufferConfig.bytes_per_row); uint16 *fb = (uint16 *)((uint8 *)mFrameBufferConfig.frame_buffer + y*mFrameBufferConfig.bytes_per_row);
for (x=x1; x<=x2; x++) for (x=x1; x<=x2; x++)
fb[x] = pat->GetColor(x,y).GetColor15(); fb[x] = pat->ColorAt(x,y).GetColor15();
} break; } break;
case B_RGB16_BIG: case B_RGB16_BIG:
case B_RGB16_LITTLE: case B_RGB16_LITTLE:
{ {
uint16 *fb = (uint16 *)((uint8 *)mFrameBufferConfig.frame_buffer + y*mFrameBufferConfig.bytes_per_row); uint16 *fb = (uint16 *)((uint8 *)mFrameBufferConfig.frame_buffer + y*mFrameBufferConfig.bytes_per_row);
for (x=x1; x<=x2; x++) for (x=x1; x<=x2; x++)
fb[x] = pat->GetColor(x,y).GetColor16(); fb[x] = pat->ColorAt(x,y).GetColor16();
} break; } break;
case B_RGB32_BIG: case B_RGB32_BIG:
case B_RGBA32_BIG: case B_RGBA32_BIG:
@ -607,7 +607,7 @@ void AccelerantDriver::HLine(int32 x1, int32 x2, int32 y, PatternHandler *pat)
rgb_color color; rgb_color color;
for (x=x1; x<=x2; x++) for (x=x1; x<=x2; x++)
{ {
color = pat->GetColor(x,y).GetColor32(); color = pat->ColorAt(x,y).GetColor32();
fb[x] = (color.alpha << 24) | (color.red << 16) | (color.green << 8) | (color.blue); fb[x] = (color.alpha << 24) | (color.red << 16) | (color.green << 8) | (color.blue);
} }
} break; } break;
@ -644,7 +644,7 @@ void AccelerantDriver::HLinePatternThick(int32 x1, int32 x2, int32 y)
for (y=y1; y<=y2; y++) for (y=y1; y<=y2; y++)
{ {
for (x=x1; x<=x2; x++) for (x=x1; x<=x2; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor8(); fb[x] = fDrawPattern.ColorAt(x,y).GetColor8();
fb += mFrameBufferConfig.bytes_per_row; fb += mFrameBufferConfig.bytes_per_row;
} }
} break; } break;
@ -657,7 +657,7 @@ void AccelerantDriver::HLinePatternThick(int32 x1, int32 x2, int32 y)
for (y=y1; y<=y2; y++) for (y=y1; y<=y2; y++)
{ {
for (x=x1; x<=x2; x++) for (x=x1; x<=x2; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor15(); fb[x] = fDrawPattern.ColorAt(x,y).GetColor15();
fb = (uint16 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row); fb = (uint16 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row);
} }
} break; } break;
@ -668,7 +668,7 @@ void AccelerantDriver::HLinePatternThick(int32 x1, int32 x2, int32 y)
for (y=y1; y<=y2; y++) for (y=y1; y<=y2; y++)
{ {
for (x=x1; x<=x2; x++) for (x=x1; x<=x2; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor16(); fb[x] = fDrawPattern.ColorAt(x,y).GetColor16();
fb = (uint16 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row); fb = (uint16 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row);
} }
} break; } break;
@ -683,7 +683,7 @@ void AccelerantDriver::HLinePatternThick(int32 x1, int32 x2, int32 y)
{ {
for (x=x1; x<=x2; x++) for (x=x1; x<=x2; x++)
{ {
color = fDrawPattern.GetColor(x,y).GetColor32(); color = fDrawPattern.ColorAt(x,y).GetColor32();
fb[x] = (color.alpha << 24) | (color.red << 16) | (color.green << 8) | (color.blue); fb[x] = (color.alpha << 24) | (color.red << 16) | (color.green << 8) | (color.blue);
} }
fb = (uint32 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row); fb = (uint32 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row);
@ -721,7 +721,7 @@ void AccelerantDriver::VLinePatternThick(int32 x, int32 y1, int32 y2)
for (y=y1; y<=y2; y++) for (y=y1; y<=y2; y++)
{ {
for (x=x1; x<=x2; x++) for (x=x1; x<=x2; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor8(); fb[x] = fDrawPattern.ColorAt(x,y).GetColor8();
fb += mFrameBufferConfig.bytes_per_row; fb += mFrameBufferConfig.bytes_per_row;
} }
} break; } break;
@ -734,7 +734,7 @@ void AccelerantDriver::VLinePatternThick(int32 x, int32 y1, int32 y2)
for (y=y1; y<=y2; y++) for (y=y1; y<=y2; y++)
{ {
for (x=x1; x<=x2; x++) for (x=x1; x<=x2; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor15(); fb[x] = fDrawPattern.ColorAt(x,y).GetColor15();
fb = (uint16 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row); fb = (uint16 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row);
} }
} break; } break;
@ -745,7 +745,7 @@ void AccelerantDriver::VLinePatternThick(int32 x, int32 y1, int32 y2)
for (y=y1; y<=y2; y++) for (y=y1; y<=y2; y++)
{ {
for (x=x1; x<=x2; x++) for (x=x1; x<=x2; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor16(); fb[x] = fDrawPattern.ColorAt(x,y).GetColor16();
fb = (uint16 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row); fb = (uint16 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row);
} }
} break; } break;
@ -760,7 +760,7 @@ void AccelerantDriver::VLinePatternThick(int32 x, int32 y1, int32 y2)
{ {
for (x=x1; x<=x2; x++) for (x=x1; x<=x2; x++)
{ {
color = fDrawPattern.GetColor(x,y).GetColor32(); color = fDrawPattern.ColorAt(x,y).GetColor32();
fb[x] = (color.alpha << 24) | (color.red << 16) | (color.green << 8) | (color.blue); fb[x] = (color.alpha << 24) | (color.red << 16) | (color.green << 8) | (color.blue);
} }
fb = (uint32 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row); fb = (uint32 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row);
@ -895,7 +895,7 @@ void AccelerantDriver::FillPatternRect(int32 left, int32 top, int32 right, int32
for (y=top; y<=bottom; y++) for (y=top; y<=bottom; y++)
{ {
for (x=left; x<=right; x++) for (x=left; x<=right; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor8(); fb[x] = fDrawPattern.ColorAt(x,y).GetColor8();
fb += mFrameBufferConfig.bytes_per_row; fb += mFrameBufferConfig.bytes_per_row;
} }
} break; } break;
@ -909,7 +909,7 @@ void AccelerantDriver::FillPatternRect(int32 left, int32 top, int32 right, int32
for (y=top; y<=bottom; y++) for (y=top; y<=bottom; y++)
{ {
for (x=left; x<=right; x++) for (x=left; x<=right; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor15(); fb[x] = fDrawPattern.ColorAt(x,y).GetColor15();
fb = (uint16 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row); fb = (uint16 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row);
} }
} break; } break;
@ -921,7 +921,7 @@ void AccelerantDriver::FillPatternRect(int32 left, int32 top, int32 right, int32
for (y=top; y<=bottom; y++) for (y=top; y<=bottom; y++)
{ {
for (x=left; x<=right; x++) for (x=left; x<=right; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor16(); fb[x] = fDrawPattern.ColorAt(x,y).GetColor16();
fb = (uint16 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row); fb = (uint16 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row);
} }
} break; } break;
@ -937,7 +937,7 @@ void AccelerantDriver::FillPatternRect(int32 left, int32 top, int32 right, int32
{ {
for (x=left; x<=right; x++) for (x=left; x<=right; x++)
{ {
color = fDrawPattern.GetColor(x,y).GetColor32(); color = fDrawPattern.ColorAt(x,y).GetColor32();
fb[x] = (color.alpha << 24) | (color.red << 16) | (color.green << 8) | (color.blue); fb[x] = (color.alpha << 24) | (color.red << 16) | (color.green << 8) | (color.blue);
} }
fb = (uint32 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row); fb = (uint32 *)((uint8 *)fb + mFrameBufferConfig.bytes_per_row);

View File

@ -340,7 +340,7 @@ void BitmapDriver::SetThickPatternPixel(int x, int y)
for (y=top; y<=bottom; y++) for (y=top; y<=bottom; y++)
{ {
for (x=left; x<=right; x++) for (x=left; x<=right; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor8(); fb[x] = fDrawPattern.ColorAt(x,y).GetColor8();
fb += bytes_per_row; fb += bytes_per_row;
} }
} break; } break;
@ -351,7 +351,7 @@ void BitmapDriver::SetThickPatternPixel(int x, int y)
for (y=top; y<=bottom; y++) for (y=top; y<=bottom; y++)
{ {
for (x=left; x<=right; x++) for (x=left; x<=right; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor15(); fb[x] = fDrawPattern.ColorAt(x,y).GetColor15();
fb = (uint16 *)((uint8 *)fb + bytes_per_row); fb = (uint16 *)((uint8 *)fb + bytes_per_row);
} }
} break; } break;
@ -362,7 +362,7 @@ void BitmapDriver::SetThickPatternPixel(int x, int y)
for (y=top; y<=bottom; y++) for (y=top; y<=bottom; y++)
{ {
for (x=left; x<=right; x++) for (x=left; x<=right; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor16(); fb[x] = fDrawPattern.ColorAt(x,y).GetColor16();
fb = (uint16 *)((uint8 *)fb + bytes_per_row); fb = (uint16 *)((uint8 *)fb + bytes_per_row);
} }
} break; } break;
@ -376,7 +376,7 @@ void BitmapDriver::SetThickPatternPixel(int x, int y)
{ {
for (x=left; x<=right; x++) for (x=left; x<=right; x++)
{ {
color = fDrawPattern.GetColor(x,y).GetColor32(); color = fDrawPattern.ColorAt(x,y).GetColor32();
fb[x] = (color.alpha << 24) | (color.red << 16) | (color.green << 8) | (color.blue); fb[x] = (color.alpha << 24) | (color.red << 16) | (color.green << 8) | (color.blue);
} }
fb = (uint32 *)((uint8 *)fb + bytes_per_row); fb = (uint32 *)((uint8 *)fb + bytes_per_row);
@ -414,7 +414,7 @@ void BitmapDriver::HLinePatternThick(int32 x1, int32 x2, int32 y)
for (y=y1; y<=y2; y++) for (y=y1; y<=y2; y++)
{ {
for (x=x1; x<=x2; x++) for (x=x1; x<=x2; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor8(); fb[x] = fDrawPattern.ColorAt(x,y).GetColor8();
fb += bytes_per_row; fb += bytes_per_row;
} }
} break; } break;
@ -424,7 +424,7 @@ void BitmapDriver::HLinePatternThick(int32 x1, int32 x2, int32 y)
for (y=y1; y<=y2; y++) for (y=y1; y<=y2; y++)
{ {
for (x=x1; x<=x2; x++) for (x=x1; x<=x2; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor15(); fb[x] = fDrawPattern.ColorAt(x,y).GetColor15();
fb = (uint16 *)((uint8 *)fb + bytes_per_row); fb = (uint16 *)((uint8 *)fb + bytes_per_row);
} }
} break; } break;
@ -434,7 +434,7 @@ void BitmapDriver::HLinePatternThick(int32 x1, int32 x2, int32 y)
for (y=y1; y<=y2; y++) for (y=y1; y<=y2; y++)
{ {
for (x=x1; x<=x2; x++) for (x=x1; x<=x2; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor16(); fb[x] = fDrawPattern.ColorAt(x,y).GetColor16();
fb = (uint16 *)((uint8 *)fb + bytes_per_row); fb = (uint16 *)((uint8 *)fb + bytes_per_row);
} }
} break; } break;
@ -447,7 +447,7 @@ void BitmapDriver::HLinePatternThick(int32 x1, int32 x2, int32 y)
{ {
for (x=x1; x<=x2; x++) for (x=x1; x<=x2; x++)
{ {
color = fDrawPattern.GetColor(x,y).GetColor32(); color = fDrawPattern.ColorAt(x,y).GetColor32();
fb[x] = (color.alpha << 24) | (color.red << 16) | (color.green << 8) | (color.blue); fb[x] = (color.alpha << 24) | (color.red << 16) | (color.green << 8) | (color.blue);
} }
fb = (uint32 *)((uint8 *)fb + bytes_per_row); fb = (uint32 *)((uint8 *)fb + bytes_per_row);
@ -485,7 +485,7 @@ void BitmapDriver::VLinePatternThick(int32 x, int32 y1, int32 y2)
for (y=y1; y<=y2; y++) for (y=y1; y<=y2; y++)
{ {
for (x=x1; x<=x2; x++) for (x=x1; x<=x2; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor8(); fb[x] = fDrawPattern.ColorAt(x,y).GetColor8();
fb += bytes_per_row; fb += bytes_per_row;
} }
} break; } break;
@ -495,7 +495,7 @@ void BitmapDriver::VLinePatternThick(int32 x, int32 y1, int32 y2)
for (y=y1; y<=y2; y++) for (y=y1; y<=y2; y++)
{ {
for (x=x1; x<=x2; x++) for (x=x1; x<=x2; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor15(); fb[x] = fDrawPattern.ColorAt(x,y).GetColor15();
fb = (uint16 *)((uint8 *)fb + bytes_per_row); fb = (uint16 *)((uint8 *)fb + bytes_per_row);
} }
} break; } break;
@ -505,7 +505,7 @@ void BitmapDriver::VLinePatternThick(int32 x, int32 y1, int32 y2)
for (y=y1; y<=y2; y++) for (y=y1; y<=y2; y++)
{ {
for (x=x1; x<=x2; x++) for (x=x1; x<=x2; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor16(); fb[x] = fDrawPattern.ColorAt(x,y).GetColor16();
fb = (uint16 *)((uint8 *)fb + bytes_per_row); fb = (uint16 *)((uint8 *)fb + bytes_per_row);
} }
} break; } break;
@ -518,7 +518,7 @@ void BitmapDriver::VLinePatternThick(int32 x, int32 y1, int32 y2)
{ {
for (x=x1; x<=x2; x++) for (x=x1; x<=x2; x++)
{ {
color = fDrawPattern.GetColor(x,y).GetColor32(); color = fDrawPattern.ColorAt(x,y).GetColor32();
fb[x] = (color.alpha << 24) | (color.red << 16) | (color.green << 8) | (color.blue); fb[x] = (color.alpha << 24) | (color.red << 16) | (color.green << 8) | (color.blue);
} }
fb = (uint32 *)((uint8 *)fb + bytes_per_row); fb = (uint32 *)((uint8 *)fb + bytes_per_row);
@ -760,7 +760,7 @@ void BitmapDriver::FillPatternRect(const BRect &rect, const DrawData *d)
for (y=top; y<=bottom; y++) for (y=top; y<=bottom; y++)
{ {
for (x=left; x<=right; x++) for (x=left; x<=right; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor8(); fb[x] = fDrawPattern.ColorAt(x,y).GetColor8();
fb += bytes_per_row; fb += bytes_per_row;
} }
} break; } break;
@ -771,7 +771,7 @@ void BitmapDriver::FillPatternRect(const BRect &rect, const DrawData *d)
for (y=top; y<=bottom; y++) for (y=top; y<=bottom; y++)
{ {
for (x=left; x<=right; x++) for (x=left; x<=right; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor15(); fb[x] = fDrawPattern.ColorAt(x,y).GetColor15();
fb = (uint16 *)((uint8 *)fb + bytes_per_row); fb = (uint16 *)((uint8 *)fb + bytes_per_row);
} }
} break; } break;
@ -782,7 +782,7 @@ void BitmapDriver::FillPatternRect(const BRect &rect, const DrawData *d)
for (y=top; y<=bottom; y++) for (y=top; y<=bottom; y++)
{ {
for (x=left; x<=right; x++) for (x=left; x<=right; x++)
fb[x] = fDrawPattern.GetColor(x,y).GetColor16(); fb[x] = fDrawPattern.ColorAt(x,y).GetColor16();
fb = (uint16 *)((uint8 *)fb + bytes_per_row); fb = (uint16 *)((uint8 *)fb + bytes_per_row);
} }
} break; } break;
@ -796,7 +796,7 @@ void BitmapDriver::FillPatternRect(const BRect &rect, const DrawData *d)
{ {
for (x=left; x<=right; x++) for (x=left; x<=right; x++)
{ {
color = fDrawPattern.GetColor(x,y).GetColor32(); color = fDrawPattern.ColorAt(x,y).GetColor32();
fb[x] = (color.alpha << 24) | (color.red << 16) | (color.green << 8) | (color.blue); fb[x] = (color.alpha << 24) | (color.red << 16) | (color.green << 8) | (color.blue);
} }
fb = (uint32 *)((uint8 *)fb + bytes_per_row); fb = (uint32 *)((uint8 *)fb + bytes_per_row);

View File

@ -36,7 +36,7 @@ DrawData::DrawData(void)
highcolor.SetColor(0, 0, 0, 255); highcolor.SetColor(0, 0, 0, 255);
lowcolor.SetColor(255, 255, 255, 255); lowcolor.SetColor(255, 255, 255, 255);
patt=pat_solidhigh; patt=kSolidHigh;
draw_mode=B_OP_COPY; draw_mode=B_OP_COPY;
lineCap =B_BUTT_CAP; lineCap =B_BUTT_CAP;

View File

@ -1,5 +1,5 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Copyright (c) 2001-2002, Haiku, Inc. // Copyright (c) 2001-2005, Haiku, Inc.
// //
// Permission is hereby granted, free of charge, to any person obtaining a // Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"), // copy of this software and associated documentation files (the "Software"),
@ -21,15 +21,19 @@
// //
// File Name: PatternHandler.cpp // File Name: PatternHandler.cpp
// Author: DarkWyrm <bpmagic@columbus.rr.com> // Author: DarkWyrm <bpmagic@columbus.rr.com>
// Stephan Aßmus <superstippi@gmx.de>
// Description: Class for easy calculation and use of patterns // Description: Class for easy calculation and use of patterns
// //
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include <Point.h> #include <Point.h>
#include "PatternHandler.h" #include "PatternHandler.h"
const Pattern pat_solidhigh(0xFFFFFFFFFFFFFFFFLL); const Pattern kSolidHigh(0xFFFFFFFFFFFFFFFFLL);
const Pattern pat_solidlow((uint64)0); const Pattern kSolidLow((uint64)0);
const Pattern pat_mixedcolors(0xAAAAAAAAAAAAAAAALL); const Pattern kMixedColors(0xAAAAAAAAAAAAAAAALL);
const rgb_color kBlack = (rgb_color){ 0, 0, 0, 255 };
const rgb_color kWhite = (rgb_color){ 255, 255, 255, 255 };
/*! /*!
\brief Void constructor \brief Void constructor
@ -38,10 +42,10 @@ const Pattern pat_mixedcolors(0xAAAAAAAAAAAAAAAALL);
low color is set to white. low color is set to white.
*/ */
PatternHandler::PatternHandler(void) PatternHandler::PatternHandler(void)
: fPattern(kSolidHigh),
fHighColor(kBlack),
fLowColor(kWhite)
{ {
_pat=0xFFFFFFFFFFFFFFFFLL;
_high=new RGBColor(0,0,0,255);
_low=new RGBColor(255,255,255,255);
} }
/*! /*!
@ -51,15 +55,11 @@ PatternHandler::PatternHandler(void)
This initializes to the given pattern or B_SOLID_HIGH if the pattern This initializes to the given pattern or B_SOLID_HIGH if the pattern
is NULL. High color is set to black, and low color is set to white. is NULL. High color is set to black, and low color is set to white.
*/ */
PatternHandler::PatternHandler(int8 *pat) PatternHandler::PatternHandler(const int8* pat)
: fPattern(pat ? Pattern(pat) : Pattern(kSolidHigh)),
fHighColor(kBlack),
fLowColor(kWhite)
{ {
if(pat)
_pat.Set(pat);
else
_pat=0xFFFFFFFFFFFFFFFFLL;
_high=new RGBColor(0,0,0,255);
_low=new RGBColor(255,255,255,255);
} }
/*! /*!
@ -69,25 +69,43 @@ PatternHandler::PatternHandler(int8 *pat)
This initializes to the given pattern or B_SOLID_HIGH if the pattern This initializes to the given pattern or B_SOLID_HIGH if the pattern
is NULL. High color is set to black, and low color is set to white. is NULL. High color is set to black, and low color is set to white.
*/ */
PatternHandler::PatternHandler(const uint64 &pat) PatternHandler::PatternHandler(const uint64& pat)
: fPattern(pat),
fHighColor(kBlack),
fLowColor(kWhite)
{ {
_pat=pat;
_high=new RGBColor(0,0,0,255);
_low=new RGBColor(255,255,255,255);
} }
PatternHandler::PatternHandler(const Pattern &pat) /*!
\brief Constructor initializes to given pattern
\param pat Pattern to use.
This initializes to the given Pattern.
High color is set to black, and low color is set to white.
*/
PatternHandler::PatternHandler(const Pattern& pat)
: fPattern(pat),
fHighColor(kBlack),
fLowColor(kWhite)
{ {
_pat=pat;
_high=new RGBColor(0,0,0,255);
_low=new RGBColor(255,255,255,255);
} }
//! Destructor frees internal color variables /*!
\brief Constructor initializes to given PatternHandler
\param other PatternHandler to copy.
Copy constructor.
*/
PatternHandler::PatternHandler(const PatternHandler& other)
: fPattern(other.fPattern),
fHighColor(other.fHighColor),
fLowColor(other.fLowColor)
{
}
//! Destructor does nothing
PatternHandler::~PatternHandler(void) PatternHandler::~PatternHandler(void)
{ {
delete _high;
delete _low;
} }
/*! /*!
@ -97,30 +115,39 @@ PatternHandler::~PatternHandler(void)
This initializes to the given pattern or B_SOLID_HIGH if the pattern This initializes to the given pattern or B_SOLID_HIGH if the pattern
is NULL. is NULL.
*/ */
void PatternHandler::SetTarget(int8 *pat) void PatternHandler::SetPattern(const int8* pat)
{ {
if(pat) if (pat)
_pat.Set(pat); fPattern.Set(pat);
else else
_pat=0xFFFFFFFFFFFFFFFFLL; fPattern = kSolidHigh;
} }
/*! /*!
\brief Sets the pattern for the handler to the one given \brief Sets the pattern for the handler to the one given
\param pat Pattern to use. \param pat Pattern to use.
*/ */
void PatternHandler::SetTarget(const uint64 &pat) void PatternHandler::SetPattern(const uint64& pat)
{ {
_pat=pat; fPattern = pat;
} }
/*! /*!
\brief Sets the pattern for the handler to the one given \brief Sets the pattern for the handler to the one given
\param pat Pattern to use. \param pat Pattern to use.
*/ */
void PatternHandler::SetTarget(const Pattern &pat) void PatternHandler::SetPattern(const Pattern& pat)
{ {
_pat=pat; fPattern = pat;
}
/*!
\brief Sets the pattern for the handler to the one given
\param pat R5 style pattern to use.
*/
void PatternHandler::SetPattern(const pattern& pat)
{
fPattern = pat;
} }
/*! /*!
@ -128,10 +155,28 @@ void PatternHandler::SetTarget(const Pattern &pat)
\param high High color for the handler \param high High color for the handler
\param low Low color for the handler \param low Low color for the handler
*/ */
void PatternHandler::SetColors(const RGBColor &high, const RGBColor &low) void PatternHandler::SetColors(const RGBColor& high, const RGBColor& low)
{ {
*_high=high; fHighColor = high;
*_low=low; fLowColor = low;
}
/*!
\brief Set the high color for the pattern to use
\param color High color for the handler
*/
void PatternHandler::SetHighColor(const RGBColor& color)
{
fHighColor = color;
}
/*!
\brief Set the low color for the pattern to use
\param color Low color for the handler
*/
void PatternHandler::SetLowColor(const RGBColor& color)
{
fLowColor = color;
} }
/*! /*!
@ -139,9 +184,10 @@ void PatternHandler::SetColors(const RGBColor &high, const RGBColor &low)
\param pt Coordinates to get the color for \param pt Coordinates to get the color for
\return Color for the coordinates \return Color for the coordinates
*/ */
RGBColor PatternHandler::GetColor(const BPoint &pt) RGBColor
PatternHandler::ColorAt(const BPoint &pt) const
{ {
return GetColor(pt.x,pt.y); return ColorAt(pt.x, pt.y);
} }
/*! /*!
@ -150,26 +196,10 @@ RGBColor PatternHandler::GetColor(const BPoint &pt)
\param y Y coordinate to get the color for \param y Y coordinate to get the color for
\return Color for the coordinates \return Color for the coordinates
*/ */
RGBColor PatternHandler::GetColor(const float &x, const float &y) RGBColor
PatternHandler::ColorAt(float x, float y) const
{ {
const int8 *ptr=_pat.GetInt8(); return ColorAt(int(x), int(y));
int32 value=ptr[(uint32)y%8] & (1 << (7-((uint32)x%8)) );
return (value==0)?*_low:*_high;
}
/*!
\brief Obtains the value of the pattern at the specified coordinates
\param x X coordinate to get the value for
\param y Y coordinate to get the value for
\return Value for the coordinates - true if high, false if low.
*/
bool PatternHandler::GetValue(const float &x, const float &y)
{
const int8 *ptr=_pat.GetInt8();
int32 value=ptr[(uint32)y%8] & (1 << (7-((uint32)x%8)) );
return (value==0)?false:true;
} }
/*! /*!
@ -177,8 +207,8 @@ bool PatternHandler::GetValue(const float &x, const float &y)
\param pt Coordinates to get the value for \param pt Coordinates to get the value for
\return Value for the coordinates - true if high, false if low. \return Value for the coordinates - true if high, false if low.
*/ */
bool PatternHandler::GetValue(const BPoint &pt) bool PatternHandler::IsHighColor(const BPoint &pt) const
{ {
return GetValue(pt.x,pt.y); return IsHighColor((int)pt.x, (int)pt.y);
} }