2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "SkDrawCommand.h"
|
|
|
|
#include "SkObjectParser.h"
|
|
|
|
|
|
|
|
// TODO(chudy): Refactor into non subclass model.
|
|
|
|
|
2013-05-29 13:24:23 +00:00
|
|
|
SkDrawCommand::SkDrawCommand(DrawType type)
|
|
|
|
: fDrawType(type)
|
|
|
|
, fVisible(true) {
|
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
SkDrawCommand::SkDrawCommand() {
|
|
|
|
fVisible = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
SkDrawCommand::~SkDrawCommand() {
|
2012-08-07 20:41:37 +00:00
|
|
|
fInfo.deleteAll();
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char* SkDrawCommand::GetCommandString(DrawType 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";
|
2013-01-02 20:20:31 +00:00
|
|
|
case CLIP_RRECT: return "Clip RRect";
|
2012-06-29 14:21:22 +00:00
|
|
|
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";
|
2012-09-20 19:09:17 +00:00
|
|
|
case DRAW_BITMAP_RECT_TO_RECT: return "Draw Bitmap Rect";
|
2012-06-29 14:21:22 +00:00
|
|
|
case DRAW_DATA: return "Draw Data";
|
2013-01-02 20:20:31 +00:00
|
|
|
case DRAW_OVAL: return "Draw Oval";
|
2012-06-29 14:21:22 +00:00
|
|
|
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";
|
2013-01-02 20:20:31 +00:00
|
|
|
case DRAW_RRECT: return "Draw RRect";
|
2012-06-29 14:21:22 +00:00
|
|
|
case DRAW_SPRITE: return "Draw Sprite";
|
|
|
|
case DRAW_TEXT: return "Draw Text";
|
|
|
|
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 "Set Matrix";
|
|
|
|
case SKEW: return "Skew";
|
|
|
|
case TRANSLATE: return "Translate";
|
2013-02-15 17:19:15 +00:00
|
|
|
case NOOP: return "NoOp";
|
2013-05-29 13:24:23 +00:00
|
|
|
case BEGIN_COMMENT_GROUP: return "BeginCommentGroup";
|
|
|
|
case COMMENT: return "Comment";
|
|
|
|
case END_COMMENT_GROUP: return "EndCommentGroup";
|
2012-06-29 14:21:22 +00:00
|
|
|
default:
|
|
|
|
SkDebugf("DrawType error 0x%08x\n", type);
|
|
|
|
SkASSERT(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
SkDEBUGFAIL("DrawType UNUSED\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-08-07 20:41:37 +00:00
|
|
|
SkString SkDrawCommand::toString() {
|
|
|
|
return SkString(GetCommandString(fDrawType));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Clear::Clear(SkColor color) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fColor = color;
|
|
|
|
fDrawType = DRAW_CLEAR;
|
|
|
|
fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Clear::execute(SkCanvas* canvas) {
|
2013-03-22 16:33:31 +00:00
|
|
|
canvas->clear(fColor);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-11-21 17:11:02 +00:00
|
|
|
ClipPath::ClipPath(const SkPath& path, SkRegion::Op op, bool doAA, SkBitmap& bitmap) {
|
2013-03-17 18:33:46 +00:00
|
|
|
fPath = path;
|
|
|
|
fOp = op;
|
|
|
|
fDoAA = doAA;
|
|
|
|
fDrawType = CLIP_PATH;
|
|
|
|
fBitmap = bitmap;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-03-17 18:33:46 +00:00
|
|
|
fInfo.push(SkObjectParser::PathToString(path));
|
|
|
|
fInfo.push(SkObjectParser::RegionOpToString(op));
|
|
|
|
fInfo.push(SkObjectParser::BoolToString(doAA));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ClipPath::execute(SkCanvas* canvas) {
|
2013-03-17 18:33:46 +00:00
|
|
|
canvas->clipPath(fPath, fOp, fDoAA);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-11-21 17:11:02 +00:00
|
|
|
const SkBitmap* ClipPath::getBitmap() const {
|
|
|
|
return &fBitmap;
|
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
ClipRegion::ClipRegion(const SkRegion& region, SkRegion::Op op) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fRegion = region;
|
|
|
|
fOp = op;
|
|
|
|
fDrawType = CLIP_REGION;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-03-22 16:33:31 +00:00
|
|
|
fInfo.push(SkObjectParser::RegionToString(region));
|
|
|
|
fInfo.push(SkObjectParser::RegionOpToString(op));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ClipRegion::execute(SkCanvas* canvas) {
|
2013-03-22 16:33:31 +00:00
|
|
|
canvas->clipRegion(fRegion, fOp);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ClipRect::ClipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
|
2013-03-22 12:25:30 +00:00
|
|
|
fRect = rect;
|
|
|
|
fOp = op;
|
|
|
|
fDoAA = doAA;
|
|
|
|
fDrawType = CLIP_RECT;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-03-22 12:25:30 +00:00
|
|
|
fInfo.push(SkObjectParser::RectToString(rect));
|
|
|
|
fInfo.push(SkObjectParser::RegionOpToString(op));
|
|
|
|
fInfo.push(SkObjectParser::BoolToString(doAA));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ClipRect::execute(SkCanvas* canvas) {
|
2013-03-22 12:25:30 +00:00
|
|
|
canvas->clipRect(fRect, fOp, fDoAA);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-02 20:20:31 +00:00
|
|
|
ClipRRect::ClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
|
2013-03-22 12:25:30 +00:00
|
|
|
fRRect = rrect;
|
|
|
|
fOp = op;
|
|
|
|
fDoAA = doAA;
|
|
|
|
fDrawType = CLIP_RRECT;
|
2013-01-02 20:20:31 +00:00
|
|
|
|
2013-03-22 12:25:30 +00:00
|
|
|
fInfo.push(SkObjectParser::RRectToString(rrect));
|
|
|
|
fInfo.push(SkObjectParser::RegionOpToString(op));
|
|
|
|
fInfo.push(SkObjectParser::BoolToString(doAA));
|
2013-01-02 20:20:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ClipRRect::execute(SkCanvas* canvas) {
|
2013-03-22 12:25:30 +00:00
|
|
|
canvas->clipRRect(fRRect, fOp, fDoAA);
|
2013-01-02 20:20:31 +00:00
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
Concat::Concat(const SkMatrix& matrix) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fMatrix = matrix;
|
|
|
|
fDrawType = CONCAT;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-03-22 16:33:31 +00:00
|
|
|
fInfo.push(SkObjectParser::MatrixToString(matrix));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Concat::execute(SkCanvas* canvas) {
|
2013-03-22 16:33:31 +00:00
|
|
|
canvas->concat(fMatrix);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DrawBitmap::DrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
|
2013-03-22 16:33:31 +00:00
|
|
|
const SkPaint* paint, SkBitmap& resizedBitmap) {
|
|
|
|
fBitmap = bitmap;
|
|
|
|
fLeft = left;
|
|
|
|
fTop = top;
|
|
|
|
if (NULL != paint) {
|
|
|
|
fPaint = *paint;
|
|
|
|
fPaintPtr = &fPaint;
|
|
|
|
} else {
|
|
|
|
fPaintPtr = NULL;
|
|
|
|
}
|
|
|
|
fDrawType = DRAW_BITMAP;
|
|
|
|
fResizedBitmap = resizedBitmap;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-03-22 16:33:31 +00:00
|
|
|
fInfo.push(SkObjectParser::BitmapToString(bitmap));
|
|
|
|
fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: "));
|
|
|
|
fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: "));
|
2013-01-22 14:32:09 +00:00
|
|
|
if (NULL != paint) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fInfo.push(SkObjectParser::PaintToString(*paint));
|
2013-01-22 14:32:09 +00:00
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawBitmap::execute(SkCanvas* canvas) {
|
2013-03-22 16:33:31 +00:00
|
|
|
canvas->drawBitmap(fBitmap, fLeft, fTop, fPaintPtr);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-11-26 13:09:17 +00:00
|
|
|
const SkBitmap* DrawBitmap::getBitmap() const {
|
|
|
|
return &fResizedBitmap;
|
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
DrawBitmapMatrix::DrawBitmapMatrix(const SkBitmap& bitmap,
|
2013-03-23 07:01:28 +00:00
|
|
|
const SkMatrix& matrix,
|
|
|
|
const SkPaint* paint,
|
2013-03-22 16:33:31 +00:00
|
|
|
SkBitmap& resizedBitmap) {
|
|
|
|
fBitmap = bitmap;
|
|
|
|
fMatrix = matrix;
|
|
|
|
if (NULL != paint) {
|
|
|
|
fPaint = *paint;
|
|
|
|
fPaintPtr = &fPaint;
|
|
|
|
} else {
|
|
|
|
fPaintPtr = NULL;
|
|
|
|
}
|
|
|
|
fDrawType = DRAW_BITMAP_MATRIX;
|
|
|
|
fResizedBitmap = resizedBitmap;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-03-22 16:33:31 +00:00
|
|
|
fInfo.push(SkObjectParser::BitmapToString(bitmap));
|
|
|
|
fInfo.push(SkObjectParser::MatrixToString(matrix));
|
2013-01-22 14:32:09 +00:00
|
|
|
if (NULL != paint) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fInfo.push(SkObjectParser::PaintToString(*paint));
|
2013-01-22 14:32:09 +00:00
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawBitmapMatrix::execute(SkCanvas* canvas) {
|
2013-03-22 16:33:31 +00:00
|
|
|
canvas->drawBitmapMatrix(fBitmap, fMatrix, fPaintPtr);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-11-26 13:09:17 +00:00
|
|
|
const SkBitmap* DrawBitmapMatrix::getBitmap() const {
|
|
|
|
return &fResizedBitmap;
|
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
DrawBitmapNine::DrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
|
2013-03-23 07:01:28 +00:00
|
|
|
const SkRect& dst, const SkPaint* paint,
|
2013-03-22 16:33:31 +00:00
|
|
|
SkBitmap& resizedBitmap) {
|
|
|
|
fBitmap = bitmap;
|
|
|
|
fCenter = center;
|
|
|
|
fDst = dst;
|
|
|
|
if (NULL != paint) {
|
|
|
|
fPaint = *paint;
|
|
|
|
fPaintPtr = &fPaint;
|
|
|
|
} else {
|
|
|
|
fPaintPtr = NULL;
|
|
|
|
}
|
|
|
|
fDrawType = DRAW_BITMAP_NINE;
|
|
|
|
fResizedBitmap = resizedBitmap;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-03-22 16:33:31 +00:00
|
|
|
fInfo.push(SkObjectParser::BitmapToString(bitmap));
|
|
|
|
fInfo.push(SkObjectParser::IRectToString(center));
|
|
|
|
fInfo.push(SkObjectParser::RectToString(dst, "Dst: "));
|
2013-01-22 14:32:09 +00:00
|
|
|
if (NULL != paint) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fInfo.push(SkObjectParser::PaintToString(*paint));
|
2013-01-22 14:32:09 +00:00
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawBitmapNine::execute(SkCanvas* canvas) {
|
2013-03-22 16:33:31 +00:00
|
|
|
canvas->drawBitmapNine(fBitmap, fCenter, fDst, fPaintPtr);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-11-26 13:09:17 +00:00
|
|
|
const SkBitmap* DrawBitmapNine::getBitmap() const {
|
|
|
|
return &fResizedBitmap;
|
|
|
|
}
|
|
|
|
|
2012-09-18 15:14:33 +00:00
|
|
|
DrawBitmapRect::DrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
|
2013-03-18 07:01:03 +00:00
|
|
|
const SkRect& dst, const SkPaint* paint,
|
2013-03-17 18:33:46 +00:00
|
|
|
SkBitmap& resizedBitmap) {
|
|
|
|
fBitmap = bitmap;
|
|
|
|
if (NULL != src) {
|
|
|
|
fSrc = *src;
|
|
|
|
} else {
|
|
|
|
fSrc.setEmpty();
|
|
|
|
}
|
|
|
|
fDst = dst;
|
|
|
|
|
2013-01-31 15:56:22 +00:00
|
|
|
if (NULL != paint) {
|
2013-03-17 18:33:46 +00:00
|
|
|
fPaint = *paint;
|
|
|
|
fPaintPtr = &fPaint;
|
2013-01-31 15:56:22 +00:00
|
|
|
} else {
|
2013-03-17 18:33:46 +00:00
|
|
|
fPaintPtr = NULL;
|
2013-01-31 15:56:22 +00:00
|
|
|
}
|
2013-03-17 18:33:46 +00:00
|
|
|
fDrawType = DRAW_BITMAP_RECT_TO_RECT;
|
|
|
|
fResizedBitmap = resizedBitmap;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-03-17 18:33:46 +00:00
|
|
|
fInfo.push(SkObjectParser::BitmapToString(bitmap));
|
2013-01-22 14:32:09 +00:00
|
|
|
if (NULL != src) {
|
2013-03-17 18:33:46 +00:00
|
|
|
fInfo.push(SkObjectParser::RectToString(*src, "Src: "));
|
2013-01-22 14:32:09 +00:00
|
|
|
}
|
2013-03-17 18:33:46 +00:00
|
|
|
fInfo.push(SkObjectParser::RectToString(dst, "Dst: "));
|
2013-01-22 14:32:09 +00:00
|
|
|
if (NULL != paint) {
|
2013-03-17 18:33:46 +00:00
|
|
|
fInfo.push(SkObjectParser::PaintToString(*paint));
|
2013-01-22 14:32:09 +00:00
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawBitmapRect::execute(SkCanvas* canvas) {
|
2013-03-17 18:33:46 +00:00
|
|
|
canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-11-26 13:09:17 +00:00
|
|
|
const SkBitmap* DrawBitmapRect::getBitmap() const {
|
|
|
|
return &fResizedBitmap;
|
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
DrawData::DrawData(const void* data, size_t length) {
|
2013-03-25 11:50:42 +00:00
|
|
|
fData = new char[length];
|
|
|
|
memcpy(fData, data, length);
|
|
|
|
fLength = length;
|
|
|
|
fDrawType = DRAW_DATA;
|
|
|
|
|
|
|
|
// TODO: add display of actual data?
|
|
|
|
SkString* str = new SkString;
|
2013-03-25 12:01:45 +00:00
|
|
|
str->appendf("length: %d", (int) length);
|
2013-03-25 11:50:42 +00:00
|
|
|
fInfo.push(str);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawData::execute(SkCanvas* canvas) {
|
2013-03-25 11:50:42 +00:00
|
|
|
canvas->drawData(fData, fLength);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-05-29 13:24:23 +00:00
|
|
|
BeginCommentGroup::BeginCommentGroup(const char* description)
|
|
|
|
: INHERITED(BEGIN_COMMENT_GROUP)
|
|
|
|
, fDescription(description) {
|
|
|
|
SkString* temp = new SkString;
|
|
|
|
temp->appendf("Description: %s", description);
|
|
|
|
fInfo.push(temp);
|
|
|
|
}
|
|
|
|
|
|
|
|
Comment::Comment(const char* kywd, const char* value)
|
|
|
|
: INHERITED(COMMENT)
|
|
|
|
, fKywd(kywd)
|
|
|
|
, fValue(value) {
|
|
|
|
SkString* temp = new SkString;
|
|
|
|
temp->appendf("%s: %s", kywd, value);
|
|
|
|
fInfo.push(temp);
|
|
|
|
}
|
|
|
|
|
|
|
|
EndCommentGroup::EndCommentGroup() : INHERITED(END_COMMENT_GROUP) {
|
|
|
|
}
|
|
|
|
|
2013-01-02 20:20:31 +00:00
|
|
|
DrawOval::DrawOval(const SkRect& oval, const SkPaint& paint) {
|
2013-03-22 12:25:30 +00:00
|
|
|
fOval = oval;
|
|
|
|
fPaint = paint;
|
|
|
|
fDrawType = DRAW_OVAL;
|
2013-01-02 20:20:31 +00:00
|
|
|
|
2013-03-22 12:25:30 +00:00
|
|
|
fInfo.push(SkObjectParser::RectToString(oval));
|
|
|
|
fInfo.push(SkObjectParser::PaintToString(paint));
|
2013-01-02 20:20:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawOval::execute(SkCanvas* canvas) {
|
2013-03-22 12:25:30 +00:00
|
|
|
canvas->drawOval(fOval, fPaint);
|
2013-01-02 20:20:31 +00:00
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
DrawPaint::DrawPaint(const SkPaint& paint) {
|
2013-03-22 12:25:30 +00:00
|
|
|
fPaint = paint;
|
|
|
|
fDrawType = DRAW_PAINT;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-03-22 12:25:30 +00:00
|
|
|
fInfo.push(SkObjectParser::PaintToString(paint));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawPaint::execute(SkCanvas* canvas) {
|
2013-03-22 12:25:30 +00:00
|
|
|
canvas->drawPaint(fPaint);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-11-21 17:11:02 +00:00
|
|
|
DrawPath::DrawPath(const SkPath& path, const SkPaint& paint, SkBitmap& bitmap) {
|
2013-03-17 18:33:46 +00:00
|
|
|
fPath = path;
|
|
|
|
fPaint = paint;
|
|
|
|
fBitmap = bitmap;
|
|
|
|
fDrawType = DRAW_PATH;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-03-17 18:33:46 +00:00
|
|
|
fInfo.push(SkObjectParser::PathToString(path));
|
|
|
|
fInfo.push(SkObjectParser::PaintToString(paint));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawPath::execute(SkCanvas* canvas) {
|
2013-03-17 18:33:46 +00:00
|
|
|
canvas->drawPath(fPath, fPaint);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-11-21 17:11:02 +00:00
|
|
|
const SkBitmap* DrawPath::getBitmap() const {
|
|
|
|
return &fBitmap;
|
|
|
|
}
|
|
|
|
|
2013-03-25 11:50:42 +00:00
|
|
|
DrawPicture::DrawPicture(SkPicture& picture) :
|
|
|
|
fPicture(picture) {
|
|
|
|
fDrawType = DRAW_PICTURE;
|
|
|
|
fInfo.push(SkObjectParser::CustomTextToString("To be implemented."));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawPicture::execute(SkCanvas* canvas) {
|
2013-03-25 11:50:42 +00:00
|
|
|
canvas->drawPicture(fPicture);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DrawPoints::DrawPoints(SkCanvas::PointMode mode, size_t count,
|
2013-03-22 12:25:30 +00:00
|
|
|
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;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-03-22 12:25:30 +00:00
|
|
|
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));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawPoints::execute(SkCanvas* canvas) {
|
2013-03-22 12:25:30 +00:00
|
|
|
canvas->drawPoints(fMode, fCount, fPts, fPaint);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DrawPosText::DrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
|
2013-03-22 12:25:30 +00:00
|
|
|
const SkPaint& paint) {
|
|
|
|
size_t numPts = paint.countText(text, byteLength);
|
|
|
|
|
|
|
|
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()));
|
2012-06-29 14:21:22 +00:00
|
|
|
// TODO(chudy): Test that this works.
|
2013-03-22 12:25:30 +00:00
|
|
|
fInfo.push(SkObjectParser::PointsToString(pos, 1));
|
|
|
|
fInfo.push(SkObjectParser::PaintToString(paint));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawPosText::execute(SkCanvas* canvas) {
|
2013-03-22 12:25:30 +00:00
|
|
|
canvas->drawPosText(fText, fByteLength, fPos, fPaint);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DrawPosTextH::DrawPosTextH(const void* text, size_t byteLength,
|
2013-03-18 07:01:03 +00:00
|
|
|
const SkScalar xpos[], SkScalar constY,
|
2013-03-17 18:33:46 +00:00
|
|
|
const SkPaint& paint) {
|
2013-03-22 12:25:30 +00:00
|
|
|
size_t numPts = paint.countText(text, byteLength);
|
|
|
|
|
|
|
|
fText = new char[byteLength];
|
|
|
|
memcpy(fText, text, byteLength);
|
2013-03-17 18:33:46 +00:00
|
|
|
fByteLength = byteLength;
|
2013-03-22 12:25:30 +00:00
|
|
|
|
|
|
|
fXpos = new SkScalar[numPts];
|
|
|
|
memcpy(fXpos, xpos, numPts * sizeof(SkScalar));
|
|
|
|
|
2013-03-17 18:33:46 +00:00
|
|
|
fConstY = constY;
|
|
|
|
fPaint = paint;
|
|
|
|
fDrawType = DRAW_POS_TEXT_H;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-03-17 18:33:46 +00:00
|
|
|
fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
|
|
|
|
fInfo.push(SkObjectParser::ScalarToString(xpos[0], "XPOS: "));
|
|
|
|
fInfo.push(SkObjectParser::ScalarToString(constY, "SkScalar constY: "));
|
|
|
|
fInfo.push(SkObjectParser::PaintToString(paint));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawPosTextH::execute(SkCanvas* canvas) {
|
2013-03-17 18:33:46 +00:00
|
|
|
canvas->drawPosTextH(fText, fByteLength, fXpos, fConstY, fPaint);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DrawRectC::DrawRectC(const SkRect& rect, const SkPaint& paint) {
|
2013-03-17 18:33:46 +00:00
|
|
|
fRect = rect;
|
|
|
|
fPaint = paint;
|
|
|
|
fDrawType = DRAW_RECT;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-03-17 18:33:46 +00:00
|
|
|
fInfo.push(SkObjectParser::RectToString(rect));
|
|
|
|
fInfo.push(SkObjectParser::PaintToString(paint));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawRectC::execute(SkCanvas* canvas) {
|
2013-03-17 18:33:46 +00:00
|
|
|
canvas->drawRect(fRect, fPaint);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-02 20:20:31 +00:00
|
|
|
DrawRRect::DrawRRect(const SkRRect& rrect, const SkPaint& paint) {
|
2013-03-25 11:50:42 +00:00
|
|
|
fRRect = rrect;
|
|
|
|
fPaint = paint;
|
|
|
|
fDrawType = DRAW_RRECT;
|
2013-01-02 20:20:31 +00:00
|
|
|
|
2013-03-25 11:50:42 +00:00
|
|
|
fInfo.push(SkObjectParser::RRectToString(rrect));
|
|
|
|
fInfo.push(SkObjectParser::PaintToString(paint));
|
2013-01-02 20:20:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawRRect::execute(SkCanvas* canvas) {
|
2013-03-11 22:53:11 +00:00
|
|
|
canvas->drawRRect(fRRect, fPaint);
|
2013-01-02 20:20:31 +00:00
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
DrawSprite::DrawSprite(const SkBitmap& bitmap, int left, int top,
|
2013-03-25 11:50:42 +00:00
|
|
|
const SkPaint* paint, SkBitmap& resizedBitmap) {
|
|
|
|
fBitmap = bitmap;
|
|
|
|
fLeft = left;
|
|
|
|
fTop = top;
|
|
|
|
if (NULL != paint) {
|
|
|
|
fPaint = *paint;
|
|
|
|
fPaintPtr = &fPaint;
|
|
|
|
} else {
|
|
|
|
fPaintPtr = NULL;
|
|
|
|
}
|
|
|
|
fDrawType = DRAW_SPRITE;
|
|
|
|
fResizedBitmap = resizedBitmap;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-03-25 11:50:42 +00:00
|
|
|
fInfo.push(SkObjectParser::BitmapToString(bitmap));
|
|
|
|
fInfo.push(SkObjectParser::IntToString(left, "Left: "));
|
|
|
|
fInfo.push(SkObjectParser::IntToString(top, "Top: "));
|
|
|
|
if (NULL != paint) {
|
|
|
|
fInfo.push(SkObjectParser::PaintToString(*paint));
|
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawSprite::execute(SkCanvas* canvas) {
|
2013-03-25 11:50:42 +00:00
|
|
|
canvas->drawSprite(fBitmap, fLeft, fTop, fPaintPtr);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-11-26 13:09:17 +00:00
|
|
|
const SkBitmap* DrawSprite::getBitmap() const {
|
|
|
|
return &fResizedBitmap;
|
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
DrawTextC::DrawTextC(const void* text, size_t byteLength, SkScalar x, SkScalar y,
|
2013-03-25 11:50:42 +00:00
|
|
|
const SkPaint& paint) {
|
|
|
|
fText = new char[byteLength];
|
|
|
|
memcpy(fText, text, byteLength);
|
|
|
|
fByteLength = byteLength;
|
|
|
|
fX = x;
|
|
|
|
fY = y;
|
|
|
|
fPaint = paint;
|
|
|
|
fDrawType = DRAW_TEXT;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-03-25 11:50:42 +00:00
|
|
|
fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
|
|
|
|
fInfo.push(SkObjectParser::ScalarToString(x, "SkScalar x: "));
|
|
|
|
fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: "));
|
|
|
|
fInfo.push(SkObjectParser::PaintToString(paint));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawTextC::execute(SkCanvas* canvas) {
|
2013-03-25 11:50:42 +00:00
|
|
|
canvas->drawText(fText, fByteLength, fX, fY, fPaint);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DrawTextOnPath::DrawTextOnPath(const void* text, size_t byteLength,
|
2013-03-26 07:01:04 +00:00
|
|
|
const SkPath& path, const SkMatrix* matrix,
|
2013-03-25 11:50:42 +00:00
|
|
|
const SkPaint& paint) {
|
|
|
|
fText = new char[byteLength];
|
|
|
|
memcpy(fText, text, byteLength);
|
|
|
|
fByteLength = byteLength;
|
|
|
|
fPath = path;
|
|
|
|
if (NULL != matrix) {
|
|
|
|
fMatrix = *matrix;
|
|
|
|
} else {
|
|
|
|
fMatrix.setIdentity();
|
|
|
|
}
|
|
|
|
fPaint = paint;
|
|
|
|
fDrawType = DRAW_TEXT_ON_PATH;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-03-25 11:50:42 +00:00
|
|
|
fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
|
|
|
|
fInfo.push(SkObjectParser::PathToString(path));
|
|
|
|
if (NULL != matrix) {
|
|
|
|
fInfo.push(SkObjectParser::MatrixToString(*matrix));
|
|
|
|
}
|
|
|
|
fInfo.push(SkObjectParser::PaintToString(paint));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawTextOnPath::execute(SkCanvas* canvas) {
|
2013-03-25 11:50:42 +00:00
|
|
|
canvas->drawTextOnPath(fText, fByteLength, fPath,
|
|
|
|
fMatrix.isIdentity() ? NULL : &fMatrix,
|
|
|
|
fPaint);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DrawVertices::DrawVertices(SkCanvas::VertexMode vmode, int vertexCount,
|
2013-03-26 07:01:04 +00:00
|
|
|
const SkPoint vertices[], const SkPoint texs[],
|
|
|
|
const SkColor colors[], SkXfermode* xfermode,
|
2013-03-25 11:50:42 +00:00
|
|
|
const uint16_t indices[], int indexCount,
|
|
|
|
const SkPaint& paint) {
|
|
|
|
fVmode = vmode;
|
|
|
|
|
|
|
|
fVertexCount = vertexCount;
|
|
|
|
|
|
|
|
fVertices = new SkPoint[vertexCount];
|
|
|
|
memcpy(fVertices, vertices, vertexCount * sizeof(SkPoint));
|
|
|
|
|
|
|
|
if (NULL != texs) {
|
|
|
|
fTexs = new SkPoint[vertexCount];
|
|
|
|
memcpy(fTexs, texs, vertexCount * sizeof(SkPoint));
|
|
|
|
} else {
|
|
|
|
fTexs = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL != colors) {
|
|
|
|
fColors = new SkColor[vertexCount];
|
|
|
|
memcpy(fColors, colors, vertexCount * sizeof(SkColor));
|
|
|
|
} else {
|
|
|
|
fColors = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
fXfermode = xfermode;
|
|
|
|
if (NULL != fXfermode) {
|
|
|
|
fXfermode->ref();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (indexCount > 0) {
|
|
|
|
fIndices = new uint16_t[indexCount];
|
|
|
|
memcpy(fIndices, indices, indexCount * sizeof(uint16_t));
|
|
|
|
} else {
|
|
|
|
fIndices = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
fIndexCount = indexCount;
|
|
|
|
fPaint = paint;
|
|
|
|
fDrawType = DRAW_VERTICES;
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
// TODO(chudy)
|
2013-03-25 11:50:42 +00:00
|
|
|
fInfo.push(SkObjectParser::CustomTextToString("To be implemented."));
|
|
|
|
fInfo.push(SkObjectParser::PaintToString(paint));
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawVertices::~DrawVertices() {
|
|
|
|
delete [] fVertices;
|
|
|
|
delete [] fTexs;
|
|
|
|
delete [] fColors;
|
|
|
|
SkSafeUnref(fXfermode);
|
|
|
|
delete [] fIndices;
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawVertices::execute(SkCanvas* canvas) {
|
2013-03-25 11:50:42 +00:00
|
|
|
canvas->drawVertices(fVmode, fVertexCount, fVertices,
|
|
|
|
fTexs, fColors, fXfermode, fIndices,
|
|
|
|
fIndexCount, fPaint);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Restore::Restore() {
|
2013-03-22 16:33:31 +00:00
|
|
|
fDrawType = RESTORE;
|
|
|
|
fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Restore::execute(SkCanvas* canvas) {
|
|
|
|
canvas->restore();
|
|
|
|
}
|
|
|
|
|
2012-11-27 16:09:42 +00:00
|
|
|
void Restore::trackSaveState(int* state) {
|
|
|
|
(*state)--;
|
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
Rotate::Rotate(SkScalar degrees) {
|
2013-03-25 11:50:42 +00:00
|
|
|
fDegrees = degrees;
|
|
|
|
fDrawType = ROTATE;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-03-25 11:50:42 +00:00
|
|
|
fInfo.push(SkObjectParser::ScalarToString(degrees, "SkScalar degrees: "));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Rotate::execute(SkCanvas* canvas) {
|
2013-03-25 11:50:42 +00:00
|
|
|
canvas->rotate(fDegrees);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Save::Save(SkCanvas::SaveFlags flags) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fFlags = flags;
|
|
|
|
fDrawType = SAVE;
|
|
|
|
fInfo.push(SkObjectParser::SaveFlagsToString(flags));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Save::execute(SkCanvas* canvas) {
|
2013-03-22 16:33:31 +00:00
|
|
|
canvas->save(fFlags);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-11-27 16:09:42 +00:00
|
|
|
void Save::trackSaveState(int* state) {
|
|
|
|
(*state)++;
|
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
SaveLayer::SaveLayer(const SkRect* bounds, const SkPaint* paint,
|
2013-03-22 16:33:31 +00:00
|
|
|
SkCanvas::SaveFlags flags) {
|
|
|
|
if (NULL != bounds) {
|
|
|
|
fBounds = *bounds;
|
|
|
|
} else {
|
|
|
|
fBounds.setEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL != paint) {
|
|
|
|
fPaint = *paint;
|
|
|
|
fPaintPtr = &fPaint;
|
|
|
|
} else {
|
|
|
|
fPaintPtr = NULL;
|
|
|
|
}
|
|
|
|
fFlags = flags;
|
|
|
|
fDrawType = SAVE_LAYER;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-03-22 16:33:31 +00:00
|
|
|
if (NULL != bounds) {
|
|
|
|
fInfo.push(SkObjectParser::RectToString(*bounds, "Bounds: "));
|
|
|
|
}
|
|
|
|
if (NULL != paint) {
|
|
|
|
fInfo.push(SkObjectParser::PaintToString(*paint));
|
|
|
|
}
|
|
|
|
fInfo.push(SkObjectParser::SaveFlagsToString(flags));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SaveLayer::execute(SkCanvas* canvas) {
|
2013-03-23 07:01:28 +00:00
|
|
|
canvas->saveLayer(fBounds.isEmpty() ? NULL : &fBounds,
|
2013-03-22 16:33:31 +00:00
|
|
|
fPaintPtr,
|
|
|
|
fFlags);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-11-27 16:09:42 +00:00
|
|
|
void SaveLayer::trackSaveState(int* state) {
|
|
|
|
(*state)++;
|
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
Scale::Scale(SkScalar sx, SkScalar sy) {
|
2013-03-25 11:50:42 +00:00
|
|
|
fSx = sx;
|
|
|
|
fSy = sy;
|
|
|
|
fDrawType = SCALE;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-03-25 11:50:42 +00:00
|
|
|
fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: "));
|
|
|
|
fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: "));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Scale::execute(SkCanvas* canvas) {
|
2013-03-25 11:50:42 +00:00
|
|
|
canvas->scale(fSx, fSy);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SetMatrix::SetMatrix(const SkMatrix& matrix) {
|
2013-03-25 11:50:42 +00:00
|
|
|
fMatrix = matrix;
|
|
|
|
fDrawType = SET_MATRIX;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-03-25 11:50:42 +00:00
|
|
|
fInfo.push(SkObjectParser::MatrixToString(matrix));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetMatrix::execute(SkCanvas* canvas) {
|
2013-03-25 11:50:42 +00:00
|
|
|
canvas->setMatrix(fMatrix);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Skew::Skew(SkScalar sx, SkScalar sy) {
|
2013-03-25 11:50:42 +00:00
|
|
|
fSx = sx;
|
|
|
|
fSy = sy;
|
|
|
|
fDrawType = SKEW;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-03-25 11:50:42 +00:00
|
|
|
fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: "));
|
|
|
|
fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: "));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Skew::execute(SkCanvas* canvas) {
|
2013-03-25 11:50:42 +00:00
|
|
|
canvas->skew(fSx, fSy);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Translate::Translate(SkScalar dx, SkScalar dy) {
|
2013-03-25 11:50:42 +00:00
|
|
|
fDx = dx;
|
|
|
|
fDy = dy;
|
|
|
|
fDrawType = TRANSLATE;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-03-25 11:50:42 +00:00
|
|
|
fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: "));
|
|
|
|
fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: "));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Translate::execute(SkCanvas* canvas) {
|
2013-03-25 11:50:42 +00:00
|
|
|
canvas->translate(fDx, fDy);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|