* get rid of RGBColor usage where it is not needed, this simplified many things,

possibly making them a little faster too
* mess with decorator button size calculation to make the whole layout scale
  more agreeable with the font size (no more fixed offsets/insets), but it
  is work in progress
* DefaultDecorator no longer allocated the border color array, it is part of
  the object now
* small memory footprint optimizations in ViewLayer, Decorator and WindowLayer


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22003 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2007-08-17 12:56:20 +00:00
parent 5d19a6e65c
commit f7e1df7560
48 changed files with 425 additions and 509 deletions
+1 -1
View File
@@ -482,7 +482,7 @@ Decorator::DrawZoom(void)
} }
RGBColor rgb_color
Decorator::UIColor(color_which which) Decorator::UIColor(color_which which)
{ {
// TODO: for now - calling ui_color() from within the app_server // TODO: for now - calling ui_color() from within the app_server
+5 -5
View File
@@ -116,7 +116,7 @@ class Decorator {
virtual void DrawTitle(); virtual void DrawTitle();
virtual void DrawZoom(); virtual void DrawZoom();
RGBColor UIColor(color_which which); rgb_color UIColor(color_which which);
protected: protected:
int32 _TitleWidth() const int32 _TitleWidth() const
@@ -149,11 +149,11 @@ class Decorator {
BRect fBorderRect; BRect fBorderRect;
private: private:
bool fClosePressed; bool fClosePressed : 1;
bool fZoomPressed; bool fZoomPressed : 1;
bool fMinimizePressed; bool fMinimizePressed : 1;
bool fIsFocused; bool fIsFocused : 1;
BString fTitle; BString fTitle;
}; };
+118 -100
View File
@@ -17,7 +17,6 @@
#include "DrawState.h" #include "DrawState.h"
#include "FontManager.h" #include "FontManager.h"
#include "PatternHandler.h" #include "PatternHandler.h"
#include "RGBColor.h"
#include <WindowPrivate.h> #include <WindowPrivate.h>
@@ -90,13 +89,12 @@ DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect,
{ {
DefaultDecorator::SetLook(settings, look); DefaultDecorator::SetLook(settings, look);
fFrameColors = new RGBColor[6]; fFrameColors[0] = (rgb_color){ 152, 152, 152, 255 };
fFrameColors[0].SetColor(152, 152, 152); fFrameColors[1] = (rgb_color){ 255, 255, 255, 255 };
fFrameColors[1].SetColor(255, 255, 255); fFrameColors[2] = (rgb_color){ 216, 216, 216, 255 };
fFrameColors[2].SetColor(216, 216, 216); fFrameColors[3] = (rgb_color){ 136, 136, 136, 255 };
fFrameColors[3].SetColor(136, 136, 136); fFrameColors[4] = (rgb_color){ 152, 152, 152, 255 };
fFrameColors[4].SetColor(152, 152, 152); fFrameColors[5] = (rgb_color){ 96, 96, 96, 255 };
fFrameColors[5].SetColor(96, 96, 96);
// Set appropriate colors based on the current focus value. In this case, each decorator // Set appropriate colors based on the current focus value. In this case, each decorator
// defaults to not having the focus. // defaults to not having the focus.
@@ -116,7 +114,6 @@ DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect,
DefaultDecorator::~DefaultDecorator() DefaultDecorator::~DefaultDecorator()
{ {
STRACE(("DefaultDecorator: ~DefaultDecorator()\n")); STRACE(("DefaultDecorator: ~DefaultDecorator()\n"));
delete [] fFrameColors;
} }
@@ -605,20 +602,22 @@ DefaultDecorator::_DoLayout()
if (hasTab) { if (hasTab) {
// distance from one item of the tab bar to another. // distance from one item of the tab bar to another.
// In this case the text and close/zoom rects // In this case the text and close/zoom rects
fTextOffset = (fLook == B_FLOATING_WINDOW_LOOK || fLook == kLeftTitledWindowLook) fTextOffset = (fLook == B_FLOATING_WINDOW_LOOK
? 10 : 18; || fLook == kLeftTitledWindowLook) ? 10 : 18;
font_height fontHeight; font_height fontHeight;
fDrawState.Font().GetHeight(fontHeight); fDrawState.Font().GetHeight(fontHeight);
if (fLook != kLeftTitledWindowLook) { if (fLook != kLeftTitledWindowLook) {
fTabRect.Set(fFrame.left - fBorderWidth, fTabRect.Set(fFrame.left - fBorderWidth,
fFrame.top - fBorderWidth - ceilf(fontHeight.ascent + fontHeight.descent + 7.0), fFrame.top - fBorderWidth
- ceilf(fontHeight.ascent + fontHeight.descent + 7.0),
((fFrame.right - fFrame.left) < 35.0 ? ((fFrame.right - fFrame.left) < 35.0 ?
fFrame.left + 35.0 : fFrame.right) + fBorderWidth, fFrame.left + 35.0 : fFrame.right) + fBorderWidth,
fFrame.top - fBorderWidth); fFrame.top - fBorderWidth);
} else { } else {
fTabRect.Set(fFrame.left - fBorderWidth - ceilf(fontHeight.ascent + fontHeight.descent + 5.0), fTabRect.Set(fFrame.left - fBorderWidth
- ceilf(fontHeight.ascent + fontHeight.descent + 5.0),
fFrame.top - fBorderWidth, fFrame.left - fBorderWidth, fFrame.top - fBorderWidth, fFrame.left - fBorderWidth,
fFrame.bottom + fBorderWidth); fFrame.bottom + fBorderWidth);
} }
@@ -631,10 +630,11 @@ DefaultDecorator::_DoLayout()
float offset; float offset;
float size; float size;
_GetButtonSizeAndOffset(fTabRect, &offset, &size); float inset;
_GetButtonSizeAndOffset(fTabRect, &offset, &size, &inset);
// fMinTabSize contains just the room for the buttons // fMinTabSize contains just the room for the buttons
fMinTabSize = 4.0 + fTextOffset; fMinTabSize = inset * 2 + fTextOffset;
if ((fFlags & B_NOT_CLOSABLE) == 0) if ((fFlags & B_NOT_CLOSABLE) == 0)
fMinTabSize += offset + size; fMinTabSize += offset + size;
if ((fFlags & B_NOT_ZOOMABLE) == 0) if ((fFlags & B_NOT_ZOOMABLE) == 0)
@@ -701,8 +701,10 @@ DefaultDecorator::_DoLayout()
if (fTabOffset < 0) if (fTabOffset < 0)
fTabOffset = 0; fTabOffset = 0;
if (fTabLocation != 0.0 if (fTabLocation != 0.0
&& fTabOffset > (fRightBorder.right - fLeftBorder.left - fTabRect.Width())) && fTabOffset > (fRightBorder.right - fLeftBorder.left
fTabOffset = uint32(fRightBorder.right - fLeftBorder.left - fTabRect.Width()); - fTabRect.Width()))
fTabOffset = uint32(fRightBorder.right - fLeftBorder.left
- fTabRect.Width());
fTabRect.OffsetBy(fTabOffset, 0); fTabRect.OffsetBy(fTabOffset, 0);
// finally, layout the buttons and text within the tab rect // finally, layout the buttons and text within the tab rect
@@ -737,12 +739,13 @@ DefaultDecorator::_DrawFrame(BRect invalid)
if (invalid.Intersects(fTopBorder)) { if (invalid.Intersects(fTopBorder)) {
for (int8 i = 0; i < 5; i++) { for (int8 i = 0; i < 5; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i), fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
BPoint(r.right - i, r.top + i), BPoint(r.right - i, r.top + i), fFrameColors[i]);
fFrameColors[i]);
} }
if (fTabRect.IsValid()) { if (fTabRect.IsValid()) {
// grey along the bottom of the tab (overwrites "white" from frame) // grey along the bottom of the tab
fDrawingEngine->StrokeLine(BPoint(fTabRect.left + 2, fTabRect.bottom + 1), // (overwrites "white" from frame)
fDrawingEngine->StrokeLine(
BPoint(fTabRect.left + 2, fTabRect.bottom + 1),
BPoint(fTabRect.right - 2, fTabRect.bottom + 1), BPoint(fTabRect.right - 2, fTabRect.bottom + 1),
fFrameColors[2]); fFrameColors[2]);
} }
@@ -751,8 +754,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) { if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
for (int8 i = 0; i < 5; i++) { for (int8 i = 0; i < 5; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i), fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
BPoint(r.left + i, r.bottom - i), BPoint(r.left + i, r.bottom - i), fFrameColors[i]);
fFrameColors[i]);
} }
} }
// bottom // bottom
@@ -781,12 +783,13 @@ DefaultDecorator::_DrawFrame(BRect invalid)
if (invalid.Intersects(fTopBorder)) { if (invalid.Intersects(fTopBorder)) {
for (int8 i = 0; i < 3; i++) { for (int8 i = 0; i < 3; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i), fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
BPoint(r.right - i, r.top + i), BPoint(r.right - i, r.top + i), fFrameColors[i * 2]);
fFrameColors[i * 2]);
} }
if (fTabRect.IsValid() && fLook != kLeftTitledWindowLook) { if (fTabRect.IsValid() && fLook != kLeftTitledWindowLook) {
// grey along the bottom of the tab (overwrites "white" from frame) // grey along the bottom of the tab
fDrawingEngine->StrokeLine(BPoint(fTabRect.left + 2, fTabRect.bottom + 1), // (overwrites "white" from frame)
fDrawingEngine->StrokeLine(
BPoint(fTabRect.left + 2, fTabRect.bottom + 1),
BPoint(fTabRect.right - 2, fTabRect.bottom + 1), BPoint(fTabRect.right - 2, fTabRect.bottom + 1),
fFrameColors[2]); fFrameColors[2]);
} }
@@ -795,12 +798,13 @@ DefaultDecorator::_DrawFrame(BRect invalid)
if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) { if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
for (int8 i = 0; i < 3; i++) { for (int8 i = 0; i < 3; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i), fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
BPoint(r.left + i, r.bottom - i), BPoint(r.left + i, r.bottom - i), fFrameColors[i * 2]);
fFrameColors[i * 2]);
} }
if (fLook == kLeftTitledWindowLook && fTabRect.IsValid()) { if (fLook == kLeftTitledWindowLook && fTabRect.IsValid()) {
// grey along the right side of the tab (overwrites "white" from frame) // grey along the right side of the tab
fDrawingEngine->StrokeLine(BPoint(fTabRect.right + 1, fTabRect.top + 2), // (overwrites "white" from frame)
fDrawingEngine->StrokeLine(
BPoint(fTabRect.right + 1, fTabRect.top + 2),
BPoint(fTabRect.right + 1, fTabRect.bottom - 2), BPoint(fTabRect.right + 1, fTabRect.bottom - 2),
fFrameColors[2]); fFrameColors[2]);
} }
@@ -846,15 +850,16 @@ DefaultDecorator::_DrawFrame(BRect invalid)
float x = r.right - 3; float x = r.right - 3;
float y = r.bottom - 3; float y = r.bottom - 3;
fDrawingEngine->FillRect(BRect(x - 13, y - 13, x, y), fFrameColors[2]); fDrawingEngine->FillRect(BRect(x - 13, y - 13, x, y),
fDrawingEngine->StrokeLine(BPoint(x - 15, y - 15), BPoint(x - 15, y - 2), fFrameColors[2]);
fFrameColors[0]); fDrawingEngine->StrokeLine(BPoint(x - 15, y - 15),
fDrawingEngine->StrokeLine(BPoint(x - 14, y - 14), BPoint(x - 14, y - 1), BPoint(x - 15, y - 2), fFrameColors[0]);
fFrameColors[1]); fDrawingEngine->StrokeLine(BPoint(x - 14, y - 14),
fDrawingEngine->StrokeLine(BPoint(x - 15, y - 15), BPoint(x - 2, y - 15), BPoint(x - 14, y - 1), fFrameColors[1]);
fFrameColors[0]); fDrawingEngine->StrokeLine(BPoint(x - 15, y - 15),
fDrawingEngine->StrokeLine(BPoint(x - 14, y - 14), BPoint(x - 1, y - 14), BPoint(x - 2, y - 15), fFrameColors[0]);
fFrameColors[1]); fDrawingEngine->StrokeLine(BPoint(x - 14, y - 14),
BPoint(x - 1, y - 14), fFrameColors[1]);
if (!IsFocus()) if (!IsFocus())
break; break;
@@ -880,10 +885,12 @@ DefaultDecorator::_DrawFrame(BRect invalid)
fBottomBorder.bottom - 1))) fBottomBorder.bottom - 1)))
break; break;
fDrawingEngine->StrokeLine(BPoint(fRightBorder.left, fBottomBorder.bottom - 22), fDrawingEngine->StrokeLine(
BPoint(fRightBorder.left, fBottomBorder.bottom - 22),
BPoint(fRightBorder.right - 1, fBottomBorder.bottom - 22), BPoint(fRightBorder.right - 1, fBottomBorder.bottom - 22),
fFrameColors[0]); fFrameColors[0]);
fDrawingEngine->StrokeLine(BPoint(fRightBorder.right - 22, fBottomBorder.top), fDrawingEngine->StrokeLine(
BPoint(fRightBorder.right - 22, fBottomBorder.top),
BPoint(fRightBorder.right - 22, fBottomBorder.bottom - 1), BPoint(fRightBorder.right - 22, fBottomBorder.bottom - 1),
fFrameColors[0]); fFrameColors[0]);
break; break;
@@ -908,26 +915,34 @@ DefaultDecorator::_DrawTab(BRect invalid)
return; return;
// outer frame // outer frame
fDrawingEngine->StrokeLine(fTabRect.LeftTop(), fTabRect.LeftBottom(), fFrameColors[0]); fDrawingEngine->StrokeLine(fTabRect.LeftTop(), fTabRect.LeftBottom(),
fDrawingEngine->StrokeLine(fTabRect.LeftTop(), fTabRect.RightTop(), fFrameColors[0]); fFrameColors[0]);
if (fLook != kLeftTitledWindowLook) fDrawingEngine->StrokeLine(fTabRect.LeftTop(), fTabRect.RightTop(),
fDrawingEngine->StrokeLine(fTabRect.RightTop(),fTabRect.RightBottom(), fFrameColors[5]); fFrameColors[0]);
else if (fLook != kLeftTitledWindowLook) {
fDrawingEngine->StrokeLine(fTabRect.LeftBottom(),fTabRect.RightBottom(), fFrameColors[5]); fDrawingEngine->StrokeLine(fTabRect.RightTop(), fTabRect.RightBottom(),
fFrameColors[5]);
} else {
fDrawingEngine->StrokeLine(fTabRect.LeftBottom(),
fTabRect.RightBottom(), fFrameColors[5]);
}
// bevel // bevel
fDrawingEngine->StrokeLine(BPoint(fTabRect.left + 1, fTabRect.top + 1), fDrawingEngine->StrokeLine(BPoint(fTabRect.left + 1, fTabRect.top + 1),
BPoint(fTabRect.left + 1, fTabRect.bottom - (fLook == kLeftTitledWindowLook ? 1 : 0)), BPoint(fTabRect.left + 1,
fTabRect.bottom - (fLook == kLeftTitledWindowLook ? 1 : 0)),
fTabColorLight); fTabColorLight);
fDrawingEngine->StrokeLine(BPoint(fTabRect.left + 1, fTabRect.top + 1), fDrawingEngine->StrokeLine(BPoint(fTabRect.left + 1, fTabRect.top + 1),
BPoint(fTabRect.right - (fLook == kLeftTitledWindowLook ? 0 : 1), fTabRect.top + 1), BPoint(fTabRect.right - (fLook == kLeftTitledWindowLook ? 0 : 1),
fTabRect.top + 1),
fTabColorLight); fTabColorLight);
if (fLook != kLeftTitledWindowLook) { if (fLook != kLeftTitledWindowLook) {
fDrawingEngine->StrokeLine(BPoint(fTabRect.right - 1, fTabRect.top + 2), fDrawingEngine->StrokeLine(BPoint(fTabRect.right - 1, fTabRect.top + 2),
BPoint(fTabRect.right - 1, fTabRect.bottom), fTabColorShadow); BPoint(fTabRect.right - 1, fTabRect.bottom), fTabColorShadow);
} else { } else {
fDrawingEngine->StrokeLine(BPoint(fTabRect.left + 2, fTabRect.bottom - 1), fDrawingEngine->StrokeLine(
BPoint(fTabRect.left + 2, fTabRect.bottom - 1),
BPoint(fTabRect.right, fTabRect.bottom - 1), fTabColorShadow); BPoint(fTabRect.right, fTabRect.bottom - 1), fTabColorShadow);
} }
@@ -964,8 +979,8 @@ DefaultDecorator::_DrawTitle(BRect r)
{ {
STRACE(("_DrawTitle(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom)); STRACE(("_DrawTitle(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom));
fDrawingEngine->SetHighColor(fTextColor.GetColor32()); fDrawingEngine->SetHighColor(fTextColor);
fDrawingEngine->SetLowColor(fTabColor.GetColor32()); fDrawingEngine->SetLowColor(fTabColor);
fDrawingEngine->SetFont(fDrawState.Font()); fDrawingEngine->SetFont(fDrawState.Font());
// figure out position of text // figure out position of text
@@ -976,11 +991,13 @@ DefaultDecorator::_DrawTitle(BRect r)
if (fLook != kLeftTitledWindowLook) { if (fLook != kLeftTitledWindowLook) {
titlePos.x = fCloseRect.IsValid() ? fCloseRect.right + fTextOffset titlePos.x = fCloseRect.IsValid() ? fCloseRect.right + fTextOffset
: fTabRect.left + fTextOffset; : fTabRect.left + fTextOffset;
titlePos.y = floorf(((fTabRect.top + 2.0) + fTabRect.bottom + fontHeight.ascent titlePos.y = floorf(((fTabRect.top + 2.0) + fTabRect.bottom
+ fontHeight.descent) / 2.0 - fontHeight.descent + 0.5); + fontHeight.ascent + fontHeight.descent) / 2.0
- fontHeight.descent + 0.5);
} else { } else {
titlePos.x = floorf(((fTabRect.left + 2.0) + fTabRect.right + fontHeight.ascent titlePos.x = floorf(((fTabRect.left + 2.0) + fTabRect.right
+ fontHeight.descent) / 2.0 - fontHeight.descent + 0.5); + fontHeight.ascent + fontHeight.descent) / 2.0
- fontHeight.descent + 0.5);
titlePos.y = fZoomRect.IsValid() ? fZoomRect.top - fTextOffset titlePos.y = fZoomRect.IsValid() ? fZoomRect.top - fTextOffset
: fTabRect.bottom - fTextOffset; : fTabRect.bottom - fTextOffset;
} }
@@ -1015,37 +1032,30 @@ DefaultDecorator::_SetFocus()
// SetFocus() performs necessary duties for color swapping and // SetFocus() performs necessary duties for color swapping and
// other things when a window is deactivated or activated. // other things when a window is deactivated or activated.
if (IsFocus() || ((fLook == B_FLOATING_WINDOW_LOOK || fLook == kLeftTitledWindowLook) if (IsFocus()
|| ((fLook == B_FLOATING_WINDOW_LOOK || fLook == kLeftTitledWindowLook)
&& (fFlags & B_AVOID_FOCUS) != 0)) { && (fFlags & B_AVOID_FOCUS) != 0)) {
fTabColor = UIColor(B_WINDOW_TAB_COLOR); fTabColor = UIColor(B_WINDOW_TAB_COLOR);
fTextColor = UIColor(B_WINDOW_TEXT_COLOR); fTextColor = UIColor(B_WINDOW_TEXT_COLOR);
fButtonHighColor.SetColor(tint_color(fTabColor.GetColor32(), B_LIGHTEN_2_TINT)); fButtonHighColor = tint_color(fTabColor, B_LIGHTEN_2_TINT);
fButtonLowColor.SetColor(tint_color(fTabColor.GetColor32(), B_DARKEN_1_TINT)); fButtonLowColor = tint_color(fTabColor, B_DARKEN_1_TINT);
// fFrameColors[0].SetColor(152, 152, 152); fFrameColors[2] = (rgb_color){ 216, 216, 216, 255 };
// fFrameColors[1].SetColor(255, 255, 255); fFrameColors[3] = (rgb_color){ 136, 136, 136, 255 };
fFrameColors[2].SetColor(216, 216, 216);
fFrameColors[3].SetColor(136, 136, 136);
// fFrameColors[4].SetColor(152, 152, 152);
// fFrameColors[5].SetColor(96, 96, 96);
} else { } else {
fTabColor = UIColor(B_WINDOW_INACTIVE_TAB_COLOR); fTabColor = UIColor(B_WINDOW_INACTIVE_TAB_COLOR);
fTextColor = UIColor(B_WINDOW_INACTIVE_TEXT_COLOR); fTextColor = UIColor(B_WINDOW_INACTIVE_TEXT_COLOR);
fButtonHighColor.SetColor(tint_color(fTabColor.GetColor32(), B_LIGHTEN_2_TINT)); fButtonHighColor = tint_color(fTabColor, B_LIGHTEN_2_TINT);
fButtonLowColor.SetColor(tint_color(fTabColor.GetColor32(), B_DARKEN_1_TINT)); fButtonLowColor = tint_color(fTabColor, B_DARKEN_1_TINT);
// fFrameColors[0].SetColor(152, 152, 152); fFrameColors[2] = (rgb_color){ 232, 232, 232, 255 };
// fFrameColors[1].SetColor(255, 255, 255); fFrameColors[3] = (rgb_color){ 148, 148, 148, 255 };
fFrameColors[2].SetColor(232, 232, 232);
fFrameColors[3].SetColor(148, 148, 148);
// fFrameColors[4].SetColor(152, 152, 152);
// fFrameColors[5].SetColor(96, 96, 96);
} }
fTabColorLight = RGBColor(tint_color(fTabColor.GetColor32(), fTabColorLight = tint_color(fTabColor,
(B_LIGHTEN_2_TINT + B_LIGHTEN_MAX_TINT) / 2)); (B_LIGHTEN_2_TINT + B_LIGHTEN_MAX_TINT) / 2);
fTabColorShadow = RGBColor(tint_color(fTabColor.GetColor32(), fTabColorShadow = tint_color(fTabColor,
B_DARKEN_2_TINT)); B_DARKEN_2_TINT);
} }
// _SetColors // _SetColors
@@ -1067,18 +1077,18 @@ DefaultDecorator::_DrawBlendedRect(BRect r, bool down)
int32 w = r.IntegerWidth(); int32 w = r.IntegerWidth();
int32 h = r.IntegerHeight(); int32 h = r.IntegerHeight();
RGBColor temprgbcol; rgb_color tempColor;
rgb_color halfColor, startColor, endColor; rgb_color halfColor, startColor, endColor;
float rstep, gstep, bstep; float rstep, gstep, bstep;
int steps = w < h ? w : h; int steps = w < h ? w : h;
if (down) { if (down) {
startColor = fButtonLowColor.GetColor32(); startColor = fButtonLowColor;
endColor = fButtonHighColor.GetColor32(); endColor = fButtonHighColor;
} else { } else {
startColor = fButtonHighColor.GetColor32(); startColor = fButtonHighColor;
endColor = fButtonLowColor.GetColor32(); endColor = fButtonLowColor;
} }
halfColor = make_blend_color(startColor, endColor, 0.5); halfColor = make_blend_color(startColor, endColor, 0.5);
@@ -1088,19 +1098,19 @@ DefaultDecorator::_DrawBlendedRect(BRect r, bool down)
bstep = float(startColor.blue - halfColor.blue) / steps; bstep = float(startColor.blue - halfColor.blue) / steps;
for (int32 i = 0; i <= steps; i++) { for (int32 i = 0; i <= steps; i++) {
temprgbcol.SetColor(uint8(startColor.red - (i * rstep)), tempColor.red = uint8(startColor.red - (i * rstep));
uint8(startColor.green - (i * gstep)), tempColor.green = uint8(startColor.green - (i * gstep));
uint8(startColor.blue - (i * bstep))); tempColor.blue = uint8(startColor.blue - (i * bstep));
fDrawingEngine->StrokeLine(BPoint(r.left, r.top + i), fDrawingEngine->StrokeLine(BPoint(r.left, r.top + i),
BPoint(r.left + i, r.top), temprgbcol); BPoint(r.left + i, r.top), tempColor);
temprgbcol.SetColor(uint8(halfColor.red - (i * rstep)), tempColor.red = uint8(halfColor.red - (i * rstep));
uint8(halfColor.green - (i * gstep)), tempColor.green = uint8(halfColor.green - (i * gstep));
uint8(halfColor.blue - (i * bstep))); tempColor.blue = uint8(halfColor.blue - (i * bstep));
fDrawingEngine->StrokeLine(BPoint(r.left + steps, r.top + i), fDrawingEngine->StrokeLine(BPoint(r.left + steps, r.top + i),
BPoint(r.left + i, r.top + steps), temprgbcol); BPoint(r.left + i, r.top + steps), tempColor);
} }
fDrawingEngine->StrokeRect(r, fFrameColors[3]); fDrawingEngine->StrokeRect(r, fFrameColors[3]);
} }
@@ -1108,16 +1118,23 @@ DefaultDecorator::_DrawBlendedRect(BRect r, bool down)
// _GetButtonSizeAndOffset // _GetButtonSizeAndOffset
void void
DefaultDecorator::_GetButtonSizeAndOffset(const BRect& tabRect, float* _offset, DefaultDecorator::_GetButtonSizeAndOffset(const BRect& tabRect, float* _offset,
float* _size) const float* _size, float* _inset) const
{ {
*_offset = fLook == B_FLOATING_WINDOW_LOOK || fLook == kLeftTitledWindowLook ? 4.0 : 5.0; float tabSize = fLook == kLeftTitledWindowLook ?
tabRect.Width() : tabRect.Height();
bool smallTab = fLook == B_FLOATING_WINDOW_LOOK
|| fLook == kLeftTitledWindowLook;
*_offset = smallTab ? floorf(fDrawState.Font().Size() / 2.5)
: floorf(fDrawState.Font().Size() / 2.0);
*_inset = smallTab ? floorf(fDrawState.Font().Size() / 5.0)
: floorf(fDrawState.Font().Size() / 6.0);
printf("");
// "+ 2" so that the rects are centered within the solid area // "+ 2" so that the rects are centered within the solid area
// (without the 2 pixels for the top border) // (without the 2 pixels for the top border)
if (fLook != kLeftTitledWindowLook) *_size = tabSize - *_inset * *_offset + *_inset;
*_size = tabRect.Height() - 2.0 * *_offset + 2.0f;
else
*_size = tabRect.Width() - 2.0 * *_offset + 2.0f;
} }
// _LayoutTabItems // _LayoutTabItems
@@ -1126,7 +1143,8 @@ DefaultDecorator::_LayoutTabItems(const BRect& tabRect)
{ {
float offset; float offset;
float size; float size;
_GetButtonSizeAndOffset(tabRect, &offset, &size); float inset;
_GetButtonSizeAndOffset(tabRect, &offset, &size, &inset);
// calulate close rect based on the tab rectangle // calulate close rect based on the tab rectangle
if (fLook != kLeftTitledWindowLook) { if (fLook != kLeftTitledWindowLook) {
@@ -1160,9 +1178,9 @@ DefaultDecorator::_LayoutTabItems(const BRect& tabRect)
// truncated for no apparent reason - OTOH the title does // truncated for no apparent reason - OTOH the title does
// also not appear perfectly in the middle // also not appear perfectly in the middle
if (fLook != kLeftTitledWindowLook) if (fLook != kLeftTitledWindowLook)
size = (fZoomRect.left - fCloseRect.right) - fTextOffset * 2 + 2; size = (fZoomRect.left - fCloseRect.right) - fTextOffset * 2 + inset;
else else
size = (fZoomRect.top - fCloseRect.bottom) - fTextOffset * 2 + 2; size = (fZoomRect.top - fCloseRect.bottom) - fTextOffset * 2 + inset;
fTruncatedTitle = Title(); fTruncatedTitle = Title();
fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END, size); fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END, size);
+12 -15
View File
@@ -19,8 +19,7 @@ class Desktop;
class DefaultDecorator: public Decorator { class DefaultDecorator: public Decorator {
public: public:
DefaultDecorator(DesktopSettings& settings, DefaultDecorator(DesktopSettings& settings,
BRect frame, BRect frame, window_look look,
window_look look,
uint32 flags); uint32 flags);
virtual ~DefaultDecorator(); virtual ~DefaultDecorator();
@@ -47,10 +46,8 @@ class DefaultDecorator: public Decorator {
virtual void Draw(BRect updateRect); virtual void Draw(BRect updateRect);
virtual void Draw(); virtual void Draw();
virtual void GetSizeLimits(int32* minWidth, virtual void GetSizeLimits(int32* minWidth, int32* minHeight,
int32* minHeight, int32* maxWidth, int32* maxHeight) const;
int32* maxWidth,
int32* maxHeight) const;
virtual void GetFootprint(BRegion* region); virtual void GetFootprint(BRegion* region);
@@ -73,18 +70,18 @@ class DefaultDecorator: public Decorator {
private: private:
void _DrawBlendedRect(BRect r, bool down); void _DrawBlendedRect(BRect r, bool down);
void _GetButtonSizeAndOffset(const BRect& tabRect, void _GetButtonSizeAndOffset(const BRect& tabRect,
float* offset, float* offset, float* size,
float*size) const; float* inset) const;
void _LayoutTabItems(const BRect& tabRect); void _LayoutTabItems(const BRect& tabRect);
RGBColor fButtonHighColor; rgb_color fButtonHighColor;
RGBColor fButtonLowColor; rgb_color fButtonLowColor;
RGBColor fTextColor; rgb_color fTextColor;
RGBColor fTabColor; rgb_color fTabColor;
RGBColor fTabColorLight; rgb_color fTabColorLight;
RGBColor fTabColorShadow; rgb_color fTabColorShadow;
RGBColor* fFrameColors; rgb_color fFrameColors[6];
// Individual rects for handling window frame // Individual rects for handling window frame
// rendering the proper way // rendering the proper way
+1 -1
View File
@@ -799,7 +799,7 @@ void
Desktop::_SetWorkspace(int32 index) Desktop::_SetWorkspace(int32 index)
{ {
int32 previousIndex = fCurrentWorkspace; int32 previousIndex = fCurrentWorkspace;
RGBColor previousColor = fWorkspaces[fCurrentWorkspace].Color(); rgb_color previousColor = fWorkspaces[fCurrentWorkspace].Color();
bool movedMouseEventWindow = false; bool movedMouseEventWindow = false;
if (fMouseEventWindow != NULL) { if (fMouseEventWindow != NULL) {
+10 -8
View File
@@ -27,8 +27,8 @@ DrawState::DrawState()
: fOrigin(0.0, 0.0), : fOrigin(0.0, 0.0),
fScale(1.0), fScale(1.0),
fClippingRegion(NULL), fClippingRegion(NULL),
fHighColor(0, 0, 0, 255), fHighColor((rgb_color){ 0, 0, 0, 255 }),
fLowColor(255, 255, 255, 255), fLowColor((rgb_color){ 255, 255, 255, 255 }),
fPattern(kSolidHigh), fPattern(kSolidHigh),
fDrawingMode(B_OP_COPY), fDrawingMode(B_OP_COPY),
fAlphaSrcMode(B_PIXEL_ALPHA), fAlphaSrcMode(B_PIXEL_ALPHA),
@@ -253,8 +253,8 @@ DrawState::WriteToLink(BPrivate::LinkSender& link) const
// Attach view state // Attach view state
link.Attach<BPoint>(fPenLocation); link.Attach<BPoint>(fPenLocation);
link.Attach<float>(fPenSize); link.Attach<float>(fPenSize);
link.Attach<rgb_color>(fHighColor.GetColor32()); link.Attach<rgb_color>(fHighColor);
link.Attach<rgb_color>(fLowColor.GetColor32()); link.Attach<rgb_color>(fLowColor);
link.Attach<uint64>(fPattern.GetInt64()); link.Attach<uint64>(fPattern.GetInt64());
link.Attach<BPoint>(fOrigin); link.Attach<BPoint>(fOrigin);
link.Attach<uint8>((uint8)fDrawingMode); link.Attach<uint8>((uint8)fDrawingMode);
@@ -434,14 +434,14 @@ DrawState::SetClippingRegion(const BRegion* region)
void void
DrawState::SetHighColor(const RGBColor& color) DrawState::SetHighColor(const rgb_color& color)
{ {
fHighColor = color; fHighColor = color;
} }
void void
DrawState::SetLowColor(const RGBColor& color) DrawState::SetLowColor(const rgb_color& color)
{ {
fLowColor = color; fLowColor = color;
} }
@@ -606,8 +606,10 @@ DrawState::PrintToStream() const
printf("\t Pen Location and Size: (%.1f, %.1f) - %.2f (%.2f)\n", printf("\t Pen Location and Size: (%.1f, %.1f) - %.2f (%.2f)\n",
fPenLocation.x, fPenLocation.y, PenSize(), fPenSize); fPenLocation.x, fPenLocation.y, PenSize(), fPenSize);
printf("\t HighColor: "); fHighColor.PrintToStream(); printf("\t HighColor: r=%d g=%d b=%d a=%d\n",
printf("\t LowColor: "); fLowColor.PrintToStream(); fHighColor.red, fHighColor.green, fHighColor.blue, fHighColor.alpha);
printf("\t LowColor: r=%d g=%d b=%d a=%d\n",
fLowColor.red, fLowColor.green, fLowColor.blue, fLowColor.alpha);
printf("\t Pattern: %llu\n", fPattern.GetInt64()); printf("\t Pattern: %llu\n", fPattern.GetInt64());
printf("\t DrawMode: %lu\n", (uint32)fDrawingMode); printf("\t DrawMode: %lu\n", (uint32)fDrawingMode);
+6 -7
View File
@@ -17,7 +17,6 @@
#include <Point.h> #include <Point.h>
#include <View.h> // for B_FONT_ALL #include <View.h> // for B_FONT_ALL
#include "RGBColor.h"
#include "FontManager.h" #include "FontManager.h"
#include "ServerFont.h" #include "ServerFont.h"
#include "PatternHandler.h" #include "PatternHandler.h"
@@ -78,12 +77,12 @@ class DrawState {
inline BRect ClippingRectAt(int32 index) const;*/ inline BRect ClippingRectAt(int32 index) const;*/
// color // color
void SetHighColor(const RGBColor& color); void SetHighColor(const rgb_color& color);
const RGBColor& HighColor() const const rgb_color& HighColor() const
{ return fHighColor; } { return fHighColor; }
void SetLowColor(const RGBColor& color); void SetLowColor(const rgb_color& color);
const RGBColor& LowColor() const const rgb_color& LowColor() const
{ return fLowColor; } { return fLowColor; }
void SetPattern(const Pattern& pattern); void SetPattern(const Pattern& pattern);
@@ -147,8 +146,8 @@ class DrawState {
BRegion* fClippingRegion; BRegion* fClippingRegion;
RGBColor fHighColor; rgb_color fHighColor;
RGBColor fLowColor; rgb_color fLowColor;
Pattern fPattern; Pattern fPattern;
drawing_mode fDrawingMode; drawing_mode fDrawingMode;
+1 -1
View File
@@ -2231,7 +2231,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
index = fDesktop->CurrentWorkspace(); index = fDesktop->CurrentWorkspace();
Workspace workspace(*fDesktop, index); Workspace workspace(*fDesktop, index);
fLink.Attach<rgb_color>(workspace.Color().GetColor32()); fLink.Attach<rgb_color>(workspace.Color());
fDesktop->Unlock(); fDesktop->Unlock();
fLink.Flush(); fLink.Flush();
-2
View File
@@ -10,8 +10,6 @@
#define SERVER_BITMAP_H #define SERVER_BITMAP_H
#include "RGBColor.h"
#include <GraphicsDefs.h> #include <GraphicsDefs.h>
#include <Rect.h> #include <Rect.h>
#include <OS.h> #include <OS.h>
+4 -4
View File
@@ -548,7 +548,7 @@ set_pen_size(ViewLayer *view, float size)
static void static void
set_fore_color(ViewLayer *view, rgb_color color) set_fore_color(ViewLayer *view, rgb_color color)
{ {
view->CurrentState()->SetHighColor(RGBColor(color)); view->CurrentState()->SetHighColor(color);
view->Window()->GetDrawingEngine()->SetHighColor(color); view->Window()->GetDrawingEngine()->SetHighColor(color);
} }
@@ -556,7 +556,7 @@ set_fore_color(ViewLayer *view, rgb_color color)
static void static void
set_back_color(ViewLayer *view, rgb_color color) set_back_color(ViewLayer *view, rgb_color color)
{ {
view->CurrentState()->SetLowColor(RGBColor(color)); view->CurrentState()->SetLowColor(color);
view->Window()->GetDrawingEngine()->SetLowColor(color); view->Window()->GetDrawingEngine()->SetLowColor(color);
} }
@@ -823,8 +823,8 @@ ServerPicture::SyncState(ViewLayer *view)
//WriteSetPattern(*view->CurrentState()->GetPattern().GetInt8()); //WriteSetPattern(*view->CurrentState()->GetPattern().GetInt8());
WriteSetDrawingMode(view->CurrentState()->GetDrawingMode()); WriteSetDrawingMode(view->CurrentState()->GetDrawingMode());
WriteSetHighColor(view->CurrentState()->HighColor().GetColor32()); WriteSetHighColor(view->CurrentState()->HighColor());
WriteSetLowColor(view->CurrentState()->LowColor().GetColor32()); WriteSetLowColor(view->CurrentState()->LowColor());
ExitStateChange(); ExitStateChange();
} }
+7 -7
View File
@@ -1586,7 +1586,7 @@ ServerWindow::_DispatchViewMessage(int32 code,
link.Read(&c, sizeof(rgb_color)); link.Read(&c, sizeof(rgb_color));
fCurrentLayer->SetViewColor(RGBColor(c)); fCurrentLayer->SetViewColor(c);
break; break;
} }
@@ -1595,7 +1595,7 @@ ServerWindow::_DispatchViewMessage(int32 code,
Title(), fCurrentLayer->Name())); Title(), fCurrentLayer->Name()));
fLink.StartMessage(B_OK); fLink.StartMessage(B_OK);
fLink.Attach<rgb_color>(fCurrentLayer->CurrentState()->HighColor().GetColor32()); fLink.Attach<rgb_color>(fCurrentLayer->CurrentState()->HighColor());
fLink.Flush(); fLink.Flush();
break; break;
@@ -1604,7 +1604,7 @@ ServerWindow::_DispatchViewMessage(int32 code,
Title(), fCurrentLayer->Name())); Title(), fCurrentLayer->Name()));
fLink.StartMessage(B_OK); fLink.StartMessage(B_OK);
fLink.Attach<rgb_color>(fCurrentLayer->CurrentState()->LowColor().GetColor32()); fLink.Attach<rgb_color>(fCurrentLayer->CurrentState()->LowColor());
fLink.Flush(); fLink.Flush();
break; break;
@@ -1613,7 +1613,7 @@ ServerWindow::_DispatchViewMessage(int32 code,
Title(), fCurrentLayer->Name())); Title(), fCurrentLayer->Name()));
fLink.StartMessage(B_OK); fLink.StartMessage(B_OK);
fLink.Attach<rgb_color>(fCurrentLayer->ViewColor().GetColor32()); fLink.Attach<rgb_color>(fCurrentLayer->ViewColor());
fLink.Flush(); fLink.Flush();
break; break;
@@ -1699,7 +1699,7 @@ ServerWindow::_DispatchViewMessage(int32 code,
if (bitmap != NULL && bitmap->Overlay() != NULL) { if (bitmap != NULL && bitmap->Overlay() != NULL) {
bitmap->Overlay()->SetFlags(options); bitmap->Overlay()->SetFlags(options);
colorKey = bitmap->Overlay()->Color().GetColor32(); colorKey = bitmap->Overlay()->Color();
} }
} else } else
status = B_BAD_VALUE; status = B_BAD_VALUE;
@@ -1849,7 +1849,7 @@ ServerWindow::_DispatchViewMessage(int32 code,
rgb_color c; rgb_color c;
link.Read(&c, sizeof(rgb_color)); link.Read(&c, sizeof(rgb_color));
fCurrentLayer->CurrentState()->SetHighColor(RGBColor(c)); fCurrentLayer->CurrentState()->SetHighColor(c);
fWindowLayer->GetDrawingEngine()->SetHighColor(c); fWindowLayer->GetDrawingEngine()->SetHighColor(c);
break; break;
} }
@@ -1860,7 +1860,7 @@ ServerWindow::_DispatchViewMessage(int32 code,
rgb_color c; rgb_color c;
link.Read(&c, sizeof(rgb_color)); link.Read(&c, sizeof(rgb_color));
fCurrentLayer->CurrentState()->SetLowColor(RGBColor(c)); fCurrentLayer->CurrentState()->SetLowColor(c);
fWindowLayer->GetDrawingEngine()->SetLowColor(c); fWindowLayer->GetDrawingEngine()->SetLowColor(c);
break; break;
} }
+3 -3
View File
@@ -80,7 +80,7 @@ ViewLayer::ViewLayer(IntRect frame, IntPoint scrollingOffset, const char* name,
fFrame(frame), fFrame(frame),
fScrollingOffset(scrollingOffset), fScrollingOffset(scrollingOffset),
fViewColor(RGBColor(255, 255, 255)), fViewColor((rgb_color){ 255, 255, 255, 255 }),
fDrawState(new (nothrow) DrawState), fDrawState(new (nothrow) DrawState),
fViewBitmap(NULL), fViewBitmap(NULL),
@@ -1175,7 +1175,7 @@ ViewLayer::Draw(DrawingEngine* drawingEngine, BRegion* effectiveClipping,
return; return;
} }
if (fViewBitmap != NULL || !fViewColor.IsTransparentMagic()) { if (fViewBitmap != NULL || fViewColor != B_TRANSPARENT_COLOR) {
// we can only draw within our own area // we can only draw within our own area
BRegion* redraw = fWindow->GetRegion(ScreenClipping(windowContentClipping)); BRegion* redraw = fWindow->GetRegion(ScreenClipping(windowContentClipping));
if (!redraw) if (!redraw)
@@ -1265,7 +1265,7 @@ ViewLayer::Draw(DrawingEngine* drawingEngine, BRegion* effectiveClipping,
} }
if (!fViewColor.IsTransparentMagic()) { if (fViewColor != B_TRANSPARENT_COLOR) {
// fill visible region with view color, // fill visible region with view color,
// this version of FillRegion ignores any // this version of FillRegion ignores any
// clipping, that's why "redraw" needs to // clipping, that's why "redraw" needs to
+6 -9
View File
@@ -13,7 +13,6 @@
#define VIEW_LAYER_H #define VIEW_LAYER_H
#include "RGBColor.h"
#include "IntRect.h" #include "IntRect.h"
#include <GraphicsDefs.h> #include <GraphicsDefs.h>
@@ -157,10 +156,8 @@ class ViewLayer {
const BRegion& LocalClipping() const { return fLocalClipping; } const BRegion& LocalClipping() const { return fLocalClipping; }
const RGBColor& ViewColor() const const rgb_color& ViewColor() const
{ return fViewColor; } { return fViewColor; }
void SetViewColor(const RGBColor& color)
{ fViewColor = color; }
void SetViewColor(const rgb_color& color) void SetViewColor(const rgb_color& color)
{ fViewColor = color; } { fViewColor = color; }
@@ -246,7 +243,7 @@ class ViewLayer {
// scrolling offset // scrolling offset
IntPoint fScrollingOffset; IntPoint fScrollingOffset;
RGBColor fViewColor; rgb_color fViewColor;
DrawState* fDrawState; DrawState* fDrawState;
ServerBitmap* fViewBitmap; ServerBitmap* fViewBitmap;
IntRect fBitmapSource; IntRect fBitmapSource;
@@ -256,10 +253,10 @@ class ViewLayer {
uint32 fResizeMode; uint32 fResizeMode;
uint32 fFlags; uint32 fFlags;
bool fHidden; bool fHidden : 1;
bool fVisible; bool fVisible : 1;
bool fBackgroundDirty; bool fBackgroundDirty : 1;
bool fIsDesktopBackground; bool fIsDesktopBackground : 1;
uint32 fEventMask; uint32 fEventMask;
uint32 fEventOptions; uint32 fEventOptions;
+7 -7
View File
@@ -374,7 +374,7 @@ WindowLayer::ResizeBy(int32 x, int32 y, BRegion* dirtyRegion)
if (fDecorator) { if (fDecorator) {
fDecorator->ResizeBy(x, y, dirtyRegion); fDecorator->ResizeBy(x, y, dirtyRegion);
//if (dirtyRegion) { //if (dirtyRegion) {
//fDrawingEngine->FillRegion(*dirtyRegion, RGBColor(255, 255, 0, 255)); //fDrawingEngine->FillRegion(*dirtyRegion, (rgb_color){ 255, 255, 0, 255 });
//snooze(40000); //snooze(40000);
//} //}
} }
@@ -385,7 +385,7 @@ WindowLayer::ResizeBy(int32 x, int32 y, BRegion* dirtyRegion)
} }
//if (dirtyRegion) //if (dirtyRegion)
//fDrawingEngine->FillRegion(*dirtyRegion, RGBColor(0, 255, 255, 255)); //fDrawingEngine->FillRegion(*dirtyRegion, (rgb_color){ 0, 255, 255, 255 });
// send a message to the client informing about the changed size // send a message to the client informing about the changed size
BRect frame(Frame()); BRect frame(Frame());
@@ -412,7 +412,7 @@ WindowLayer::ScrollViewBy(ViewLayer* view, int32 dx, int32 dy)
view->ScrollBy(dx, dy, dirty); view->ScrollBy(dx, dy, dirty);
//fDrawingEngine->FillRegion(dirty, RGBColor(255, 0, 255, 255)); //fDrawingEngine->FillRegion(dirty, rgb_color{ 255, 0, 255, 255 });
//snooze(2000); //snooze(2000);
if (IsVisible() && view->IsVisible()) { if (IsVisible() && view->IsVisible()) {
@@ -715,7 +715,7 @@ WindowLayer::InvalidateView(ViewLayer* layer, BRegion& layerRegion)
if (layerRegion.CountRects() > 0) { if (layerRegion.CountRects() > 0) {
layerRegion.IntersectWith(&layer->ScreenClipping(&fContentRegion)); layerRegion.IntersectWith(&layer->ScreenClipping(&fContentRegion));
//fDrawingEngine->FillRegion(layerRegion, RGBColor(0, 255, 0, 255)); //fDrawingEngine->FillRegion(layerRegion, rgb_color{ 0, 255, 0, 255 });
//snooze(10000); //snooze(10000);
fDirtyCause |= UPDATE_REQUEST; fDirtyCause |= UPDATE_REQUEST;
_TriggerContentRedraw(layerRegion); _TriggerContentRedraw(layerRegion);
@@ -1817,7 +1817,7 @@ WindowLayer::_TransferToUpdateSession(BRegion* contentDirtyRegion)
if (contentDirtyRegion->CountRects() <= 0) if (contentDirtyRegion->CountRects() <= 0)
return; return;
//fDrawingEngine->FillRegion(*contentDirtyRegion, RGBColor(sPendingColor)); //fDrawingEngine->FillRegion(*contentDirtyRegion, sPendingColor);
//snooze(10000); //snooze(10000);
// add to pending // add to pending
@@ -1910,7 +1910,7 @@ WindowLayer::BeginUpdate(BPrivate::PortLink& link)
//sPendingColor.red = rand() % 255; //sPendingColor.red = rand() % 255;
//sPendingColor.green = rand() % 255; //sPendingColor.green = rand() % 255;
//sPendingColor.blue = rand() % 255; //sPendingColor.blue = rand() % 255;
//fDrawingEngine->FillRegion(*dirty, RGBColor(sCurrentColor)); //fDrawingEngine->FillRegion(*dirty, sCurrentColor);
//snooze(10000); //snooze(10000);
link.StartMessage(B_OK); link.StartMessage(B_OK);
@@ -1929,7 +1929,7 @@ WindowLayer::BeginUpdate(BPrivate::PortLink& link)
link.Flush(); link.Flush();
if (!fCurrentUpdateSession.IsExpose() && fDrawingEngine->LockParallelAccess()) { if (!fCurrentUpdateSession.IsExpose() && fDrawingEngine->LockParallelAccess()) {
//fDrawingEngine->FillRegion(dirty, RGBColor(255, 0, 0, 255)); //fDrawingEngine->FillRegion(dirty, (rgb_color){ 255, 0, 0, 255 });
fDrawingEngine->SuspendAutoSync(); fDrawingEngine->SuspendAutoSync();
fTopLayer->Draw(fDrawingEngine, dirty, fTopLayer->Draw(fDrawingEngine, dirty,
+5 -5
View File
@@ -333,12 +333,12 @@ class WindowLayer {
UpdateSession fPendingUpdateSession; UpdateSession fPendingUpdateSession;
// these two flags are supposed to ensure a sane // these two flags are supposed to ensure a sane
// and consistent update session // and consistent update session
bool fUpdateRequested; bool fUpdateRequested : 1;
bool fInUpdate; bool fInUpdate : 1;
bool fHidden; bool fHidden : 1;
bool fMinimized; bool fMinimized : 1;
bool fIsFocus; bool fIsFocus : 1;
window_look fLook; window_look fLook;
window_feel fFeel; window_feel fFeel;
+7 -8
View File
@@ -17,7 +17,7 @@
#include <stdlib.h> #include <stdlib.h>
static RGBColor kDefaultColor = RGBColor(51, 102, 152); static rgb_color kDefaultColor = (rgb_color){ 51, 102, 152, 255 };
Workspace::Private::Private() Workspace::Private::Private()
@@ -38,7 +38,7 @@ Workspace::Private::SetDisplaysFromDesktop(Desktop* desktop)
void void
Workspace::Private::SetColor(const RGBColor& color) Workspace::Private::SetColor(const rgb_color& color)
{ {
fColor = color; fColor = color;
} }
@@ -49,7 +49,7 @@ Workspace::Private::RestoreConfiguration(const BMessage& settings)
{ {
rgb_color color; rgb_color color;
if (settings.FindInt32("color", (int32 *)&color) == B_OK) if (settings.FindInt32("color", (int32 *)&color) == B_OK)
fColor.SetColor(color); fColor = color;
} }
@@ -59,16 +59,15 @@ Workspace::Private::RestoreConfiguration(const BMessage& settings)
void void
Workspace::Private::StoreConfiguration(BMessage& settings) Workspace::Private::StoreConfiguration(BMessage& settings)
{ {
rgb_color color = fColor.GetColor32();
settings.RemoveName("color"); settings.RemoveName("color");
settings.AddInt32("color", *(int32 *)&color); settings.AddInt32("color", *(int32 *)&fColor);
} }
void void
Workspace::Private::_SetDefaults() Workspace::Private::_SetDefaults()
{ {
fColor.SetColor(kDefaultColor); fColor = kDefaultColor;
} }
@@ -96,7 +95,7 @@ Workspace::~Workspace()
} }
const RGBColor& const rgb_color&
Workspace::Color() const Workspace::Color() const
{ {
return fWorkspace.Color(); return fWorkspace.Color();
@@ -104,7 +103,7 @@ Workspace::Color() const
void void
Workspace::SetColor(const RGBColor& color, bool makeDefault) Workspace::SetColor(const rgb_color& color, bool makeDefault)
{ {
if (color == Color()) if (color == Color())
return; return;
+3 -4
View File
@@ -9,11 +9,10 @@
#define WORKSPACE_H #define WORKSPACE_H
#include <SupportDefs.h> #include <InterfaceDefs.h>
class Desktop; class Desktop;
class RGBColor;
class WindowLayer; class WindowLayer;
@@ -22,8 +21,8 @@ class Workspace {
Workspace(Desktop& desktop, int32 index); Workspace(Desktop& desktop, int32 index);
~Workspace(); ~Workspace();
const RGBColor& Color() const; const rgb_color& Color() const;
void SetColor(const RGBColor& color, bool makeDefault); void SetColor(const rgb_color& color, bool makeDefault);
bool IsCurrent() const bool IsCurrent() const
{ return fCurrentWorkspace; } { return fCurrentWorkspace; }
+3 -4
View File
@@ -9,7 +9,6 @@
#define WORKSPACE_PRIVATE_H #define WORKSPACE_PRIVATE_H
#include "RGBColor.h"
#include "WindowList.h" #include "WindowList.h"
#include "Workspace.h" #include "Workspace.h"
@@ -42,8 +41,8 @@ class Workspace::Private {
// configuration // configuration
const RGBColor& Color() const { return fColor; } const rgb_color& Color() const { return fColor; }
void SetColor(const RGBColor& color); void SetColor(const rgb_color& color);
void RestoreConfiguration(const BMessage& settings); void RestoreConfiguration(const BMessage& settings);
void StoreConfiguration(BMessage& settings); void StoreConfiguration(BMessage& settings);
@@ -57,7 +56,7 @@ class Workspace::Private {
BObjectList<display_info> fDisplays; BObjectList<display_info> fDisplays;
RGBColor fColor; rgb_color fColor;
}; };
#endif /* WORKSPACE_PRIVATE_H */ #endif /* WORKSPACE_PRIVATE_H */
+11 -11
View File
@@ -26,8 +26,8 @@ WorkspacesLayer::WorkspacesLayer(BRect frame, BPoint scrollingOffset,
fSelectedWorkspace(-1), fSelectedWorkspace(-1),
fHasMoved(false) fHasMoved(false)
{ {
fDrawState->SetLowColor(RGBColor(255, 255, 255)); fDrawState->SetLowColor((rgb_color){ 255, 255, 255, 255 });
fDrawState->SetHighColor(RGBColor(0, 0, 0)); fDrawState->SetHighColor((rgb_color){ 0, 0, 0, 255 });
} }
@@ -161,11 +161,11 @@ WorkspacesLayer::_DrawWindow(DrawingEngine* drawingEngine, const BRect& workspac
return; return;
// ToDo: let decorator do this! // ToDo: let decorator do this!
RGBColor yellow; rgb_color yellow;
if (decorator != NULL) if (decorator != NULL)
yellow = decorator->UIColor(B_WINDOW_TAB_COLOR); yellow = decorator->UIColor(B_WINDOW_TAB_COLOR);
RGBColor frameColor(180, 180, 180); rgb_color frameColor = (rgb_color){ 180, 180, 180, 255 };
RGBColor white(255, 255, 255); rgb_color white = (rgb_color){ 255, 255, 255, 255 };
if (!active) { if (!active) {
_DarkenColor(yellow); _DarkenColor(yellow);
@@ -174,7 +174,7 @@ WorkspacesLayer::_DrawWindow(DrawingEngine* drawingEngine, const BRect& workspac
} }
if (window == fSelectedWindow) { if (window == fSelectedWindow) {
// TODO: what about standard navigation color here? // TODO: what about standard navigation color here?
frameColor.SetColor(80, 80, 80); frameColor = (rgb_color){ 80, 80, 80, 255 };
} }
if (tabFrame.left < frame.left) if (tabFrame.left < frame.left)
@@ -237,16 +237,16 @@ WorkspacesLayer::_DrawWorkspace(DrawingEngine* drawingEngine,
bool active = workspace.IsCurrent(); bool active = workspace.IsCurrent();
if (active) { if (active) {
// draw active frame // draw active frame
RGBColor black(0, 0, 0); rgb_color black = (rgb_color){ 0, 0, 0, 255 };
drawingEngine->StrokeRect(rect, black); drawingEngine->StrokeRect(rect, black);
} else if (index == fSelectedWorkspace) { } else if (index == fSelectedWorkspace) {
RGBColor gray(80, 80, 80); rgb_color gray = (rgb_color){ 80, 80, 80, 255 };
drawingEngine->StrokeRect(rect, gray); drawingEngine->StrokeRect(rect, gray);
} }
rect.InsetBy(1, 1); rect.InsetBy(1, 1);
RGBColor color = workspace.Color(); rgb_color color = workspace.Color();
if (!active) if (!active)
_DarkenColor(color); _DarkenColor(color);
@@ -279,9 +279,9 @@ WorkspacesLayer::_DrawWorkspace(DrawingEngine* drawingEngine,
void void
WorkspacesLayer::_DarkenColor(RGBColor& color) const WorkspacesLayer::_DarkenColor(rgb_color& color) const
{ {
color = tint_color(color.GetColor32(), B_DARKEN_2_TINT); color = tint_color(color, B_DARKEN_2_TINT);
} }
+1 -1
View File
@@ -48,7 +48,7 @@ class WorkspacesLayer : public ViewLayer {
void _DrawWorkspace(DrawingEngine* drawingEngine, BRegion& redraw, void _DrawWorkspace(DrawingEngine* drawingEngine, BRegion& redraw,
int32 index); int32 index);
void _DarkenColor(RGBColor& color) const; void _DarkenColor(rgb_color& color) const;
void _Invalidate() const; void _Invalidate() const;
private: private:
@@ -972,11 +972,12 @@ AccelerantHWInterface::CopyRegion(const clipping_rect* sortedRectList,
// FillRegion // FillRegion
void void
AccelerantHWInterface::FillRegion(/*const*/ BRegion& region, const RGBColor& color, AccelerantHWInterface::FillRegion(/*const*/ BRegion& region,
bool autoSync) const rgb_color& color, bool autoSync)
{ {
if (fAccFillRect && fAccAcquireEngine) { if (fAccFillRect && fAccAcquireEngine) {
if (fAccAcquireEngine(B_2D_ACCELERATION, 0xff, &fSyncToken, &fEngineToken) >= B_OK) { if (fAccAcquireEngine(B_2D_ACCELERATION, 0xff, &fSyncToken,
&fEngineToken) >= B_OK) {
// convert the region // convert the region
uint32 count; uint32 count;
@@ -1136,34 +1137,33 @@ AccelerantHWInterface::_RegionToRectParams(/*const*/ BRegion* region,
// _NativeColor // _NativeColor
uint32 uint32
AccelerantHWInterface::_NativeColor(const RGBColor& color) const AccelerantHWInterface::_NativeColor(const rgb_color& color) const
{ {
// NOTE: This functions looks somehow suspicios to me. // NOTE: This functions looks somehow suspicios to me.
// It assumes that all graphics cards have the same native endianess, no? // It assumes that all graphics cards have the same native endianess, no?
switch (fDisplayMode.space) { switch (fDisplayMode.space) {
case B_CMAP8: case B_CMAP8:
case B_GRAY8: case B_GRAY8:
return color.GetColor8(); return RGBColor(color).GetColor8();
case B_RGB15_BIG: case B_RGB15_BIG:
case B_RGBA15_BIG: case B_RGBA15_BIG:
case B_RGB15_LITTLE: case B_RGB15_LITTLE:
case B_RGBA15_LITTLE: case B_RGBA15_LITTLE:
return color.GetColor15(); return RGBColor(color).GetColor15();
case B_RGB16_BIG: case B_RGB16_BIG:
case B_RGB16_LITTLE: case B_RGB16_LITTLE:
return color.GetColor16(); return RGBColor(color).GetColor16();
case B_RGB32_BIG: case B_RGB32_BIG:
case B_RGBA32_BIG: case B_RGBA32_BIG:
case B_RGB32_LITTLE: case B_RGB32_LITTLE:
case B_RGBA32_LITTLE: { case B_RGBA32_LITTLE: {
rgb_color c = color.GetColor32(); uint32 native = (color.alpha << 24) |
uint32 native = (c.alpha << 24) | (color.red << 16) |
(c.red << 16) | (color.green << 8) |
(c.green << 8) | (color.blue);
(c.blue);
return native; return native;
} }
} }
@@ -73,7 +73,7 @@ public:
uint32 count, uint32 count,
int32 xOffset, int32 yOffset); int32 xOffset, int32 yOffset);
virtual void FillRegion(/*const*/ BRegion& region, virtual void FillRegion(/*const*/ BRegion& region,
const RGBColor& color, const rgb_color& color,
bool autoSync); bool autoSync);
virtual void InvertRegion(/*const*/ BRegion& region); virtual void InvertRegion(/*const*/ BRegion& region);
@@ -101,7 +101,7 @@ private:
status_t _UpdateFrameBufferConfig(); status_t _UpdateFrameBufferConfig();
void _RegionToRectParams(/*const*/ BRegion* region, void _RegionToRectParams(/*const*/ BRegion* region,
uint32* count) const; uint32* count) const;
uint32 _NativeColor(const RGBColor& color) const; uint32 _NativeColor(const rgb_color& color) const;
status_t _SetFallbackMode(display_mode& mode) const; status_t _SetFallbackMode(display_mode& mode) const;
void _SetSystemPalette(); void _SetSystemPalette();
void _SetGrayscalePalette(); void _SetGrayscalePalette();
+12 -11
View File
@@ -946,10 +946,12 @@ DWindowHWInterface::CopyRegion(const clipping_rect* sortedRectList,
// FillRegion // FillRegion
void void
DWindowHWInterface::FillRegion(/*const*/ BRegion& region, const RGBColor& color, bool autoSync) DWindowHWInterface::FillRegion(/*const*/ BRegion& region,
const rgb_color& color, bool autoSync)
{ {
if (fAccFillRect && fAccAcquireEngine) { if (fAccFillRect && fAccAcquireEngine) {
if (fAccAcquireEngine(B_2D_ACCELERATION, 0xff, &fSyncToken, &fEngineToken) >= B_OK) { if (fAccAcquireEngine(B_2D_ACCELERATION, 0xff, &fSyncToken,
&fEngineToken) >= B_OK) {
// convert the region // convert the region
uint32 count; uint32 count;
@@ -1081,34 +1083,33 @@ DWindowHWInterface::_RegionToRectParams(/*const*/ BRegion* region,
// _NativeColor // _NativeColor
uint32 uint32
DWindowHWInterface::_NativeColor(const RGBColor& color) const DWindowHWInterface::_NativeColor(const rgb_color& color) const
{ {
// NOTE: This functions looks somehow suspicios to me. // NOTE: This functions looks somehow suspicios to me.
// It assumes that all graphics cards have the same native endianess, no? // It assumes that all graphics cards have the same native endianess, no?
switch (fDisplayMode.space) { switch (fDisplayMode.space) {
case B_CMAP8: case B_CMAP8:
case B_GRAY8: case B_GRAY8:
return color.GetColor8(); return RGBColor(color).GetColor8();
case B_RGB15_BIG: case B_RGB15_BIG:
case B_RGBA15_BIG: case B_RGBA15_BIG:
case B_RGB15_LITTLE: case B_RGB15_LITTLE:
case B_RGBA15_LITTLE: case B_RGBA15_LITTLE:
return color.GetColor15(); return RGBColor(color).GetColor15();
case B_RGB16_BIG: case B_RGB16_BIG:
case B_RGB16_LITTLE: case B_RGB16_LITTLE:
return color.GetColor16(); return RGBColor(color).GetColor16();
case B_RGB32_BIG: case B_RGB32_BIG:
case B_RGBA32_BIG: case B_RGBA32_BIG:
case B_RGB32_LITTLE: case B_RGB32_LITTLE:
case B_RGBA32_LITTLE: { case B_RGBA32_LITTLE: {
rgb_color c = color.GetColor32(); uint32 native = (color.alpha << 24) |
uint32 native = (c.alpha << 24) | (color.red << 16) |
(c.red << 16) | (color.green << 8) |
(c.green << 8) | (color.blue);
(c.blue);
return native; return native;
} }
} }
+2 -2
View File
@@ -59,7 +59,7 @@ class DWindowHWInterface : public HWInterface {
uint32 count, uint32 count,
int32 xOffset, int32 yOffset); int32 xOffset, int32 yOffset);
virtual void FillRegion(/*const*/ BRegion& region, virtual void FillRegion(/*const*/ BRegion& region,
const RGBColor& color, const rgb_color& color,
bool autoSync); bool autoSync);
virtual void InvertRegion(/*const*/ BRegion& region); virtual void InvertRegion(/*const*/ BRegion& region);
@@ -92,7 +92,7 @@ class DWindowHWInterface : public HWInterface {
void _RegionToRectParams(/*const*/ BRegion* region, void _RegionToRectParams(/*const*/ BRegion* region,
uint32* count) const; uint32* count) const;
uint32 _NativeColor(const RGBColor& color) const; uint32 _NativeColor(const rgb_color& color) const;
+10 -10
View File
@@ -648,10 +648,10 @@ DrawingEngine::DrawPolygon(BPoint* ptlist, int32 numpts,
} }
} }
// #pragma mark - RGBColor // #pragma mark - rgb_color
void void
DrawingEngine::StrokePoint(const BPoint& pt, const RGBColor &color) DrawingEngine::StrokePoint(const BPoint& pt, const rgb_color &color)
{ {
StrokeLine(pt, pt, color); StrokeLine(pt, pt, color);
} }
@@ -662,7 +662,7 @@ DrawingEngine::StrokePoint(const BPoint& pt, const RGBColor &color)
// * it assumes a one pixel wide line // * it assumes a one pixel wide line
void void
DrawingEngine::StrokeLine(const BPoint &start, const BPoint &end, DrawingEngine::StrokeLine(const BPoint &start, const BPoint &end,
const RGBColor &color) const rgb_color &color)
{ {
CRASH_IF_NOT_LOCKED CRASH_IF_NOT_LOCKED
@@ -671,7 +671,7 @@ DrawingEngine::StrokeLine(const BPoint &start, const BPoint &end,
touched = fPainter->ClipRect(touched); touched = fPainter->ClipRect(touched);
bool cursorTouched = fGraphicsCard->HideSoftwareCursor(touched); bool cursorTouched = fGraphicsCard->HideSoftwareCursor(touched);
if (!fPainter->StraightLine(start, end, color.GetColor32())) { if (!fPainter->StraightLine(start, end, color)) {
fPainter->SetHighColor(color); fPainter->SetHighColor(color);
fPainter->SetDrawingMode(B_OP_OVER); fPainter->SetDrawingMode(B_OP_OVER);
fPainter->StrokeLine(start, end); fPainter->StrokeLine(start, end);
@@ -684,7 +684,7 @@ DrawingEngine::StrokeLine(const BPoint &start, const BPoint &end,
// this function is used to draw a one pixel wide rect // this function is used to draw a one pixel wide rect
void void
DrawingEngine::StrokeRect(BRect r, const RGBColor &color) DrawingEngine::StrokeRect(BRect r, const rgb_color &color)
{ {
CRASH_IF_NOT_LOCKED CRASH_IF_NOT_LOCKED
@@ -693,7 +693,7 @@ DrawingEngine::StrokeRect(BRect r, const RGBColor &color)
if (clipped.IsValid()) { if (clipped.IsValid()) {
bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->StrokeRect(r, color.GetColor32()); fPainter->StrokeRect(r, color);
fGraphicsCard->Invalidate(clipped); fGraphicsCard->Invalidate(clipped);
if (cursorTouched) if (cursorTouched)
@@ -703,7 +703,7 @@ DrawingEngine::StrokeRect(BRect r, const RGBColor &color)
void void
DrawingEngine::FillRect(BRect r, const RGBColor& color) DrawingEngine::FillRect(BRect r, const rgb_color& color)
{ {
CRASH_IF_NOT_LOCKED CRASH_IF_NOT_LOCKED
@@ -723,7 +723,7 @@ DrawingEngine::FillRect(BRect r, const RGBColor& color)
fSuspendSyncLevel == 0 fSuspendSyncLevel == 0
|| cursorTouched); || cursorTouched);
} else { } else {
fPainter->FillRect(r, color.GetColor32()); fPainter->FillRect(r, color);
fGraphicsCard->Invalidate(r); fGraphicsCard->Invalidate(r);
} }
@@ -735,7 +735,7 @@ DrawingEngine::FillRect(BRect r, const RGBColor& color)
void void
DrawingEngine::FillRegion(BRegion& r, const RGBColor& color) DrawingEngine::FillRegion(BRegion& r, const rgb_color& color)
{ {
CRASH_IF_NOT_LOCKED CRASH_IF_NOT_LOCKED
@@ -751,7 +751,7 @@ DrawingEngine::FillRegion(BRegion& r, const RGBColor& color)
} else { } else {
int32 count = r.CountRects(); int32 count = r.CountRects();
for (int32 i = 0; i < count; i++) { for (int32 i = 0; i < count; i++) {
fPainter->FillRectNoClipping(r.RectAt(i), color.GetColor32()); fPainter->FillRectNoClipping(r.RectAt(i), color);
} }
fGraphicsCard->Invalidate(frame); fGraphicsCard->Invalidate(frame);
+6 -7
View File
@@ -24,7 +24,6 @@ class BRegion;
class DrawState; class DrawState;
class Painter; class Painter;
class RGBColor;
class ServerBitmap; class ServerBitmap;
class ServerCursor; class ServerCursor;
class ServerFont; class ServerFont;
@@ -104,12 +103,12 @@ public:
void DrawPolygon(BPoint *ptlist, int32 numpts, void DrawPolygon(BPoint *ptlist, int32 numpts,
BRect bounds, bool filled, bool closed); BRect bounds, bool filled, bool closed);
// these RGBColor versions are used internally by the server // these rgb_color versions are used internally by the server
void StrokePoint(const BPoint& pt, void StrokePoint(const BPoint& pt,
const RGBColor& color); const rgb_color& color);
void StrokeRect(BRect r, const RGBColor &color); void StrokeRect(BRect r, const rgb_color &color);
void FillRect(BRect r, const RGBColor &color); void FillRect(BRect r, const rgb_color &color);
void FillRegion(BRegion& r, const RGBColor& color); void FillRegion(BRegion& r, const rgb_color& color);
void StrokeRect(BRect r); void StrokeRect(BRect r);
void FillRect(BRect r); void FillRect(BRect r);
@@ -129,7 +128,7 @@ public:
// this version used by Decorator // this version used by Decorator
void StrokeLine(const BPoint& start, void StrokeLine(const BPoint& start,
const BPoint& end, const RGBColor& color); const BPoint& end, const rgb_color& color);
void StrokeLine(const BPoint& start, void StrokeLine(const BPoint& start,
const BPoint& end); const BPoint& end);
+1 -2
View File
@@ -23,7 +23,6 @@
class Overlay; class Overlay;
class RenderingBuffer; class RenderingBuffer;
class RGBColor;
class ServerBitmap; class ServerBitmap;
class ServerCursor; class ServerCursor;
class UpdateQueue; class UpdateQueue;
@@ -98,7 +97,7 @@ class HWInterface : protected MultiLocker {
uint32 count, uint32 count,
int32 xOffset, int32 yOffset) {} int32 xOffset, int32 yOffset) {}
virtual void FillRegion(/*const*/ BRegion& region, virtual void FillRegion(/*const*/ BRegion& region,
const RGBColor& color, const rgb_color& color,
bool autoSync) {} bool autoSync) {}
virtual void InvertRegion(/*const*/ BRegion& region) {} virtual void InvertRegion(/*const*/ BRegion& region) {}
+2 -4
View File
@@ -14,8 +14,6 @@
#include <BitmapPrivate.h> #include <BitmapPrivate.h>
#include <InterfaceDefs.h>
const static bigtime_t kOverlayTimeout = 1000000LL; const static bigtime_t kOverlayTimeout = 1000000LL;
// after 1 second, the team holding the lock will be killed // after 1 second, the team holding the lock will be killed
@@ -62,7 +60,7 @@ Overlay::Overlay(HWInterface& interface, ServerBitmap* bitmap,
fOverlayToken(token) fOverlayToken(token)
{ {
fSemaphore = create_sem(1, "overlay lock"); fSemaphore = create_sem(1, "overlay lock");
fColor.SetColor(21, 16, 21, 16); fColor = (rgb_color){ 21, 16, 21, 16 };
// TODO: whatever fine color we want to use here... // TODO: whatever fine color we want to use here...
fWindow.offset_top = 0; fWindow.offset_top = 0;
@@ -221,7 +219,7 @@ Overlay::SetColorSpace(uint32 colorSpace)
return; return;
uint8 colorShift = 0, greenShift = 0, alphaShift = 0; uint8 colorShift = 0, greenShift = 0, alphaShift = 0;
rgb_color colorKey = fColor.GetColor32(); rgb_color colorKey = fColor;
switch (colorSpace) { switch (colorSpace) {
case B_CMAP8: case B_CMAP8:
+3 -3
View File
@@ -9,7 +9,7 @@
#define OVERLAY_H #define OVERLAY_H
#include "RGBColor.h" #include <InterfaceDefs.h>
#include <video_overlay.h> #include <video_overlay.h>
@@ -48,7 +48,7 @@ class Overlay {
sem_id Semaphore() const sem_id Semaphore() const
{ return fSemaphore; } { return fSemaphore; }
const RGBColor& Color() const const rgb_color& Color() const
{ return fColor; } { return fColor; }
void Configure(const BRect& source, const BRect& destination); void Configure(const BRect& source, const BRect& destination);
@@ -65,7 +65,7 @@ class Overlay {
overlay_view fView; overlay_view fView;
overlay_window fWindow; overlay_window fWindow;
sem_id fSemaphore; sem_id fSemaphore;
RGBColor fColor; rgb_color fColor;
}; };
#endif // OVERLAY_H #endif // OVERLAY_H
+15 -15
View File
@@ -107,7 +107,7 @@ Painter::AttachToBuffer(RenderingBuffer* buffer)
// These are the AGG renderes and rasterizes which // These are the AGG renderes and rasterizes which
// will be used for stroking paths // will be used for stroking paths
_SetRendererColor(fPatternHandler.HighColor().GetColor32()); _SetRendererColor(fPatternHandler.HighColor());
} }
} }
@@ -152,8 +152,8 @@ Painter::SetDrawState(const DrawState* data, int32 xOffset, int32 yOffset)
// adopt the color *after* the pattern is set // adopt the color *after* the pattern is set
// to set the renderers to the correct color // to set the renderers to the correct color
SetHighColor(data->HighColor().GetColor32()); SetHighColor(data->HighColor());
SetLowColor(data->LowColor().GetColor32()); SetLowColor(data->LowColor());
if (updateDrawingMode || fPixelFormat.UsesOpCopyForText()) if (updateDrawingMode || fPixelFormat.UsesOpCopyForText())
_UpdateDrawingMode(); _UpdateDrawingMode();
@@ -179,7 +179,7 @@ Painter::ConstrainClipping(const BRegion* region)
void void
Painter::SetHighColor(const rgb_color& color) Painter::SetHighColor(const rgb_color& color)
{ {
if (fPatternHandler.HighColor().GetColor32() == color) if (fPatternHandler.HighColor() == color)
return; return;
fPatternHandler.SetHighColor(color); fPatternHandler.SetHighColor(color);
if (*(fPatternHandler.GetR5Pattern()) == B_SOLID_HIGH) if (*(fPatternHandler.GetR5Pattern()) == B_SOLID_HIGH)
@@ -245,10 +245,10 @@ Painter::SetPattern(const pattern& p, bool drawingText)
// update renderer color if necessary // update renderer color if necessary
if (fPatternHandler.IsSolidHigh()) { if (fPatternHandler.IsSolidHigh()) {
// pattern was not solid high before // pattern was not solid high before
_SetRendererColor(fPatternHandler.HighColor().GetColor32()); _SetRendererColor(fPatternHandler.HighColor());
} else if (fPatternHandler.IsSolidLow()) { } else if (fPatternHandler.IsSolidLow()) {
// pattern was not solid low before // pattern was not solid low before
_SetRendererColor(fPatternHandler.LowColor().GetColor32()); _SetRendererColor(fPatternHandler.LowColor());
} }
} }
} }
@@ -290,10 +290,10 @@ Painter::StrokeLine(BPoint a, BPoint b)
pattern pat = *fPatternHandler.GetR5Pattern(); pattern pat = *fPatternHandler.GetR5Pattern();
if (pat == B_SOLID_HIGH if (pat == B_SOLID_HIGH
&& StraightLine(a, b, fPatternHandler.HighColor().GetColor32())) { && StraightLine(a, b, fPatternHandler.HighColor())) {
return; return;
} else if (pat == B_SOLID_LOW } else if (pat == B_SOLID_LOW
&& StraightLine(a, b, fPatternHandler.LowColor().GetColor32())) { && StraightLine(a, b, fPatternHandler.LowColor())) {
return; return;
} }
} }
@@ -574,12 +574,12 @@ Painter::StrokeRect(const BRect& r) const
if (p == B_SOLID_HIGH) { if (p == B_SOLID_HIGH) {
BRect rect(a, b); BRect rect(a, b);
StrokeRect(rect, StrokeRect(rect,
fPatternHandler.HighColor().GetColor32()); fPatternHandler.HighColor());
return _Clipped(rect); return _Clipped(rect);
} else if (p == B_SOLID_LOW) { } else if (p == B_SOLID_LOW) {
BRect rect(a, b); BRect rect(a, b);
StrokeRect(rect, StrokeRect(rect,
fPatternHandler.LowColor().GetColor32()); fPatternHandler.LowColor());
return _Clipped(rect); return _Clipped(rect);
} }
} }
@@ -638,11 +638,11 @@ Painter::FillRect(const BRect& r) const
pattern p = *fPatternHandler.GetR5Pattern(); pattern p = *fPatternHandler.GetR5Pattern();
if (p == B_SOLID_HIGH) { if (p == B_SOLID_HIGH) {
BRect rect(a, b); BRect rect(a, b);
FillRect(rect, fPatternHandler.HighColor().GetColor32()); FillRect(rect, fPatternHandler.HighColor());
return _Clipped(rect); return _Clipped(rect);
} else if (p == B_SOLID_LOW) { } else if (p == B_SOLID_LOW) {
BRect rect(a, b); BRect rect(a, b);
FillRect(rect, fPatternHandler.LowColor().GetColor32()); FillRect(rect, fPatternHandler.LowColor());
return _Clipped(rect); return _Clipped(rect);
} }
} }
@@ -650,12 +650,12 @@ Painter::FillRect(const BRect& r) const
pattern p = *fPatternHandler.GetR5Pattern(); pattern p = *fPatternHandler.GetR5Pattern();
if (p == B_SOLID_HIGH) { if (p == B_SOLID_HIGH) {
BRect rect(a, b); BRect rect(a, b);
_BlendRect32(rect, fPatternHandler.HighColor().GetColor32()); _BlendRect32(rect, fPatternHandler.HighColor());
return _Clipped(rect); return _Clipped(rect);
} else if (p == B_SOLID_LOW) { } else if (p == B_SOLID_LOW) {
rgb_color c = fPatternHandler.LowColor().GetColor32(); rgb_color c = fPatternHandler.LowColor();
if (fAlphaSrcMode == B_CONSTANT_ALPHA) if (fAlphaSrcMode == B_CONSTANT_ALPHA)
c.alpha = fPatternHandler.HighColor().GetColor32().alpha; c.alpha = fPatternHandler.HighColor().alpha;
BRect rect(a, b); BRect rect(a, b);
_BlendRect32(rect, c); _BlendRect32(rect, c);
return _Clipped(rect); return _Clipped(rect);
+2 -36
View File
@@ -12,7 +12,6 @@
#include "AGGTextRenderer.h" #include "AGGTextRenderer.h"
#include "FontManager.h" #include "FontManager.h"
#include "PatternHandler.h" #include "PatternHandler.h"
#include "RGBColor.h"
#include "ServerFont.h" #include "ServerFont.h"
#include "defines.h" #include "defines.h"
@@ -53,21 +52,12 @@ class Painter {
// object settings // object settings
void SetHighColor(const rgb_color& color); void SetHighColor(const rgb_color& color);
inline void SetHighColor(uint8 r, uint8 g, uint8 b, uint8 a = 255);
inline void SetHighColor(const RGBColor& color)
{ SetHighColor(color.GetColor32()); }
inline rgb_color HighColor() const inline rgb_color HighColor() const
{ return fPatternHandler. { return fPatternHandler.HighColor(); }
HighColor().GetColor32(); }
void SetLowColor(const rgb_color& color); void SetLowColor(const rgb_color& color);
inline void SetLowColor(uint8 r, uint8 g, uint8 b, uint8 a = 255);
inline void SetLowColor(const RGBColor& color)
{ SetLowColor(color.GetColor32()); }
inline rgb_color LowColor() const inline rgb_color LowColor() const
{ return fPatternHandler. { return fPatternHandler.LowColor(); }
LowColor().GetColor32(); }
void SetPenSize(float size); void SetPenSize(float size);
inline float PenSize() const inline float PenSize() const
@@ -290,30 +280,6 @@ mutable agg::conv_curve<agg::path_storage> fCurve;
mutable AGGTextRenderer fTextRenderer; mutable AGGTextRenderer fTextRenderer;
}; };
// SetHighColor
inline void
Painter::SetHighColor(uint8 r, uint8 g, uint8 b, uint8 a)
{
rgb_color color;
color.red = r;
color.green = g;
color.blue = b;
color.alpha = a;
SetHighColor(color);
}
// SetLowColor
inline void
Painter::SetLowColor(uint8 r, uint8 g, uint8 b, uint8 a)
{
rgb_color color;
color.red = r;
color.green = g;
color.blue = b;
color.alpha = a;
SetLowColor(color);
}
#endif // PAINTER_H #endif // PAINTER_H
@@ -41,7 +41,7 @@ blend_pixel_add(int x, int y, const color_type& c, uint8 cover,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
if (cover == 255) { if (cover == 255) {
ASSIGN_ADD(p, color.red, color.green, color.blue); ASSIGN_ADD(p, color.red, color.green, color.blue);
} else { } else {
@@ -58,7 +58,7 @@ blend_hline_add(int x, int y, unsigned len,
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
if (cover == 255) { if (cover == 255) {
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
ASSIGN_ADD(p, color.red, color.green, color.blue); ASSIGN_ADD(p, color.red, color.green, color.blue);
@@ -67,7 +67,7 @@ blend_hline_add(int x, int y, unsigned len,
} while(--len); } while(--len);
} else { } else {
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
BLEND_ADD(p, color.red, color.green, color.blue, cover); BLEND_ADD(p, color.red, color.green, color.blue, cover);
@@ -85,7 +85,7 @@ blend_solid_hspan_add(int x, int y, unsigned len,
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
if (*covers) { if (*covers) {
if (*covers == 255) { if (*covers == 255) {
ASSIGN_ADD(p, color.red, color.green, color.blue); ASSIGN_ADD(p, color.red, color.green, color.blue);
@@ -109,7 +109,7 @@ blend_solid_vspan_add(int x, int y, unsigned len,
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
if (*covers) { if (*covers) {
if (*covers == 255) { if (*covers == 255) {
ASSIGN_ADD(p, color.red, color.green, color.blue); ASSIGN_ADD(p, color.red, color.green, color.blue);
@@ -32,8 +32,8 @@ blend_pixel_alpha_cc(int x, int y, const color_type& c, uint8 cover,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
uint16 alpha = pattern->HighColor().GetColor32().alpha * cover; uint16 alpha = pattern->HighColor().alpha * cover;
if (alpha == 255 * 255) { if (alpha == 255 * 255) {
ASSIGN_ALPHA_CC(p, color.red, color.green, color.blue); ASSIGN_ALPHA_CC(p, color.red, color.green, color.blue);
} else { } else {
@@ -47,7 +47,7 @@ blend_hline_alpha_cc(int x, int y, unsigned len,
const color_type& c, uint8 cover, const color_type& c, uint8 cover,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
rgb_color color = pattern->HighColor().GetColor32(); rgb_color color = pattern->HighColor();
uint16 alpha = color.alpha * cover; uint16 alpha = color.alpha * cover;
if (alpha == 255 * 255) { if (alpha == 255 * 255) {
// cache the low and high color as 32bit values // cache the low and high color as 32bit values
@@ -59,7 +59,7 @@ blend_hline_alpha_cc(int x, int y, unsigned len,
p8[2] = color.red; p8[2] = color.red;
p8[3] = 255; p8[3] = 255;
// low color // low color
color = pattern->LowColor().GetColor32(); color = pattern->LowColor();
uint32 vl; uint32 vl;
p8 = (uint8*)&vl; p8 = (uint8*)&vl;
p8[0] = color.blue; p8[0] = color.blue;
@@ -79,7 +79,7 @@ blend_hline_alpha_cc(int x, int y, unsigned len,
} else { } else {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
BLEND_ALPHA_CC(p, color.red, color.green, color.blue, alpha); BLEND_ALPHA_CC(p, color.red, color.green, color.blue, alpha);
x++; x++;
p += 4; p += 4;
@@ -94,9 +94,9 @@ blend_solid_hspan_alpha_cc(int x, int y, unsigned len,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
uint8 hAlpha = pattern->HighColor().GetColor32().alpha; uint8 hAlpha = pattern->HighColor().alpha;
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
uint16 alpha = hAlpha * *covers; uint16 alpha = hAlpha * *covers;
if (alpha) { if (alpha) {
if (alpha == 255 * 255) { if (alpha == 255 * 255) {
@@ -118,9 +118,9 @@ blend_solid_vspan_alpha_cc(int x, int y, unsigned len,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
uint8 hAlpha = pattern->HighColor().GetColor32().alpha; uint8 hAlpha = pattern->HighColor().alpha;
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
uint16 alpha = hAlpha * *covers; uint16 alpha = hAlpha * *covers;
if (alpha) { if (alpha) {
if (alpha == 255 * 255) { if (alpha == 255 * 255) {
@@ -144,7 +144,7 @@ blend_color_hspan_alpha_cc(int x, int y, unsigned len,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
uint8 hAlpha = pattern->HighColor().GetColor32().alpha; uint8 hAlpha = pattern->HighColor().alpha;
if (covers) { if (covers) {
// non-solid opacity // non-solid opacity
do { do {
@@ -32,8 +32,8 @@ blend_pixel_alpha_co(int x, int y, const color_type& c, uint8 cover,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
uint16 alpha = pattern->HighColor().GetColor32().alpha * cover; uint16 alpha = pattern->HighColor().alpha * cover;
if (alpha == 255 * 255) { if (alpha == 255 * 255) {
ASSIGN_ALPHA_CO(p, color.red, color.green, color.blue); ASSIGN_ALPHA_CO(p, color.red, color.green, color.blue);
} else { } else {
@@ -47,7 +47,7 @@ blend_hline_alpha_co(int x, int y, unsigned len,
const color_type& c, uint8 cover, const color_type& c, uint8 cover,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
rgb_color color = pattern->HighColor().GetColor32(); rgb_color color = pattern->HighColor();
uint16 alpha = color.alpha * cover; uint16 alpha = color.alpha * cover;
if (alpha == 255*255) { if (alpha == 255*255) {
// cache the low and high color as 32bit values // cache the low and high color as 32bit values
@@ -59,7 +59,7 @@ blend_hline_alpha_co(int x, int y, unsigned len,
p8[2] = color.red; p8[2] = color.red;
p8[3] = 255; p8[3] = 255;
// low color // low color
color = pattern->LowColor().GetColor32(); color = pattern->LowColor();
uint32 vl; uint32 vl;
p8 = (uint8*)&vl; p8 = (uint8*)&vl;
p8[0] = color.blue; p8[0] = color.blue;
@@ -79,7 +79,7 @@ blend_hline_alpha_co(int x, int y, unsigned len,
} else { } else {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
BLEND_ALPHA_CO(p, color.red, color.green, color.blue, alpha); BLEND_ALPHA_CO(p, color.red, color.green, color.blue, alpha);
x++; x++;
p += 4; p += 4;
@@ -94,9 +94,9 @@ blend_solid_hspan_alpha_co(int x, int y, unsigned len,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
uint8 hAlpha = pattern->HighColor().GetColor32().alpha; uint8 hAlpha = pattern->HighColor().alpha;
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
uint16 alpha = hAlpha * *covers; uint16 alpha = hAlpha * *covers;
if (alpha) { if (alpha) {
if (alpha == 255 * 255) { if (alpha == 255 * 255) {
@@ -120,9 +120,9 @@ blend_solid_vspan_alpha_co(int x, int y, unsigned len,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
uint8 hAlpha = pattern->HighColor().GetColor32().alpha; uint8 hAlpha = pattern->HighColor().alpha;
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
uint16 alpha = hAlpha * *covers; uint16 alpha = hAlpha * *covers;
if (alpha) { if (alpha) {
if (alpha == 255 * 255) { if (alpha == 255 * 255) {
@@ -146,7 +146,7 @@ blend_color_hspan_alpha_co(int x, int y, unsigned len,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
uint8 hAlpha = pattern->HighColor().GetColor32().alpha; uint8 hAlpha = pattern->HighColor().alpha;
if (covers) { if (covers) {
// non-solid opacity // non-solid opacity
do { do {
@@ -17,7 +17,7 @@ blend_pixel_alpha_co_solid(int x, int y, const color_type& c, uint8 cover,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
uint16 alpha = pattern->HighColor().GetColor32().alpha * cover; uint16 alpha = pattern->HighColor().alpha * cover;
if (alpha == 255 * 255) { if (alpha == 255 * 255) {
ASSIGN_ALPHA_CO(p, c.r, c.g, c.b); ASSIGN_ALPHA_CO(p, c.r, c.g, c.b);
} else { } else {
@@ -31,7 +31,7 @@ blend_hline_alpha_co_solid(int x, int y, unsigned len,
const color_type& c, uint8 cover, const color_type& c, uint8 cover,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint16 alpha = pattern->HighColor().GetColor32().alpha * cover; uint16 alpha = pattern->HighColor().alpha * cover;
if (alpha == 255 * 255) { if (alpha == 255 * 255) {
// cache the color as 32bit values // cache the color as 32bit values
uint32 v; uint32 v;
@@ -69,7 +69,7 @@ blend_solid_hspan_alpha_co_solid(int x, int y, unsigned len,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
uint8 hAlpha = pattern->HighColor().GetColor32().alpha; uint8 hAlpha = pattern->HighColor().alpha;
do { do {
uint16 alpha = hAlpha * *covers; uint16 alpha = hAlpha * *covers;
if (alpha) { if (alpha) {
@@ -94,7 +94,7 @@ blend_solid_vspan_alpha_co_solid(int x, int y, unsigned len,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
uint8 hAlpha = pattern->HighColor().GetColor32().alpha; uint8 hAlpha = pattern->HighColor().alpha;
do { do {
uint16 alpha = hAlpha * *covers; uint16 alpha = hAlpha * *covers;
if (alpha) { if (alpha) {
@@ -32,7 +32,7 @@ blend_pixel_alpha_pc(int x, int y, const color_type& c, uint8 cover,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
uint16 alpha = color.alpha * cover; uint16 alpha = color.alpha * cover;
if (alpha == 255*255) { if (alpha == 255*255) {
ASSIGN_ALPHA_PC(p, color.red, color.green, color.blue); ASSIGN_ALPHA_PC(p, color.red, color.green, color.blue);
@@ -49,7 +49,7 @@ blend_hline_alpha_pc(int x, int y, unsigned len,
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
uint16 alpha = color.alpha * cover; uint16 alpha = color.alpha * cover;
if (alpha) { if (alpha) {
if (alpha == 255) { if (alpha == 255) {
@@ -71,7 +71,7 @@ blend_solid_hspan_alpha_pc(int x, int y, unsigned len,
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
uint16 alpha = color.alpha * *covers; uint16 alpha = color.alpha * *covers;
if (alpha) { if (alpha) {
if(alpha == 255 * 255) { if(alpha == 255 * 255) {
@@ -94,7 +94,7 @@ blend_solid_vspan_alpha_pc(int x, int y, unsigned len,
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
uint16 alpha = color.alpha * *covers; uint16 alpha = color.alpha * *covers;
if (alpha) { if (alpha) {
if (alpha == 255 * 255) { if (alpha == 255 * 255) {
@@ -32,7 +32,7 @@ blend_pixel_alpha_po(int x, int y, const color_type& c, uint8 cover,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
uint16 alpha = color.alpha * cover; uint16 alpha = color.alpha * cover;
if (alpha == 255 * 255) { if (alpha == 255 * 255) {
ASSIGN_ALPHA_PO(p, color.red, color.green, color.blue); ASSIGN_ALPHA_PO(p, color.red, color.green, color.blue);
@@ -49,7 +49,7 @@ blend_hline_alpha_po(int x, int y, unsigned len,
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
uint16 alpha = color.alpha * cover; uint16 alpha = color.alpha * cover;
if (alpha) { if (alpha) {
if (alpha == 255) { if (alpha == 255) {
@@ -71,7 +71,7 @@ blend_solid_hspan_alpha_po(int x, int y, unsigned len,
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
uint16 alpha = color.alpha * *covers; uint16 alpha = color.alpha * *covers;
if (alpha) { if (alpha) {
if(alpha == 255 * 255) { if(alpha == 255 * 255) {
@@ -96,7 +96,7 @@ blend_solid_vspan_alpha_po(int x, int y, unsigned len,
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
uint16 alpha = color.alpha * *covers; uint16 alpha = color.alpha * *covers;
if (alpha) { if (alpha) {
if (alpha == 255 * 255) { if (alpha == 255 * 255) {
@@ -39,7 +39,7 @@ blend_pixel_blend(int x, int y, const color_type& c, uint8 cover,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
if (cover == 255) { if (cover == 255) {
ASSIGN_BLEND(p, color.red, color.green, color.blue); ASSIGN_BLEND(p, color.red, color.green, color.blue);
} else { } else {
@@ -56,7 +56,7 @@ blend_hline_blend(int x, int y, unsigned len,
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
if (cover == 255) { if (cover == 255) {
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
ASSIGN_BLEND(p, color.red, color.green, color.blue); ASSIGN_BLEND(p, color.red, color.green, color.blue);
@@ -65,7 +65,7 @@ blend_hline_blend(int x, int y, unsigned len,
} while(--len); } while(--len);
} else { } else {
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
BLEND_BLEND(p, color.red, color.green, color.blue, cover); BLEND_BLEND(p, color.red, color.green, color.blue, cover);
@@ -83,7 +83,7 @@ blend_solid_hspan_blend(int x, int y, unsigned len,
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
if (*covers) { if (*covers) {
if (*covers == 255) { if (*covers == 255) {
ASSIGN_BLEND(p, color.red, color.green, color.blue); ASSIGN_BLEND(p, color.red, color.green, color.blue);
@@ -107,7 +107,7 @@ blend_solid_vspan_blend(int x, int y, unsigned len,
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
if (*covers) { if (*covers) {
if (*covers == 255) { if (*covers == 255) {
ASSIGN_BLEND(p, color.red, color.green, color.blue); ASSIGN_BLEND(p, color.red, color.green, color.blue);
@@ -33,11 +33,11 @@ blend_pixel_copy(int x, int y, const color_type& c, uint8 cover,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
if (cover == 255) { if (cover == 255) {
ASSIGN_COPY(p, color.red, color.green, color.blue, color.alpha); ASSIGN_COPY(p, color.red, color.green, color.blue, color.alpha);
} else { } else {
rgb_color l = pattern->LowColor().GetColor32(); rgb_color l = pattern->LowColor();
BLEND_COPY(p, color.red, color.green, color.blue, cover, BLEND_COPY(p, color.red, color.green, color.blue, cover,
l.red, l.green, l.blue); l.red, l.green, l.blue);
} }
@@ -52,7 +52,7 @@ blend_hline_copy(int x, int y, unsigned len,
if (cover == 255) { if (cover == 255) {
// cache the low and high color as 32bit values // cache the low and high color as 32bit values
// high color // high color
rgb_color color = pattern->HighColor().GetColor32(); rgb_color color = pattern->HighColor();
uint32 vh; uint32 vh;
uint8* p8 = (uint8*)&vh; uint8* p8 = (uint8*)&vh;
p8[0] = (uint8)color.blue; p8[0] = (uint8)color.blue;
@@ -60,7 +60,7 @@ blend_hline_copy(int x, int y, unsigned len,
p8[2] = (uint8)color.red; p8[2] = (uint8)color.red;
p8[3] = 255; p8[3] = 255;
// low color // low color
color = pattern->LowColor().GetColor32(); color = pattern->LowColor();
uint32 vl; uint32 vl;
p8 = (uint8*)&vl; p8 = (uint8*)&vl;
p8[0] = (uint8)color.blue; p8[0] = (uint8)color.blue;
@@ -79,9 +79,9 @@ blend_hline_copy(int x, int y, unsigned len,
} while(--len); } while(--len);
} else { } else {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color l = pattern->LowColor().GetColor32(); rgb_color l = pattern->LowColor();
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
BLEND_COPY(p, color.red, color.green, color.blue, cover, BLEND_COPY(p, color.red, color.green, color.blue, cover,
l.red, l.green, l.blue); l.red, l.green, l.blue);
x++; x++;
@@ -97,9 +97,9 @@ blend_solid_hspan_copy(int x, int y, unsigned len,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color l = pattern->LowColor().GetColor32(); rgb_color l = pattern->LowColor();
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
if (*covers) { if (*covers) {
if (*covers == 255) { if (*covers == 255) {
ASSIGN_COPY(p, color.red, color.green, color.blue, color.alpha); ASSIGN_COPY(p, color.red, color.green, color.blue, color.alpha);
@@ -123,9 +123,9 @@ blend_solid_vspan_copy(int x, int y, unsigned len,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color l = pattern->LowColor().GetColor32(); rgb_color l = pattern->LowColor();
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
if (*covers) { if (*covers) {
if (*covers == 255) { if (*covers == 255) {
ASSIGN_COPY(p, color.red, color.green, color.blue, color.alpha); ASSIGN_COPY(p, color.red, color.green, color.blue, color.alpha);
@@ -148,7 +148,7 @@ blend_color_hspan_copy(int x, int y, unsigned len, const color_type* colors,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color l = pattern->LowColor().GetColor32(); rgb_color l = pattern->LowColor();
if (covers) { if (covers) {
// non-solid opacity // non-solid opacity
do { do {
@@ -20,7 +20,7 @@ blend_pixel_copy_text(int x, int y, const color_type& c, uint8 cover,
if (cover == 255) { if (cover == 255) {
ASSIGN_COPY(p, c.r, c.g, c.b, c.a); ASSIGN_COPY(p, c.r, c.g, c.b, c.a);
} else { } else {
rgb_color l = pattern->LowColor().GetColor32(); rgb_color l = pattern->LowColor();
BLEND_COPY(p, c.r, c.g, c.b, cover, BLEND_COPY(p, c.r, c.g, c.b, cover,
l.red, l.green, l.blue); l.red, l.green, l.blue);
} }
@@ -48,7 +48,7 @@ blend_hline_copy_text(int x, int y, unsigned len,
} while(--len); } while(--len);
} else { } else {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color l = pattern->LowColor().GetColor32(); rgb_color l = pattern->LowColor();
do { do {
BLEND_COPY(p, c.r, c.g, c.b, cover, BLEND_COPY(p, c.r, c.g, c.b, cover,
l.red, l.green, l.blue); l.red, l.green, l.blue);
@@ -68,7 +68,7 @@ blend_solid_hspan_copy_text(int x, int y, unsigned len,
// uint8* p = buffer->row_ptr(y) + (x << 2); // uint8* p = buffer->row_ptr(y) + (x << 2);
uint32* p = (uint32*)(buffer->row_ptr(y) + (x << 2)); uint32* p = (uint32*)(buffer->row_ptr(y) + (x << 2));
const uint32* cache = (const uint32*)pattern->OpCopyColorCache(); const uint32* cache = (const uint32*)pattern->OpCopyColorCache();
// rgb_color l = pattern->LowColor().GetColor32(); // rgb_color l = pattern->LowColor();
do { do {
// if (*covers) { // if (*covers) {
*p = cache[*covers]; *p = cache[*covers];
@@ -95,7 +95,7 @@ blend_solid_vspan_copy_text(int x, int y, unsigned len,
const PatternHandler* pattern) const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color l = pattern->LowColor().GetColor32(); rgb_color l = pattern->LowColor();
do { do {
if (*covers) { if (*covers) {
if (*covers == 255) { if (*covers == 255) {
@@ -120,7 +120,7 @@ blend_color_hspan_copy_text(int x, int y, unsigned len,
const PatternHandler* pattern) const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color l = pattern->LowColor().GetColor32(); rgb_color l = pattern->LowColor();
if (covers) { if (covers) {
// non-solid opacity // non-solid opacity
do { do {
@@ -33,7 +33,7 @@ blend_pixel_erase(int x, int y, const color_type& c, uint8 cover,
{ {
if (pattern->IsHighColor(x, y)) { if (pattern->IsHighColor(x, y)) {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color color = pattern->LowColor().GetColor32(); rgb_color color = pattern->LowColor();
if (cover == 255) { if (cover == 255) {
ASSIGN_ERASE(p, color.red, color.green, color.blue); ASSIGN_ERASE(p, color.red, color.green, color.blue);
} else { } else {
@@ -49,7 +49,7 @@ blend_hline_erase(int x, int y, unsigned len,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
if (cover == 255) { if (cover == 255) {
rgb_color color = pattern->LowColor().GetColor32(); rgb_color color = pattern->LowColor();
uint32 v; uint32 v;
uint8* p8 = (uint8*)&v; uint8* p8 = (uint8*)&v;
p8[0] = (uint8)color.blue; p8[0] = (uint8)color.blue;
@@ -65,7 +65,7 @@ blend_hline_erase(int x, int y, unsigned len,
} while(--len); } while(--len);
} else { } else {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color color = pattern->LowColor().GetColor32(); rgb_color color = pattern->LowColor();
do { do {
if (pattern->IsHighColor(x, y)) { if (pattern->IsHighColor(x, y)) {
BLEND_ERASE(p, color.red, color.green, color.blue, cover); BLEND_ERASE(p, color.red, color.green, color.blue, cover);
@@ -83,7 +83,7 @@ blend_solid_hspan_erase(int x, int y, unsigned len,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color color = pattern->LowColor().GetColor32(); rgb_color color = pattern->LowColor();
do { do {
if (pattern->IsHighColor(x, y)) { if (pattern->IsHighColor(x, y)) {
if (*covers) { if (*covers) {
@@ -109,7 +109,7 @@ blend_solid_vspan_erase(int x, int y, unsigned len,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color color = pattern->LowColor().GetColor32(); rgb_color color = pattern->LowColor();
do { do {
if (pattern->IsHighColor(x, y)) { if (pattern->IsHighColor(x, y)) {
if (*covers) { if (*covers) {
@@ -41,7 +41,7 @@ blend_pixel_max(int x, int y, const color_type& c, uint8 cover,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
if (cover == 255) { if (cover == 255) {
ASSIGN_MAX(p, color.red, color.green, color.blue); ASSIGN_MAX(p, color.red, color.green, color.blue);
} else { } else {
@@ -58,7 +58,7 @@ blend_hline_max(int x, int y, unsigned len,
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
if (cover == 255) { if (cover == 255) {
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
ASSIGN_MAX(p, color.red, color.green, color.blue); ASSIGN_MAX(p, color.red, color.green, color.blue);
@@ -67,7 +67,7 @@ blend_hline_max(int x, int y, unsigned len,
} while(--len); } while(--len);
} else { } else {
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
BLEND_MAX(p, color.red, color.green, color.blue, cover); BLEND_MAX(p, color.red, color.green, color.blue, cover);
@@ -85,7 +85,7 @@ blend_solid_hspan_max(int x, int y, unsigned len,
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
if (*covers) { if (*covers) {
if (*covers == 255) { if (*covers == 255) {
ASSIGN_MAX(p, color.red, color.green, color.blue); ASSIGN_MAX(p, color.red, color.green, color.blue);
@@ -109,7 +109,7 @@ blend_solid_vspan_max(int x, int y, unsigned len,
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
if (*covers) { if (*covers) {
if (*covers == 255) { if (*covers == 255) {
ASSIGN_MAX(p, color.red, color.green, color.blue); ASSIGN_MAX(p, color.red, color.green, color.blue);
@@ -35,7 +35,7 @@ blend_pixel_min(int x, int y, const color_type& c, uint8 cover,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
if (cover == 255) { if (cover == 255) {
ASSIGN_MIN(p, color.red, color.green, color.blue); ASSIGN_MIN(p, color.red, color.green, color.blue);
} else { } else {
@@ -52,7 +52,7 @@ blend_hline_min(int x, int y, unsigned len,
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
if (cover == 255) { if (cover == 255) {
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
ASSIGN_MIN(p, color.red, color.green, color.blue); ASSIGN_MIN(p, color.red, color.green, color.blue);
@@ -61,7 +61,7 @@ blend_hline_min(int x, int y, unsigned len,
} while(--len); } while(--len);
} else { } else {
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
BLEND_MIN(p, color.red, color.green, color.blue, cover); BLEND_MIN(p, color.red, color.green, color.blue, cover);
@@ -79,7 +79,7 @@ blend_solid_hspan_min(int x, int y, unsigned len,
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
if (*covers) { if (*covers) {
if (*covers == 255) { if (*covers == 255) {
ASSIGN_MIN(p, color.red, color.green, color.blue); ASSIGN_MIN(p, color.red, color.green, color.blue);
@@ -103,7 +103,7 @@ blend_solid_vspan_min(int x, int y, unsigned len,
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
if (*covers) { if (*covers) {
if (*covers == 255) { if (*covers == 255) {
ASSIGN_MIN(p, color.red, color.green, color.blue); ASSIGN_MIN(p, color.red, color.green, color.blue);
@@ -33,7 +33,7 @@ blend_pixel_over(int x, int y, const color_type& c, uint8 cover,
{ {
if (pattern->IsHighColor(x, y)) { if (pattern->IsHighColor(x, y)) {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color color = pattern->HighColor().GetColor32(); rgb_color color = pattern->HighColor();
if (cover == 255) { if (cover == 255) {
ASSIGN_OVER(p, color.red, color.green, color.blue); ASSIGN_OVER(p, color.red, color.green, color.blue);
} else { } else {
@@ -49,7 +49,7 @@ blend_hline_over(int x, int y, unsigned len,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
if (cover == 255) { if (cover == 255) {
rgb_color color = pattern->HighColor().GetColor32(); rgb_color color = pattern->HighColor();
uint32 v; uint32 v;
uint8* p8 = (uint8*)&v; uint8* p8 = (uint8*)&v;
p8[0] = (uint8)color.blue; p8[0] = (uint8)color.blue;
@@ -65,7 +65,7 @@ blend_hline_over(int x, int y, unsigned len,
} while(--len); } while(--len);
} else { } else {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color color = pattern->HighColor().GetColor32(); rgb_color color = pattern->HighColor();
do { do {
if (pattern->IsHighColor(x, y)) { if (pattern->IsHighColor(x, y)) {
BLEND_OVER(p, color.red, color.green, color.blue, cover); BLEND_OVER(p, color.red, color.green, color.blue, cover);
@@ -83,7 +83,7 @@ blend_solid_hspan_over(int x, int y, unsigned len,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color color = pattern->HighColor().GetColor32(); rgb_color color = pattern->HighColor();
do { do {
if (pattern->IsHighColor(x, y)) { if (pattern->IsHighColor(x, y)) {
if (*covers) { if (*covers) {
@@ -109,7 +109,7 @@ blend_solid_vspan_over(int x, int y, unsigned len,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color color = pattern->HighColor().GetColor32(); rgb_color color = pattern->HighColor();
do { do {
if (pattern->IsHighColor(x, y)) { if (pattern->IsHighColor(x, y)) {
if (*covers) { if (*covers) {
@@ -57,8 +57,8 @@ blend_pixel_select(int x, int y, const color_type& c, uint8 cover,
{ {
if (pattern->IsHighColor(x, y)) { if (pattern->IsHighColor(x, y)) {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color high = pattern->HighColor().GetColor32(); rgb_color high = pattern->HighColor();
rgb_color low = pattern->LowColor().GetColor32(); rgb_color low = pattern->LowColor();
rgb_color color; rgb_color color;
if (compare(p, high, low, &color)) { if (compare(p, high, low, &color)) {
if (cover == 255) { if (cover == 255) {
@@ -77,8 +77,8 @@ blend_hline_select(int x, int y, unsigned len,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color high = pattern->HighColor().GetColor32(); rgb_color high = pattern->HighColor();
rgb_color low = pattern->LowColor().GetColor32(); rgb_color low = pattern->LowColor();
rgb_color color; rgb_color color;
if (cover == 255) { if (cover == 255) {
do { do {
@@ -107,8 +107,8 @@ blend_solid_hspan_select(int x, int y, unsigned len,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color high = pattern->HighColor().GetColor32(); rgb_color high = pattern->HighColor();
rgb_color low = pattern->LowColor().GetColor32(); rgb_color low = pattern->LowColor();
rgb_color color; rgb_color color;
do { do {
if (pattern->IsHighColor(x, y)) { if (pattern->IsHighColor(x, y)) {
@@ -135,8 +135,8 @@ blend_solid_vspan_select(int x, int y, unsigned len,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color high = pattern->HighColor().GetColor32(); rgb_color high = pattern->HighColor();
rgb_color low = pattern->LowColor().GetColor32(); rgb_color low = pattern->LowColor();
rgb_color color; rgb_color color;
do { do {
if (pattern->IsHighColor(x, y)) { if (pattern->IsHighColor(x, y)) {
@@ -163,8 +163,8 @@ blend_color_hspan_select(int x, int y, unsigned len,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color high = pattern->HighColor().GetColor32(); rgb_color high = pattern->HighColor();
rgb_color low = pattern->LowColor().GetColor32(); rgb_color low = pattern->LowColor();
rgb_color color; rgb_color color;
if (covers) { if (covers) {
// non-solid opacity // non-solid opacity
@@ -43,7 +43,7 @@ blend_pixel_subtract(int x, int y, const color_type& c, uint8 cover,
agg_buffer* buffer, const PatternHandler* pattern) agg_buffer* buffer, const PatternHandler* pattern)
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
if (cover == 255) { if (cover == 255) {
ASSIGN_SUBTRACT(p, color.red, color.green, color.blue); ASSIGN_SUBTRACT(p, color.red, color.green, color.blue);
} else { } else {
@@ -60,7 +60,7 @@ blend_hline_subtract(int x, int y, unsigned len,
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
if (cover == 255) { if (cover == 255) {
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
ASSIGN_SUBTRACT(p, color.red, color.green, color.blue); ASSIGN_SUBTRACT(p, color.red, color.green, color.blue);
@@ -69,7 +69,7 @@ blend_hline_subtract(int x, int y, unsigned len,
} while(--len); } while(--len);
} else { } else {
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
BLEND_SUBTRACT(p, color.red, color.green, color.blue, cover); BLEND_SUBTRACT(p, color.red, color.green, color.blue, cover);
@@ -87,7 +87,7 @@ blend_solid_hspan_subtract(int x, int y, unsigned len,
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
if (*covers) { if (*covers) {
if (*covers == 255) { if (*covers == 255) {
ASSIGN_SUBTRACT(p, color.red, color.green, color.blue); ASSIGN_SUBTRACT(p, color.red, color.green, color.blue);
@@ -111,7 +111,7 @@ blend_solid_vspan_subtract(int x, int y, unsigned len,
{ {
uint8* p = buffer->row_ptr(y) + (x << 2); uint8* p = buffer->row_ptr(y) + (x << 2);
do { do {
rgb_color color = pattern->R5ColorAt(x, y); rgb_color color = pattern->ColorAt(x, y);
if (*covers) { if (*covers) {
if (*covers == 255) { if (*covers == 255) {
ASSIGN_SUBTRACT(p, color.red, color.green, color.blue); ASSIGN_SUBTRACT(p, color.red, color.green, color.blue);
+11 -47
View File
@@ -159,38 +159,6 @@ PatternHandler::SetPattern(const pattern& pat)
fPattern = pat; fPattern = pat;
} }
/*!
\brief Set the colors for the pattern to use
\param high High color for the handler
\param low Low color for the handler
*/
void
PatternHandler::SetColors(const RGBColor& high, const RGBColor& low)
{
fHighColor = high;
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;
}
/*! /*!
\brief Set the colors for the pattern to use \brief Set the colors for the pattern to use
\param high High color for the handler \param high High color for the handler
@@ -200,6 +168,7 @@ void
PatternHandler::SetColors(const rgb_color& high, const rgb_color& low) PatternHandler::SetColors(const rgb_color& high, const rgb_color& low)
{ {
fHighColor = high; fHighColor = high;
fLowColor = low;
} }
/*! /*!
@@ -227,7 +196,7 @@ PatternHandler::SetLowColor(const rgb_color& color)
\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 rgb_color
PatternHandler::ColorAt(const BPoint &pt) const PatternHandler::ColorAt(const BPoint &pt) const
{ {
return ColorAt(pt.x, pt.y); return ColorAt(pt.x, pt.y);
@@ -239,7 +208,7 @@ PatternHandler::ColorAt(const BPoint &pt) const
\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 rgb_color
PatternHandler::ColorAt(float x, float y) const PatternHandler::ColorAt(float x, float y) const
{ {
return ColorAt(int(x), int(y)); return ColorAt(int(x), int(y));
@@ -272,13 +241,8 @@ PatternHandler::SetOffsets(int32 x, int32 y)
void void
PatternHandler::MakeOpCopyColorCache() PatternHandler::MakeOpCopyColorCache()
{ {
rgb_color highColor = fHighColor.GetColor32(); uint64 t = *(uint32*)&fHighColor;
rgb_color lowColor = fLowColor.GetColor32(); uint64 colors = (t << 32) | *(uint32*)&fLowColor;
uint64 t1 = *(uint32*)&highColor;
uint32 t2 = *(uint32*)&lowColor;
uint64 colors = (t1 << 32) | t2;
if (fColorsWhenCached == colors) if (fColorsWhenCached == colors)
return; return;
@@ -286,13 +250,13 @@ PatternHandler::MakeOpCopyColorCache()
fColorsWhenCached = colors; fColorsWhenCached = colors;
// ramp from low color to high color // ramp from low color to high color
uint8 rA = fLowColor.GetColor32().red; uint8 rA = fLowColor.red;
uint8 gA = fLowColor.GetColor32().green; uint8 gA = fLowColor.green;
uint8 bA = fLowColor.GetColor32().blue; uint8 bA = fLowColor.blue;
uint8 rB = fHighColor.GetColor32().red; uint8 rB = fHighColor.red;
uint8 gB = fHighColor.GetColor32().green; uint8 gB = fHighColor.green;
uint8 bB = fHighColor.GetColor32().blue; uint8 bB = fHighColor.blue;
for (int32 i = 0; i < 256; i++) { for (int32 i = 0; i < 256; i++) {
// NOTE: rgb is twisted around, since this is // NOTE: rgb is twisted around, since this is
+10 -29
View File
@@ -12,7 +12,6 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <GraphicsDefs.h> #include <GraphicsDefs.h>
#include "RGBColor.h"
class Pattern { class Pattern {
public: public:
@@ -95,25 +94,19 @@ class PatternHandler {
void SetPattern(const Pattern& p); void SetPattern(const Pattern& p);
void SetPattern(const pattern& p); void SetPattern(const pattern& p);
void SetColors(const RGBColor& high, const RGBColor& low); void SetColors(const rgb_color& high,
void SetHighColor(const RGBColor& color); const rgb_color& low);
void SetLowColor(const RGBColor& color);
void SetColors(const rgb_color& high, const rgb_color& low);
void SetHighColor(const rgb_color& color); void SetHighColor(const rgb_color& color);
void SetLowColor(const rgb_color& color); void SetLowColor(const rgb_color& color);
rgb_color HighColor() const
RGBColor HighColor() const
{ return fHighColor; } { return fHighColor; }
RGBColor LowColor() const rgb_color LowColor() const
{ return fLowColor; } { return fLowColor; }
RGBColor ColorAt(const BPoint& pt) const; rgb_color ColorAt(const BPoint& pt) const;
RGBColor ColorAt(float x, float y) const; rgb_color ColorAt(float x, float y) const;
inline RGBColor ColorAt(int x, int y) const; inline rgb_color ColorAt(int x, int y) const;
// TODO: any ideas for a better name of the rgb_color version of this function?
inline rgb_color R5ColorAt(int x, int y) const;
bool IsHighColor(const BPoint& pt) const; bool IsHighColor(const BPoint& pt) const;
inline bool IsHighColor(int x, int y) const; inline bool IsHighColor(int x, int y) const;
@@ -137,8 +130,8 @@ class PatternHandler {
private: private:
Pattern fPattern; Pattern fPattern;
RGBColor fHighColor; rgb_color fHighColor;
RGBColor fLowColor; rgb_color fLowColor;
uint16 fXOffset; uint16 fXOffset;
uint16 fYOffset; uint16 fYOffset;
@@ -153,24 +146,12 @@ class PatternHandler {
\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
*/ */
inline RGBColor inline rgb_color
PatternHandler::ColorAt(int x, int y) const PatternHandler::ColorAt(int x, int y) const
{ {
return IsHighColor(x, y) ? fHighColor : fLowColor; return IsHighColor(x, y) ? fHighColor : fLowColor;
} }
/*!
\brief Obtains the color in the pattern at the specified coordinates
\param x X coordinate to get the color for
\param y Y coordinate to get the color for
\return Color for the coordinates
*/
inline rgb_color
PatternHandler::R5ColorAt(int x, int y) const
{
return IsHighColor(x, y) ? fHighColor.GetColor32() : fLowColor.GetColor32();
}
/*! /*!
\brief Obtains the value of the pattern at the specified coordinates \brief Obtains the value of the pattern at the specified coordinates
\param pt Coordinates to get the value for \param pt Coordinates to get the value for