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"
|
2015-02-13 19:13:00 +00:00
|
|
|
#include "SkPicture.h"
|
2014-08-26 14:56:44 +00:00
|
|
|
#include "SkTextBlob.h"
|
2015-12-09 02:59:18 +00:00
|
|
|
#include "SkTextBlobRunIterator.h"
|
2014-08-26 14:56:44 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
// TODO(chudy): Refactor into non subclass model.
|
|
|
|
|
2015-02-13 19:13:00 +00:00
|
|
|
SkDrawCommand::SkDrawCommand(OpType type)
|
|
|
|
: fOpType(type)
|
2013-05-29 13:24:23 +00:00
|
|
|
, fVisible(true) {
|
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
SkDrawCommand::~SkDrawCommand() {
|
2012-08-07 20:41:37 +00:00
|
|
|
fInfo.deleteAll();
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 19:13:00 +00:00
|
|
|
const char* SkDrawCommand::GetCommandString(OpType type) {
|
2012-06-29 14:21:22 +00:00
|
|
|
switch (type) {
|
2015-04-02 03:58:37 +00:00
|
|
|
case kBeginDrawPicture_OpType: return "BeginDrawPicture";
|
2015-02-13 19:13:00 +00:00
|
|
|
case kClipPath_OpType: return "ClipPath";
|
|
|
|
case kClipRegion_OpType: return "ClipRegion";
|
|
|
|
case kClipRect_OpType: return "ClipRect";
|
|
|
|
case kClipRRect_OpType: return "ClipRRect";
|
|
|
|
case kConcat_OpType: return "Concat";
|
|
|
|
case kDrawBitmap_OpType: return "DrawBitmap";
|
|
|
|
case kDrawBitmapNine_OpType: return "DrawBitmapNine";
|
|
|
|
case kDrawBitmapRect_OpType: return "DrawBitmapRect";
|
|
|
|
case kDrawClear_OpType: return "DrawClear";
|
|
|
|
case kDrawDRRect_OpType: return "DrawDRRect";
|
2015-07-22 17:23:01 +00:00
|
|
|
case kDrawImage_OpType: return "DrawImage";
|
|
|
|
case kDrawImageRect_OpType: return "DrawImageRect";
|
2015-02-13 19:13:00 +00:00
|
|
|
case kDrawOval_OpType: return "DrawOval";
|
|
|
|
case kDrawPaint_OpType: return "DrawPaint";
|
|
|
|
case kDrawPatch_OpType: return "DrawPatch";
|
|
|
|
case kDrawPath_OpType: return "DrawPath";
|
|
|
|
case kDrawPoints_OpType: return "DrawPoints";
|
|
|
|
case kDrawPosText_OpType: return "DrawPosText";
|
|
|
|
case kDrawPosTextH_OpType: return "DrawPosTextH";
|
|
|
|
case kDrawRect_OpType: return "DrawRect";
|
|
|
|
case kDrawRRect_OpType: return "DrawRRect";
|
|
|
|
case kDrawText_OpType: return "DrawText";
|
|
|
|
case kDrawTextBlob_OpType: return "DrawTextBlob";
|
|
|
|
case kDrawTextOnPath_OpType: return "DrawTextOnPath";
|
|
|
|
case kDrawVertices_OpType: return "DrawVertices";
|
2015-04-02 03:58:37 +00:00
|
|
|
case kEndDrawPicture_OpType: return "EndDrawPicture";
|
2015-02-13 19:13:00 +00:00
|
|
|
case kRestore_OpType: return "Restore";
|
|
|
|
case kSave_OpType: return "Save";
|
|
|
|
case kSaveLayer_OpType: return "SaveLayer";
|
|
|
|
case kSetMatrix_OpType: return "SetMatrix";
|
2012-06-29 14:21:22 +00:00
|
|
|
default:
|
2015-02-13 19:13:00 +00:00
|
|
|
SkDebugf("OpType error 0x%08x\n", type);
|
2012-06-29 14:21:22 +00:00
|
|
|
SkASSERT(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
SkDEBUGFAIL("DrawType UNUSED\n");
|
2015-08-27 14:41:13 +00:00
|
|
|
return nullptr;
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
SkString SkDrawCommand::toString() const {
|
2015-02-13 19:13:00 +00:00
|
|
|
return SkString(GetCommandString(fOpType));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 19:13:00 +00:00
|
|
|
SkClearCommand::SkClearCommand(SkColor color) : INHERITED(kDrawClear_OpType) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fColor = color;
|
|
|
|
fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkClearCommand::execute(SkCanvas* canvas) const {
|
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);
|
|
|
|
|
|
|
|
const SkRect& bounds = path.getBounds();
|
2015-10-06 14:24:03 +00:00
|
|
|
if (bounds.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
2013-06-06 23:59:28 +00:00
|
|
|
|
2015-10-06 14:24:03 +00:00
|
|
|
SkAutoCanvasRestore acr(canvas, true);
|
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->drawPath(path, p);
|
|
|
|
}
|
|
|
|
|
2015-08-27 14:41:13 +00:00
|
|
|
void render_bitmap(SkCanvas* canvas, const SkBitmap& input, const SkRect* srcRect = nullptr) {
|
2013-06-06 23:59:28 +00:00
|
|
|
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
|
|
|
|
2015-09-24 13:56:27 +00:00
|
|
|
static const int kNumBlocks = 8;
|
|
|
|
|
2013-06-06 23:59:28 +00:00
|
|
|
canvas->clear(0xFFFFFFFF);
|
2015-09-24 13:56:27 +00:00
|
|
|
SkISize block = {
|
|
|
|
canvas->imageInfo().width()/kNumBlocks,
|
|
|
|
canvas->imageInfo().height()/kNumBlocks
|
|
|
|
};
|
|
|
|
for (int y = 0; y < kNumBlocks; ++y) {
|
|
|
|
for (int x = 0; x < kNumBlocks; ++x) {
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setColor((x+y)%2 ? SK_ColorLTGRAY : SK_ColorDKGRAY);
|
|
|
|
SkRect r = SkRect::MakeXYWH(SkIntToScalar(x*block.width()),
|
|
|
|
SkIntToScalar(y*block.height()),
|
|
|
|
SkIntToScalar(block.width()),
|
|
|
|
SkIntToScalar(block.height()));
|
|
|
|
canvas->drawRect(r, paint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-06 17:02:53 +00:00
|
|
|
canvas->drawBitmapRect(input, dst, nullptr);
|
2013-06-06 23:59:28 +00:00
|
|
|
|
2014-09-05 20:34:00 +00:00
|
|
|
if (srcRect) {
|
2013-06-06 23:59:28 +00:00
|
|
|
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
|
|
|
|
2014-02-24 17:28:55 +00:00
|
|
|
void render_drrect(SkCanvas* canvas, const SkRRect& outer, const SkRRect& inner) {
|
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
canvas->save();
|
|
|
|
|
|
|
|
const SkRect& bounds = outer.getBounds();
|
|
|
|
|
|
|
|
xlate_and_scale_to_bounds(canvas, bounds);
|
|
|
|
|
|
|
|
SkPaint p;
|
|
|
|
p.setColor(SK_ColorBLACK);
|
|
|
|
p.setStyle(SkPaint::kStroke_Style);
|
|
|
|
|
|
|
|
canvas->drawDRRect(outer, inner, p);
|
|
|
|
canvas->restore();
|
|
|
|
}
|
|
|
|
|
2013-06-06 23:59:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-03-25 23:31:33 +00:00
|
|
|
SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool doAA)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kClipPath_OpType) {
|
2013-03-17 18:33:46 +00:00
|
|
|
fPath = path;
|
|
|
|
fOp = op;
|
|
|
|
fDoAA = doAA;
|
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
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkClipPathCommand::execute(SkCanvas* canvas) const {
|
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
|
|
|
}
|
|
|
|
|
2014-03-27 03:02:48 +00:00
|
|
|
SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkRegion::Op op)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kClipRegion_OpType) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fRegion = region;
|
|
|
|
fOp = op;
|
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
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkClipRegionCommand::execute(SkCanvas* canvas) const {
|
2013-03-22 16:33:31 +00:00
|
|
|
canvas->clipRegion(fRegion, fOp);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-03-25 23:31:33 +00:00
|
|
|
SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool doAA)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kClipRect_OpType) {
|
2013-03-22 12:25:30 +00:00
|
|
|
fRect = rect;
|
|
|
|
fOp = op;
|
|
|
|
fDoAA = doAA;
|
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
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkClipRectCommand::execute(SkCanvas* canvas) const {
|
2013-03-22 12:25:30 +00:00
|
|
|
canvas->clipRect(fRect, fOp, fDoAA);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-03-27 03:02:48 +00:00
|
|
|
SkClipRRectCommand::SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bool doAA)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kClipRRect_OpType) {
|
2013-03-22 12:25:30 +00:00
|
|
|
fRRect = rrect;
|
|
|
|
fOp = op;
|
|
|
|
fDoAA = doAA;
|
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
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkClipRRectCommand::execute(SkCanvas* canvas) const {
|
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;
|
|
|
|
}
|
|
|
|
|
2014-03-25 23:31:33 +00:00
|
|
|
SkConcatCommand::SkConcatCommand(const SkMatrix& matrix)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kConcat_OpType) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fMatrix = matrix;
|
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
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkConcatCommand::execute(SkCanvas* canvas) const {
|
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,
|
2014-08-13 17:46:23 +00:00
|
|
|
const SkPaint* paint)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kDrawBitmap_OpType) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fBitmap = bitmap;
|
|
|
|
fLeft = left;
|
|
|
|
fTop = top;
|
2014-09-05 20:34:00 +00:00
|
|
|
if (paint) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fPaint = *paint;
|
|
|
|
fPaintPtr = &fPaint;
|
|
|
|
} else {
|
2015-08-27 14:41:13 +00:00
|
|
|
fPaintPtr = nullptr;
|
2013-03-22 16:33:31 +00:00
|
|
|
}
|
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: "));
|
2014-09-05 20:34:00 +00:00
|
|
|
if (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
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawBitmapCommand::execute(SkCanvas* canvas) const {
|
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
|
|
|
SkDrawBitmapNineCommand::SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center,
|
2014-03-27 03:02:48 +00:00
|
|
|
const SkRect& dst, const SkPaint* paint)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kDrawBitmapNine_OpType) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fBitmap = bitmap;
|
|
|
|
fCenter = center;
|
|
|
|
fDst = dst;
|
2014-09-05 20:34:00 +00:00
|
|
|
if (paint) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fPaint = *paint;
|
|
|
|
fPaintPtr = &fPaint;
|
|
|
|
} else {
|
2015-08-27 14:41:13 +00:00
|
|
|
fPaintPtr = nullptr;
|
2013-03-22 16:33:31 +00:00
|
|
|
}
|
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: "));
|
2014-09-05 20:34:00 +00:00
|
|
|
if (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
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawBitmapNineCommand::execute(SkCanvas* canvas) const {
|
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 {
|
2015-11-18 20:59:42 +00:00
|
|
|
SkRect tmp = SkRect::Make(fCenter);
|
|
|
|
render_bitmap(canvas, fBitmap, &tmp);
|
2013-06-06 23:59:28 +00:00
|
|
|
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,
|
2015-07-14 17:54:12 +00:00
|
|
|
SkCanvas::SrcRectConstraint constraint)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kDrawBitmapRect_OpType) {
|
2013-03-17 18:33:46 +00:00
|
|
|
fBitmap = bitmap;
|
2014-09-05 20:34:00 +00:00
|
|
|
if (src) {
|
2013-03-17 18:33:46 +00:00
|
|
|
fSrc = *src;
|
|
|
|
} else {
|
|
|
|
fSrc.setEmpty();
|
|
|
|
}
|
|
|
|
fDst = dst;
|
|
|
|
|
2014-09-05 20:34:00 +00:00
|
|
|
if (paint) {
|
2013-03-17 18:33:46 +00:00
|
|
|
fPaint = *paint;
|
|
|
|
fPaintPtr = &fPaint;
|
2013-01-31 15:56:22 +00:00
|
|
|
} else {
|
2015-08-27 14:41:13 +00:00
|
|
|
fPaintPtr = nullptr;
|
2013-01-31 15:56:22 +00:00
|
|
|
}
|
2015-07-14 17:54:12 +00:00
|
|
|
fConstraint = constraint;
|
2013-08-16 10:24:37 +00:00
|
|
|
|
2013-03-17 18:33:46 +00:00
|
|
|
fInfo.push(SkObjectParser::BitmapToString(bitmap));
|
2014-09-05 20:34:00 +00:00
|
|
|
if (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: "));
|
2014-09-05 20:34:00 +00:00
|
|
|
if (paint) {
|
2013-03-17 18:33:46 +00:00
|
|
|
fInfo.push(SkObjectParser::PaintToString(*paint));
|
2013-01-22 14:32:09 +00:00
|
|
|
}
|
2015-07-14 17:54:12 +00:00
|
|
|
fInfo.push(SkObjectParser::IntToString(fConstraint, "Constraint: "));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) const {
|
2015-08-06 17:02:53 +00:00
|
|
|
canvas->legacy_drawBitmapRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fConstraint);
|
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
|
|
|
}
|
|
|
|
|
2015-07-22 17:23:01 +00:00
|
|
|
SkDrawImageCommand::SkDrawImageCommand(const SkImage* image, SkScalar left, SkScalar top,
|
|
|
|
const SkPaint* paint)
|
|
|
|
: INHERITED(kDrawImage_OpType)
|
|
|
|
, fImage(SkRef(image))
|
|
|
|
, fLeft(left)
|
|
|
|
, fTop(top) {
|
|
|
|
|
2015-10-29 19:13:48 +00:00
|
|
|
fInfo.push(SkObjectParser::ImageToString(image));
|
|
|
|
fInfo.push(SkObjectParser::ScalarToString(left, "Left: "));
|
|
|
|
fInfo.push(SkObjectParser::ScalarToString(top, "Top: "));
|
|
|
|
|
2015-07-22 17:23:01 +00:00
|
|
|
if (paint) {
|
|
|
|
fPaint.set(*paint);
|
2015-10-29 19:13:48 +00:00
|
|
|
fInfo.push(SkObjectParser::PaintToString(*paint));
|
2015-07-22 17:23:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDrawImageCommand::execute(SkCanvas* canvas) const {
|
|
|
|
canvas->drawImage(fImage, fLeft, fTop, fPaint.getMaybeNull());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SkDrawImageCommand::render(SkCanvas* canvas) const {
|
|
|
|
SkAutoCanvasRestore acr(canvas, true);
|
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
|
|
|
|
xlate_and_scale_to_bounds(canvas, SkRect::MakeXYWH(fLeft, fTop,
|
|
|
|
SkIntToScalar(fImage->width()),
|
|
|
|
SkIntToScalar(fImage->height())));
|
|
|
|
this->execute(canvas);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
SkDrawImageRectCommand::SkDrawImageRectCommand(const SkImage* image, const SkRect* src,
|
|
|
|
const SkRect& dst, const SkPaint* paint,
|
|
|
|
SkCanvas::SrcRectConstraint constraint)
|
|
|
|
: INHERITED(kDrawImageRect_OpType)
|
|
|
|
, fImage(SkRef(image))
|
|
|
|
, fDst(dst)
|
|
|
|
, fConstraint(constraint) {
|
|
|
|
|
|
|
|
if (src) {
|
|
|
|
fSrc.set(*src);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (paint) {
|
|
|
|
fPaint.set(*paint);
|
|
|
|
}
|
2015-08-24 15:27:38 +00:00
|
|
|
|
|
|
|
fInfo.push(SkObjectParser::ImageToString(image));
|
|
|
|
if (src) {
|
|
|
|
fInfo.push(SkObjectParser::RectToString(*src, "Src: "));
|
|
|
|
}
|
|
|
|
fInfo.push(SkObjectParser::RectToString(dst, "Dst: "));
|
|
|
|
if (paint) {
|
|
|
|
fInfo.push(SkObjectParser::PaintToString(*paint));
|
|
|
|
}
|
|
|
|
fInfo.push(SkObjectParser::IntToString(fConstraint, "Constraint: "));
|
2015-07-22 17:23:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SkDrawImageRectCommand::execute(SkCanvas* canvas) const {
|
2015-08-06 17:02:53 +00:00
|
|
|
canvas->legacy_drawImageRect(fImage, fSrc.getMaybeNull(), fDst, fPaint.getMaybeNull(), fConstraint);
|
2015-07-22 17:23:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SkDrawImageRectCommand::render(SkCanvas* canvas) const {
|
|
|
|
SkAutoCanvasRestore acr(canvas, true);
|
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
|
|
|
|
xlate_and_scale_to_bounds(canvas, fDst);
|
|
|
|
|
|
|
|
this->execute(canvas);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-03-25 23:31:33 +00:00
|
|
|
SkDrawOvalCommand::SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kDrawOval_OpType) {
|
2013-03-22 12:25:30 +00:00
|
|
|
fOval = oval;
|
|
|
|
fPaint = paint;
|
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
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawOvalCommand::execute(SkCanvas* canvas) const {
|
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;
|
|
|
|
}
|
|
|
|
|
2014-03-25 23:31:33 +00:00
|
|
|
SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kDrawPaint_OpType) {
|
2013-03-22 12:25:30 +00:00
|
|
|
fPaint = 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
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawPaintCommand::execute(SkCanvas* canvas) const {
|
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;
|
|
|
|
}
|
|
|
|
|
2014-03-25 23:31:33 +00:00
|
|
|
SkDrawPathCommand::SkDrawPathCommand(const SkPath& path, const SkPaint& paint)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kDrawPath_OpType) {
|
2013-03-17 18:33:46 +00:00
|
|
|
fPath = path;
|
|
|
|
fPaint = paint;
|
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
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawPathCommand::execute(SkCanvas* canvas) const {
|
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
|
|
|
}
|
|
|
|
|
2015-04-02 03:58:37 +00:00
|
|
|
SkBeginDrawPictureCommand::SkBeginDrawPictureCommand(const SkPicture* picture,
|
|
|
|
const SkMatrix* matrix,
|
|
|
|
const SkPaint* paint)
|
|
|
|
: INHERITED(kBeginDrawPicture_OpType)
|
|
|
|
, fPicture(SkRef(picture)) {
|
2014-08-13 17:46:23 +00:00
|
|
|
|
2015-04-02 03:58:37 +00:00
|
|
|
SkString* str = new SkString;
|
|
|
|
str->appendf("SkPicture: L: %f T: %f R: %f B: %f",
|
|
|
|
picture->cullRect().fLeft, picture->cullRect().fTop,
|
|
|
|
picture->cullRect().fRight, picture->cullRect().fBottom);
|
|
|
|
fInfo.push(str);
|
2014-08-13 17:46:23 +00:00
|
|
|
|
2014-09-05 20:34:00 +00:00
|
|
|
if (matrix) {
|
2015-04-02 03:58:37 +00:00
|
|
|
fMatrix.set(*matrix);
|
2014-08-13 17:46:23 +00:00
|
|
|
fInfo.push(SkObjectParser::MatrixToString(*matrix));
|
|
|
|
}
|
2015-04-02 03:58:37 +00:00
|
|
|
|
2014-09-05 20:34:00 +00:00
|
|
|
if (paint) {
|
2015-04-02 03:58:37 +00:00
|
|
|
fPaint.set(*paint);
|
2014-08-13 17:46:23 +00:00
|
|
|
fInfo.push(SkObjectParser::PaintToString(*paint));
|
|
|
|
}
|
2015-04-02 03:58:37 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2015-04-02 03:58:37 +00:00
|
|
|
void SkBeginDrawPictureCommand::execute(SkCanvas* canvas) const {
|
|
|
|
if (fPaint.isValid()) {
|
|
|
|
SkRect bounds = fPicture->cullRect();
|
|
|
|
if (fMatrix.isValid()) {
|
|
|
|
fMatrix.get()->mapRect(&bounds);
|
|
|
|
}
|
|
|
|
canvas->saveLayer(&bounds, fPaint.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fMatrix.isValid()) {
|
|
|
|
if (!fPaint.isValid()) {
|
|
|
|
canvas->save();
|
|
|
|
}
|
|
|
|
canvas->concat(*fMatrix.get());
|
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2015-04-02 03:58:37 +00:00
|
|
|
bool SkBeginDrawPictureCommand::render(SkCanvas* canvas) const {
|
2013-11-21 17:08:12 +00:00
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
canvas->save();
|
|
|
|
|
2014-08-29 15:03:56 +00:00
|
|
|
xlate_and_scale_to_bounds(canvas, fPicture->cullRect());
|
2013-11-21 17:08:12 +00:00
|
|
|
|
2014-06-04 12:40:44 +00:00
|
|
|
canvas->drawPicture(fPicture.get());
|
2013-11-21 17:08:12 +00:00
|
|
|
|
|
|
|
canvas->restore();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-04-02 03:58:37 +00:00
|
|
|
SkEndDrawPictureCommand::SkEndDrawPictureCommand(bool restore)
|
|
|
|
: INHERITED(kEndDrawPicture_OpType) , fRestore(restore) { }
|
|
|
|
|
|
|
|
void SkEndDrawPictureCommand::execute(SkCanvas* canvas) const {
|
|
|
|
if (fRestore) {
|
|
|
|
canvas->restore();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawPointsCommand::SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count,
|
2014-03-25 23:31:33 +00:00
|
|
|
const SkPoint pts[], const SkPaint& paint)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kDrawPoints_OpType) {
|
2013-03-22 12:25:30 +00:00
|
|
|
fMode = mode;
|
|
|
|
fCount = count;
|
|
|
|
fPts = new SkPoint[count];
|
|
|
|
memcpy(fPts, pts, count * sizeof(SkPoint));
|
|
|
|
fPaint = paint;
|
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
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawPointsCommand::execute(SkCanvas* canvas) const {
|
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,
|
2014-03-25 23:31:33 +00:00
|
|
|
const SkPoint pos[], const SkPaint& paint)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kDrawPosText_OpType) {
|
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;
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawPosTextCommand::execute(SkCanvas* canvas) const {
|
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,
|
2014-03-25 23:31:33 +00:00
|
|
|
const SkPaint& paint)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kDrawPosTextH_OpType) {
|
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;
|
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
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawPosTextHCommand::execute(SkCanvas* canvas) const {
|
2013-03-17 18:33:46 +00:00
|
|
|
canvas->drawPosTextH(fText, fByteLength, fXpos, fConstY, fPaint);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-08-26 14:56:44 +00:00
|
|
|
SkDrawTextBlobCommand::SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x, SkScalar y,
|
|
|
|
const SkPaint& paint)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kDrawTextBlob_OpType)
|
2015-12-09 02:59:18 +00:00
|
|
|
, fBlob(SkRef(blob))
|
2014-08-26 14:56:44 +00:00
|
|
|
, fXPos(x)
|
|
|
|
, fYPos(y)
|
|
|
|
, fPaint(paint) {
|
|
|
|
|
2015-12-09 02:59:18 +00:00
|
|
|
SkAutoTDelete<SkString> runsStr(new SkString);
|
2014-08-26 14:56:44 +00:00
|
|
|
fInfo.push(SkObjectParser::ScalarToString(x, "XPOS: "));
|
2014-12-09 13:28:20 +00:00
|
|
|
fInfo.push(SkObjectParser::ScalarToString(y, "YPOS: "));
|
|
|
|
fInfo.push(SkObjectParser::RectToString(fBlob->bounds(), "Bounds: "));
|
2015-12-09 02:59:18 +00:00
|
|
|
fInfo.push(runsStr);
|
2014-08-26 14:56:44 +00:00
|
|
|
fInfo.push(SkObjectParser::PaintToString(paint));
|
2015-12-09 02:59:18 +00:00
|
|
|
|
|
|
|
unsigned runs = 0;
|
|
|
|
SkPaint runPaint(paint);
|
|
|
|
SkTextBlobRunIterator iter(blob);
|
|
|
|
while (!iter.done()) {
|
|
|
|
SkAutoTDelete<SkString> label(new SkString);
|
|
|
|
label->printf("==== Run [%d] ====", runs++);
|
|
|
|
fInfo.push(label.release());
|
|
|
|
|
|
|
|
fInfo.push(SkObjectParser::IntToString(iter.glyphCount(), "GlyphCount: "));
|
|
|
|
iter.applyFontToPaint(&runPaint);
|
|
|
|
fInfo.push(SkObjectParser::PaintToString(runPaint));
|
|
|
|
|
|
|
|
iter.next();
|
|
|
|
}
|
|
|
|
|
|
|
|
runsStr->printf("Runs: %d", runs);
|
|
|
|
// runStr is owned by fInfo at this point.
|
|
|
|
runsStr.release();
|
2014-08-26 14:56:44 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawTextBlobCommand::execute(SkCanvas* canvas) const {
|
2014-08-26 14:56:44 +00:00
|
|
|
canvas->drawTextBlob(fBlob, fXPos, fYPos, fPaint);
|
|
|
|
}
|
|
|
|
|
2014-08-29 22:08:20 +00:00
|
|
|
bool SkDrawTextBlobCommand::render(SkCanvas* canvas) const {
|
|
|
|
canvas->clear(SK_ColorWHITE);
|
|
|
|
canvas->save();
|
|
|
|
|
|
|
|
SkRect bounds = fBlob->bounds().makeOffset(fXPos, fYPos);
|
|
|
|
xlate_and_scale_to_bounds(canvas, bounds);
|
|
|
|
|
|
|
|
canvas->drawTextBlob(fBlob.get(), fXPos, fYPos, fPaint);
|
|
|
|
|
|
|
|
canvas->restore();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-02-13 19:13:00 +00:00
|
|
|
SkDrawPatchCommand::SkDrawPatchCommand(const SkPoint cubics[12], const SkColor colors[4],
|
|
|
|
const SkPoint texCoords[4], SkXfermode* xfermode,
|
|
|
|
const SkPaint& paint)
|
|
|
|
: INHERITED(kDrawPatch_OpType) {
|
|
|
|
memcpy(fCubics, cubics, sizeof(fCubics));
|
|
|
|
memcpy(fColors, colors, sizeof(fColors));
|
|
|
|
memcpy(fTexCoords, texCoords, sizeof(fTexCoords));
|
|
|
|
fXfermode.reset(xfermode);
|
|
|
|
fPaint = paint;
|
|
|
|
|
|
|
|
fInfo.push(SkObjectParser::PaintToString(paint));
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDrawPatchCommand::execute(SkCanvas* canvas) const {
|
|
|
|
canvas->drawPatch(fCubics, fColors, fTexCoords, fXfermode, fPaint);
|
|
|
|
}
|
|
|
|
|
2014-03-25 23:31:33 +00:00
|
|
|
SkDrawRectCommand::SkDrawRectCommand(const SkRect& rect, const SkPaint& paint)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kDrawRect_OpType) {
|
2013-03-17 18:33:46 +00:00
|
|
|
fRect = rect;
|
|
|
|
fPaint = paint;
|
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
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawRectCommand::execute(SkCanvas* canvas) const {
|
2013-03-17 18:33:46 +00:00
|
|
|
canvas->drawRect(fRect, fPaint);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-03-25 23:31:33 +00:00
|
|
|
SkDrawRRectCommand::SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kDrawRRect_OpType) {
|
2013-03-25 11:50:42 +00:00
|
|
|
fRRect = rrect;
|
|
|
|
fPaint = paint;
|
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
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawRRectCommand::execute(SkCanvas* canvas) const {
|
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;
|
|
|
|
}
|
|
|
|
|
2014-02-25 03:05:18 +00:00
|
|
|
SkDrawDRRectCommand::SkDrawDRRectCommand(const SkRRect& outer,
|
2014-02-24 17:28:55 +00:00
|
|
|
const SkRRect& inner,
|
2014-03-25 23:31:33 +00:00
|
|
|
const SkPaint& paint)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kDrawDRRect_OpType) {
|
2014-02-24 17:28:55 +00:00
|
|
|
fOuter = outer;
|
|
|
|
fInner = inner;
|
|
|
|
fPaint = paint;
|
|
|
|
|
|
|
|
fInfo.push(SkObjectParser::RRectToString(outer));
|
|
|
|
fInfo.push(SkObjectParser::RRectToString(inner));
|
|
|
|
fInfo.push(SkObjectParser::PaintToString(paint));
|
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawDRRectCommand::execute(SkCanvas* canvas) const {
|
2014-02-24 17:28:55 +00:00
|
|
|
canvas->drawDRRect(fOuter, fInner, fPaint);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SkDrawDRRectCommand::render(SkCanvas* canvas) const {
|
|
|
|
render_drrect(canvas, fOuter, fInner);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawTextCommand::SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar y,
|
2014-03-25 23:31:33 +00:00
|
|
|
const SkPaint& paint)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kDrawText_OpType) {
|
2013-03-25 11:50:42 +00:00
|
|
|
fText = new char[byteLength];
|
|
|
|
memcpy(fText, text, byteLength);
|
|
|
|
fByteLength = byteLength;
|
|
|
|
fX = x;
|
|
|
|
fY = y;
|
|
|
|
fPaint = paint;
|
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
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawTextCommand::execute(SkCanvas* canvas) const {
|
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,
|
2014-03-25 23:31:33 +00:00
|
|
|
const SkPaint& paint)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kDrawTextOnPath_OpType) {
|
2013-03-25 11:50:42 +00:00
|
|
|
fText = new char[byteLength];
|
|
|
|
memcpy(fText, text, byteLength);
|
|
|
|
fByteLength = byteLength;
|
|
|
|
fPath = path;
|
2014-09-05 20:34:00 +00:00
|
|
|
if (matrix) {
|
2013-03-25 11:50:42 +00:00
|
|
|
fMatrix = *matrix;
|
|
|
|
} else {
|
|
|
|
fMatrix.setIdentity();
|
|
|
|
}
|
|
|
|
fPaint = paint;
|
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));
|
2014-09-05 20:34:00 +00:00
|
|
|
if (matrix) {
|
2013-03-25 11:50:42 +00:00
|
|
|
fInfo.push(SkObjectParser::MatrixToString(*matrix));
|
|
|
|
}
|
|
|
|
fInfo.push(SkObjectParser::PaintToString(paint));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawTextOnPathCommand::execute(SkCanvas* canvas) const {
|
2013-03-25 11:50:42 +00:00
|
|
|
canvas->drawTextOnPath(fText, fByteLength, fPath,
|
2015-08-27 14:41:13 +00:00
|
|
|
fMatrix.isIdentity() ? nullptr : &fMatrix,
|
2013-03-25 11:50:42 +00:00
|
|
|
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,
|
2014-03-25 23:31:33 +00:00
|
|
|
const SkPaint& paint)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kDrawVertices_OpType) {
|
2013-03-25 11:50:42 +00:00
|
|
|
fVmode = vmode;
|
|
|
|
|
|
|
|
fVertexCount = vertexCount;
|
|
|
|
|
|
|
|
fVertices = new SkPoint[vertexCount];
|
|
|
|
memcpy(fVertices, vertices, vertexCount * sizeof(SkPoint));
|
|
|
|
|
2014-09-05 20:34:00 +00:00
|
|
|
if (texs) {
|
2013-03-25 11:50:42 +00:00
|
|
|
fTexs = new SkPoint[vertexCount];
|
|
|
|
memcpy(fTexs, texs, vertexCount * sizeof(SkPoint));
|
|
|
|
} else {
|
2015-08-27 14:41:13 +00:00
|
|
|
fTexs = nullptr;
|
2013-03-25 11:50:42 +00:00
|
|
|
}
|
|
|
|
|
2014-09-05 20:34:00 +00:00
|
|
|
if (colors) {
|
2013-03-25 11:50:42 +00:00
|
|
|
fColors = new SkColor[vertexCount];
|
|
|
|
memcpy(fColors, colors, vertexCount * sizeof(SkColor));
|
|
|
|
} else {
|
2015-08-27 14:41:13 +00:00
|
|
|
fColors = nullptr;
|
2013-03-25 11:50:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fXfermode = xfermode;
|
2014-09-05 20:34:00 +00:00
|
|
|
if (fXfermode) {
|
2013-03-25 11:50:42 +00:00
|
|
|
fXfermode->ref();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (indexCount > 0) {
|
|
|
|
fIndices = new uint16_t[indexCount];
|
|
|
|
memcpy(fIndices, indices, indexCount * sizeof(uint16_t));
|
|
|
|
} else {
|
2015-08-27 14:41:13 +00:00
|
|
|
fIndices = nullptr;
|
2013-03-25 11:50:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fIndexCount = indexCount;
|
|
|
|
fPaint = paint;
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawVerticesCommand::execute(SkCanvas* canvas) const {
|
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
|
|
|
}
|
|
|
|
|
2014-03-25 23:31:33 +00:00
|
|
|
SkRestoreCommand::SkRestoreCommand()
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kRestore_OpType) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkRestoreCommand::execute(SkCanvas* canvas) const {
|
2012-06-29 14:21:22 +00:00
|
|
|
canvas->restore();
|
|
|
|
}
|
|
|
|
|
2014-06-30 14:13:28 +00:00
|
|
|
SkSaveCommand::SkSaveCommand()
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kSave_OpType) {
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkSaveCommand::execute(SkCanvas* canvas) const {
|
2014-06-30 14:13:28 +00:00
|
|
|
canvas->save();
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkSaveLayerCommand::SkSaveLayerCommand(const SkRect* bounds, const SkPaint* paint,
|
2014-03-25 23:31:33 +00:00
|
|
|
SkCanvas::SaveFlags flags)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kSaveLayer_OpType) {
|
2014-09-05 20:34:00 +00:00
|
|
|
if (bounds) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fBounds = *bounds;
|
|
|
|
} else {
|
|
|
|
fBounds.setEmpty();
|
|
|
|
}
|
|
|
|
|
2014-09-05 20:34:00 +00:00
|
|
|
if (paint) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fPaint = *paint;
|
|
|
|
fPaintPtr = &fPaint;
|
|
|
|
} else {
|
2015-08-27 14:41:13 +00:00
|
|
|
fPaintPtr = nullptr;
|
2013-03-22 16:33:31 +00:00
|
|
|
}
|
|
|
|
fFlags = flags;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2014-09-05 20:34:00 +00:00
|
|
|
if (bounds) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fInfo.push(SkObjectParser::RectToString(*bounds, "Bounds: "));
|
|
|
|
}
|
2014-09-05 20:34:00 +00:00
|
|
|
if (paint) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fInfo.push(SkObjectParser::PaintToString(*paint));
|
|
|
|
}
|
|
|
|
fInfo.push(SkObjectParser::SaveFlagsToString(flags));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkSaveLayerCommand::execute(SkCanvas* canvas) const {
|
2015-08-27 14:41:13 +00:00
|
|
|
canvas->saveLayer(fBounds.isEmpty() ? nullptr : &fBounds,
|
2013-03-22 16:33:31 +00:00
|
|
|
fPaintPtr,
|
|
|
|
fFlags);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkSaveLayerCommand::vizExecute(SkCanvas* canvas) const {
|
2014-03-03 23:25:41 +00:00
|
|
|
canvas->save();
|
|
|
|
}
|
|
|
|
|
2014-03-25 23:31:33 +00:00
|
|
|
SkSetMatrixCommand::SkSetMatrixCommand(const SkMatrix& matrix)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kSetMatrix_OpType) {
|
2014-10-16 21:28:28 +00:00
|
|
|
fUserMatrix.reset();
|
2013-03-25 11:50:42 +00:00
|
|
|
fMatrix = 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
|
|
|
}
|
|
|
|
|
2014-10-16 21:28:28 +00:00
|
|
|
void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) {
|
|
|
|
fUserMatrix = userMatrix;
|
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkSetMatrixCommand::execute(SkCanvas* canvas) const {
|
2014-10-16 21:28:28 +00:00
|
|
|
SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix);
|
|
|
|
canvas->setMatrix(temp);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|