const SkTDArray<SkDrawCommand*>& commands = this->getDrawCommands();
SkTDArray<int> counts;
- counts.setCount(LAST_DRAWTYPE_ENUM+1);
- for (int i = 0; i < LAST_DRAWTYPE_ENUM+1; ++i) {
+ counts.setCount(SkDrawCommand::kOpTypeCount);
+ for (int i = 0; i < SkDrawCommand::kOpTypeCount; ++i) {
counts[i] = 0;
}
#ifdef SK_DEBUG
double totPercent = 0, tempSum = 0;
#endif
- for (int i = 0; i < LAST_DRAWTYPE_ENUM+1; ++i) {
+ for (int i = 0; i < SkDrawCommand::kOpTypeCount; ++i) {
if (0 == counts[i]) {
// if there were no commands of this type then they should've consumed no time
SkASSERT(NULL == typeTimes || 0.0 == (*typeTimes)[i]);
continue;
}
- overview->append(SkDrawCommand::GetCommandString((DrawType) i));
+ overview->append(SkDrawCommand::GetCommandString((SkDrawCommand::OpType) i));
overview->append(": ");
overview->appendS32(counts[i]);
if (typeTimes && totTime >= 0.0) {
}
void SkDebugCanvas::didConcat(const SkMatrix& matrix) {
- switch (matrix.getType()) {
- case SkMatrix::kTranslate_Mask:
- this->addDrawCommand(new SkTranslateCommand(matrix.getTranslateX(),
- matrix.getTranslateY()));
- break;
- case SkMatrix::kScale_Mask:
- this->addDrawCommand(new SkScaleCommand(matrix.getScaleX(),
- matrix.getScaleY()));
- break;
- default:
- this->addDrawCommand(new SkConcatCommand(matrix));
- break;
- }
-
+ this->addDrawCommand(new SkConcatCommand(matrix));
this->INHERITED::didConcat(matrix);
}
this->addDrawCommand(new SkDrawTextBlobCommand(blob, x, y, paint));
}
+void SkDebugCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
+ const SkPoint texCoords[4], SkXfermode* xmode,
+ const SkPaint& paint) {
+ this->addDrawCommand(new SkDrawPatchCommand(cubics, colors, texCoords, xmode, paint));
+}
+
void SkDebugCanvas::onDrawVertices(VertexMode vmode, int vertexCount, const SkPoint vertices[],
const SkPoint texs[], const SkColor colors[],
SkXfermode*, const uint16_t indices[], int indexCount,
void didSetMatrix(const SkMatrix&) SK_OVERRIDE;
void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
- virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
- const SkPaint&) SK_OVERRIDE;
- virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
- const SkPaint&) SK_OVERRIDE;
- virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
- SkScalar constY, const SkPaint&) SK_OVERRIDE;
- virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
- const SkMatrix* matrix, const SkPaint&) SK_OVERRIDE;
- virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
- const SkPaint& paint) SK_OVERRIDE;
-
+ void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
+ const SkPaint&) SK_OVERRIDE;
+ void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
+ const SkPaint&) SK_OVERRIDE;
+ void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
+ SkScalar constY, const SkPaint&) SK_OVERRIDE;
+ void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
+ const SkMatrix* matrix, const SkPaint&) SK_OVERRIDE;
+ void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
+ const SkPaint& paint) SK_OVERRIDE;
+
+ void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
+ const SkPoint texCoords[4], SkXfermode* xmode, const SkPaint& paint);
void onDrawPaint(const SkPaint&) SK_OVERRIDE;
- void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) SK_OVERRIDE;
+
void onDrawRect(const SkRect&, const SkPaint&) SK_OVERRIDE;
void onDrawOval(const SkRect&, const SkPaint&) SK_OVERRIDE;
void onDrawRRect(const SkRRect&, const SkPaint&) SK_OVERRIDE;
+ void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) SK_OVERRIDE;
+ void onDrawVertices(VertexMode vmode, int vertexCount,
+ const SkPoint vertices[], const SkPoint texs[],
+ const SkColor colors[], SkXfermode* xmode,
+ const uint16_t indices[], int indexCount,
+ const SkPaint&) SK_OVERRIDE;
void onDrawPath(const SkPath&, const SkPaint&) SK_OVERRIDE;
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) SK_OVERRIDE;
void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
const SkPaint*) SK_OVERRIDE;
void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*) SK_OVERRIDE;
- void onDrawVertices(VertexMode vmode, int vertexCount,
- const SkPoint vertices[], const SkPoint texs[],
- const SkColor colors[], SkXfermode* xmode,
- const uint16_t indices[], int indexCount,
- const SkPaint&) SK_OVERRIDE;
-
void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
#include "SkDrawCommand.h"
#include "SkObjectParser.h"
-
+#include "SkPicture.h"
#include "SkTextBlob.h"
// TODO(chudy): Refactor into non subclass model.
-const char* SkDrawCommand::kDrawRectString = "Draw Rect";
-const char* SkDrawCommand::kClipRectString = "Clip Rect";
-
-const SkDrawCommand::OpType SkDrawCommand::kSave_OpType = SAVE;
-const SkDrawCommand::OpType SkDrawCommand::kClipRect_OpType = CLIP_RECT;
-const SkDrawCommand::OpType SkDrawCommand::kDrawRect_OpType = DRAW_RECT;
-const SkDrawCommand::OpType SkDrawCommand::kRestore_OpType = RESTORE;
-const SkDrawCommand::OpType SkDrawCommand::kSetMatrix_OpType = SET_MATRIX;
+const char* SkDrawCommand::kDrawRectString = "DrawRect";
+const char* SkDrawCommand::kClipRectString = "ClipRect";
-SkDrawCommand::SkDrawCommand(DrawType type)
- : fDrawType(type)
+SkDrawCommand::SkDrawCommand(OpType type)
+ : fOpType(type)
, fOffset(0)
, fVisible(true) {
}
fInfo.deleteAll();
}
-const char* SkDrawCommand::GetCommandString(DrawType type) {
+const char* SkDrawCommand::GetCommandString(OpType type) {
switch (type) {
- case UNUSED: SkDEBUGFAIL("DrawType UNUSED\n"); break;
- case DRAW_CLEAR: return "Clear";
- case CLIP_PATH: return "Clip Path";
- case CLIP_REGION: return "Clip Region";
- case CLIP_RECT: return "Clip Rect";
- case CLIP_RRECT: return "Clip RRect";
- case CONCAT: return "Concat";
- case DRAW_BITMAP: return "Draw Bitmap";
- case DRAW_BITMAP_MATRIX: return "Draw Bitmap Matrix";
- case DRAW_BITMAP_NINE: return "Draw Bitmap Nine";
- case DRAW_BITMAP_RECT_TO_RECT: return "Draw Bitmap Rect";
- case DRAW_DATA: return "Draw Data";
- case DRAW_OVAL: return "Draw Oval";
- case DRAW_PAINT: return "Draw Paint";
- case DRAW_PATH: return "Draw Path";
- case DRAW_PICTURE: return "Draw Picture";
- case DRAW_POINTS: return "Draw Points";
- case DRAW_POS_TEXT: return "Draw Pos Text";
- case DRAW_POS_TEXT_H: return "Draw Pos Text H";
- case DRAW_RECT: return "Draw Rect";
- case DRAW_RRECT: return "Draw RRect";
- case DRAW_SPRITE: return "Draw Sprite";
- case DRAW_TEXT: return "Draw Text";
- case DRAW_TEXT_BLOB: return "Draw Text Blob";
- case DRAW_TEXT_ON_PATH: return "Draw Text On Path";
- case DRAW_VERTICES: return "Draw Vertices";
- case RESTORE: return "Restore";
- case ROTATE: return "Rotate";
- case SAVE: return "Save";
- case SAVE_LAYER: return "Save Layer";
- case SCALE: return "Scale";
- case SET_MATRIX: return "SetMatrix";
- case SKEW: return "Skew";
- case TRANSLATE: return "Translate";
- case NOOP: return "NoOp";
- case BEGIN_COMMENT_GROUP: return "BeginCommentGroup";
- case COMMENT: return "Comment";
- case END_COMMENT_GROUP: return "EndCommentGroup";
- case DRAW_DRRECT: return "Draw DRRect";
+ case kBeginCommentGroup_OpType: return "BeginCommentGroup";
+ case kClipPath_OpType: return "ClipPath";
+ case kClipRegion_OpType: return "ClipRegion";
+ case kClipRect_OpType: return "ClipRect";
+ case kClipRRect_OpType: return "ClipRRect";
+ case kComment_OpType: return "Comment";
+ case kConcat_OpType: return "Concat";
+ case kDrawBitmap_OpType: return "DrawBitmap";
+ case kDrawBitmapNine_OpType: return "DrawBitmapNine";
+ case kDrawBitmapRect_OpType: return "DrawBitmapRect";
+ case kDrawClear_OpType: return "DrawClear";
+ case kDrawDRRect_OpType: return "DrawDRRect";
+ case kDrawOval_OpType: return "DrawOval";
+ case kDrawPaint_OpType: return "DrawPaint";
+ case kDrawPatch_OpType: return "DrawPatch";
+ case kDrawPath_OpType: return "DrawPath";
+ case kDrawPicture_OpType: return "DrawPicture";
+ case kDrawPoints_OpType: return "DrawPoints";
+ case kDrawPosText_OpType: return "DrawPosText";
+ case kDrawPosTextH_OpType: return "DrawPosTextH";
+ case kDrawRect_OpType: return "DrawRect";
+ case kDrawRRect_OpType: return "DrawRRect";
+ case kDrawSprite_OpType: return "DrawSprite";
+ case kDrawText_OpType: return "DrawText";
+ case kDrawTextBlob_OpType: return "DrawTextBlob";
+ case kDrawTextOnPath_OpType: return "DrawTextOnPath";
+ case kDrawVertices_OpType: return "DrawVertices";
+ case kEndCommentGroup_OpType: return "EndCommentGroup";
+ case kRestore_OpType: return "Restore";
+ case kSave_OpType: return "Save";
+ case kSaveLayer_OpType: return "SaveLayer";
+ case kSetMatrix_OpType: return "SetMatrix";
default:
- SkDebugf("DrawType error 0x%08x\n", type);
+ SkDebugf("OpType error 0x%08x\n", type);
SkASSERT(0);
break;
}
}
SkString SkDrawCommand::toString() const {
- return SkString(GetCommandString(fDrawType));
+ return SkString(GetCommandString(fOpType));
}
-SkClearCommand::SkClearCommand(SkColor color) : INHERITED(DRAW_CLEAR) {
+SkClearCommand::SkClearCommand(SkColor color) : INHERITED(kDrawClear_OpType) {
fColor = color;
fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
}
SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool doAA)
- : INHERITED(CLIP_PATH) {
+ : INHERITED(kClipPath_OpType) {
fPath = path;
fOp = op;
fDoAA = doAA;
}
SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkRegion::Op op)
- : INHERITED(CLIP_REGION) {
+ : INHERITED(kClipRegion_OpType) {
fRegion = region;
fOp = op;
}
SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool doAA)
- : INHERITED(CLIP_RECT) {
+ : INHERITED(kClipRect_OpType) {
fRect = rect;
fOp = op;
fDoAA = doAA;
}
SkClipRRectCommand::SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bool doAA)
- : INHERITED(CLIP_RRECT) {
+ : INHERITED(kClipRRect_OpType) {
fRRect = rrect;
fOp = op;
fDoAA = doAA;
}
SkConcatCommand::SkConcatCommand(const SkMatrix& matrix)
- : INHERITED(CONCAT) {
+ : INHERITED(kConcat_OpType) {
fMatrix = matrix;
fInfo.push(SkObjectParser::MatrixToString(matrix));
SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top,
const SkPaint* paint)
- : INHERITED(DRAW_BITMAP) {
+ : INHERITED(kDrawBitmap_OpType) {
fBitmap = bitmap;
fLeft = left;
fTop = top;
SkDrawBitmapNineCommand::SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center,
const SkRect& dst, const SkPaint* paint)
- : INHERITED(DRAW_BITMAP_NINE) {
+ : INHERITED(kDrawBitmapNine_OpType) {
fBitmap = bitmap;
fCenter = center;
fDst = dst;
SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src,
const SkRect& dst, const SkPaint* paint,
SkCanvas::DrawBitmapRectFlags flags)
- : INHERITED(DRAW_BITMAP_RECT_TO_RECT) {
+ : INHERITED(kDrawBitmapRect_OpType) {
fBitmap = bitmap;
if (src) {
fSrc = *src;
}
SkBeginCommentGroupCommand::SkBeginCommentGroupCommand(const char* description)
- : INHERITED(BEGIN_COMMENT_GROUP)
+ : INHERITED(kBeginCommentGroup_OpType)
, fDescription(description) {
SkString* temp = new SkString;
temp->appendf("Description: %s", description);
}
SkCommentCommand::SkCommentCommand(const char* kywd, const char* value)
- : INHERITED(COMMENT)
+ : INHERITED(kComment_OpType)
, fKywd(kywd)
, fValue(value) {
SkString* temp = new SkString;
}
SkEndCommentGroupCommand::SkEndCommentGroupCommand()
- : INHERITED(END_COMMENT_GROUP) {
+ : INHERITED(kEndCommentGroup_OpType) {
}
SkDrawOvalCommand::SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint)
- : INHERITED(DRAW_OVAL) {
+ : INHERITED(kDrawOval_OpType) {
fOval = oval;
fPaint = paint;
}
SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint)
- : INHERITED(DRAW_PAINT) {
+ : INHERITED(kDrawPaint_OpType) {
fPaint = paint;
fInfo.push(SkObjectParser::PaintToString(paint));
}
SkDrawPathCommand::SkDrawPathCommand(const SkPath& path, const SkPaint& paint)
- : INHERITED(DRAW_PATH) {
+ : INHERITED(kDrawPath_OpType) {
fPath = path;
fPaint = paint;
SkDrawPictureCommand::SkDrawPictureCommand(const SkPicture* picture,
const SkMatrix* matrix,
const SkPaint* paint)
- : INHERITED(DRAW_PICTURE)
+ : INHERITED(kDrawPicture_OpType)
, fPicture(SkRef(picture))
, fMatrixPtr(NULL)
, fPaintPtr(NULL) {
SkDrawPointsCommand::SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count,
const SkPoint pts[], const SkPaint& paint)
- : INHERITED(DRAW_POINTS) {
+ : INHERITED(kDrawPoints_OpType) {
fMode = mode;
fCount = count;
fPts = new SkPoint[count];
SkDrawPosTextCommand::SkDrawPosTextCommand(const void* text, size_t byteLength,
const SkPoint pos[], const SkPaint& paint)
- : INHERITED(DRAW_POS_TEXT) {
+ : INHERITED(kDrawPosText_OpType) {
size_t numPts = paint.countText(text, byteLength);
fText = new char[byteLength];
SkDrawPosTextHCommand::SkDrawPosTextHCommand(const void* text, size_t byteLength,
const SkScalar xpos[], SkScalar constY,
const SkPaint& paint)
- : INHERITED(DRAW_POS_TEXT_H) {
+ : INHERITED(kDrawPosTextH_OpType) {
size_t numPts = paint.countText(text, byteLength);
fText = new char[byteLength];
SkDrawTextBlobCommand::SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x, SkScalar y,
const SkPaint& paint)
- : INHERITED(DRAW_TEXT_BLOB)
+ : INHERITED(kDrawTextBlob_OpType)
, fBlob(blob)
, fXPos(x)
, fYPos(y)
return true;
}
+SkDrawPatchCommand::SkDrawPatchCommand(const SkPoint cubics[12], const SkColor colors[4],
+ const SkPoint texCoords[4], SkXfermode* xfermode,
+ const SkPaint& paint)
+ : INHERITED(kDrawPatch_OpType) {
+ memcpy(fCubics, cubics, sizeof(fCubics));
+ memcpy(fColors, colors, sizeof(fColors));
+ memcpy(fTexCoords, texCoords, sizeof(fTexCoords));
+ fXfermode.reset(xfermode);
+ fPaint = paint;
+
+ fInfo.push(SkObjectParser::PaintToString(paint));
+}
+
+void SkDrawPatchCommand::execute(SkCanvas* canvas) const {
+ canvas->drawPatch(fCubics, fColors, fTexCoords, fXfermode, fPaint);
+}
+
SkDrawRectCommand::SkDrawRectCommand(const SkRect& rect, const SkPaint& paint)
- : INHERITED(DRAW_RECT) {
+ : INHERITED(kDrawRect_OpType) {
fRect = rect;
fPaint = paint;
}
SkDrawRRectCommand::SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint)
- : INHERITED(DRAW_RRECT) {
+ : INHERITED(kDrawRRect_OpType) {
fRRect = rrect;
fPaint = paint;
SkDrawDRRectCommand::SkDrawDRRectCommand(const SkRRect& outer,
const SkRRect& inner,
const SkPaint& paint)
- : INHERITED(DRAW_DRRECT) {
+ : INHERITED(kDrawDRRect_OpType) {
fOuter = outer;
fInner = inner;
fPaint = paint;
SkDrawSpriteCommand::SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int top,
const SkPaint* paint)
- : INHERITED(DRAW_SPRITE) {
+ : INHERITED(kDrawSprite_OpType) {
fBitmap = bitmap;
fLeft = left;
fTop = top;
SkDrawTextCommand::SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar y,
const SkPaint& paint)
- : INHERITED(DRAW_TEXT) {
+ : INHERITED(kDrawText_OpType) {
fText = new char[byteLength];
memcpy(fText, text, byteLength);
fByteLength = byteLength;
SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLength,
const SkPath& path, const SkMatrix* matrix,
const SkPaint& paint)
- : INHERITED(DRAW_TEXT_ON_PATH) {
+ : INHERITED(kDrawTextOnPath_OpType) {
fText = new char[byteLength];
memcpy(fText, text, byteLength);
fByteLength = byteLength;
const SkColor colors[], SkXfermode* xfermode,
const uint16_t indices[], int indexCount,
const SkPaint& paint)
- : INHERITED(DRAW_VERTICES) {
+ : INHERITED(kDrawVertices_OpType) {
fVmode = vmode;
fVertexCount = vertexCount;
}
SkRestoreCommand::SkRestoreCommand()
- : INHERITED(RESTORE) {
+ : INHERITED(kRestore_OpType) {
fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
}
canvas->restore();
}
-SkRotateCommand::SkRotateCommand(SkScalar degrees)
- : INHERITED(ROTATE) {
- fDegrees = degrees;
-
- fInfo.push(SkObjectParser::ScalarToString(degrees, "SkScalar degrees: "));
-}
-
-void SkRotateCommand::execute(SkCanvas* canvas) const {
- canvas->rotate(fDegrees);
-}
-
SkSaveCommand::SkSaveCommand()
- : INHERITED(SAVE) {
+ : INHERITED(kSave_OpType) {
}
void SkSaveCommand::execute(SkCanvas* canvas) const {
SkSaveLayerCommand::SkSaveLayerCommand(const SkRect* bounds, const SkPaint* paint,
SkCanvas::SaveFlags flags)
- : INHERITED(SAVE_LAYER) {
+ : INHERITED(kSaveLayer_OpType) {
if (bounds) {
fBounds = *bounds;
} else {
canvas->save();
}
-SkScaleCommand::SkScaleCommand(SkScalar sx, SkScalar sy)
- : INHERITED(SCALE) {
- fSx = sx;
- fSy = sy;
-
- fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: "));
- fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: "));
-}
-
-void SkScaleCommand::execute(SkCanvas* canvas) const {
- canvas->scale(fSx, fSy);
-}
-
SkSetMatrixCommand::SkSetMatrixCommand(const SkMatrix& matrix)
- : INHERITED(SET_MATRIX) {
+ : INHERITED(kSetMatrix_OpType) {
fUserMatrix.reset();
fMatrix = matrix;
canvas->setMatrix(temp);
}
-SkSkewCommand::SkSkewCommand(SkScalar sx, SkScalar sy)
- : INHERITED(SKEW) {
- fSx = sx;
- fSy = sy;
-
- fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: "));
- fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: "));
-}
-
-void SkSkewCommand::execute(SkCanvas* canvas) const {
- canvas->skew(fSx, fSy);
-}
-
-SkTranslateCommand::SkTranslateCommand(SkScalar dx, SkScalar dy)
- : INHERITED(TRANSLATE) {
- fDx = dx;
- fDy = dy;
-
- fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: "));
- fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: "));
-}
-
-void SkTranslateCommand::execute(SkCanvas* canvas) const {
- canvas->translate(fDx, fDy);
-}
-
#ifndef SKDRAWCOMMAND_H_
#define SKDRAWCOMMAND_H_
-#include "SkPictureFlat.h"
#include "SkCanvas.h"
#include "SkString.h"
class SK_API SkDrawCommand {
public:
// Staging for Chromium
- typedef DrawType OpType;
-
- static const int kOpTypeCount = LAST_DRAWTYPE_ENUM+1;
-
static const char* kDrawRectString;
static const char* kClipRectString;
-
- static const OpType kSave_OpType;
- static const OpType kClipRect_OpType;
- static const OpType kDrawRect_OpType;
- static const OpType kRestore_OpType;
- static const OpType kSetMatrix_OpType;
// End Staging
+ enum OpType {
+ kBeginCommentGroup_OpType,
+ kClipPath_OpType,
+ kClipRegion_OpType,
+ kClipRect_OpType,
+ kClipRRect_OpType,
+ kComment_OpType,
+ kConcat_OpType,
+ kDrawBitmap_OpType,
+ kDrawBitmapNine_OpType,
+ kDrawBitmapRect_OpType,
+ kDrawClear_OpType,
+ kDrawDRRect_OpType,
+ kDrawOval_OpType,
+ kDrawPaint_OpType,
+ kDrawPatch_OpType,
+ kDrawPath_OpType,
+ kDrawPicture_OpType,
+ kDrawPoints_OpType,
+ kDrawPosText_OpType,
+ kDrawPosTextH_OpType,
+ kDrawRect_OpType,
+ kDrawRRect_OpType,
+ kDrawSprite_OpType,
+ kDrawText_OpType,
+ kDrawTextBlob_OpType,
+ kDrawTextOnPath_OpType,
+ kDrawVertices_OpType,
+ kEndCommentGroup_OpType,
+ kRestore_OpType,
+ kSave_OpType,
+ kSaveLayer_OpType,
+ kSetMatrix_OpType,
+
+ kLast_OpType = kSetMatrix_OpType
+ };
+
+ static const int kOpTypeCount = kLast_OpType + 1;
- SkDrawCommand(DrawType drawType);
+ SkDrawCommand(OpType opType);
virtual ~SkDrawCommand();
size_t offset() const { return fOffset; }
virtual const char* toCString() const {
- return GetCommandString(fDrawType);
+ return GetCommandString(fOpType);
}
bool isVisible() const {
virtual void setActive(bool active) {}
virtual bool active() const { return false; }
- DrawType getType() const { return fDrawType; }
+ OpType getType() const { return fOpType; }
virtual bool render(SkCanvas* canvas) const { return false; }
- static const char* GetCommandString(DrawType type);
+ static const char* GetCommandString(OpType type);
protected:
SkTDArray<SkString*> fInfo;
private:
- DrawType fDrawType;
+ OpType fOpType;
size_t fOffset;
bool fVisible;
};
typedef SkDrawCommand INHERITED;
};
+class SkDrawPatchCommand : public SkDrawCommand {
+public:
+ SkDrawPatchCommand(const SkPoint cubics[12], const SkColor colors[4],
+ const SkPoint texCoords[4], SkXfermode* xmode,
+ const SkPaint& paint);
+ void execute(SkCanvas* canvas) const SK_OVERRIDE;
+
+private:
+ SkPoint fCubics[12];
+ SkColor fColors[4];
+ SkPoint fTexCoords[4];
+ SkAutoTUnref<SkXfermode> fXfermode;
+ SkPaint fPaint;
+
+ typedef SkDrawCommand INHERITED;
+};
+
+
class SkDrawRectCommand : public SkDrawCommand {
public:
SkDrawRectCommand(const SkRect& rect, const SkPaint& paint);
typedef SkDrawCommand INHERITED;
};
-class SkRotateCommand : public SkDrawCommand {
-public:
- SkRotateCommand(SkScalar degrees);
- void execute(SkCanvas* canvas) const SK_OVERRIDE;
-private:
- SkScalar fDegrees;
-
- typedef SkDrawCommand INHERITED;
-};
-
class SkSaveCommand : public SkDrawCommand {
public:
SkSaveCommand();
typedef SkDrawCommand INHERITED;
};
-class SkScaleCommand : public SkDrawCommand {
-public:
- SkScaleCommand(SkScalar sx, SkScalar sy);
- void execute(SkCanvas* canvas) const SK_OVERRIDE;
-
- SkScalar x() const { return fSx; }
- SkScalar y() const { return fSy; }
-
-private:
- SkScalar fSx;
- SkScalar fSy;
-
- typedef SkDrawCommand INHERITED;
-};
-
class SkSetMatrixCommand : public SkDrawCommand {
public:
SkSetMatrixCommand(const SkMatrix& matrix);
typedef SkDrawCommand INHERITED;
};
-class SkSkewCommand : public SkDrawCommand {
-public:
- SkSkewCommand(SkScalar sx, SkScalar sy);
- void execute(SkCanvas* canvas) const SK_OVERRIDE;
-private:
- SkScalar fSx;
- SkScalar fSy;
-
- typedef SkDrawCommand INHERITED;
-};
-
-class SkTranslateCommand : public SkDrawCommand {
-public:
- SkTranslateCommand(SkScalar dx, SkScalar dy);
- void execute(SkCanvas* canvas) const SK_OVERRIDE;
-
- SkScalar x() const { return fDx; }
- SkScalar y() const { return fDy; }
-
-private:
- SkScalar fDx;
- SkScalar fDy;
-
- typedef SkDrawCommand INHERITED;
-};
-
#endif
// RESTORE
// where the saveLayer's color can be moved into the drawBitmapRect
static bool check_0(SkDebugCanvas* canvas, int curCommand) {
- if (SAVE_LAYER != canvas->getDrawCommandAt(curCommand)->getType() ||
+ if (SkDrawCommand::kSaveLayer_OpType != canvas->getDrawCommandAt(curCommand)->getType() ||
canvas->getSize() <= curCommand+2 ||
- DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() ||
- RESTORE != canvas->getDrawCommandAt(curCommand+2)->getType()) {
+ SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() ||
+ SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+2)->getType()) {
return false;
}
// RESTORE
// where the saveLayer's color can be moved into the drawBitmapRect
static bool check_1(SkDebugCanvas* canvas, int curCommand) {
- if (SAVE_LAYER != canvas->getDrawCommandAt(curCommand)->getType() ||
+ if (SkDrawCommand::kSaveLayer_OpType != canvas->getDrawCommandAt(curCommand)->getType() ||
canvas->getSize() <= curCommand+5 ||
- SAVE != canvas->getDrawCommandAt(curCommand+1)->getType() ||
- CLIP_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() ||
- DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+3)->getType() ||
- RESTORE != canvas->getDrawCommandAt(curCommand+4)->getType() ||
- RESTORE != canvas->getDrawCommandAt(curCommand+5)->getType()) {
+ SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() ||
+ SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+2)->getType() ||
+ SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCommand+3)->getType() ||
+ SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+4)->getType() ||
+ SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+5)->getType()) {
return false;
}
// RESTORE
// where the rect is entirely within the clip and the clip is an intersect
static bool check_2(SkDebugCanvas* canvas, int curCommand) {
- if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() ||
+ if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->getType() ||
canvas->getSize() <= curCommand+4 ||
- CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() ||
- DRAW_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() ||
- RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) {
+ SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() ||
+ SkDrawCommand::kDrawRect_OpType != canvas->getDrawCommandAt(curCommand+2)->getType() ||
+ SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+3)->getType()) {
return false;
}
// RESTORE
// where the rect entirely encloses the clip
static bool check_3(SkDebugCanvas* canvas, int curCommand) {
- if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() ||
+ if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->getType() ||
canvas->getSize() <= curCommand+4 ||
- CLIP_RRECT != canvas->getDrawCommandAt(curCommand+1)->getType() ||
- DRAW_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() ||
- RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) {
+ SkDrawCommand::kClipRRect_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() ||
+ SkDrawCommand::kDrawRect_OpType != canvas->getDrawCommandAt(curCommand+2)->getType() ||
+ SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+3)->getType()) {
return false;
}
// RESTORE
// where the rect and drawBitmapRect dst exactly match
static bool check_4(SkDebugCanvas* canvas, int curCommand) {
- if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() ||
+ if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->getType() ||
canvas->getSize() <= curCommand+4 ||
- CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() ||
- DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() ||
- RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) {
+ SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() ||
+ SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCommand+2)->getType() ||
+ SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+3)->getType()) {
return false;
}
canvas->deleteDrawCommandAt(curCommand); // save
}
-// Check for:
-// TRANSLATE
-// where the translate is zero
-static bool check_5(SkDebugCanvas* canvas, int curCommand) {
- if (TRANSLATE != canvas->getDrawCommandAt(curCommand)->getType()) {
- return false;
- }
-
- SkTranslateCommand* t =
- (SkTranslateCommand*) canvas->getDrawCommandAt(curCommand);
-
- return 0 == t->x() && 0 == t->y();
-}
-
-// Just remove the translate
-static void apply_5(SkDebugCanvas* canvas, int curCommand) {
- canvas->deleteDrawCommandAt(curCommand); // translate
-}
-
-// Check for:
-// SCALE
-// where the scale is 1,1
-static bool check_6(SkDebugCanvas* canvas, int curCommand) {
- if (SCALE != canvas->getDrawCommandAt(curCommand)->getType()) {
- return false;
- }
-
- SkScaleCommand* s = (SkScaleCommand*) canvas->getDrawCommandAt(curCommand);
-
- return SK_Scalar1 == s->x() && SK_Scalar1 == s->y();
-}
-
-// Just remove the scale
-static void apply_6(SkDebugCanvas* canvas, int curCommand) {
- canvas->deleteDrawCommandAt(curCommand); // scale
-}
-
// Check for:
// SAVE
// CLIP_RECT
// all the saveLayer's paints can be rolled into the drawBitmapRectToRect's paint
// This pattern is used by Google spreadsheet when drawing the toolbar buttons
static bool check_7(SkDebugCanvas* canvas, int curCommand) {
- if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() ||
+ if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->getType() ||
canvas->getSize() <= curCommand+13 ||
- CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() ||
- SAVE_LAYER != canvas->getDrawCommandAt(curCommand+2)->getType() ||
- SAVE != canvas->getDrawCommandAt(curCommand+3)->getType() ||
- CLIP_RECT != canvas->getDrawCommandAt(curCommand+4)->getType() ||
- SAVE_LAYER != canvas->getDrawCommandAt(curCommand+5)->getType() ||
- SAVE != canvas->getDrawCommandAt(curCommand+6)->getType() ||
- CLIP_RECT != canvas->getDrawCommandAt(curCommand+7)->getType() ||
- DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+8)->getType() ||
- RESTORE != canvas->getDrawCommandAt(curCommand+9)->getType() ||
- RESTORE != canvas->getDrawCommandAt(curCommand+10)->getType() ||
- RESTORE != canvas->getDrawCommandAt(curCommand+11)->getType() ||
- RESTORE != canvas->getDrawCommandAt(curCommand+12)->getType() ||
- RESTORE != canvas->getDrawCommandAt(curCommand+13)->getType()) {
+ SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() ||
+ SkDrawCommand::kSaveLayer_OpType != canvas->getDrawCommandAt(curCommand+2)->getType() ||
+ SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand+3)->getType() ||
+ SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+4)->getType() ||
+ SkDrawCommand::kSaveLayer_OpType != canvas->getDrawCommandAt(curCommand+5)->getType() ||
+ SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand+6)->getType() ||
+ SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+7)->getType() ||
+ SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCommand+8)->getType() ||
+ SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+9)->getType() ||
+ SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+10)->getType() ||
+ SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+11)->getType() ||
+ SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+12)->getType() ||
+ SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+13)->getType()) {
return false;
}
// the drawBitmapRectToRect is a 1-1 copy from src to dest
// the clip rect is BW and a subset of the drawBitmapRectToRect's dest rect
static bool check_8(SkDebugCanvas* canvas, int curCommand) {
- if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() ||
+ if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->getType() ||
canvas->getSize() <= curCommand+4 ||
- CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() ||
- DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() ||
- RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) {
+ SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() ||
+ SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCommand+2)->getType() ||
+ SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+3)->getType()) {
return false;
}
// where:
// clipRect is BW and encloses the DBMR2R's dest rect
static bool check_9(SkDebugCanvas* canvas, int curCommand) {
- if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() ||
+ if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->getType() ||
canvas->getSize() <= curCommand+4 ||
- CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() ||
- DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() ||
- RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) {
+ SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() ||
+ SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCommand+2)->getType() ||
+ SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+3)->getType()) {
return false;
}
{ check_2, apply_2, 0 },
{ check_3, apply_3, 0 },
{ check_4, apply_4, 0 },
- { check_5, apply_5, 0 },
- { check_6, apply_6, 0 },
{ check_7, apply_7, 0 },
{ check_8, apply_8, 0 },
{ check_9, apply_9, 0 },