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:
robertphillips@google.com 2013-03-22 12:25:30 +00:00
Родитель f1b6b0675e
Коммит a3a09ab1d5
3 изменённых файлов: 97 добавлений и 70 удалений

Просмотреть файл

@ -395,7 +395,7 @@ void SkDebugCanvas::drawPicture(SkPicture& picture) {
}
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));
}

Просмотреть файл

@ -113,33 +113,33 @@ void ClipRegion::execute(SkCanvas* canvas) {
}
ClipRect::ClipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
this->fRect = ▭
this->fOp = op;
this->fDoAA = doAA;
this->fDrawType = CLIP_RECT;
fRect = rect;
fOp = op;
fDoAA = doAA;
fDrawType = CLIP_RECT;
this->fInfo.push(SkObjectParser::RectToString(rect));
this->fInfo.push(SkObjectParser::RegionOpToString(op));
this->fInfo.push(SkObjectParser::BoolToString(doAA));
fInfo.push(SkObjectParser::RectToString(rect));
fInfo.push(SkObjectParser::RegionOpToString(op));
fInfo.push(SkObjectParser::BoolToString(doAA));
}
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) {
this->fRRect = rrect;
this->fOp = op;
this->fDoAA = doAA;
this->fDrawType = CLIP_RRECT;
fRRect = rrect;
fOp = op;
fDoAA = doAA;
fDrawType = CLIP_RRECT;
this->fInfo.push(SkObjectParser::RRectToString(rrect));
this->fInfo.push(SkObjectParser::RegionOpToString(op));
this->fInfo.push(SkObjectParser::BoolToString(doAA));
fInfo.push(SkObjectParser::RRectToString(rrect));
fInfo.push(SkObjectParser::RegionOpToString(op));
fInfo.push(SkObjectParser::BoolToString(doAA));
}
void ClipRRect::execute(SkCanvas* canvas) {
canvas->clipRRect(this->fRRect, this->fOp, this->fDoAA);
canvas->clipRRect(fRRect, fOp, fDoAA);
}
Concat::Concat(const SkMatrix& matrix) {
@ -276,27 +276,27 @@ void DrawData::execute(SkCanvas* canvas) {
}
DrawOval::DrawOval(const SkRect& oval, const SkPaint& paint) {
this->fOval = &oval;
this->fPaint = &paint;
this->fDrawType = DRAW_OVAL;
fOval = oval;
fPaint = paint;
fDrawType = DRAW_OVAL;
this->fInfo.push(SkObjectParser::RectToString(oval));
this->fInfo.push(SkObjectParser::PaintToString(paint));
fInfo.push(SkObjectParser::RectToString(oval));
fInfo.push(SkObjectParser::PaintToString(paint));
}
void DrawOval::execute(SkCanvas* canvas) {
canvas->drawOval(*this->fOval, *this->fPaint);
canvas->drawOval(fOval, fPaint);
}
DrawPaint::DrawPaint(const SkPaint& paint) {
this->fPaint = &paint;
this->fDrawType = DRAW_PAINT;
fPaint = paint;
fDrawType = DRAW_PAINT;
this->fInfo.push(SkObjectParser::PaintToString(paint));
fInfo.push(SkObjectParser::PaintToString(paint));
}
void DrawPaint::execute(SkCanvas* canvas) {
canvas->drawPaint(*this->fPaint);
canvas->drawPaint(fPaint);
}
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,
const SkPoint pts[], const SkPaint& paint) {
this->fMode = mode;
this->fCount = count;
this->fPts = pts;
this->fPaint = &paint;
this->fDrawType = DRAW_POINTS;
const SkPoint pts[], const SkPaint& paint) {
fMode = mode;
fCount = count;
fPts = new SkPoint[count];
memcpy(fPts, pts, count * sizeof(SkPoint));
fPaint = paint;
fDrawType = DRAW_POINTS;
this->fInfo.push(SkObjectParser::PointsToString(pts, count));
this->fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar((unsigned int)count),
"Points: "));
this->fInfo.push(SkObjectParser::PointModeToString(mode));
this->fInfo.push(SkObjectParser::PaintToString(paint));
fInfo.push(SkObjectParser::PointsToString(pts, count));
fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar((unsigned int)count),
"Points: "));
fInfo.push(SkObjectParser::PointModeToString(mode));
fInfo.push(SkObjectParser::PaintToString(paint));
}
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[],
const SkPaint& paint) {
this->fText = text;
this->fByteLength = byteLength;
this->fPos = pos;
this->fPaint = &paint;
this->fDrawType = DRAW_POS_TEXT;
const SkPaint& paint) {
size_t numPts = paint.countText(text, byteLength);
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.
this->fInfo.push(SkObjectParser::PointsToString(pos, 1));
this->fInfo.push(SkObjectParser::PaintToString(paint));
fInfo.push(SkObjectParser::PointsToString(pos, 1));
fInfo.push(SkObjectParser::PaintToString(paint));
}
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,
const SkScalar xpos[], SkScalar constY,
const SkPaint& paint) {
fText = text;
size_t numPts = paint.countText(text, byteLength);
fText = new char[byteLength];
memcpy(fText, text, byteLength);
fByteLength = byteLength;
fXpos = xpos;
fXpos = new SkScalar[numPts];
memcpy(fXpos, xpos, numPts * sizeof(SkScalar));
fConstY = constY;
fPaint = paint;
fDrawType = DRAW_POS_TEXT_H;

Просмотреть файл

@ -95,14 +95,16 @@ public:
ClipRect(const SkRect& rect, SkRegion::Op op, bool doAA);
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; }
bool doAA() const { return fDoAA; }
private:
const SkRect* fRect;
SkRect fRect;
SkRegion::Op fOp;
bool fDoAA;
bool fDoAA;
typedef SkDrawCommand INHERITED;
};
class ClipRRect : public SkDrawCommand {
@ -115,9 +117,11 @@ public:
bool doAA() const { return fDoAA; }
private:
SkRRect fRRect;
SkRRect fRRect;
SkRegion::Op fOp;
bool fDoAA;
bool fDoAA;
typedef SkDrawCommand INHERITED;
};
class Concat : public SkDrawCommand {
@ -214,8 +218,10 @@ public:
DrawOval(const SkRect& oval, const SkPaint& paint);
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
const SkRect* fOval;
const SkPaint* fPaint;
SkRect fOval;
SkPaint fPaint;
typedef SkDrawCommand INHERITED;
};
class DrawPaint : public SkDrawCommand {
@ -223,7 +229,9 @@ public:
DrawPaint(const SkPaint& paint);
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
const SkPaint* fPaint;
SkPaint fPaint;
typedef SkDrawCommand INHERITED;
};
class DrawPath : public SkDrawCommand {
@ -251,13 +259,17 @@ private:
class DrawPoints : public SkDrawCommand {
public:
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;
private:
const SkPoint* fPts;
SkCanvas::PointMode fMode;
size_t fCount;
const SkPaint* fPaint;
size_t fCount;
SkPoint* fPts;
SkPaint fPaint;
typedef SkDrawCommand INHERITED;
};
/* TODO(chudy): DrawText is a predefined macro and was breaking something
@ -279,19 +291,20 @@ private:
class DrawPosText : public SkDrawCommand {
public:
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;
private:
const SkPoint* fPos;
const void* fText;
SkPoint* fPos;
char* fText;
size_t fByteLength;
const SkPaint* fPaint;
SkPaint fPaint;
};
class DrawTextOnPath : public SkDrawCommand {
public:
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;
private:
const SkMatrix* fMatrix;
@ -305,10 +318,11 @@ class DrawPosTextH : public SkDrawCommand {
public:
DrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
SkScalar constY, const SkPaint& paint);
virtual ~DrawPosTextH() { delete [] fXpos; delete [] fText; }
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
const SkScalar* fXpos;
const void* fText;
SkScalar* fXpos;
char* fText;
size_t fByteLength;
SkScalar fConstY;
SkPaint fPaint;