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.
|
|
|
|
|
|
|
|
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";
|
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) {
|
|
|
|
this->fColor = color;
|
|
|
|
this->fDrawType = DRAW_CLEAR;
|
2012-08-07 20:41:37 +00:00
|
|
|
this->fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Clear::execute(SkCanvas* canvas) {
|
|
|
|
canvas->clear(this->fColor);
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
this->fRegion = ®ion;
|
|
|
|
this->fOp = op;
|
|
|
|
this->fDrawType = CLIP_REGION;
|
|
|
|
|
2012-08-07 20:41:37 +00:00
|
|
|
this->fInfo.push(SkObjectParser::RegionToString(region));
|
|
|
|
this->fInfo.push(SkObjectParser::RegionOpToString(op));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ClipRegion::execute(SkCanvas* canvas) {
|
|
|
|
canvas->clipRegion(*this->fRegion, this->fOp);
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
|
|
|
this->fMatrix = &matrix;
|
|
|
|
this->fDrawType = CONCAT;
|
|
|
|
|
2012-08-07 20:41:37 +00:00
|
|
|
this->fInfo.push(SkObjectParser::MatrixToString(matrix));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Concat::execute(SkCanvas* canvas) {
|
|
|
|
canvas->concat(*this->fMatrix);
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawBitmap::DrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
|
2012-11-26 13:09:17 +00:00
|
|
|
const SkPaint* paint, SkBitmap& resizedBitmap) {
|
2012-06-29 14:21:22 +00:00
|
|
|
this->fBitmap = &bitmap;
|
|
|
|
this->fLeft = left;
|
|
|
|
this->fTop = top;
|
|
|
|
this->fPaint = paint;
|
|
|
|
this->fDrawType = DRAW_BITMAP;
|
2012-11-26 13:09:17 +00:00
|
|
|
this->fResizedBitmap = resizedBitmap;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-08-07 20:41:37 +00:00
|
|
|
this->fInfo.push(SkObjectParser::BitmapToString(bitmap));
|
|
|
|
this->fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: "));
|
|
|
|
this->fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: "));
|
2013-01-22 14:32:09 +00:00
|
|
|
if (NULL != paint) {
|
|
|
|
this->fInfo.push(SkObjectParser::PaintToString(*paint));
|
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawBitmap::execute(SkCanvas* canvas) {
|
|
|
|
canvas->drawBitmap(*this->fBitmap, this->fLeft, this->fTop, this->fPaint);
|
|
|
|
}
|
|
|
|
|
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,
|
2012-11-26 13:09:17 +00:00
|
|
|
const SkMatrix& matrix, const SkPaint* paint, SkBitmap& resizedBitmap) {
|
2012-06-29 14:21:22 +00:00
|
|
|
this->fBitmap = &bitmap;
|
|
|
|
this->fMatrix = &matrix;
|
|
|
|
this->fPaint = paint;
|
|
|
|
this->fDrawType = DRAW_BITMAP_MATRIX;
|
2012-11-26 13:09:17 +00:00
|
|
|
this->fResizedBitmap = resizedBitmap;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-08-07 20:41:37 +00:00
|
|
|
this->fInfo.push(SkObjectParser::BitmapToString(bitmap));
|
|
|
|
this->fInfo.push(SkObjectParser::MatrixToString(matrix));
|
2013-01-22 14:32:09 +00:00
|
|
|
if (NULL != paint) {
|
|
|
|
this->fInfo.push(SkObjectParser::PaintToString(*paint));
|
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawBitmapMatrix::execute(SkCanvas* canvas) {
|
|
|
|
canvas->drawBitmapMatrix(*this->fBitmap, *this->fMatrix, this->fPaint);
|
|
|
|
}
|
|
|
|
|
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,
|
2012-11-26 13:09:17 +00:00
|
|
|
const SkRect& dst, const SkPaint* paint, SkBitmap& resizedBitmap) {
|
2012-06-29 14:21:22 +00:00
|
|
|
this->fBitmap = &bitmap;
|
|
|
|
this->fCenter = ¢er;
|
|
|
|
this->fDst = &dst;
|
|
|
|
this->fPaint = paint;
|
|
|
|
this->fDrawType = DRAW_BITMAP_NINE;
|
2012-11-26 13:09:17 +00:00
|
|
|
this->fResizedBitmap = resizedBitmap;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-08-07 20:41:37 +00:00
|
|
|
this->fInfo.push(SkObjectParser::BitmapToString(bitmap));
|
|
|
|
this->fInfo.push(SkObjectParser::IRectToString(center));
|
2012-11-06 16:45:36 +00:00
|
|
|
this->fInfo.push(SkObjectParser::RectToString(dst, "Dst: "));
|
2013-01-22 14:32:09 +00:00
|
|
|
if (NULL != paint) {
|
|
|
|
this->fInfo.push(SkObjectParser::PaintToString(*paint));
|
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawBitmapNine::execute(SkCanvas* canvas) {
|
|
|
|
canvas->drawBitmapNine(*this->fBitmap, *this->fCenter, *this->fDst, this->fPaint);
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
this->fData = data;
|
|
|
|
this->fLength = length;
|
|
|
|
this->fDrawType = DRAW_DATA;
|
|
|
|
// TODO(chudy): See if we can't display data and length.
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrawData::execute(SkCanvas* canvas) {
|
|
|
|
canvas->drawData(this->fData, this->fLength);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
DrawPicture::DrawPicture(SkPicture& picture) {
|
|
|
|
this->fPicture = &picture;
|
|
|
|
this->fDrawType = DRAW_PICTURE;
|
2012-08-07 20:41:37 +00:00
|
|
|
this->fInfo.push(SkObjectParser::CustomTextToString("To be implemented."));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawPicture::execute(SkCanvas* canvas) {
|
|
|
|
canvas->drawPicture(*this->fPicture);
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
|
|
|
this->fRRect = rrect;
|
2013-03-11 22:53:11 +00:00
|
|
|
this->fPaint = paint;
|
2013-01-02 20:20:31 +00:00
|
|
|
this->fDrawType = DRAW_RRECT;
|
|
|
|
|
|
|
|
this->fInfo.push(SkObjectParser::RRectToString(rrect));
|
|
|
|
this->fInfo.push(SkObjectParser::PaintToString(paint));
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
2012-11-26 13:09:17 +00:00
|
|
|
const SkPaint* paint, SkBitmap& resizedBitmap) {
|
2012-06-29 14:21:22 +00:00
|
|
|
this->fBitmap = &bitmap;
|
|
|
|
this->fLeft = left;
|
|
|
|
this->fTop = top;
|
|
|
|
this->fPaint = paint;
|
|
|
|
this->fDrawType = DRAW_SPRITE;
|
2012-11-26 13:09:17 +00:00
|
|
|
this->fResizedBitmap = resizedBitmap;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-08-07 20:41:37 +00:00
|
|
|
this->fInfo.push(SkObjectParser::BitmapToString(bitmap));
|
|
|
|
this->fInfo.push(SkObjectParser::IntToString(left, "Left: "));
|
|
|
|
this->fInfo.push(SkObjectParser::IntToString(top, "Top: "));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawSprite::execute(SkCanvas* canvas) {
|
|
|
|
canvas->drawSprite(*this->fBitmap, this->fLeft, this->fTop, this->fPaint);
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
const SkPaint& paint) {
|
|
|
|
this->fText = text;
|
|
|
|
this->fByteLength = byteLength;
|
|
|
|
this->fX = x;
|
|
|
|
this->fY = y;
|
|
|
|
this->fPaint = &paint;
|
|
|
|
this->fDrawType = DRAW_TEXT;
|
|
|
|
|
2013-03-07 20:30:32 +00:00
|
|
|
this->fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
|
2012-08-07 20:41:37 +00:00
|
|
|
this->fInfo.push(SkObjectParser::ScalarToString(x, "SkScalar x: "));
|
|
|
|
this->fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: "));
|
|
|
|
this->fInfo.push(SkObjectParser::PaintToString(paint));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawTextC::execute(SkCanvas* canvas) {
|
|
|
|
canvas->drawText(this->fText, this->fByteLength, this->fX, this->fY, *this->fPaint);
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawTextOnPath::DrawTextOnPath(const void* text, size_t byteLength,
|
|
|
|
const SkPath& path, const SkMatrix* matrix, const SkPaint& paint) {
|
|
|
|
this->fText = text;
|
|
|
|
this->fByteLength = byteLength;
|
|
|
|
this->fPath = &path;
|
|
|
|
this->fMatrix = matrix;
|
|
|
|
this->fPaint = &paint;
|
|
|
|
this->fDrawType = DRAW_TEXT_ON_PATH;
|
|
|
|
|
2013-03-07 20:30:32 +00:00
|
|
|
this->fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
|
2012-08-07 20:41:37 +00:00
|
|
|
this->fInfo.push(SkObjectParser::PathToString(path));
|
|
|
|
if (matrix) this->fInfo.push(SkObjectParser::MatrixToString(*matrix));
|
|
|
|
this->fInfo.push(SkObjectParser::PaintToString(paint));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawTextOnPath::execute(SkCanvas* canvas) {
|
|
|
|
canvas->drawTextOnPath(this->fText, this->fByteLength, *this->fPath,
|
|
|
|
this->fMatrix, *this->fPaint);
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawVertices::DrawVertices(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) {
|
|
|
|
this->fVmode = vmode;
|
|
|
|
this->fVertexCount = vertexCount;
|
|
|
|
this->fTexs = texs;
|
|
|
|
this->fColors = colors;
|
|
|
|
this->fXfermode = xfermode;
|
|
|
|
this->fIndices = indices;
|
|
|
|
this->fIndexCount = indexCount;
|
|
|
|
this->fPaint = &paint;
|
|
|
|
this->fDrawType = DRAW_VERTICES;
|
|
|
|
// TODO(chudy)
|
2012-08-07 20:41:37 +00:00
|
|
|
this->fInfo.push(SkObjectParser::CustomTextToString("To be implemented."));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawVertices::execute(SkCanvas* canvas) {
|
|
|
|
canvas->drawVertices(this->fVmode, this->fVertexCount, this->fVertices,
|
|
|
|
this->fTexs, this->fColors, this->fXfermode, this->fIndices,
|
|
|
|
this->fIndexCount, *this->fPaint);
|
|
|
|
}
|
|
|
|
|
|
|
|
Restore::Restore() {
|
|
|
|
this->fDrawType = RESTORE;
|
2012-08-07 20:41:37 +00:00
|
|
|
this->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) {
|
|
|
|
this->fDegrees = degrees;
|
|
|
|
this->fDrawType = ROTATE;
|
|
|
|
|
2012-08-07 20:41:37 +00:00
|
|
|
this->fInfo.push(SkObjectParser::ScalarToString(degrees, "SkScalar degrees: "));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Rotate::execute(SkCanvas* canvas) {
|
|
|
|
canvas->rotate(this->fDegrees);
|
|
|
|
}
|
|
|
|
|
|
|
|
Save::Save(SkCanvas::SaveFlags flags) {
|
|
|
|
this->fFlags = flags;
|
|
|
|
this->fDrawType = SAVE;
|
2012-08-07 20:41:37 +00:00
|
|
|
this->fInfo.push(SkObjectParser::SaveFlagsToString(flags));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Save::execute(SkCanvas* canvas) {
|
|
|
|
canvas->save(this->fFlags);
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
SkCanvas::SaveFlags flags) {
|
|
|
|
this->fBounds = bounds;
|
|
|
|
this->fPaint = paint;
|
|
|
|
this->fFlags = flags;
|
|
|
|
this->fDrawType = SAVE_LAYER;
|
|
|
|
|
2012-11-06 16:45:36 +00:00
|
|
|
if (bounds) this->fInfo.push(SkObjectParser::RectToString(*bounds, "Bounds: "));
|
2012-08-07 20:41:37 +00:00
|
|
|
if (paint) this->fInfo.push(SkObjectParser::PaintToString(*paint));
|
|
|
|
this->fInfo.push(SkObjectParser::SaveFlagsToString(flags));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SaveLayer::execute(SkCanvas* canvas) {
|
|
|
|
canvas->saveLayer(this->fBounds, this->fPaint, this->fFlags);
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
this->fSx = sx;
|
|
|
|
this->fSy = sy;
|
|
|
|
this->fDrawType = SCALE;
|
|
|
|
|
2012-08-07 20:41:37 +00:00
|
|
|
this->fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: "));
|
|
|
|
this->fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: "));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Scale::execute(SkCanvas* canvas) {
|
|
|
|
canvas->scale(this->fSx, this->fSy);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetMatrix::SetMatrix(const SkMatrix& matrix) {
|
2013-02-19 21:00:26 +00:00
|
|
|
this->fMatrix = matrix;
|
2012-06-29 14:21:22 +00:00
|
|
|
this->fDrawType = SET_MATRIX;
|
|
|
|
|
2012-08-07 20:41:37 +00:00
|
|
|
this->fInfo.push(SkObjectParser::MatrixToString(matrix));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetMatrix::execute(SkCanvas* canvas) {
|
2013-02-19 21:00:26 +00:00
|
|
|
canvas->setMatrix(this->fMatrix);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Skew::Skew(SkScalar sx, SkScalar sy) {
|
|
|
|
this->fSx = sx;
|
|
|
|
this->fSy = sy;
|
|
|
|
this->fDrawType = SKEW;
|
|
|
|
|
2012-08-07 20:41:37 +00:00
|
|
|
this->fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: "));
|
|
|
|
this->fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: "));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Skew::execute(SkCanvas* canvas) {
|
|
|
|
canvas->skew(this->fSx, this->fSy);
|
|
|
|
}
|
|
|
|
|
|
|
|
Translate::Translate(SkScalar dx, SkScalar dy) {
|
|
|
|
this->fDx = dx;
|
|
|
|
this->fDy = dy;
|
|
|
|
this->fDrawType = TRANSLATE;
|
|
|
|
|
2012-08-07 20:41:37 +00:00
|
|
|
this->fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: "));
|
|
|
|
this->fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: "));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Translate::execute(SkCanvas* canvas) {
|
|
|
|
canvas->translate(this->fDx, this->fDy);
|
|
|
|
}
|