зеркало из https://github.com/mozilla/moz-skia.git
More SkDrawCommand cleanup
https://codereview.chromium.org/12979004/ git-svn-id: http://skia.googlecode.com/svn/trunk@8328 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
f1b6b0675e
Коммит
a3a09ab1d5
|
@ -395,7 +395,7 @@ void SkDebugCanvas::drawPicture(SkPicture& picture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkDebugCanvas::drawPoints(PointMode mode, size_t count,
|
void SkDebugCanvas::drawPoints(PointMode mode, size_t count,
|
||||||
const SkPoint pts[], const SkPaint& paint) {
|
const SkPoint pts[], const SkPaint& paint) {
|
||||||
addDrawCommand(new DrawPoints(mode, count, pts, paint));
|
addDrawCommand(new DrawPoints(mode, count, pts, paint));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,33 +113,33 @@ void ClipRegion::execute(SkCanvas* canvas) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ClipRect::ClipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
|
ClipRect::ClipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
|
||||||
this->fRect = ▭
|
fRect = rect;
|
||||||
this->fOp = op;
|
fOp = op;
|
||||||
this->fDoAA = doAA;
|
fDoAA = doAA;
|
||||||
this->fDrawType = CLIP_RECT;
|
fDrawType = CLIP_RECT;
|
||||||
|
|
||||||
this->fInfo.push(SkObjectParser::RectToString(rect));
|
fInfo.push(SkObjectParser::RectToString(rect));
|
||||||
this->fInfo.push(SkObjectParser::RegionOpToString(op));
|
fInfo.push(SkObjectParser::RegionOpToString(op));
|
||||||
this->fInfo.push(SkObjectParser::BoolToString(doAA));
|
fInfo.push(SkObjectParser::BoolToString(doAA));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClipRect::execute(SkCanvas* canvas) {
|
void ClipRect::execute(SkCanvas* canvas) {
|
||||||
canvas->clipRect(*this->fRect, this->fOp, this->fDoAA);
|
canvas->clipRect(fRect, fOp, fDoAA);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClipRRect::ClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
|
ClipRRect::ClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
|
||||||
this->fRRect = rrect;
|
fRRect = rrect;
|
||||||
this->fOp = op;
|
fOp = op;
|
||||||
this->fDoAA = doAA;
|
fDoAA = doAA;
|
||||||
this->fDrawType = CLIP_RRECT;
|
fDrawType = CLIP_RRECT;
|
||||||
|
|
||||||
this->fInfo.push(SkObjectParser::RRectToString(rrect));
|
fInfo.push(SkObjectParser::RRectToString(rrect));
|
||||||
this->fInfo.push(SkObjectParser::RegionOpToString(op));
|
fInfo.push(SkObjectParser::RegionOpToString(op));
|
||||||
this->fInfo.push(SkObjectParser::BoolToString(doAA));
|
fInfo.push(SkObjectParser::BoolToString(doAA));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClipRRect::execute(SkCanvas* canvas) {
|
void ClipRRect::execute(SkCanvas* canvas) {
|
||||||
canvas->clipRRect(this->fRRect, this->fOp, this->fDoAA);
|
canvas->clipRRect(fRRect, fOp, fDoAA);
|
||||||
}
|
}
|
||||||
|
|
||||||
Concat::Concat(const SkMatrix& matrix) {
|
Concat::Concat(const SkMatrix& matrix) {
|
||||||
|
@ -276,27 +276,27 @@ void DrawData::execute(SkCanvas* canvas) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawOval::DrawOval(const SkRect& oval, const SkPaint& paint) {
|
DrawOval::DrawOval(const SkRect& oval, const SkPaint& paint) {
|
||||||
this->fOval = &oval;
|
fOval = oval;
|
||||||
this->fPaint = &paint;
|
fPaint = paint;
|
||||||
this->fDrawType = DRAW_OVAL;
|
fDrawType = DRAW_OVAL;
|
||||||
|
|
||||||
this->fInfo.push(SkObjectParser::RectToString(oval));
|
fInfo.push(SkObjectParser::RectToString(oval));
|
||||||
this->fInfo.push(SkObjectParser::PaintToString(paint));
|
fInfo.push(SkObjectParser::PaintToString(paint));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawOval::execute(SkCanvas* canvas) {
|
void DrawOval::execute(SkCanvas* canvas) {
|
||||||
canvas->drawOval(*this->fOval, *this->fPaint);
|
canvas->drawOval(fOval, fPaint);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawPaint::DrawPaint(const SkPaint& paint) {
|
DrawPaint::DrawPaint(const SkPaint& paint) {
|
||||||
this->fPaint = &paint;
|
fPaint = paint;
|
||||||
this->fDrawType = DRAW_PAINT;
|
fDrawType = DRAW_PAINT;
|
||||||
|
|
||||||
this->fInfo.push(SkObjectParser::PaintToString(paint));
|
fInfo.push(SkObjectParser::PaintToString(paint));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawPaint::execute(SkCanvas* canvas) {
|
void DrawPaint::execute(SkCanvas* canvas) {
|
||||||
canvas->drawPaint(*this->fPaint);
|
canvas->drawPaint(fPaint);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawPath::DrawPath(const SkPath& path, const SkPaint& paint, SkBitmap& bitmap) {
|
DrawPath::DrawPath(const SkPath& path, const SkPaint& paint, SkBitmap& bitmap) {
|
||||||
|
@ -328,49 +328,62 @@ void DrawPicture::execute(SkCanvas* canvas) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawPoints::DrawPoints(SkCanvas::PointMode mode, size_t count,
|
DrawPoints::DrawPoints(SkCanvas::PointMode mode, size_t count,
|
||||||
const SkPoint pts[], const SkPaint& paint) {
|
const SkPoint pts[], const SkPaint& paint) {
|
||||||
this->fMode = mode;
|
fMode = mode;
|
||||||
this->fCount = count;
|
fCount = count;
|
||||||
this->fPts = pts;
|
fPts = new SkPoint[count];
|
||||||
this->fPaint = &paint;
|
memcpy(fPts, pts, count * sizeof(SkPoint));
|
||||||
this->fDrawType = DRAW_POINTS;
|
fPaint = paint;
|
||||||
|
fDrawType = DRAW_POINTS;
|
||||||
|
|
||||||
this->fInfo.push(SkObjectParser::PointsToString(pts, count));
|
fInfo.push(SkObjectParser::PointsToString(pts, count));
|
||||||
this->fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar((unsigned int)count),
|
fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar((unsigned int)count),
|
||||||
"Points: "));
|
"Points: "));
|
||||||
this->fInfo.push(SkObjectParser::PointModeToString(mode));
|
fInfo.push(SkObjectParser::PointModeToString(mode));
|
||||||
this->fInfo.push(SkObjectParser::PaintToString(paint));
|
fInfo.push(SkObjectParser::PaintToString(paint));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawPoints::execute(SkCanvas* canvas) {
|
void DrawPoints::execute(SkCanvas* canvas) {
|
||||||
canvas->drawPoints(this->fMode, this->fCount, this->fPts, *this->fPaint);
|
canvas->drawPoints(fMode, fCount, fPts, fPaint);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawPosText::DrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
|
DrawPosText::DrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
|
||||||
const SkPaint& paint) {
|
const SkPaint& paint) {
|
||||||
this->fText = text;
|
size_t numPts = paint.countText(text, byteLength);
|
||||||
this->fByteLength = byteLength;
|
|
||||||
this->fPos = pos;
|
|
||||||
this->fPaint = &paint;
|
|
||||||
this->fDrawType = DRAW_POS_TEXT;
|
|
||||||
|
|
||||||
this->fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
|
fText = new char[byteLength];
|
||||||
|
memcpy(fText, text, byteLength);
|
||||||
|
fByteLength = byteLength;
|
||||||
|
|
||||||
|
fPos = new SkPoint[numPts];
|
||||||
|
memcpy(fPos, pos, numPts * sizeof(SkPoint));
|
||||||
|
|
||||||
|
fPaint = paint;
|
||||||
|
fDrawType = DRAW_POS_TEXT;
|
||||||
|
|
||||||
|
fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
|
||||||
// TODO(chudy): Test that this works.
|
// TODO(chudy): Test that this works.
|
||||||
this->fInfo.push(SkObjectParser::PointsToString(pos, 1));
|
fInfo.push(SkObjectParser::PointsToString(pos, 1));
|
||||||
this->fInfo.push(SkObjectParser::PaintToString(paint));
|
fInfo.push(SkObjectParser::PaintToString(paint));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawPosText::execute(SkCanvas* canvas) {
|
void DrawPosText::execute(SkCanvas* canvas) {
|
||||||
canvas->drawPosText(this->fText, this->fByteLength, this->fPos, *this->fPaint);
|
canvas->drawPosText(fText, fByteLength, fPos, fPaint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DrawPosTextH::DrawPosTextH(const void* text, size_t byteLength,
|
DrawPosTextH::DrawPosTextH(const void* text, size_t byteLength,
|
||||||
const SkScalar xpos[], SkScalar constY,
|
const SkScalar xpos[], SkScalar constY,
|
||||||
const SkPaint& paint) {
|
const SkPaint& paint) {
|
||||||
fText = text;
|
size_t numPts = paint.countText(text, byteLength);
|
||||||
|
|
||||||
|
fText = new char[byteLength];
|
||||||
|
memcpy(fText, text, byteLength);
|
||||||
fByteLength = byteLength;
|
fByteLength = byteLength;
|
||||||
fXpos = xpos;
|
|
||||||
|
fXpos = new SkScalar[numPts];
|
||||||
|
memcpy(fXpos, xpos, numPts * sizeof(SkScalar));
|
||||||
|
|
||||||
fConstY = constY;
|
fConstY = constY;
|
||||||
fPaint = paint;
|
fPaint = paint;
|
||||||
fDrawType = DRAW_POS_TEXT_H;
|
fDrawType = DRAW_POS_TEXT_H;
|
||||||
|
|
|
@ -95,14 +95,16 @@ public:
|
||||||
ClipRect(const SkRect& rect, SkRegion::Op op, bool doAA);
|
ClipRect(const SkRect& rect, SkRegion::Op op, bool doAA);
|
||||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||||
|
|
||||||
const SkRect& rect() const { return *fRect; }
|
const SkRect& rect() const { return fRect; }
|
||||||
SkRegion::Op op() const { return fOp; }
|
SkRegion::Op op() const { return fOp; }
|
||||||
bool doAA() const { return fDoAA; }
|
bool doAA() const { return fDoAA; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const SkRect* fRect;
|
SkRect fRect;
|
||||||
SkRegion::Op fOp;
|
SkRegion::Op fOp;
|
||||||
bool fDoAA;
|
bool fDoAA;
|
||||||
|
|
||||||
|
typedef SkDrawCommand INHERITED;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ClipRRect : public SkDrawCommand {
|
class ClipRRect : public SkDrawCommand {
|
||||||
|
@ -115,9 +117,11 @@ public:
|
||||||
bool doAA() const { return fDoAA; }
|
bool doAA() const { return fDoAA; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SkRRect fRRect;
|
SkRRect fRRect;
|
||||||
SkRegion::Op fOp;
|
SkRegion::Op fOp;
|
||||||
bool fDoAA;
|
bool fDoAA;
|
||||||
|
|
||||||
|
typedef SkDrawCommand INHERITED;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Concat : public SkDrawCommand {
|
class Concat : public SkDrawCommand {
|
||||||
|
@ -214,8 +218,10 @@ public:
|
||||||
DrawOval(const SkRect& oval, const SkPaint& paint);
|
DrawOval(const SkRect& oval, const SkPaint& paint);
|
||||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||||
private:
|
private:
|
||||||
const SkRect* fOval;
|
SkRect fOval;
|
||||||
const SkPaint* fPaint;
|
SkPaint fPaint;
|
||||||
|
|
||||||
|
typedef SkDrawCommand INHERITED;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DrawPaint : public SkDrawCommand {
|
class DrawPaint : public SkDrawCommand {
|
||||||
|
@ -223,7 +229,9 @@ public:
|
||||||
DrawPaint(const SkPaint& paint);
|
DrawPaint(const SkPaint& paint);
|
||||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||||
private:
|
private:
|
||||||
const SkPaint* fPaint;
|
SkPaint fPaint;
|
||||||
|
|
||||||
|
typedef SkDrawCommand INHERITED;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DrawPath : public SkDrawCommand {
|
class DrawPath : public SkDrawCommand {
|
||||||
|
@ -251,13 +259,17 @@ private:
|
||||||
class DrawPoints : public SkDrawCommand {
|
class DrawPoints : public SkDrawCommand {
|
||||||
public:
|
public:
|
||||||
DrawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
|
DrawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
|
||||||
const SkPaint& paint);
|
const SkPaint& paint);
|
||||||
|
virtual ~DrawPoints() { delete [] fPts; }
|
||||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const SkPoint* fPts;
|
|
||||||
SkCanvas::PointMode fMode;
|
SkCanvas::PointMode fMode;
|
||||||
size_t fCount;
|
size_t fCount;
|
||||||
const SkPaint* fPaint;
|
SkPoint* fPts;
|
||||||
|
SkPaint fPaint;
|
||||||
|
|
||||||
|
typedef SkDrawCommand INHERITED;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* TODO(chudy): DrawText is a predefined macro and was breaking something
|
/* TODO(chudy): DrawText is a predefined macro and was breaking something
|
||||||
|
@ -279,19 +291,20 @@ private:
|
||||||
class DrawPosText : public SkDrawCommand {
|
class DrawPosText : public SkDrawCommand {
|
||||||
public:
|
public:
|
||||||
DrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
|
DrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
|
||||||
const SkPaint& paint);
|
const SkPaint& paint);
|
||||||
|
virtual ~DrawPosText() { delete [] fPos; delete [] fText; }
|
||||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||||
private:
|
private:
|
||||||
const SkPoint* fPos;
|
SkPoint* fPos;
|
||||||
const void* fText;
|
char* fText;
|
||||||
size_t fByteLength;
|
size_t fByteLength;
|
||||||
const SkPaint* fPaint;
|
SkPaint fPaint;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DrawTextOnPath : public SkDrawCommand {
|
class DrawTextOnPath : public SkDrawCommand {
|
||||||
public:
|
public:
|
||||||
DrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
|
DrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
|
||||||
const SkMatrix* matrix, const SkPaint& paint);
|
const SkMatrix* matrix, const SkPaint& paint);
|
||||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||||
private:
|
private:
|
||||||
const SkMatrix* fMatrix;
|
const SkMatrix* fMatrix;
|
||||||
|
@ -305,10 +318,11 @@ class DrawPosTextH : public SkDrawCommand {
|
||||||
public:
|
public:
|
||||||
DrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
|
DrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
|
||||||
SkScalar constY, const SkPaint& paint);
|
SkScalar constY, const SkPaint& paint);
|
||||||
|
virtual ~DrawPosTextH() { delete [] fXpos; delete [] fText; }
|
||||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||||
private:
|
private:
|
||||||
const SkScalar* fXpos;
|
SkScalar* fXpos;
|
||||||
const void* fText;
|
char* fText;
|
||||||
size_t fByteLength;
|
size_t fByteLength;
|
||||||
SkScalar fConstY;
|
SkScalar fConstY;
|
||||||
SkPaint fPaint;
|
SkPaint fPaint;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче