Style fixes.

This commit is contained in:
Adrien Destugues
2014-01-21 13:59:35 +01:00
parent 2585a0c5c9
commit 77bf4d8d51
5 changed files with 173 additions and 167 deletions
+24 -10
View File
@@ -34,22 +34,30 @@ DrawingContext::DrawingContext()
status_t
DrawingContext::InitCheck() const
{
if (fDrawState == NULL)
return B_NO_MEMORY;
return B_OK;
}
void void
DrawingContext::PushState() DrawingContext::PushState()
{ {
DrawState* newState = fDrawState->PushState(); DrawState* newState = fDrawState->PushState();
if (newState) { if (newState)
fDrawState = newState; fDrawState = newState;
}
} }
void void
DrawingContext::PopState() DrawingContext::PopState()
{ {
if (fDrawState->PreviousState() == NULL) { if (fDrawState->PreviousState() == NULL)
return; return;
}
bool rebuildClipping = fDrawState->HasAdditionalClipping(); bool rebuildClipping = fDrawState->HasAdditionalClipping();
@@ -152,7 +160,8 @@ void
DrawingContext::ConvertToScreenForDrawing(BGradient* gradient) const DrawingContext::ConvertToScreenForDrawing(BGradient* gradient) const
{ {
switch(gradient->GetType()) { switch(gradient->GetType()) {
case BGradient::TYPE_LINEAR: { case BGradient::TYPE_LINEAR:
{
BGradientLinear* linear = (BGradientLinear*) gradient; BGradientLinear* linear = (BGradientLinear*) gradient;
BPoint start = linear->Start(); BPoint start = linear->Start();
BPoint end = linear->End(); BPoint end = linear->End();
@@ -165,7 +174,8 @@ DrawingContext::ConvertToScreenForDrawing(BGradient* gradient) const
linear->SortColorStopsByOffset(); linear->SortColorStopsByOffset();
break; break;
} }
case BGradient::TYPE_RADIAL: { case BGradient::TYPE_RADIAL:
{
BGradientRadial* radial = (BGradientRadial*) gradient; BGradientRadial* radial = (BGradientRadial*) gradient;
BPoint center = radial->Center(); BPoint center = radial->Center();
fDrawState->Transform(&center); fDrawState->Transform(&center);
@@ -174,7 +184,8 @@ DrawingContext::ConvertToScreenForDrawing(BGradient* gradient) const
radial->SortColorStopsByOffset(); radial->SortColorStopsByOffset();
break; break;
} }
case BGradient::TYPE_RADIAL_FOCUS: { case BGradient::TYPE_RADIAL_FOCUS:
{
BGradientRadialFocus* radialFocus = (BGradientRadialFocus*) gradient; BGradientRadialFocus* radialFocus = (BGradientRadialFocus*) gradient;
BPoint center = radialFocus->Center(); BPoint center = radialFocus->Center();
BPoint focal = radialFocus->Focal(); BPoint focal = radialFocus->Focal();
@@ -187,7 +198,8 @@ DrawingContext::ConvertToScreenForDrawing(BGradient* gradient) const
radialFocus->SortColorStopsByOffset(); radialFocus->SortColorStopsByOffset();
break; break;
} }
case BGradient::TYPE_DIAMOND: { case BGradient::TYPE_DIAMOND:
{
BGradientDiamond* diamond = (BGradientDiamond*) gradient; BGradientDiamond* diamond = (BGradientDiamond*) gradient;
BPoint center = diamond->Center(); BPoint center = diamond->Center();
fDrawState->Transform(&center); fDrawState->Transform(&center);
@@ -196,7 +208,8 @@ DrawingContext::ConvertToScreenForDrawing(BGradient* gradient) const
diamond->SortColorStopsByOffset(); diamond->SortColorStopsByOffset();
break; break;
} }
case BGradient::TYPE_CONIC: { case BGradient::TYPE_CONIC:
{
BGradientConic* conic = (BGradientConic*) gradient; BGradientConic* conic = (BGradientConic*) gradient;
BPoint center = conic->Center(); BPoint center = conic->Center();
fDrawState->Transform(&center); fDrawState->Transform(&center);
@@ -205,7 +218,8 @@ DrawingContext::ConvertToScreenForDrawing(BGradient* gradient) const
conic->SortColorStopsByOffset(); conic->SortColorStopsByOffset();
break; break;
} }
case BGradient::TYPE_NONE: { case BGradient::TYPE_NONE:
{
break; break;
} }
} }
+3 -2
View File
@@ -10,8 +10,8 @@
* Marcus Overhagen <[email protected]> * Marcus Overhagen <[email protected]>
* Adrien Destugues <[email protected]> * Adrien Destugues <[email protected]>
*/ */
#ifndef DRAWINGCONTEXT_H #ifndef DRAWING_CONTEXT_H
#define DRAWINGCONTEXT_H #define DRAWING_CONTEXT_H
#include <Point.h> #include <Point.h>
@@ -29,6 +29,7 @@ class ServerPicture;
class DrawingContext { class DrawingContext {
public: public:
DrawingContext(); DrawingContext();
status_t InitCheck() const;
virtual void PushState(); virtual void PushState();
virtual void PopState(); virtual void PopState();
+146 -144
View File
@@ -44,7 +44,7 @@ using std::stack;
class ShapePainter : public BShapeIterator { class ShapePainter : public BShapeIterator {
public: public:
ShapePainter(DrawingContext* view); ShapePainter(DrawingContext* context);
virtual ~ShapePainter(); virtual ~ShapePainter();
status_t Iterate(const BShape* shape); status_t Iterate(const BShape* shape);
@@ -59,15 +59,15 @@ public:
void Draw(BRect frame, bool filled); void Draw(BRect frame, bool filled);
private: private:
DrawingContext* fView; DrawingContext* fContext;
stack<uint32> fOpStack; stack<uint32> fOpStack;
stack<BPoint> fPtStack; stack<BPoint> fPtStack;
}; };
ShapePainter::ShapePainter(DrawingContext* view) ShapePainter::ShapePainter(DrawingContext* context)
: :
fView(view) fContext(context)
{ {
} }
@@ -203,10 +203,10 @@ ShapePainter::Draw(BRect frame, bool filled)
fPtStack.pop(); fPtStack.pop();
} }
BPoint offset(fView->CurrentState()->PenLocation()); BPoint offset(fContext->CurrentState()->PenLocation());
fView->ConvertToScreenForDrawing(&offset); fContext->ConvertToScreenForDrawing(&offset);
fView->GetDrawingEngine()->DrawShape(frame, opCount, opList, ptCount, fContext->GetDrawingEngine()->DrawShape(frame, opCount, opList,
ptList, filled, offset, fView->Scale()); ptCount, ptList, filled, offset, fContext->Scale());
delete[] opList; delete[] opList;
delete[] ptList; delete[] ptList;
@@ -253,23 +253,23 @@ nop()
static void static void
move_pen_by(DrawingContext* view, BPoint delta) move_pen_by(DrawingContext* context, BPoint delta)
{ {
view->CurrentState()->SetPenLocation( context->CurrentState()->SetPenLocation(
view->CurrentState()->PenLocation() + delta); context->CurrentState()->PenLocation() + delta);
} }
static void static void
stroke_line(DrawingContext* view, BPoint start, BPoint end) stroke_line(DrawingContext* context, BPoint start, BPoint end)
{ {
BPoint penPos = end; BPoint penPos = end;
view->ConvertToScreenForDrawing(&start); context->ConvertToScreenForDrawing(&start);
view->ConvertToScreenForDrawing(&end); context->ConvertToScreenForDrawing(&end);
view->GetDrawingEngine()->StrokeLine(start, end); context->GetDrawingEngine()->StrokeLine(start, end);
view->CurrentState()->SetPenLocation(penPos); context->CurrentState()->SetPenLocation(penPos);
// the DrawingEngine/Painter does not need to be updated, since this // the DrawingEngine/Painter does not need to be updated, since this
// effects only the view->screen coord conversion, which is handled // effects only the view->screen coord conversion, which is handled
// by the view only // by the view only
@@ -277,104 +277,103 @@ stroke_line(DrawingContext* view, BPoint start, BPoint end)
static void static void
stroke_rect(DrawingContext* view, BRect rect) stroke_rect(DrawingContext* context, BRect rect)
{ {
view->ConvertToScreenForDrawing(&rect); context->ConvertToScreenForDrawing(&rect);
view->GetDrawingEngine()->StrokeRect(rect); context->GetDrawingEngine()->StrokeRect(rect);
} }
static void static void
fill_rect(DrawingContext* view, BRect rect) fill_rect(DrawingContext* context, BRect rect)
{ {
view->ConvertToScreenForDrawing(&rect); context->ConvertToScreenForDrawing(&rect);
view->GetDrawingEngine()->FillRect(rect); context->GetDrawingEngine()->FillRect(rect);
} }
static void static void
stroke_round_rect(DrawingContext* view, BRect rect, BPoint radii) stroke_round_rect(DrawingContext* context, BRect rect, BPoint radii)
{ {
view->ConvertToScreenForDrawing(&rect); context->ConvertToScreenForDrawing(&rect);
view->GetDrawingEngine()->DrawRoundRect(rect, radii.x, context->GetDrawingEngine()->DrawRoundRect(rect, radii.x,
radii.y, false); radii.y, false);
} }
static void static void
fill_round_rect(DrawingContext* view, BRect rect, BPoint radii) fill_round_rect(DrawingContext* context, BRect rect, BPoint radii)
{ {
view->ConvertToScreenForDrawing(&rect); context->ConvertToScreenForDrawing(&rect);
view->GetDrawingEngine()->DrawRoundRect(rect, radii.x, radii.y, true); context->GetDrawingEngine()->DrawRoundRect(rect, radii.x, radii.y, true);
} }
static void static void
stroke_bezier(DrawingContext* view, const BPoint* viewPoints) stroke_bezier(DrawingContext* context, const BPoint* viewPoints)
{ {
BPoint points[4]; BPoint points[4];
view->ConvertToScreenForDrawing(points, viewPoints, 4); context->ConvertToScreenForDrawing(points, viewPoints, 4);
view->GetDrawingEngine()->DrawBezier(points, false); context->GetDrawingEngine()->DrawBezier(points, false);
} }
static void static void
fill_bezier(DrawingContext* view, const BPoint* viewPoints) fill_bezier(DrawingContext* context, const BPoint* viewPoints)
{ {
BPoint points[4]; BPoint points[4];
view->ConvertToScreenForDrawing(points, viewPoints, 4); context->ConvertToScreenForDrawing(points, viewPoints, 4);
view->GetDrawingEngine()->DrawBezier(points, true); context->GetDrawingEngine()->DrawBezier(points, true);
} }
static void static void
stroke_arc(DrawingContext* view, BPoint center, BPoint radii, float startTheta, stroke_arc(DrawingContext* context, BPoint center, BPoint radii,
float arcTheta) float startTheta, float arcTheta)
{ {
BRect rect(center.x - radii.x, center.y - radii.y, BRect rect(center.x - radii.x, center.y - radii.y,
center.x + radii.x - 1, center.y + radii.y - 1); center.x + radii.x - 1, center.y + radii.y - 1);
view->ConvertToScreenForDrawing(&rect); context->ConvertToScreenForDrawing(&rect);
view->GetDrawingEngine()->DrawArc(rect, startTheta, arcTheta, false); context->GetDrawingEngine()->DrawArc(rect, startTheta, arcTheta, false);
} }
static void static void
fill_arc(DrawingContext* view, BPoint center, BPoint radii, float startTheta, fill_arc(DrawingContext* context, BPoint center, BPoint radii,
float arcTheta) float startTheta, float arcTheta)
{ {
BRect rect(center.x - radii.x, center.y - radii.y, BRect rect(center.x - radii.x, center.y - radii.y,
center.x + radii.x - 1, center.y + radii.y - 1); center.x + radii.x - 1, center.y + radii.y - 1);
view->ConvertToScreenForDrawing(&rect); context->ConvertToScreenForDrawing(&rect);
view->GetDrawingEngine()->DrawArc(rect, startTheta, context->GetDrawingEngine()->DrawArc(rect, startTheta, arcTheta, true);
arcTheta, true);
} }
static void static void
stroke_ellipse(DrawingContext* view, BPoint center, BPoint radii) stroke_ellipse(DrawingContext* context, BPoint center, BPoint radii)
{ {
BRect rect(center.x - radii.x, center.y - radii.y, BRect rect(center.x - radii.x, center.y - radii.y,
center.x + radii.x - 1, center.y + radii.y - 1); center.x + radii.x - 1, center.y + radii.y - 1);
view->ConvertToScreenForDrawing(&rect); context->ConvertToScreenForDrawing(&rect);
view->GetDrawingEngine()->DrawEllipse(rect, false); context->GetDrawingEngine()->DrawEllipse(rect, false);
} }
static void static void
fill_ellipse(DrawingContext* view, BPoint center, BPoint radii) fill_ellipse(DrawingContext* context, BPoint center, BPoint radii)
{ {
BRect rect(center.x - radii.x, center.y - radii.y, BRect rect(center.x - radii.x, center.y - radii.y,
center.x + radii.x - 1, center.y + radii.y - 1); center.x + radii.x - 1, center.y + radii.y - 1);
view->ConvertToScreenForDrawing(&rect); context->ConvertToScreenForDrawing(&rect);
view->GetDrawingEngine()->DrawEllipse(rect, true); context->GetDrawingEngine()->DrawEllipse(rect, true);
} }
static void static void
stroke_polygon(DrawingContext* view, int32 numPoints, const BPoint* viewPoints, stroke_polygon(DrawingContext* context, int32 numPoints,
bool isClosed) const BPoint* viewPoints, bool isClosed)
{ {
if (numPoints <= 0) if (numPoints <= 0)
return; return;
@@ -385,12 +384,12 @@ stroke_polygon(DrawingContext* view, int32 numPoints, const BPoint* viewPoints,
char data[200 * sizeof(BPoint)]; char data[200 * sizeof(BPoint)];
BPoint* points = (BPoint*)data; BPoint* points = (BPoint*)data;
view->ConvertToScreenForDrawing(points, viewPoints, numPoints); context->ConvertToScreenForDrawing(points, viewPoints, numPoints);
BRect polyFrame; BRect polyFrame;
get_polygon_frame(points, numPoints, &polyFrame); get_polygon_frame(points, numPoints, &polyFrame);
view->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame, context->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame,
false, isClosed && numPoints > 2); false, isClosed && numPoints > 2);
} else { } else {
// avoid constructor/destructor calls by // avoid constructor/destructor calls by
@@ -399,12 +398,12 @@ stroke_polygon(DrawingContext* view, int32 numPoints, const BPoint* viewPoints,
if (points == NULL) if (points == NULL)
return; return;
view->ConvertToScreenForDrawing(points, viewPoints, numPoints); context->ConvertToScreenForDrawing(points, viewPoints, numPoints);
BRect polyFrame; BRect polyFrame;
get_polygon_frame(points, numPoints, &polyFrame); get_polygon_frame(points, numPoints, &polyFrame);
view->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame, context->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame,
false, isClosed && numPoints > 2); false, isClosed && numPoints > 2);
free(points); free(points);
} }
@@ -412,7 +411,8 @@ stroke_polygon(DrawingContext* view, int32 numPoints, const BPoint* viewPoints,
static void static void
fill_polygon(DrawingContext* view, int32 numPoints, const BPoint* viewPoints) fill_polygon(DrawingContext* context, int32 numPoints,
const BPoint* viewPoints)
{ {
if (numPoints <= 0) if (numPoints <= 0)
return; return;
@@ -423,12 +423,12 @@ fill_polygon(DrawingContext* view, int32 numPoints, const BPoint* viewPoints)
char data[200 * sizeof(BPoint)]; char data[200 * sizeof(BPoint)];
BPoint* points = (BPoint*)data; BPoint* points = (BPoint*)data;
view->ConvertToScreenForDrawing(points, viewPoints, numPoints); context->ConvertToScreenForDrawing(points, viewPoints, numPoints);
BRect polyFrame; BRect polyFrame;
get_polygon_frame(points, numPoints, &polyFrame); get_polygon_frame(points, numPoints, &polyFrame);
view->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame, context->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame,
true, true); true, true);
} else { } else {
// avoid constructor/destructor calls by // avoid constructor/destructor calls by
@@ -437,12 +437,12 @@ fill_polygon(DrawingContext* view, int32 numPoints, const BPoint* viewPoints)
if (points == NULL) if (points == NULL)
return; return;
view->ConvertToScreenForDrawing(points, viewPoints, numPoints); context->ConvertToScreenForDrawing(points, viewPoints, numPoints);
BRect polyFrame; BRect polyFrame;
get_polygon_frame(points, numPoints, &polyFrame); get_polygon_frame(points, numPoints, &polyFrame);
view->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame, context->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame,
true, true); true, true);
free(points); free(points);
} }
@@ -450,9 +450,9 @@ fill_polygon(DrawingContext* view, int32 numPoints, const BPoint* viewPoints)
static void static void
stroke_shape(DrawingContext* view, const BShape* shape) stroke_shape(DrawingContext* context, const BShape* shape)
{ {
ShapePainter drawShape(view); ShapePainter drawShape(context);
drawShape.Iterate(shape); drawShape.Iterate(shape);
drawShape.Draw(shape->Bounds(), false); drawShape.Draw(shape->Bounds(), false);
@@ -460,9 +460,9 @@ stroke_shape(DrawingContext* view, const BShape* shape)
static void static void
fill_shape(DrawingContext* view, const BShape* shape) fill_shape(DrawingContext* context, const BShape* shape)
{ {
ShapePainter drawShape(view); ShapePainter drawShape(context);
drawShape.Iterate(shape); drawShape.Iterate(shape);
drawShape.Draw(shape->Bounds(), true); drawShape.Draw(shape->Bounds(), true);
@@ -470,21 +470,21 @@ fill_shape(DrawingContext* view, const BShape* shape)
static void static void
draw_string(DrawingContext* view, const char* string, float deltaSpace, draw_string(DrawingContext* context, const char* string, float deltaSpace,
float deltaNonSpace) float deltaNonSpace)
{ {
// NOTE: the picture data was recorded with a "set pen location" // NOTE: the picture data was recorded with a "set pen location"
// command inserted before the "draw string" command, so we can // command inserted before the "draw string" command, so we can
// use PenLocation() // use PenLocation()
BPoint location = view->CurrentState()->PenLocation(); BPoint location = context->CurrentState()->PenLocation();
escapement_delta delta = {deltaSpace, deltaNonSpace }; escapement_delta delta = {deltaSpace, deltaNonSpace };
view->ConvertToScreenForDrawing(&location); context->ConvertToScreenForDrawing(&location);
view->GetDrawingEngine()->DrawString(string, strlen(string), location, context->GetDrawingEngine()->DrawString(string, strlen(string), location,
&delta); &delta);
view->ConvertFromScreenForDrawing(&location); context->ConvertFromScreenForDrawing(&location);
view->CurrentState()->SetPenLocation(location); context->CurrentState()->SetPenLocation(location);
// the DrawingEngine/Painter does not need to be updated, since this // the DrawingEngine/Painter does not need to be updated, since this
// effects only the view->screen coord conversion, which is handled // effects only the view->screen coord conversion, which is handled
// by the view only // by the view only
@@ -492,7 +492,7 @@ draw_string(DrawingContext* view, const char* string, float deltaSpace,
static void static void
draw_pixels(DrawingContext* view, BRect src, BRect dest, int32 width, draw_pixels(DrawingContext* context, BRect src, BRect dest, int32 width,
int32 height, int32 bytesPerRow, int32 pixelFormat, int32 options, int32 height, int32 bytesPerRow, int32 pixelFormat, int32 options,
const void* data) const void* data)
{ {
@@ -504,44 +504,45 @@ draw_pixels(DrawingContext* view, BRect src, BRect dest, int32 width,
memcpy(bitmap.Bits(), data, height * bytesPerRow); memcpy(bitmap.Bits(), data, height * bytesPerRow);
view->ConvertToScreenForDrawing(&dest); context->ConvertToScreenForDrawing(&dest);
view->GetDrawingEngine()->DrawBitmap(&bitmap, src, dest, options); context->GetDrawingEngine()->DrawBitmap(&bitmap, src, dest, options);
} }
static void static void
draw_picture(DrawingContext* view, BPoint where, int32 token) draw_picture(DrawingContext* context, BPoint where, int32 token)
{ {
ServerPicture* picture = view->GetPicture(token); ServerPicture* picture = context->GetPicture(token);
if (picture != NULL) { if (picture != NULL) {
view->PushState(); context->PushState();
view->SetDrawingOrigin(where); context->SetDrawingOrigin(where);
view->PushState(); context->PushState();
picture->Play(view); picture->Play(context);
view->PopState(); context->PopState();
view->PopState(); context->PopState();
picture->ReleaseReference(); picture->ReleaseReference();
} }
} }
static void static void
set_clipping_rects(DrawingContext* view, const BRect* rects, uint32 numRects) set_clipping_rects(DrawingContext* context, const BRect* rects,
uint32 numRects)
{ {
// TODO: This might be too slow, we should copy the rects // TODO: This might be too slow, we should copy the rects
// directly to BRegion's internal data // directly to BRegion's internal data
BRegion region; BRegion region;
for (uint32 c = 0; c < numRects; c++) for (uint32 c = 0; c < numRects; c++)
region.Include(rects[c]); region.Include(rects[c]);
view->SetUserClipping(&region); context->SetUserClipping(&region);
view->UpdateCurrentDrawingRegion(); context->UpdateCurrentDrawingRegion();
} }
static void static void
clip_to_picture(DrawingContext* view, BPicture* picture, BPoint pt, clip_to_picture(DrawingContext* context, BPicture* picture, BPoint pt,
bool clipToInverse) bool clipToInverse)
{ {
printf("ClipToPicture(picture, BPoint(%.2f, %.2f), %s)\n", printf("ClipToPicture(picture, BPoint(%.2f, %.2f), %s)\n",
@@ -550,63 +551,63 @@ clip_to_picture(DrawingContext* view, BPicture* picture, BPoint pt,
static void static void
push_state(DrawingContext* view) push_state(DrawingContext* context)
{ {
view->PushState(); context->PushState();
} }
static void static void
pop_state(DrawingContext* view) pop_state(DrawingContext* context)
{ {
view->PopState(); context->PopState();
BPoint p(0, 0); BPoint p(0, 0);
view->ConvertToScreenForDrawing(&p); context->ConvertToScreenForDrawing(&p);
view->GetDrawingEngine()->SetDrawState(view->CurrentState(), (int32)p.x, context->GetDrawingEngine()->SetDrawState(context->CurrentState(),
(int32)p.y); (int32)p.x, (int32)p.y);
} }
// TODO: Be smart and actually take advantage of these methods: // TODO: Be smart and actually take advantage of these methods:
// only apply state changes when they are called // only apply state changes when they are called
static void static void
enter_state_change(DrawingContext* view) enter_state_change(DrawingContext* context)
{ {
} }
static void static void
exit_state_change(DrawingContext* view) exit_state_change(DrawingContext* context)
{ {
view->ResyncDrawState(); context->ResyncDrawState();
} }
static void static void
enter_font_state(DrawingContext* view) enter_font_state(DrawingContext* context)
{ {
} }
static void static void
exit_font_state(DrawingContext* view) exit_font_state(DrawingContext* context)
{ {
view->GetDrawingEngine()->SetFont(view->CurrentState()->Font()); context->GetDrawingEngine()->SetFont(context->CurrentState()->Font());
} }
static void static void
set_origin(DrawingContext* view, BPoint pt) set_origin(DrawingContext* context, BPoint pt)
{ {
view->CurrentState()->SetOrigin(pt); context->CurrentState()->SetOrigin(pt);
} }
static void static void
set_pen_location(DrawingContext* view, BPoint pt) set_pen_location(DrawingContext* context, BPoint pt)
{ {
view->CurrentState()->SetPenLocation(pt); context->CurrentState()->SetPenLocation(pt);
// the DrawingEngine/Painter does not need to be updated, since this // the DrawingEngine/Painter does not need to be updated, since this
// effects only the view->screen coord conversion, which is handled // effects only the view->screen coord conversion, which is handled
// by the view only // by the view only
@@ -614,64 +615,65 @@ set_pen_location(DrawingContext* view, BPoint pt)
static void static void
set_drawing_mode(DrawingContext* view, drawing_mode mode) set_drawing_mode(DrawingContext* context, drawing_mode mode)
{ {
view->CurrentState()->SetDrawingMode(mode); context->CurrentState()->SetDrawingMode(mode);
view->GetDrawingEngine()->SetDrawingMode(mode); context->GetDrawingEngine()->SetDrawingMode(mode);
} }
static void static void
set_line_mode(DrawingContext* view, cap_mode capMode, join_mode joinMode, set_line_mode(DrawingContext* context, cap_mode capMode, join_mode joinMode,
float miterLimit) float miterLimit)
{ {
DrawState* state = view->CurrentState(); DrawState* state = context->CurrentState();
state->SetLineCapMode(capMode); state->SetLineCapMode(capMode);
state->SetLineJoinMode(joinMode); state->SetLineJoinMode(joinMode);
state->SetMiterLimit(miterLimit); state->SetMiterLimit(miterLimit);
view->GetDrawingEngine()->SetStrokeMode(capMode, joinMode, miterLimit); context->GetDrawingEngine()->SetStrokeMode(capMode, joinMode, miterLimit);
} }
static void static void
set_pen_size(DrawingContext* view, float size) set_pen_size(DrawingContext* context, float size)
{ {
view->CurrentState()->SetPenSize(size); context->CurrentState()->SetPenSize(size);
view->GetDrawingEngine()->SetPenSize(view->CurrentState()->PenSize()); context->GetDrawingEngine()->SetPenSize(
context->CurrentState()->PenSize());
// DrawState::PenSize() returns the scaled pen size, so we // DrawState::PenSize() returns the scaled pen size, so we
// need to use that value to set the drawing engine pen size. // need to use that value to set the drawing engine pen size.
} }
static void static void
set_fore_color(DrawingContext* view, rgb_color color) set_fore_color(DrawingContext* context, rgb_color color)
{ {
view->CurrentState()->SetHighColor(color); context->CurrentState()->SetHighColor(color);
view->GetDrawingEngine()->SetHighColor(color); context->GetDrawingEngine()->SetHighColor(color);
} }
static void static void
set_back_color(DrawingContext* view, rgb_color color) set_back_color(DrawingContext* context, rgb_color color)
{ {
view->CurrentState()->SetLowColor(color); context->CurrentState()->SetLowColor(color);
view->GetDrawingEngine()->SetLowColor(color); context->GetDrawingEngine()->SetLowColor(color);
} }
static void static void
set_stipple_pattern(DrawingContext* view, pattern p) set_stipple_pattern(DrawingContext* context, pattern p)
{ {
view->CurrentState()->SetPattern(Pattern(p)); context->CurrentState()->SetPattern(Pattern(p));
view->GetDrawingEngine()->SetPattern(p); context->GetDrawingEngine()->SetPattern(p);
} }
static void static void
set_scale(DrawingContext* view, float scale) set_scale(DrawingContext* context, float scale)
{ {
view->CurrentState()->SetScale(scale); context->CurrentState()->SetScale(scale);
view->ResyncDrawState(); context->ResyncDrawState();
// Update the drawing engine draw state, since some stuff // Update the drawing engine draw state, since some stuff
// (for example the pen size) needs to be recalculated. // (for example the pen size) needs to be recalculated.
@@ -679,94 +681,94 @@ set_scale(DrawingContext* view, float scale)
static void static void
set_font_family(DrawingContext* view, const char* family) set_font_family(DrawingContext* context, const char* family)
{ {
FontStyle* fontStyle = gFontManager->GetStyleByIndex(family, 0); FontStyle* fontStyle = gFontManager->GetStyleByIndex(family, 0);
ServerFont font; ServerFont font;
font.SetStyle(fontStyle); font.SetStyle(fontStyle);
view->CurrentState()->SetFont(font, B_FONT_FAMILY_AND_STYLE); context->CurrentState()->SetFont(font, B_FONT_FAMILY_AND_STYLE);
} }
static void static void
set_font_style(DrawingContext* view, const char* style) set_font_style(DrawingContext* context, const char* style)
{ {
ServerFont font(view->CurrentState()->Font()); ServerFont font(context->CurrentState()->Font());
FontStyle* fontStyle = gFontManager->GetStyle(font.Family(), style); FontStyle* fontStyle = gFontManager->GetStyle(font.Family(), style);
font.SetStyle(fontStyle); font.SetStyle(fontStyle);
view->CurrentState()->SetFont(font, B_FONT_FAMILY_AND_STYLE); context->CurrentState()->SetFont(font, B_FONT_FAMILY_AND_STYLE);
} }
static void static void
set_font_spacing(DrawingContext* view, int32 spacing) set_font_spacing(DrawingContext* context, int32 spacing)
{ {
ServerFont font; ServerFont font;
font.SetSpacing(spacing); font.SetSpacing(spacing);
view->CurrentState()->SetFont(font, B_FONT_SPACING); context->CurrentState()->SetFont(font, B_FONT_SPACING);
} }
static void static void
set_font_size(DrawingContext* view, float size) set_font_size(DrawingContext* context, float size)
{ {
ServerFont font; ServerFont font;
font.SetSize(size); font.SetSize(size);
view->CurrentState()->SetFont(font, B_FONT_SIZE); context->CurrentState()->SetFont(font, B_FONT_SIZE);
} }
static void static void
set_font_rotate(DrawingContext* view, float rotation) set_font_rotate(DrawingContext* context, float rotation)
{ {
ServerFont font; ServerFont font;
font.SetRotation(rotation); font.SetRotation(rotation);
view->CurrentState()->SetFont(font, B_FONT_ROTATION); context->CurrentState()->SetFont(font, B_FONT_ROTATION);
} }
static void static void
set_font_encoding(DrawingContext* view, int32 encoding) set_font_encoding(DrawingContext* context, int32 encoding)
{ {
ServerFont font; ServerFont font;
font.SetEncoding(encoding); font.SetEncoding(encoding);
view->CurrentState()->SetFont(font, B_FONT_ENCODING); context->CurrentState()->SetFont(font, B_FONT_ENCODING);
} }
static void static void
set_font_flags(DrawingContext* view, int32 flags) set_font_flags(DrawingContext* context, int32 flags)
{ {
ServerFont font; ServerFont font;
font.SetFlags(flags); font.SetFlags(flags);
view->CurrentState()->SetFont(font, B_FONT_FLAGS); context->CurrentState()->SetFont(font, B_FONT_FLAGS);
} }
static void static void
set_font_shear(DrawingContext* view, float shear) set_font_shear(DrawingContext* context, float shear)
{ {
ServerFont font; ServerFont font;
font.SetShear(shear); font.SetShear(shear);
view->CurrentState()->SetFont(font, B_FONT_SHEAR); context->CurrentState()->SetFont(font, B_FONT_SHEAR);
} }
static void static void
set_font_face(DrawingContext* view, int32 face) set_font_face(DrawingContext* context, int32 face)
{ {
ServerFont font; ServerFont font;
font.SetFace(face); font.SetFace(face);
view->CurrentState()->SetFont(font, B_FONT_FACE); context->CurrentState()->SetFont(font, B_FONT_FACE);
} }
static void static void
set_blending_mode(DrawingContext* view, int16 alphaSrcMode, int16 alphaFncMode) set_blending_mode(DrawingContext* context, int16 alphaSrcMode, int16 alphaFncMode)
{ {
view->CurrentState()->SetBlendingMode((source_alpha)alphaSrcMode, context->CurrentState()->SetBlendingMode((source_alpha)alphaSrcMode,
(alpha_function)alphaFncMode); (alpha_function)alphaFncMode);
} }
-10
View File
@@ -150,16 +150,6 @@ View::~View()
} }
status_t
View::InitCheck() const
{
if (fDrawState == NULL)
return B_NO_MEMORY;
return B_OK;
}
IntRect IntRect
View::Bounds() const View::Bounds() const
{ {
-1
View File
@@ -43,7 +43,6 @@ class View: public DrawingContext {
const char* name, int32 token, const char* name, int32 token,
uint32 resizeMode, uint32 flags); uint32 resizeMode, uint32 flags);
virtual ~View(); virtual ~View();
status_t InitCheck() const;
int32 Token() const int32 Token() const
{ return fToken; } { return fToken; }