BShape: Style fixes for docs

This commit is contained in:
John Scipione
2014-07-14 19:02:44 -04:00
parent 22da33b202
commit db1ef05aef
3 changed files with 78 additions and 52 deletions
+8 -6
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2006-2007, Haiku, Inc. All rights reserved. * Copyright 2002-2010 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _SHAPE_H #ifndef _SHAPE_H
@@ -8,6 +8,7 @@
#include <Archivable.h> #include <Archivable.h>
class BPoint; class BPoint;
class BRect; class BRect;
class BShape; class BShape;
@@ -25,9 +26,9 @@ public:
virtual status_t IterateMoveTo(BPoint* point); virtual status_t IterateMoveTo(BPoint* point);
virtual status_t IterateLineTo(int32 lineCount, virtual status_t IterateLineTo(int32 lineCount,
BPoint* linePts); BPoint* linePoints);
virtual status_t IterateBezierTo(int32 bezierCount, virtual status_t IterateBezierTo(int32 bezierCount,
BPoint* bezierPts); BPoint* bezierPoints);
virtual status_t IterateClose(); virtual status_t IterateClose();
virtual status_t IterateArcTo(float& rx, float& ry, virtual status_t IterateArcTo(float& rx, float& ry,
@@ -81,7 +82,7 @@ public:
private: private:
// FBC padding // FBC padding
virtual status_t Perform(perform_code code, void* data); virtual status_t Perform(perform_code code, void* data);
virtual void _ReservedShape1(); virtual void _ReservedShape1();
virtual void _ReservedShape2(); virtual void _ReservedShape2();
@@ -96,10 +97,10 @@ private:
friend class BPrivate::ServerLink; friend class BPrivate::ServerLink;
void GetData(int32* opCount, int32* ptCount, void GetData(int32* opCount, int32* ptCount,
uint32** opList, BPoint** ptList); uint32** opList, BPoint** pointsList);
void SetData(int32 opCount, int32 ptCount, void SetData(int32 opCount, int32 ptCount,
const uint32* opList, const uint32* opList,
const BPoint* ptList); const BPoint* pointsList);
void InitData(); void InitData();
bool AllocatePts(int32 count); bool AllocatePts(int32 count);
bool AllocateOps(int32 count); bool AllocateOps(int32 count);
@@ -112,4 +113,5 @@ private:
uint32 reserved[4]; uint32 reserved[4];
}; };
#endif // _SHAPE_H #endif // _SHAPE_H
+7 -5
View File
@@ -1,14 +1,15 @@
/* /*
* Copyright 2003-2010, Haiku. * Copyright 2003-2010 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Adrian Oanca <[email protected]>
* Axel Dörfler, [email protected] * Axel Dörfler, [email protected]
* Adrian Oanca, [email protected]
*/ */
#ifndef SHAPE_PRIVATE_H #ifndef SHAPE_PRIVATE_H
#define SHAPE_PRIVATE_H #define SHAPE_PRIVATE_H
#define OP_LINETO 0x10000000 #define OP_LINETO 0x10000000
#define OP_BEZIERTO 0x20000000 #define OP_BEZIERTO 0x20000000
#define OP_CLOSE 0x40000000 #define OP_CLOSE 0x40000000
@@ -20,12 +21,13 @@
struct shape_data { struct shape_data {
uint32 *opList; uint32* opList;
int32 opCount; int32 opCount;
int32 opSize; int32 opSize;
BPoint *ptList; BPoint* ptList;
int32 ptCount; int32 ptCount;
int32 ptSize; int32 ptSize;
}; };
#endif
#endif // SHAPE_PRIVATE_H
+63 -41
View File
@@ -1,15 +1,14 @@
/* /*
* Copyright (c) 2001-2010, Haiku, Inc. * Copyright 2003-2010 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT license. * Distributed under the terms of the MIT license.
* *
* Authors: * Authors:
* Marc Flerackers ([email protected]) * Stephan Aßmus, [email protected]
* Stephan Aßmus <[email protected]> * Marc Flerackers, [email protected]
* Michael Lotz <[email protected]> * Michael Lotz, [email protected]
* Marcus Overhagen <[email protected]> * Marcus Overhagen, [email protected]
*/ */
/*! BShape encapsulates a Postscript-style "path" */
#include <Shape.h> #include <Shape.h>
@@ -24,6 +23,7 @@
#include <string.h> #include <string.h>
// #pragma mark - BShapeIterator
BShapeIterator::BShapeIterator() BShapeIterator::BShapeIterator()
@@ -45,25 +45,26 @@ BShapeIterator::Iterate(BShape* shape)
for (int32 i = 0; i < data->opCount; i++) { for (int32 i = 0; i < data->opCount; i++) {
int32 op = data->opList[i] & 0xFF000000; int32 op = data->opList[i] & 0xFF000000;
if (op & OP_MOVETO) { if ((op & OP_MOVETO) != 0) {
IterateMoveTo(points); IterateMoveTo(points);
points++; points++;
} }
if (op & OP_LINETO) { if ((op & OP_LINETO) != 0) {
int32 count = data->opList[i] & 0x00FFFFFF; int32 count = data->opList[i] & 0x00FFFFFF;
IterateLineTo(count, points); IterateLineTo(count, points);
points += count; points += count;
} }
if (op & OP_BEZIERTO) { if ((op & OP_BEZIERTO) != 0) {
int32 count = data->opList[i] & 0x00FFFFFF; int32 count = data->opList[i] & 0x00FFFFFF;
IterateBezierTo(count / 3, points); IterateBezierTo(count / 3, points);
points += count; points += count;
} }
if ((op & OP_LARGE_ARC_TO_CW) || (op & OP_LARGE_ARC_TO_CCW) if ((op & OP_LARGE_ARC_TO_CW) != 0 || (op & OP_LARGE_ARC_TO_CCW) != 0
|| (op & OP_SMALL_ARC_TO_CW) || (op & OP_SMALL_ARC_TO_CCW)) { || (op & OP_SMALL_ARC_TO_CW) != 0
|| (op & OP_SMALL_ARC_TO_CCW) != 0) {
int32 count = data->opList[i] & 0x00FFFFFF; int32 count = data->opList[i] & 0x00FFFFFF;
for (int32 i = 0; i < count / 3; i++) { for (int32 i = 0; i < count / 3; i++) {
IterateArcTo(points[0].x, points[0].y, points[1].x, IterateArcTo(points[0].x, points[0].y, points[1].x,
@@ -74,9 +75,8 @@ BShapeIterator::Iterate(BShape* shape)
} }
} }
if (op & OP_CLOSE) { if ((op & OP_CLOSE) != 0)
IterateClose(); IterateClose();
}
} }
return B_OK; return B_OK;
@@ -119,12 +119,15 @@ BShapeIterator::IterateArcTo(float& rx, float& ry, float& angle, bool largeArc,
} }
// #pragma mark - BShapeIterator FBC padding
void BShapeIterator::_ReservedShapeIterator2() {} void BShapeIterator::_ReservedShapeIterator2() {}
void BShapeIterator::_ReservedShapeIterator3() {} void BShapeIterator::_ReservedShapeIterator3() {}
void BShapeIterator::_ReservedShapeIterator4() {} void BShapeIterator::_ReservedShapeIterator4() {}
// #pragma mark - // #pragma mark - BShape
BShape::BShape() BShape::BShape()
@@ -133,15 +136,16 @@ BShape::BShape()
} }
BShape::BShape(const BShape &copyFrom) BShape::BShape(const BShape& other)
{ {
InitData(); InitData();
AddShape(&copyFrom); AddShape(&other);
} }
BShape::BShape(BMessage* archive) BShape::BShape(BMessage* archive)
: BArchivable(archive) :
BArchivable(archive)
{ {
InitData(); InitData();
@@ -156,8 +160,10 @@ BShape::BShape(BMessage* archive)
int32 i = 0; int32 i = 0;
const uint32* opPtr; const uint32* opPtr;
while (archive->FindData("ops", B_INT32_TYPE, i++, (const void**)&opPtr, &size) == B_OK) while (archive->FindData("ops", B_INT32_TYPE, i++,
(const void**)&opPtr, &size) == B_OK) {
data->opList[data->opCount++] = *opPtr; data->opList[data->opCount++] = *opPtr;
}
archive->GetInfo("pts", &type, &count); archive->GetInfo("pts", &type, &count);
if (!AllocatePts(count)) { if (!AllocatePts(count)) {
@@ -167,8 +173,10 @@ BShape::BShape(BMessage* archive)
i = 0; i = 0;
const BPoint* ptPtr; const BPoint* ptPtr;
while (archive->FindData("pts", B_POINT_TYPE, i++, (const void**)&ptPtr, &size) == B_OK) while (archive->FindData("pts", B_POINT_TYPE, i++,
(const void**)&ptPtr, &size) == B_OK) {
data->ptList[data->ptCount++] = *ptPtr; data->ptList[data->ptCount++] = *ptPtr;
}
} }
@@ -186,35 +194,36 @@ BShape::~BShape()
status_t status_t
BShape::Archive(BMessage* archive, bool deep) const BShape::Archive(BMessage* archive, bool deep) const
{ {
status_t err = BArchivable::Archive(archive, deep); status_t result = BArchivable::Archive(archive, deep);
if (err != B_OK) if (result != B_OK)
return err; return result;
shape_data* data = (shape_data*)fPrivateData; shape_data* data = (shape_data*)fPrivateData;
// If no valid shape data, return // If no valid shape data, return
if (data->opCount == 0 || data->ptCount == 0) if (data->opCount == 0 || data->ptCount == 0)
return err; return result;
// Avoids allocation for each point // Avoids allocation for each point
err = archive->AddData("pts", B_POINT_TYPE, data->ptList, sizeof(BPoint), true, result = archive->AddData("pts", B_POINT_TYPE, data->ptList,
data->ptCount); sizeof(BPoint), true, data->ptCount);
if (err != B_OK) if (result != B_OK)
return err; return result;
for (int32 i = 1; i < data->ptCount && err == B_OK; i++) for (int32 i = 1; i < data->ptCount && result == B_OK; i++)
err = archive->AddPoint("pts", data->ptList[i]); result = archive->AddPoint("pts", data->ptList[i]);
// Avoids allocation for each op // Avoids allocation for each op
if (err == B_OK) if (result == B_OK) {
err = archive->AddData("ops", B_INT32_TYPE, data->opList, sizeof(int32), true, result = archive->AddData("ops", B_INT32_TYPE, data->opList,
data->opCount); sizeof(int32), true, data->opCount);
}
for (int32 i = 1; i < data->opCount && err == B_OK ; i++) for (int32 i = 1; i < data->opCount && result == B_OK; i++)
err = archive->AddInt32("ops", data->opList[i]); result = archive->AddInt32("ops", data->opList[i]);
return err; return result;
} }
@@ -251,6 +260,7 @@ BShape::operator==(const BShape& other) const
if (data->opCount != otherData->opCount) if (data->opCount != otherData->opCount)
return false; return false;
if (data->ptCount != otherData->ptCount) if (data->ptCount != otherData->ptCount)
return false; return false;
@@ -310,10 +320,13 @@ BShape::Bounds() const
for (int32 i = 1; i < data->ptCount; i++) { for (int32 i = 1; i < data->ptCount; i++) {
if (bounds.left > data->ptList[i].x) if (bounds.left > data->ptList[i].x)
bounds.left = data->ptList[i].x; bounds.left = data->ptList[i].x;
if (bounds.top > data->ptList[i].y) if (bounds.top > data->ptList[i].y)
bounds.top = data->ptList[i].y; bounds.top = data->ptList[i].y;
if (bounds.right < data->ptList[i].x) if (bounds.right < data->ptList[i].x)
bounds.right = data->ptList[i].x; bounds.right = data->ptList[i].x;
if (bounds.bottom < data->ptList[i].y) if (bounds.bottom < data->ptList[i].y)
bounds.bottom = data->ptList[i].y; bounds.bottom = data->ptList[i].y;
} }
@@ -401,6 +414,7 @@ BShape::LineTo(BPoint point)
} else { } else {
if (!AllocateOps(1)) if (!AllocateOps(1))
return B_NO_MEMORY; return B_NO_MEMORY;
fBuildingOp = OP_LINETO + 1; fBuildingOp = OP_LINETO + 1;
data->opList[data->opCount++] = fBuildingOp; data->opList[data->opCount++] = fBuildingOp;
} }
@@ -483,6 +497,7 @@ BShape::ArcTo(float rx, float ry, float angle, bool largeArc,
} else { } else {
if (!AllocateOps(1)) if (!AllocateOps(1))
return B_NO_MEMORY; return B_NO_MEMORY;
fBuildingOp = op + 3; fBuildingOp = op + 3;
data->opList[data->opCount++] = fBuildingOp; data->opList[data->opCount++] = fBuildingOp;
} }
@@ -523,19 +538,28 @@ BShape::Close()
} }
// #pragma mark - BShape private methods
status_t status_t
BShape::Perform(perform_code d, void* arg) BShape::Perform(perform_code code, void* data)
{ {
return BArchivable::Perform(d, arg); return BArchivable::Perform(code, data);
} }
// #pragma mark - BShape FBC methods
void BShape::_ReservedShape1() {} void BShape::_ReservedShape1() {}
void BShape::_ReservedShape2() {} void BShape::_ReservedShape2() {}
void BShape::_ReservedShape3() {} void BShape::_ReservedShape3() {}
void BShape::_ReservedShape4() {} void BShape::_ReservedShape4() {}
// #pragma mark - BShape private methods
void void
BShape::GetData(int32* opCount, int32* ptCount, uint32** opList, BShape::GetData(int32* opCount, int32* ptCount, uint32** opList,
BPoint** ptList) BPoint** ptList)
@@ -551,7 +575,7 @@ BShape::GetData(int32* opCount, int32* ptCount, uint32** opList,
void void
BShape::SetData(int32 opCount, int32 ptCount, const uint32* opList, BShape::SetData(int32 opCount, int32 ptCount, const uint32* opList,
const BPoint* ptList) const BPoint* ptList)
{ {
Clear(); Clear();
@@ -574,8 +598,6 @@ BShape::SetData(int32 opCount, int32 ptCount, const uint32* opList,
} }
void void
BShape::InitData() BShape::InitData()
{ {
@@ -632,7 +654,7 @@ BShape::AllocatePts(int32 count)
} }
// #pragma mark - binary compatibility // #pragma mark - BShape binary compatibility methods
#if __GNUC__ < 3 #if __GNUC__ < 3