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-30 07:01:29 +00:00
|
|
|
SkDrawCommand::SkDrawCommand(DrawType type)
|
2013-05-29 13:24:23 +00:00
|
|
|
: 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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkClearCommand::SkClearCommand(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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkClearCommand::execute(SkCanvas* canvas) {
|
2013-03-22 16:33:31 +00:00
|
|
|
canvas->clear(fColor);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 23:59:28 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
void xlate_and_scale_to_bounds(SkCanvas* canvas, const SkRect& bounds) {
|
|
|
|
const SkISize& size = canvas->getDeviceSize();
|
|
|
|
|
|
|
|
static const SkScalar kInsetFrac = 0.9f; // Leave a border around object
|
|
|
|
|
|
|
|
canvas->translate(size.fWidth/2.0f, size.fHeight/2.0f);
|
|
|
|
if (bounds.width() > bounds.height()) {
|
|
|
|
canvas->scale(SkDoubleToScalar((kInsetFrac*size.fWidth)/bounds.width()),
|
|
|
|
SkDoubleToScalar((kInsetFrac*size.fHeight)/bounds.width()));
|
|
|
|
} else {
|
|
|
|
canvas->scale(SkDoubleToScalar((kInsetFrac*size.fWidth)/bounds.height()),
|
|
|
|
SkDoubleToScalar((kInsetFrac*size.fHeight)/bounds.height()));
|
|
|
|
}
|
|
|
|
canvas->translate(-bounds.centerX(), -bounds.centerY());
|
|
|
|
}
|
2013-06-07 07:01:06 +00:00
|
|
|
|
2013-06-06 23:59:28 +00:00
|
|
|
|
|
|
|
void render_path(SkCanvas* canvas, const SkPath& path) {
|
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
canvas->save();
|
|
|
|
|
|
|
|
const SkRect& bounds = path.getBounds();
|
|
|
|
|
|
|
|
xlate_and_scale_to_bounds(canvas, bounds);
|
|
|
|
|
|
|
|
SkPaint p;
|
|
|
|
p.setColor(SK_ColorBLACK);
|
|
|
|
p.setStyle(SkPaint::kStroke_Style);
|
|
|
|
|
|
|
|
canvas->drawPath(path, p);
|
|
|
|
canvas->restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
void render_bitmap(SkCanvas* canvas, const SkBitmap& input, const SkRect* srcRect = NULL) {
|
|
|
|
const SkISize& size = canvas->getDeviceSize();
|
|
|
|
|
|
|
|
SkScalar xScale = SkIntToScalar(size.fWidth-2) / input.width();
|
|
|
|
SkScalar yScale = SkIntToScalar(size.fHeight-2) / input.height();
|
|
|
|
|
|
|
|
if (input.width() > input.height()) {
|
|
|
|
yScale *= input.height() / (float) input.width();
|
|
|
|
} else {
|
|
|
|
xScale *= input.width() / (float) input.height();
|
|
|
|
}
|
|
|
|
|
|
|
|
SkRect dst = SkRect::MakeXYWH(SK_Scalar1, SK_Scalar1,
|
|
|
|
xScale * input.width(),
|
|
|
|
yScale * input.height());
|
2013-06-07 07:01:06 +00:00
|
|
|
|
2013-06-06 23:59:28 +00:00
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
canvas->drawBitmapRect(input, NULL, dst);
|
|
|
|
|
|
|
|
if (NULL != srcRect) {
|
|
|
|
SkRect r = SkRect::MakeLTRB(srcRect->fLeft * xScale + SK_Scalar1,
|
|
|
|
srcRect->fTop * yScale + SK_Scalar1,
|
|
|
|
srcRect->fRight * xScale + SK_Scalar1,
|
|
|
|
srcRect->fBottom * yScale + SK_Scalar1);
|
|
|
|
SkPaint p;
|
|
|
|
p.setColor(SK_ColorRED);
|
|
|
|
p.setStyle(SkPaint::kStroke_Style);
|
|
|
|
|
|
|
|
canvas->drawRect(r, p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void render_rrect(SkCanvas* canvas, const SkRRect& rrect) {
|
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
canvas->save();
|
|
|
|
|
|
|
|
const SkRect& bounds = rrect.getBounds();
|
|
|
|
|
|
|
|
xlate_and_scale_to_bounds(canvas, bounds);
|
|
|
|
|
|
|
|
SkPaint p;
|
|
|
|
p.setColor(SK_ColorBLACK);
|
|
|
|
p.setStyle(SkPaint::kStroke_Style);
|
|
|
|
|
|
|
|
canvas->drawRRect(rrect, p);
|
|
|
|
canvas->restore();
|
|
|
|
}
|
2013-06-07 07:01:06 +00:00
|
|
|
|
2013-06-06 23:59:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool doAA) {
|
2013-03-17 18:33:46 +00:00
|
|
|
fPath = path;
|
|
|
|
fOp = op;
|
|
|
|
fDoAA = doAA;
|
|
|
|
fDrawType = CLIP_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::RegionOpToString(op));
|
|
|
|
fInfo.push(SkObjectParser::BoolToString(doAA));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkClipPathCommand::execute(SkCanvas* canvas) {
|
2013-03-17 18:33:46 +00:00
|
|
|
canvas->clipPath(fPath, fOp, fDoAA);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
bool SkClipPathCommand::render(SkCanvas* canvas) const {
|
2013-06-06 23:59:28 +00:00
|
|
|
render_path(canvas, fPath);
|
|
|
|
return true;
|
2012-11-21 17:11:02 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkClipRegionCommand::SkClipRegionCommand(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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkClipRegionCommand::execute(SkCanvas* canvas) {
|
2013-03-22 16:33:31 +00:00
|
|
|
canvas->clipRegion(fRegion, fOp);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkClipRectCommand::SkClipRectCommand(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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkClipRectCommand::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-06-18 20:20:55 +00:00
|
|
|
SkClipRRectCommand::SkClipRRectCommand(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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkClipRRectCommand::execute(SkCanvas* canvas) {
|
2013-03-22 12:25:30 +00:00
|
|
|
canvas->clipRRect(fRRect, fOp, fDoAA);
|
2013-01-02 20:20:31 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
bool SkClipRRectCommand::render(SkCanvas* canvas) const {
|
2013-06-06 23:59:28 +00:00
|
|
|
render_rrect(canvas, fRRect);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkConcatCommand::SkConcatCommand(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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkConcatCommand::execute(SkCanvas* canvas) {
|
2013-03-22 16:33:31 +00:00
|
|
|
canvas->concat(fMatrix);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top,
|
2013-06-06 23:59:28 +00:00
|
|
|
const SkPaint* paint) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fBitmap = bitmap;
|
|
|
|
fLeft = left;
|
|
|
|
fTop = top;
|
|
|
|
if (NULL != paint) {
|
|
|
|
fPaint = *paint;
|
|
|
|
fPaintPtr = &fPaint;
|
|
|
|
} else {
|
|
|
|
fPaintPtr = NULL;
|
|
|
|
}
|
|
|
|
fDrawType = DRAW_BITMAP;
|
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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkDrawBitmapCommand::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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
bool SkDrawBitmapCommand::render(SkCanvas* canvas) const {
|
2013-06-06 23:59:28 +00:00
|
|
|
render_bitmap(canvas, fBitmap);
|
|
|
|
return true;
|
2012-11-26 13:09:17 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawBitmapMatrixCommand::SkDrawBitmapMatrixCommand(const SkBitmap& bitmap,
|
|
|
|
const SkMatrix& matrix,
|
|
|
|
const SkPaint* paint) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fBitmap = bitmap;
|
|
|
|
fMatrix = matrix;
|
|
|
|
if (NULL != paint) {
|
|
|
|
fPaint = *paint;
|
|
|
|
fPaintPtr = &fPaint;
|
|
|
|
} else {
|
|
|
|
fPaintPtr = NULL;
|
|
|
|
}
|
|
|
|
fDrawType = DRAW_BITMAP_MATRIX;
|
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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkDrawBitmapMatrixCommand::execute(SkCanvas* canvas) {
|
2013-03-22 16:33:31 +00:00
|
|
|
canvas->drawBitmapMatrix(fBitmap, fMatrix, fPaintPtr);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
bool SkDrawBitmapMatrixCommand::render(SkCanvas* canvas) const {
|
2013-06-06 23:59:28 +00:00
|
|
|
render_bitmap(canvas, fBitmap);
|
|
|
|
return true;
|
2012-11-26 13:09:17 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawBitmapNineCommand::SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center,
|
|
|
|
const SkRect& dst, const SkPaint* paint) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fBitmap = bitmap;
|
|
|
|
fCenter = center;
|
|
|
|
fDst = dst;
|
|
|
|
if (NULL != paint) {
|
|
|
|
fPaint = *paint;
|
|
|
|
fPaintPtr = &fPaint;
|
|
|
|
} else {
|
|
|
|
fPaintPtr = NULL;
|
|
|
|
}
|
|
|
|
fDrawType = DRAW_BITMAP_NINE;
|
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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkDrawBitmapNineCommand::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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
bool SkDrawBitmapNineCommand::render(SkCanvas* canvas) const {
|
2013-06-06 23:59:28 +00:00
|
|
|
render_bitmap(canvas, fBitmap);
|
|
|
|
return true;
|
2012-11-26 13:09:17 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src,
|
2013-08-16 10:24:37 +00:00
|
|
|
const SkRect& dst, const SkPaint* paint,
|
|
|
|
SkCanvas::DrawBitmapRectFlags flags) {
|
2013-03-17 18:33:46 +00:00
|
|
|
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-08-16 10:24:37 +00:00
|
|
|
fFlags = flags;
|
|
|
|
|
2013-03-17 18:33:46 +00:00
|
|
|
fDrawType = DRAW_BITMAP_RECT_TO_RECT;
|
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
|
|
|
}
|
2013-08-16 10:24:37 +00:00
|
|
|
fInfo.push(SkObjectParser::IntToString(fFlags, "Flags: "));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) {
|
2013-08-16 10:24:37 +00:00
|
|
|
canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fFlags);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const {
|
2013-06-06 23:59:28 +00:00
|
|
|
render_bitmap(canvas, fBitmap, this->srcRect());
|
|
|
|
return true;
|
2012-11-26 13:09:17 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawDataCommand::SkDrawDataCommand(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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkDrawDataCommand::execute(SkCanvas* canvas) {
|
2013-03-25 11:50:42 +00:00
|
|
|
canvas->drawData(fData, fLength);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkBeginCommentGroupCommand::SkBeginCommentGroupCommand(const char* description)
|
2013-05-29 13:24:23 +00:00
|
|
|
: INHERITED(BEGIN_COMMENT_GROUP)
|
|
|
|
, fDescription(description) {
|
|
|
|
SkString* temp = new SkString;
|
|
|
|
temp->appendf("Description: %s", description);
|
|
|
|
fInfo.push(temp);
|
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkCommentCommand::SkCommentCommand(const char* kywd, const char* value)
|
2013-05-29 13:24:23 +00:00
|
|
|
: INHERITED(COMMENT)
|
|
|
|
, fKywd(kywd)
|
|
|
|
, fValue(value) {
|
|
|
|
SkString* temp = new SkString;
|
|
|
|
temp->appendf("%s: %s", kywd, value);
|
|
|
|
fInfo.push(temp);
|
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkEndCommentGroupCommand::SkEndCommentGroupCommand() : INHERITED(END_COMMENT_GROUP) {
|
2013-05-29 13:24:23 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawOvalCommand::SkDrawOvalCommand(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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkDrawOvalCommand::execute(SkCanvas* canvas) {
|
2013-03-22 12:25:30 +00:00
|
|
|
canvas->drawOval(fOval, fPaint);
|
2013-01-02 20:20:31 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
bool SkDrawOvalCommand::render(SkCanvas* canvas) const {
|
2013-06-06 23:59:28 +00:00
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
canvas->save();
|
|
|
|
|
|
|
|
xlate_and_scale_to_bounds(canvas, fOval);
|
|
|
|
|
|
|
|
SkPaint p;
|
|
|
|
p.setColor(SK_ColorBLACK);
|
|
|
|
p.setStyle(SkPaint::kStroke_Style);
|
|
|
|
|
|
|
|
canvas->drawOval(fOval, p);
|
|
|
|
canvas->restore();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawPaintCommand::SkDrawPaintCommand(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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkDrawPaintCommand::execute(SkCanvas* canvas) {
|
2013-03-22 12:25:30 +00:00
|
|
|
canvas->drawPaint(fPaint);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
bool SkDrawPaintCommand::render(SkCanvas* canvas) const {
|
2013-06-06 23:59:28 +00:00
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
canvas->drawPaint(fPaint);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawPathCommand::SkDrawPathCommand(const SkPath& path, const SkPaint& paint) {
|
2013-03-17 18:33:46 +00:00
|
|
|
fPath = path;
|
|
|
|
fPaint = paint;
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkDrawPathCommand::execute(SkCanvas* canvas) {
|
2013-03-17 18:33:46 +00:00
|
|
|
canvas->drawPath(fPath, fPaint);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
bool SkDrawPathCommand::render(SkCanvas* canvas) const {
|
2013-06-06 23:59:28 +00:00
|
|
|
render_path(canvas, fPath);
|
|
|
|
return true;
|
2012-11-21 17:11:02 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawPictureCommand::SkDrawPictureCommand(SkPicture& picture) :
|
2013-03-25 11:50:42 +00:00
|
|
|
fPicture(picture) {
|
|
|
|
fDrawType = DRAW_PICTURE;
|
2013-11-21 17:08:12 +00:00
|
|
|
SkString* temp = new SkString;
|
|
|
|
temp->appendf("SkPicture: W: %d H: %d", picture.width(), picture.height());
|
|
|
|
fInfo.push(temp);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkDrawPictureCommand::execute(SkCanvas* canvas) {
|
2013-03-25 11:50:42 +00:00
|
|
|
canvas->drawPicture(fPicture);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-11-21 17:08:12 +00:00
|
|
|
bool SkDrawPictureCommand::render(SkCanvas* canvas) const {
|
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
canvas->save();
|
|
|
|
|
2013-11-21 17:50:15 +00:00
|
|
|
SkRect bounds = SkRect::MakeWH(SkIntToScalar(fPicture.width()),
|
|
|
|
SkIntToScalar(fPicture.height()));
|
2013-11-21 17:08:12 +00:00
|
|
|
xlate_and_scale_to_bounds(canvas, bounds);
|
|
|
|
|
|
|
|
canvas->drawPicture(const_cast<SkPicture&>(fPicture));
|
|
|
|
|
|
|
|
canvas->restore();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawPointsCommand::SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count,
|
|
|
|
const SkPoint pts[], const SkPaint& paint) {
|
2013-03-22 12:25:30 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkDrawPointsCommand::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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
bool SkDrawPointsCommand::render(SkCanvas* canvas) const {
|
2013-06-06 23:59:28 +00:00
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
canvas->save();
|
|
|
|
|
|
|
|
SkRect bounds;
|
|
|
|
|
|
|
|
bounds.setEmpty();
|
|
|
|
for (unsigned int i = 0; i < fCount; ++i) {
|
|
|
|
bounds.growToInclude(fPts[i].fX, fPts[i].fY);
|
|
|
|
}
|
2013-06-07 07:01:06 +00:00
|
|
|
|
2013-06-06 23:59:28 +00:00
|
|
|
xlate_and_scale_to_bounds(canvas, bounds);
|
|
|
|
|
|
|
|
SkPaint p;
|
|
|
|
p.setColor(SK_ColorBLACK);
|
|
|
|
p.setStyle(SkPaint::kStroke_Style);
|
|
|
|
|
|
|
|
canvas->drawPoints(fMode, fCount, fPts, p);
|
|
|
|
canvas->restore();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawPosTextCommand::SkDrawPosTextCommand(const void* text, size_t byteLength,
|
|
|
|
const SkPoint pos[], 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);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkDrawPosTextCommand::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
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawPosTextHCommand::SkDrawPosTextHCommand(const void* text, size_t byteLength,
|
|
|
|
const SkScalar xpos[], SkScalar constY,
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkDrawPosTextHCommand::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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawRectCommand::SkDrawRectCommand(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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkDrawRectCommand::execute(SkCanvas* canvas) {
|
2013-03-17 18:33:46 +00:00
|
|
|
canvas->drawRect(fRect, fPaint);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawRRectCommand::SkDrawRRectCommand(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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkDrawRRectCommand::execute(SkCanvas* canvas) {
|
2013-03-11 22:53:11 +00:00
|
|
|
canvas->drawRRect(fRRect, fPaint);
|
2013-01-02 20:20:31 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
bool SkDrawRRectCommand::render(SkCanvas* canvas) const {
|
2013-06-06 23:59:28 +00:00
|
|
|
render_rrect(canvas, fRRect);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawSpriteCommand::SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int top,
|
|
|
|
const SkPaint* paint) {
|
2013-03-25 11:50:42 +00:00
|
|
|
fBitmap = bitmap;
|
|
|
|
fLeft = left;
|
|
|
|
fTop = top;
|
|
|
|
if (NULL != paint) {
|
|
|
|
fPaint = *paint;
|
|
|
|
fPaintPtr = &fPaint;
|
|
|
|
} else {
|
|
|
|
fPaintPtr = NULL;
|
|
|
|
}
|
|
|
|
fDrawType = DRAW_SPRITE;
|
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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkDrawSpriteCommand::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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
bool SkDrawSpriteCommand::render(SkCanvas* canvas) const {
|
2013-06-06 23:59:28 +00:00
|
|
|
render_bitmap(canvas, fBitmap);
|
|
|
|
return true;
|
2012-11-26 13:09:17 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawTextCommand::SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar y,
|
|
|
|
const SkPaint& paint) {
|
2013-03-25 11:50:42 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkDrawTextCommand::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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLength,
|
|
|
|
const SkPath& path, const SkMatrix* matrix,
|
|
|
|
const SkPaint& paint) {
|
2013-03-25 11:50:42 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkDrawTextOnPathCommand::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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawVerticesCommand::SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int vertexCount,
|
|
|
|
const SkPoint vertices[], const SkPoint texs[],
|
|
|
|
const SkColor colors[], SkXfermode* xfermode,
|
|
|
|
const uint16_t indices[], int indexCount,
|
|
|
|
const SkPaint& paint) {
|
2013-03-25 11:50:42 +00:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawVerticesCommand::~SkDrawVerticesCommand() {
|
2013-03-25 11:50:42 +00:00
|
|
|
delete [] fVertices;
|
|
|
|
delete [] fTexs;
|
|
|
|
delete [] fColors;
|
|
|
|
SkSafeUnref(fXfermode);
|
|
|
|
delete [] fIndices;
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkDrawVerticesCommand::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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkRestoreCommand::SkRestoreCommand() {
|
2013-03-22 16:33:31 +00:00
|
|
|
fDrawType = RESTORE;
|
|
|
|
fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkRestoreCommand::execute(SkCanvas* canvas) {
|
2012-06-29 14:21:22 +00:00
|
|
|
canvas->restore();
|
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkRestoreCommand::trackSaveState(int* state) {
|
2012-11-27 16:09:42 +00:00
|
|
|
(*state)--;
|
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkRotateCommand::SkRotateCommand(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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkRotateCommand::execute(SkCanvas* canvas) {
|
2013-03-25 11:50:42 +00:00
|
|
|
canvas->rotate(fDegrees);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkSaveCommand::SkSaveCommand(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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkSaveCommand::execute(SkCanvas* canvas) {
|
2013-03-22 16:33:31 +00:00
|
|
|
canvas->save(fFlags);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkSaveCommand::trackSaveState(int* state) {
|
2012-11-27 16:09:42 +00:00
|
|
|
(*state)++;
|
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkSaveLayerCommand::SkSaveLayerCommand(const SkRect* bounds, const SkPaint* paint,
|
|
|
|
SkCanvas::SaveFlags flags) {
|
2013-03-22 16:33:31 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkSaveLayerCommand::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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkSaveLayerCommand::trackSaveState(int* state) {
|
2012-11-27 16:09:42 +00:00
|
|
|
(*state)++;
|
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkScaleCommand::SkScaleCommand(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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkScaleCommand::execute(SkCanvas* canvas) {
|
2013-03-25 11:50:42 +00:00
|
|
|
canvas->scale(fSx, fSy);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkSetMatrixCommand::SkSetMatrixCommand(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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkSetMatrixCommand::execute(SkCanvas* canvas) {
|
2013-03-25 11:50:42 +00:00
|
|
|
canvas->setMatrix(fMatrix);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkSkewCommand::SkSkewCommand(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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkSkewCommand::execute(SkCanvas* canvas) {
|
2013-03-25 11:50:42 +00:00
|
|
|
canvas->skew(fSx, fSy);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkTranslateCommand::SkTranslateCommand(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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
void SkTranslateCommand::execute(SkCanvas* canvas) {
|
2013-03-25 11:50:42 +00:00
|
|
|
canvas->translate(fDx, fDy);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|