DrawState: Coding style cleanup
This commit is contained in:
@@ -139,55 +139,55 @@ DrawState::ReadFontFromLink(BPrivate::LinkReceiver& link)
|
|||||||
uint16 mask;
|
uint16 mask;
|
||||||
link.Read<uint16>(&mask);
|
link.Read<uint16>(&mask);
|
||||||
|
|
||||||
if (mask & B_FONT_FAMILY_AND_STYLE) {
|
if ((mask & B_FONT_FAMILY_AND_STYLE) != 0) {
|
||||||
uint32 fontID;
|
uint32 fontID;
|
||||||
link.Read<uint32>(&fontID);
|
link.Read<uint32>(&fontID);
|
||||||
fFont.SetFamilyAndStyle(fontID);
|
fFont.SetFamilyAndStyle(fontID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & B_FONT_SIZE) {
|
if ((mask & B_FONT_SIZE) != 0) {
|
||||||
float size;
|
float size;
|
||||||
link.Read<float>(&size);
|
link.Read<float>(&size);
|
||||||
fFont.SetSize(size);
|
fFont.SetSize(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & B_FONT_SHEAR) {
|
if ((mask & B_FONT_SHEAR) != 0) {
|
||||||
float shear;
|
float shear;
|
||||||
link.Read<float>(&shear);
|
link.Read<float>(&shear);
|
||||||
fFont.SetShear(shear);
|
fFont.SetShear(shear);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & B_FONT_ROTATION) {
|
if ((mask & B_FONT_ROTATION) != 0) {
|
||||||
float rotation;
|
float rotation;
|
||||||
link.Read<float>(&rotation);
|
link.Read<float>(&rotation);
|
||||||
fFont.SetRotation(rotation);
|
fFont.SetRotation(rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & B_FONT_FALSE_BOLD_WIDTH) {
|
if ((mask & B_FONT_FALSE_BOLD_WIDTH) != 0) {
|
||||||
float falseBoldWidth;
|
float falseBoldWidth;
|
||||||
link.Read<float>(&falseBoldWidth);
|
link.Read<float>(&falseBoldWidth);
|
||||||
fFont.SetFalseBoldWidth(falseBoldWidth);
|
fFont.SetFalseBoldWidth(falseBoldWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & B_FONT_SPACING) {
|
if ((mask & B_FONT_SPACING) != 0) {
|
||||||
uint8 spacing;
|
uint8 spacing;
|
||||||
link.Read<uint8>(&spacing);
|
link.Read<uint8>(&spacing);
|
||||||
fFont.SetSpacing(spacing);
|
fFont.SetSpacing(spacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & B_FONT_ENCODING) {
|
if ((mask & B_FONT_ENCODING) != 0) {
|
||||||
uint8 encoding;
|
uint8 encoding;
|
||||||
link.Read<uint8>((uint8*)&encoding);
|
link.Read<uint8>((uint8*)&encoding);
|
||||||
fFont.SetEncoding(encoding);
|
fFont.SetEncoding(encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & B_FONT_FACE) {
|
if ((mask & B_FONT_FACE) != 0) {
|
||||||
uint16 face;
|
uint16 face;
|
||||||
link.Read<uint16>(&face);
|
link.Read<uint16>(&face);
|
||||||
fFont.SetFace(face);
|
fFont.SetFace(face);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & B_FONT_FLAGS) {
|
if ((mask & B_FONT_FLAGS) != 0) {
|
||||||
uint32 flags;
|
uint32 flags;
|
||||||
link.Read<uint32>(&flags);
|
link.Read<uint32>(&flags);
|
||||||
fFont.SetFlags(flags);
|
fFont.SetFlags(flags);
|
||||||
@@ -217,7 +217,7 @@ DrawState::ReadFromLink(BPrivate::LinkReceiver& link)
|
|||||||
fAlphaFncMode = info.alphaFunctionMode;
|
fAlphaFncMode = info.alphaFunctionMode;
|
||||||
fFontAliasing = info.fontAntialiasing;
|
fFontAliasing = info.fontAntialiasing;
|
||||||
|
|
||||||
if (fPreviousState) {
|
if (fPreviousState != NULL) {
|
||||||
fCombinedOrigin = fPreviousState->fCombinedOrigin + fOrigin;
|
fCombinedOrigin = fPreviousState->fCombinedOrigin + fOrigin;
|
||||||
fCombinedScale = fPreviousState->fCombinedScale * fScale;
|
fCombinedScale = fPreviousState->fCombinedScale * fScale;
|
||||||
} else {
|
} else {
|
||||||
@@ -284,7 +284,7 @@ DrawState::WriteToLink(BPrivate::LinkSender& link) const
|
|||||||
|
|
||||||
// TODO: Could be optimized, but is low prio, since most views do not
|
// TODO: Could be optimized, but is low prio, since most views do not
|
||||||
// use a custom clipping region...
|
// use a custom clipping region...
|
||||||
if (fClippingRegion) {
|
if (fClippingRegion != NULL) {
|
||||||
int32 clippingRectCount = fClippingRegion->CountRects();
|
int32 clippingRectCount = fClippingRegion->CountRects();
|
||||||
link.Attach<int32>(clippingRectCount);
|
link.Attach<int32>(clippingRectCount);
|
||||||
for (int i = 0; i < clippingRectCount; i++)
|
for (int i = 0; i < clippingRectCount; i++)
|
||||||
@@ -297,13 +297,13 @@ DrawState::WriteToLink(BPrivate::LinkSender& link) const
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DrawState::SetOrigin(const BPoint& origin)
|
DrawState::SetOrigin(BPoint origin)
|
||||||
{
|
{
|
||||||
fOrigin = origin;
|
fOrigin = origin;
|
||||||
|
|
||||||
// NOTE: the origins of earlier states are never expected to
|
// NOTE: the origins of earlier states are never expected to
|
||||||
// change, only the topmost state ever changes
|
// change, only the topmost state ever changes
|
||||||
if (fPreviousState) {
|
if (fPreviousState != NULL) {
|
||||||
fCombinedOrigin.x = fPreviousState->fCombinedOrigin.x
|
fCombinedOrigin.x = fPreviousState->fCombinedOrigin.x
|
||||||
+ fOrigin.x * fPreviousState->fCombinedScale;
|
+ fOrigin.x * fPreviousState->fCombinedScale;
|
||||||
fCombinedOrigin.y = fPreviousState->fCombinedOrigin.y
|
fCombinedOrigin.y = fPreviousState->fCombinedOrigin.y
|
||||||
@@ -322,7 +322,7 @@ DrawState::SetScale(float scale)
|
|||||||
|
|
||||||
// NOTE: the scales of earlier states are never expected to
|
// NOTE: the scales of earlier states are never expected to
|
||||||
// change, only the topmost state ever changes
|
// change, only the topmost state ever changes
|
||||||
if (fPreviousState)
|
if (fPreviousState != NULL)
|
||||||
fCombinedScale = fPreviousState->fCombinedScale * fScale;
|
fCombinedScale = fPreviousState->fCombinedScale * fScale;
|
||||||
else
|
else
|
||||||
fCombinedScale = fScale;
|
fCombinedScale = fScale;
|
||||||
@@ -339,10 +339,10 @@ void
|
|||||||
DrawState::SetClippingRegion(const BRegion* region)
|
DrawState::SetClippingRegion(const BRegion* region)
|
||||||
{
|
{
|
||||||
if (region) {
|
if (region) {
|
||||||
if (fClippingRegion)
|
if (fClippingRegion != NULL)
|
||||||
*fClippingRegion = *region;
|
*fClippingRegion = *region;
|
||||||
else
|
else
|
||||||
fClippingRegion = new (nothrow) BRegion(*region);
|
fClippingRegion = new(nothrow) BRegion(*region);
|
||||||
} else {
|
} else {
|
||||||
delete fClippingRegion;
|
delete fClippingRegion;
|
||||||
fClippingRegion = NULL;
|
fClippingRegion = NULL;
|
||||||
@@ -353,9 +353,9 @@ DrawState::SetClippingRegion(const BRegion* region)
|
|||||||
bool
|
bool
|
||||||
DrawState::HasClipping() const
|
DrawState::HasClipping() const
|
||||||
{
|
{
|
||||||
if (fClippingRegion)
|
if (fClippingRegion != NULL)
|
||||||
return true;
|
return true;
|
||||||
if (fPreviousState)
|
if (fPreviousState != NULL)
|
||||||
return fPreviousState->HasClipping();
|
return fPreviousState->HasClipping();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -371,16 +371,18 @@ DrawState::HasAdditionalClipping() const
|
|||||||
bool
|
bool
|
||||||
DrawState::GetCombinedClippingRegion(BRegion* region) const
|
DrawState::GetCombinedClippingRegion(BRegion* region) const
|
||||||
{
|
{
|
||||||
if (fClippingRegion) {
|
if (fClippingRegion != NULL) {
|
||||||
BRegion localTransformedClipping(*fClippingRegion);
|
BRegion localTransformedClipping(*fClippingRegion);
|
||||||
Transform(&localTransformedClipping);
|
Transform(&localTransformedClipping);
|
||||||
|
|
||||||
if (fPreviousState && fPreviousState->GetCombinedClippingRegion(region))
|
if (fPreviousState != NULL
|
||||||
|
&& fPreviousState->GetCombinedClippingRegion(region)) {
|
||||||
localTransformedClipping.IntersectWith(region);
|
localTransformedClipping.IntersectWith(region);
|
||||||
|
}
|
||||||
*region = localTransformedClipping;
|
*region = localTransformedClipping;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (fPreviousState)
|
if (fPreviousState != NULL)
|
||||||
return fPreviousState->GetCombinedClippingRegion(region);
|
return fPreviousState->GetCombinedClippingRegion(region);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -390,12 +392,8 @@ DrawState::GetCombinedClippingRegion(BRegion* region) const
|
|||||||
void
|
void
|
||||||
DrawState::SetAlphaMask(AlphaMask* mask)
|
DrawState::SetAlphaMask(AlphaMask* mask)
|
||||||
{
|
{
|
||||||
// BeOS compatibility: they implemented ClipToPicture by converting the
|
// NOTE: In BeOS, it wasn't possible to clip to a BPicture and keep
|
||||||
// picture to a complex BRegion and used that as a clipping region. As a
|
// regular custom clipping to a BRegion at the same time.
|
||||||
// result, youcan't have a picture and a region clipping at the same level
|
|
||||||
// (but you can either using PushState/PopState, or using
|
|
||||||
// ConstrainClippingRegion after ClipToPicture...)
|
|
||||||
// SetClippingRegion(NULL);
|
|
||||||
|
|
||||||
delete fAlphaMask;
|
delete fAlphaMask;
|
||||||
fAlphaMask = mask;
|
fAlphaMask = mask;
|
||||||
@@ -497,14 +495,14 @@ DrawState::InverseTransform(BPoint* point) const
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DrawState::SetHighColor(const rgb_color& color)
|
DrawState::SetHighColor(rgb_color color)
|
||||||
{
|
{
|
||||||
fHighColor = color;
|
fHighColor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DrawState::SetLowColor(const rgb_color& color)
|
DrawState::SetLowColor(rgb_color color)
|
||||||
{
|
{
|
||||||
fLowColor = color;
|
fLowColor = color;
|
||||||
}
|
}
|
||||||
@@ -533,19 +531,15 @@ DrawState::SetBlendingMode(source_alpha srcMode, alpha_function fncMode)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DrawState::SetPenLocation(const BPoint& location)
|
DrawState::SetPenLocation(BPoint location)
|
||||||
{
|
{
|
||||||
// TODO: Needs to be in local coordinate system!
|
|
||||||
// There is going to be some work involved in
|
|
||||||
// other parts of app_server...
|
|
||||||
fPenLocation = location;
|
fPenLocation = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const BPoint&
|
BPoint
|
||||||
DrawState::PenLocation() const
|
DrawState::PenLocation() const
|
||||||
{
|
{
|
||||||
// TODO: See above
|
|
||||||
return fPenLocation;
|
return fPenLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -594,30 +588,30 @@ DrawState::SetFont(const ServerFont& font, uint32 flags)
|
|||||||
fFont.SetSize(fUnscaledFontSize * fCombinedScale);
|
fFont.SetSize(fUnscaledFontSize * fCombinedScale);
|
||||||
} else {
|
} else {
|
||||||
// family & style
|
// family & style
|
||||||
if (flags & B_FONT_FAMILY_AND_STYLE)
|
if ((flags & B_FONT_FAMILY_AND_STYLE) != 0)
|
||||||
fFont.SetFamilyAndStyle(font.GetFamilyAndStyle());
|
fFont.SetFamilyAndStyle(font.GetFamilyAndStyle());
|
||||||
// size
|
// size
|
||||||
if (flags & B_FONT_SIZE) {
|
if ((flags & B_FONT_SIZE) != 0) {
|
||||||
fUnscaledFontSize = font.Size();
|
fUnscaledFontSize = font.Size();
|
||||||
fFont.SetSize(fUnscaledFontSize * fCombinedScale);
|
fFont.SetSize(fUnscaledFontSize * fCombinedScale);
|
||||||
}
|
}
|
||||||
// shear
|
// shear
|
||||||
if (flags & B_FONT_SHEAR)
|
if ((flags & B_FONT_SHEAR) != 0)
|
||||||
fFont.SetShear(font.Shear());
|
fFont.SetShear(font.Shear());
|
||||||
// rotation
|
// rotation
|
||||||
if (flags & B_FONT_ROTATION)
|
if ((flags & B_FONT_ROTATION) != 0)
|
||||||
fFont.SetRotation(font.Rotation());
|
fFont.SetRotation(font.Rotation());
|
||||||
// spacing
|
// spacing
|
||||||
if (flags & B_FONT_SPACING)
|
if ((flags & B_FONT_SPACING) != 0)
|
||||||
fFont.SetSpacing(font.Spacing());
|
fFont.SetSpacing(font.Spacing());
|
||||||
// encoding
|
// encoding
|
||||||
if (flags & B_FONT_ENCODING)
|
if ((flags & B_FONT_ENCODING) != 0)
|
||||||
fFont.SetEncoding(font.Encoding());
|
fFont.SetEncoding(font.Encoding());
|
||||||
// face
|
// face
|
||||||
if (flags & B_FONT_FACE)
|
if ((flags & B_FONT_FACE) != 0)
|
||||||
fFont.SetFace(font.Face());
|
fFont.SetFace(font.Face());
|
||||||
// flags
|
// flags
|
||||||
if (flags & B_FONT_FLAGS)
|
if ((flags & B_FONT_FLAGS) != 0)
|
||||||
fFont.SetFlags(font.Flags());
|
fFont.SetFlags(font.Flags());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -680,7 +674,7 @@ DrawState::PrintToStream() const
|
|||||||
printf("\t LineCap: %d\t LineJoin: %d\t MiterLimit: %.2f\n",
|
printf("\t LineCap: %d\t LineJoin: %d\t MiterLimit: %.2f\n",
|
||||||
(int16)fLineCapMode, (int16)fLineJoinMode, fMiterLimit);
|
(int16)fLineCapMode, (int16)fLineJoinMode, fMiterLimit);
|
||||||
|
|
||||||
if (fClippingRegion)
|
if (fClippingRegion != NULL)
|
||||||
fClippingRegion->PrintToStream();
|
fClippingRegion->PrintToStream();
|
||||||
|
|
||||||
printf("\t ===== Font Data =====\n");
|
printf("\t ===== Font Data =====\n");
|
||||||
|
|||||||
@@ -48,10 +48,10 @@ public:
|
|||||||
void WriteToLink(BPrivate::LinkSender& link) const;
|
void WriteToLink(BPrivate::LinkSender& link) const;
|
||||||
|
|
||||||
// coordinate transformation
|
// coordinate transformation
|
||||||
void SetOrigin(const BPoint& origin);
|
void SetOrigin(BPoint origin);
|
||||||
const BPoint& Origin() const
|
BPoint Origin() const
|
||||||
{ return fOrigin; }
|
{ return fOrigin; }
|
||||||
const BPoint& CombinedOrigin() const
|
BPoint CombinedOrigin() const
|
||||||
{ return fCombinedOrigin; }
|
{ return fCombinedOrigin; }
|
||||||
|
|
||||||
void SetScale(float scale);
|
void SetScale(float scale);
|
||||||
@@ -81,12 +81,12 @@ public:
|
|||||||
void InverseTransform(BPoint* point) const;
|
void InverseTransform(BPoint* point) const;
|
||||||
|
|
||||||
// color
|
// color
|
||||||
void SetHighColor(const rgb_color& color);
|
void SetHighColor(rgb_color color);
|
||||||
const rgb_color& HighColor() const
|
rgb_color HighColor() const
|
||||||
{ return fHighColor; }
|
{ return fHighColor; }
|
||||||
|
|
||||||
void SetLowColor(const rgb_color& color);
|
void SetLowColor(rgb_color color);
|
||||||
const rgb_color& LowColor() const
|
rgb_color LowColor() const
|
||||||
{ return fLowColor; }
|
{ return fLowColor; }
|
||||||
|
|
||||||
void SetPattern(const Pattern& pattern);
|
void SetPattern(const Pattern& pattern);
|
||||||
@@ -106,8 +106,8 @@ public:
|
|||||||
{ return fAlphaFncMode; }
|
{ return fAlphaFncMode; }
|
||||||
|
|
||||||
// pen
|
// pen
|
||||||
void SetPenLocation(const BPoint& location);
|
void SetPenLocation(BPoint location);
|
||||||
const BPoint& PenLocation() const;
|
BPoint PenLocation() const;
|
||||||
|
|
||||||
void SetPenSize(float size);
|
void SetPenSize(float size);
|
||||||
float PenSize() const;
|
float PenSize() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user