BShape: use BShape::Private class to access private methods.
Avoid declaring random friend classes in public header. Allow to access private methods from arbitrary source if needed. Change-Id: Iac2cf0ca59e483aa0657e3fe1fc47080c661cf8b Reviewed-on: https://review.haiku-os.org/c/haiku/+/8534 Reviewed-by: waddlesplash <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
@@ -87,6 +87,8 @@ public:
|
|||||||
const BPoint& point);
|
const BPoint& point);
|
||||||
status_t Close();
|
status_t Close();
|
||||||
|
|
||||||
|
class Private;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// FBC padding
|
// FBC padding
|
||||||
virtual status_t Perform(perform_code code, void* data);
|
virtual status_t Perform(perform_code code, void* data);
|
||||||
@@ -97,17 +99,9 @@ private:
|
|||||||
virtual void _ReservedShape4();
|
virtual void _ReservedShape4();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend class Private;
|
||||||
friend class BShapeIterator;
|
friend class BShapeIterator;
|
||||||
friend class BView;
|
|
||||||
friend class BFont;
|
|
||||||
friend class BPrivate::PicturePlayer;
|
|
||||||
friend class BPrivate::ServerLink;
|
|
||||||
|
|
||||||
void GetData(int32* opCount, int32* ptCount,
|
|
||||||
uint32** opList, BPoint** ptList);
|
|
||||||
void SetData(int32 opCount, int32 ptCount,
|
|
||||||
const uint32* opList,
|
|
||||||
const BPoint* ptList);
|
|
||||||
void InitData();
|
void InitData();
|
||||||
bool AllocatePts(int32 count);
|
bool AllocatePts(int32 count);
|
||||||
bool AllocateOps(int32 count);
|
bool AllocateOps(int32 count);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#ifndef SHAPE_PRIVATE_H
|
#ifndef SHAPE_PRIVATE_H
|
||||||
#define SHAPE_PRIVATE_H
|
#define SHAPE_PRIVATE_H
|
||||||
|
|
||||||
|
#include <Shape.h>
|
||||||
#include <Point.h>
|
#include <Point.h>
|
||||||
#include <Rect.h>
|
#include <Rect.h>
|
||||||
#include <Referenceable.h>
|
#include <Referenceable.h>
|
||||||
@@ -97,4 +98,20 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class BShape::Private {
|
||||||
|
public:
|
||||||
|
Private(BShape& shape) : fShape(shape) {}
|
||||||
|
|
||||||
|
void GetData(int32* opCount, int32* ptCount,
|
||||||
|
uint32** opList, BPoint** ptList);
|
||||||
|
void SetData(int32 opCount, int32 ptCount,
|
||||||
|
const uint32* opList,
|
||||||
|
const BPoint* ptList);
|
||||||
|
shape_data* PrivateData() {return (shape_data*)fShape.fPrivateData;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
BShape& fShape;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // SHAPE_PRIVATE_H
|
#endif // SHAPE_PRIVATE_H
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include <GradientConic.h>
|
#include <GradientConic.h>
|
||||||
#include <Region.h>
|
#include <Region.h>
|
||||||
#include <Shape.h>
|
#include <Shape.h>
|
||||||
|
#include <ShapePrivate.h>
|
||||||
#include <StackOrHeapArray.h>
|
#include <StackOrHeapArray.h>
|
||||||
|
|
||||||
#include <ServerProtocol.h>
|
#include <ServerProtocol.h>
|
||||||
@@ -105,7 +106,7 @@ ServerLink::ReadShape(BShape* shape)
|
|||||||
if (ptCount > 0)
|
if (ptCount > 0)
|
||||||
fReceiver->Read(ptList, ptCount * sizeof(BPoint));
|
fReceiver->Read(ptList, ptCount * sizeof(BPoint));
|
||||||
|
|
||||||
shape->SetData(opCount, ptCount, opList, ptList);
|
BShape::Private(*shape).SetData(opCount, ptCount, opList, ptList);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +118,7 @@ ServerLink::AttachShape(BShape& shape)
|
|||||||
uint32* opList;
|
uint32* opList;
|
||||||
BPoint* ptList;
|
BPoint* ptList;
|
||||||
|
|
||||||
shape.GetData(&opCount, &ptCount, &opList, &ptList);
|
BShape::Private(shape).GetData(&opCount, &ptCount, &opList, &ptList);
|
||||||
|
|
||||||
fSender->Attach(&opCount, sizeof(int32));
|
fSender->Attach(&opCount, sizeof(int32));
|
||||||
fSender->Attach(&ptCount, sizeof(int32));
|
fSender->Attach(&ptCount, sizeof(int32));
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include <Gradient.h>
|
#include <Gradient.h>
|
||||||
#include <PictureProtocol.h>
|
#include <PictureProtocol.h>
|
||||||
#include <Shape.h>
|
#include <Shape.h>
|
||||||
|
#include <ShapePrivate.h>
|
||||||
|
|
||||||
#include <AutoDeleter.h>
|
#include <AutoDeleter.h>
|
||||||
#include <StackOrHeapArray.h>
|
#include <StackOrHeapArray.h>
|
||||||
@@ -1062,7 +1063,7 @@ PicturePlayer::_Play(const picture_player_callbacks& callbacks, void* userData,
|
|||||||
|
|
||||||
// TODO: remove BShape data copying
|
// TODO: remove BShape data copying
|
||||||
BShape shape;
|
BShape shape;
|
||||||
shape.SetData(*opCount, *pointCount, opList, pointList);
|
BShape::Private(shape).SetData(*opCount, *pointCount, opList, pointList);
|
||||||
|
|
||||||
callbacks.draw_shape(userData, shape,
|
callbacks.draw_shape(userData, shape,
|
||||||
header->op == B_PIC_FILL_SHAPE);
|
header->op == B_PIC_FILL_SHAPE);
|
||||||
@@ -1163,7 +1164,7 @@ PicturePlayer::_Play(const picture_player_callbacks& callbacks, void* userData,
|
|||||||
|
|
||||||
// TODO: remove BShape data copying
|
// TODO: remove BShape data copying
|
||||||
BShape shape;
|
BShape shape;
|
||||||
shape.SetData(*opCount, *pointCount, opList, pointList);
|
BShape::Private(shape).SetData(*opCount, *pointCount, opList, pointList);
|
||||||
|
|
||||||
callbacks.draw_shape_gradient(userData, shape, *gradient,
|
callbacks.draw_shape_gradient(userData, shape, *gradient,
|
||||||
header->op == B_PIC_FILL_SHAPE_GRADIENT);
|
header->op == B_PIC_FILL_SHAPE_GRADIENT);
|
||||||
|
|||||||
@@ -571,10 +571,10 @@ void BShape::_ReservedShape4() {}
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BShape::GetData(int32* opCount, int32* ptCount, uint32** opList,
|
BShape::Private::GetData(int32* opCount, int32* ptCount, uint32** opList,
|
||||||
BPoint** ptList)
|
BPoint** ptList)
|
||||||
{
|
{
|
||||||
shape_data* data = (shape_data*)fPrivateData;
|
shape_data* data = PrivateData();
|
||||||
|
|
||||||
*opCount = data->opCount;
|
*opCount = data->opCount;
|
||||||
*ptCount = data->ptCount;
|
*ptCount = data->ptCount;
|
||||||
@@ -584,22 +584,22 @@ BShape::GetData(int32* opCount, int32* ptCount, uint32** opList,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BShape::SetData(int32 opCount, int32 ptCount, const uint32* opList,
|
BShape::Private::SetData(int32 opCount, int32 ptCount, const uint32* opList,
|
||||||
const BPoint* ptList)
|
const BPoint* ptList)
|
||||||
{
|
{
|
||||||
Clear();
|
fShape.Clear();
|
||||||
|
|
||||||
if (opCount == 0)
|
if (opCount == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
shape_data* data = (shape_data*)fPrivateData;
|
shape_data* data = PrivateData();
|
||||||
|
|
||||||
if (!AllocateOps(opCount) || !AllocatePts(ptCount))
|
if (!fShape.AllocateOps(opCount) || !fShape.AllocatePts(ptCount))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
memcpy(data->opList, opList, opCount * sizeof(uint32));
|
memcpy(data->opList, opList, opCount * sizeof(uint32));
|
||||||
data->opCount = opCount;
|
data->opCount = opCount;
|
||||||
fBuildingOp = data->opList[data->opCount - 1];
|
fShape.fBuildingOp = data->opList[data->opCount - 1];
|
||||||
|
|
||||||
if (ptCount > 0) {
|
if (ptCount > 0) {
|
||||||
memcpy((void*)data->ptList, ptList, ptCount * sizeof(BPoint));
|
memcpy((void*)data->ptList, ptList, ptCount * sizeof(BPoint));
|
||||||
|
|||||||
@@ -4067,7 +4067,7 @@ BView::StrokeShape(BShape* shape, ::pattern pattern)
|
|||||||
if (shape == NULL || fOwner == NULL)
|
if (shape == NULL || fOwner == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
shape_data* sd = (shape_data*)shape->fPrivateData;
|
shape_data* sd = BShape::Private(*shape).PrivateData();
|
||||||
if (sd->opCount == 0 || sd->ptCount == 0)
|
if (sd->opCount == 0 || sd->ptCount == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -4088,7 +4088,7 @@ BView::FillShape(BShape* shape, ::pattern pattern)
|
|||||||
if (shape == NULL || fOwner == NULL)
|
if (shape == NULL || fOwner == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
shape_data* sd = (shape_data*)(shape->fPrivateData);
|
shape_data* sd = BShape::Private(*shape).PrivateData();
|
||||||
if (sd->opCount == 0 || sd->ptCount == 0)
|
if (sd->opCount == 0 || sd->ptCount == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -4109,7 +4109,7 @@ BView::FillShape(BShape* shape, const BGradient& gradient)
|
|||||||
if (shape == NULL || fOwner == NULL)
|
if (shape == NULL || fOwner == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
shape_data* sd = (shape_data*)(shape->fPrivateData);
|
shape_data* sd = BShape::Private(*shape).PrivateData();
|
||||||
if (sd->opCount == 0 || sd->ptCount == 0)
|
if (sd->opCount == 0 || sd->ptCount == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -5977,7 +5977,7 @@ BView::_ClipToShape(BShape* shape, bool inverse)
|
|||||||
if (shape == NULL)
|
if (shape == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
shape_data* sd = (shape_data*)shape->fPrivateData;
|
shape_data* sd = BShape::Private(*shape).PrivateData();
|
||||||
if (sd->opCount == 0 || sd->ptCount == 0)
|
if (sd->opCount == 0 || sd->ptCount == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user