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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SKDRAWCOMMAND_H_
|
|
|
|
#define SKDRAWCOMMAND_H_
|
|
|
|
|
2017-05-03 19:16:58 +00:00
|
|
|
#include "SkBitmap.h"
|
2012-06-29 14:21:22 +00:00
|
|
|
#include "SkCanvas.h"
|
2017-07-18 14:53:11 +00:00
|
|
|
#include "SkFlattenable.h"
|
2015-08-05 20:57:49 +00:00
|
|
|
#include "SkTLazy.h"
|
|
|
|
#include "SkPath.h"
|
2017-02-13 14:32:54 +00:00
|
|
|
#include "SkRegion.h"
|
2015-08-05 20:57:49 +00:00
|
|
|
#include "SkRRect.h"
|
2016-07-07 19:47:17 +00:00
|
|
|
#include "SkRSXform.h"
|
2013-05-29 13:24:23 +00:00
|
|
|
#include "SkString.h"
|
2015-08-05 20:57:49 +00:00
|
|
|
#include "SkTDArray.h"
|
2017-03-17 16:09:04 +00:00
|
|
|
#include "SkVertices.h"
|
2016-02-10 13:40:46 +00:00
|
|
|
#include "SkJSONCPP.h"
|
2016-02-11 18:35:21 +00:00
|
|
|
#include "UrlDataManager.h"
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2016-10-11 20:26:57 +00:00
|
|
|
class SkDrawCommand {
|
2012-06-29 14:21:22 +00:00
|
|
|
public:
|
2015-02-13 19:13:00 +00:00
|
|
|
enum OpType {
|
2015-04-02 03:58:37 +00:00
|
|
|
kBeginDrawPicture_OpType,
|
2015-02-13 19:13:00 +00:00
|
|
|
kClipPath_OpType,
|
|
|
|
kClipRegion_OpType,
|
|
|
|
kClipRect_OpType,
|
|
|
|
kClipRRect_OpType,
|
|
|
|
kConcat_OpType,
|
2016-06-29 01:54:19 +00:00
|
|
|
kDrawAnnotation_OpType,
|
2015-02-13 19:13:00 +00:00
|
|
|
kDrawBitmap_OpType,
|
|
|
|
kDrawBitmapNine_OpType,
|
|
|
|
kDrawBitmapRect_OpType,
|
|
|
|
kDrawClear_OpType,
|
|
|
|
kDrawDRRect_OpType,
|
2015-07-22 17:23:01 +00:00
|
|
|
kDrawImage_OpType,
|
2017-01-12 21:20:50 +00:00
|
|
|
kDrawImageLattice_OpType,
|
2015-07-22 17:23:01 +00:00
|
|
|
kDrawImageRect_OpType,
|
2015-02-13 19:13:00 +00:00
|
|
|
kDrawOval_OpType,
|
|
|
|
kDrawPaint_OpType,
|
|
|
|
kDrawPatch_OpType,
|
|
|
|
kDrawPath_OpType,
|
|
|
|
kDrawPoints_OpType,
|
|
|
|
kDrawPosText_OpType,
|
|
|
|
kDrawPosTextH_OpType,
|
|
|
|
kDrawRect_OpType,
|
|
|
|
kDrawRRect_OpType,
|
|
|
|
kDrawText_OpType,
|
|
|
|
kDrawTextBlob_OpType,
|
|
|
|
kDrawTextOnPath_OpType,
|
2016-07-07 19:47:17 +00:00
|
|
|
kDrawTextRSXform_OpType,
|
2015-02-13 19:13:00 +00:00
|
|
|
kDrawVertices_OpType,
|
2015-04-02 03:58:37 +00:00
|
|
|
kEndDrawPicture_OpType,
|
2015-02-13 19:13:00 +00:00
|
|
|
kRestore_OpType,
|
|
|
|
kSave_OpType,
|
|
|
|
kSaveLayer_OpType,
|
|
|
|
kSetMatrix_OpType,
|
|
|
|
|
2017-05-02 20:49:24 +00:00
|
|
|
kLast_OpType = kSetMatrix_OpType
|
2015-02-13 19:13:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const int kOpTypeCount = kLast_OpType + 1;
|
2015-02-12 14:37:12 +00:00
|
|
|
|
2016-10-17 20:19:02 +00:00
|
|
|
static void WritePNG(const uint8_t* rgba, unsigned width, unsigned height,
|
2016-06-30 17:06:51 +00:00
|
|
|
SkWStream& out, bool isOpaque);
|
2016-03-21 17:19:39 +00:00
|
|
|
|
2015-02-13 19:13:00 +00:00
|
|
|
SkDrawCommand(OpType opType);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
virtual ~SkDrawCommand();
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
virtual SkString toString() const;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
virtual const char* toCString() const {
|
2015-02-13 19:13:00 +00:00
|
|
|
return GetCommandString(fOpType);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-07-31 19:55:32 +00:00
|
|
|
bool isVisible() const {
|
|
|
|
return fVisible;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setVisible(bool toggle) {
|
|
|
|
fVisible = toggle;
|
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
const SkTDArray<SkString*>* Info() const { return &fInfo; }
|
|
|
|
virtual void execute(SkCanvas*) const = 0;
|
|
|
|
virtual void vizExecute(SkCanvas*) const {}
|
2014-10-16 21:28:28 +00:00
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
virtual void setUserMatrix(const SkMatrix&) {}
|
2014-10-16 21:28:28 +00:00
|
|
|
|
2014-12-12 16:46:25 +00:00
|
|
|
// The next "active" system is only used by save, saveLayer, and restore.
|
|
|
|
// It is used to determine which saveLayers are currently active (at a
|
2014-03-03 16:32:17 +00:00
|
|
|
// given point in the rendering).
|
2014-03-25 23:31:33 +00:00
|
|
|
// saves just return a kPushLayer action but don't track active state
|
|
|
|
// restores just return a kPopLayer action
|
2014-03-03 23:25:41 +00:00
|
|
|
// saveLayers return kPushLayer but also track the active state
|
2014-03-03 16:32:17 +00:00
|
|
|
enum Action {
|
|
|
|
kNone_Action,
|
2014-03-03 23:25:41 +00:00
|
|
|
kPopLayer_Action,
|
|
|
|
kPushLayer_Action,
|
2014-03-03 16:32:17 +00:00
|
|
|
};
|
|
|
|
virtual Action action() const { return kNone_Action; }
|
|
|
|
virtual void setActive(bool active) {}
|
|
|
|
virtual bool active() const { return false; }
|
|
|
|
|
2015-02-13 19:13:00 +00:00
|
|
|
OpType getType() const { return fOpType; }
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-06-06 23:59:28 +00:00
|
|
|
virtual bool render(SkCanvas* canvas) const { return false; }
|
2012-11-21 17:11:02 +00:00
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
virtual Json::Value toJSON(UrlDataManager& urlDataManager) const;
|
2016-02-10 13:40:46 +00:00
|
|
|
|
|
|
|
/* Converts a JSON representation of a command into a newly-allocated SkDrawCommand object. It
|
|
|
|
* is the caller's responsibility to delete this object. This method may return null if an error
|
|
|
|
* occurs.
|
|
|
|
*/
|
2016-02-11 18:35:21 +00:00
|
|
|
static SkDrawCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2015-02-13 19:13:00 +00:00
|
|
|
static const char* GetCommandString(OpType type);
|
2012-11-19 20:44:29 +00:00
|
|
|
|
2016-03-03 19:39:38 +00:00
|
|
|
// Helper methods for converting things to JSON
|
2016-05-04 18:06:28 +00:00
|
|
|
static Json::Value MakeJsonColor(const SkColor color);
|
2016-09-25 20:15:58 +00:00
|
|
|
static Json::Value MakeJsonColor4f(const SkColor4f& color);
|
2016-05-04 18:06:28 +00:00
|
|
|
static Json::Value MakeJsonPoint(const SkPoint& point);
|
|
|
|
static Json::Value MakeJsonPoint(SkScalar x, SkScalar y);
|
|
|
|
static Json::Value MakeJsonRect(const SkRect& rect);
|
2016-03-03 19:39:38 +00:00
|
|
|
static Json::Value MakeJsonIRect(const SkIRect&);
|
|
|
|
static Json::Value MakeJsonMatrix(const SkMatrix&);
|
2016-07-13 21:05:28 +00:00
|
|
|
static Json::Value MakeJsonScalar(SkScalar);
|
2016-05-04 18:06:28 +00:00
|
|
|
static Json::Value MakeJsonPath(const SkPath& path);
|
|
|
|
static Json::Value MakeJsonRegion(const SkRegion& region);
|
|
|
|
static Json::Value MakeJsonPaint(const SkPaint& paint, UrlDataManager& urlDataManager);
|
2017-01-12 21:20:50 +00:00
|
|
|
static Json::Value MakeJsonLattice(const SkCanvas::Lattice& lattice);
|
2016-05-04 18:06:28 +00:00
|
|
|
|
|
|
|
static void flatten(const SkFlattenable* flattenable, Json::Value* target,
|
|
|
|
UrlDataManager& urlDataManager);
|
|
|
|
static bool flatten(const SkImage& image, Json::Value* target,
|
|
|
|
UrlDataManager& urlDataManager);
|
|
|
|
static bool flatten(const SkBitmap& bitmap, Json::Value* target,
|
|
|
|
UrlDataManager& urlDataManager);
|
2016-03-03 19:39:38 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
protected:
|
2012-08-07 20:41:37 +00:00
|
|
|
SkTDArray<SkString*> fInfo;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
private:
|
2015-02-13 19:13:00 +00:00
|
|
|
OpType fOpType;
|
2014-03-25 23:31:33 +00:00
|
|
|
bool fVisible;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkRestoreCommand : public SkDrawCommand {
|
2012-06-29 14:21:22 +00:00
|
|
|
public:
|
2013-06-18 20:20:55 +00:00
|
|
|
SkRestoreCommand();
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
|
|
|
Action action() const override { return kPopLayer_Action; }
|
2016-02-11 18:35:21 +00:00
|
|
|
static SkRestoreCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2013-03-22 16:33:31 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
typedef SkDrawCommand INHERITED;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkClearCommand : public SkDrawCommand {
|
2012-06-29 14:21:22 +00:00
|
|
|
public:
|
2013-06-18 20:20:55 +00:00
|
|
|
SkClearCommand(SkColor color);
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkClearCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
private:
|
|
|
|
SkColor fColor;
|
2013-03-22 16:33:31 +00:00
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkClipPathCommand : public SkDrawCommand {
|
2012-06-29 14:21:22 +00:00
|
|
|
public:
|
2016-12-09 14:00:50 +00:00
|
|
|
SkClipPathCommand(const SkPath& path, SkClipOp op, bool doAA);
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
|
|
|
bool render(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkClipPathCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
private:
|
2016-12-09 14:00:50 +00:00
|
|
|
SkPath fPath;
|
|
|
|
SkClipOp fOp;
|
|
|
|
bool fDoAA;
|
2013-03-17 18:33:46 +00:00
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkClipRegionCommand : public SkDrawCommand {
|
2012-06-29 14:21:22 +00:00
|
|
|
public:
|
2016-12-09 14:00:50 +00:00
|
|
|
SkClipRegionCommand(const SkRegion& region, SkClipOp op);
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkClipRegionCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
private:
|
2016-12-09 14:00:50 +00:00
|
|
|
SkRegion fRegion;
|
|
|
|
SkClipOp fOp;
|
2013-03-22 16:33:31 +00:00
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkClipRectCommand : public SkDrawCommand {
|
2012-06-29 14:21:22 +00:00
|
|
|
public:
|
2016-12-09 14:00:50 +00:00
|
|
|
SkClipRectCommand(const SkRect& rect, SkClipOp op, bool doAA);
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkClipRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2013-03-11 22:53:11 +00:00
|
|
|
|
2013-03-22 12:25:30 +00:00
|
|
|
const SkRect& rect() const { return fRect; }
|
2016-12-09 14:00:50 +00:00
|
|
|
SkClipOp op() const { return fOp; }
|
2013-03-11 22:53:11 +00:00
|
|
|
bool doAA() const { return fDoAA; }
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
private:
|
2016-12-09 14:00:50 +00:00
|
|
|
SkRect fRect;
|
|
|
|
SkClipOp fOp;
|
|
|
|
bool fDoAA;
|
2013-03-22 12:25:30 +00:00
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkClipRRectCommand : public SkDrawCommand {
|
2013-01-02 20:20:31 +00:00
|
|
|
public:
|
2016-12-09 14:00:50 +00:00
|
|
|
SkClipRRectCommand(const SkRRect& rrect, SkClipOp op, bool doAA);
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
|
|
|
bool render(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkClipRRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2013-03-11 22:53:11 +00:00
|
|
|
|
|
|
|
const SkRRect& rrect() const { return fRRect; }
|
2016-12-09 14:00:50 +00:00
|
|
|
SkClipOp op() const { return fOp; }
|
2013-03-11 22:53:11 +00:00
|
|
|
bool doAA() const { return fDoAA; }
|
|
|
|
|
2013-01-02 20:20:31 +00:00
|
|
|
private:
|
2016-12-09 14:00:50 +00:00
|
|
|
SkRRect fRRect;
|
|
|
|
SkClipOp fOp;
|
|
|
|
bool fDoAA;
|
2013-03-22 12:25:30 +00:00
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
2013-01-02 20:20:31 +00:00
|
|
|
};
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkConcatCommand : public SkDrawCommand {
|
2012-06-29 14:21:22 +00:00
|
|
|
public:
|
2013-06-18 20:20:55 +00:00
|
|
|
SkConcatCommand(const SkMatrix& matrix);
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkConcatCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
private:
|
2013-03-22 16:33:31 +00:00
|
|
|
SkMatrix fMatrix;
|
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
2016-06-29 01:54:19 +00:00
|
|
|
class SkDrawAnnotationCommand : public SkDrawCommand {
|
|
|
|
public:
|
|
|
|
SkDrawAnnotationCommand(const SkRect&, const char key[], sk_sp<SkData> value);
|
|
|
|
void execute(SkCanvas* canvas) const override;
|
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkDrawAnnotationCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
|
|
|
|
|
|
|
private:
|
|
|
|
SkRect fRect;
|
|
|
|
SkString fKey;
|
|
|
|
sk_sp<SkData> fValue;
|
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
|
|
|
};
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkDrawBitmapCommand : public SkDrawCommand {
|
2012-06-29 14:21:22 +00:00
|
|
|
public:
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top,
|
2014-03-25 23:31:33 +00:00
|
|
|
const SkPaint* paint);
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
|
|
|
bool render(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkDrawBitmapCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
private:
|
2013-03-22 16:33:31 +00:00
|
|
|
SkBitmap fBitmap;
|
2012-06-29 14:21:22 +00:00
|
|
|
SkScalar fLeft;
|
|
|
|
SkScalar fTop;
|
2013-03-22 16:33:31 +00:00
|
|
|
SkPaint fPaint;
|
|
|
|
SkPaint* fPaintPtr;
|
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkDrawBitmapNineCommand : public SkDrawCommand {
|
2012-06-29 14:21:22 +00:00
|
|
|
public:
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center,
|
2014-03-25 23:31:33 +00:00
|
|
|
const SkRect& dst, const SkPaint* paint);
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
|
|
|
bool render(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkDrawBitmapNineCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
private:
|
2013-03-22 16:33:31 +00:00
|
|
|
SkBitmap fBitmap;
|
|
|
|
SkIRect fCenter;
|
|
|
|
SkRect fDst;
|
|
|
|
SkPaint fPaint;
|
|
|
|
SkPaint* fPaintPtr;
|
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkDrawBitmapRectCommand : public SkDrawCommand {
|
2012-06-29 14:21:22 +00:00
|
|
|
public:
|
2013-06-18 20:20:55 +00:00
|
|
|
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);
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
|
|
|
bool render(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkDrawBitmapRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2013-01-31 15:56:22 +00:00
|
|
|
|
2013-03-28 12:25:25 +00:00
|
|
|
const SkBitmap& bitmap() const { return fBitmap; }
|
|
|
|
|
2013-01-31 15:56:22 +00:00
|
|
|
// The non-const 'paint' method allows modification of this object's
|
|
|
|
// SkPaint. For this reason the ctor and setPaint method make a local copy.
|
|
|
|
// The 'fPaintPtr' member acts a signal that the local SkPaint is valid
|
|
|
|
// (since only an SkPaint* is passed into the ctor).
|
|
|
|
const SkPaint* paint() const { return fPaintPtr; }
|
|
|
|
SkPaint* paint() { return fPaintPtr; }
|
|
|
|
|
|
|
|
void setPaint(const SkPaint& paint) { fPaint = paint; fPaintPtr = &fPaint; }
|
|
|
|
|
2015-08-27 14:41:13 +00:00
|
|
|
const SkRect* srcRect() const { return fSrc.isEmpty() ? nullptr : &fSrc; }
|
2013-03-28 12:25:25 +00:00
|
|
|
void setSrcRect(const SkRect& src) { fSrc = src; }
|
2013-08-16 10:24:37 +00:00
|
|
|
|
|
|
|
const SkRect& dstRect() const { return fDst; }
|
2013-03-28 12:25:25 +00:00
|
|
|
void setDstRect(const SkRect& dst) { fDst = dst; }
|
|
|
|
|
2015-07-14 17:54:12 +00:00
|
|
|
SkCanvas::SrcRectConstraint constraint() const { return fConstraint; }
|
|
|
|
void setConstraint(SkCanvas::SrcRectConstraint constraint) { fConstraint = constraint; }
|
2013-08-16 10:24:37 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
private:
|
2013-08-16 10:24:37 +00:00
|
|
|
SkBitmap fBitmap;
|
|
|
|
SkRect fSrc;
|
|
|
|
SkRect fDst;
|
|
|
|
SkPaint fPaint;
|
|
|
|
SkPaint* fPaintPtr;
|
2015-07-14 17:54:12 +00:00
|
|
|
SkCanvas::SrcRectConstraint fConstraint;
|
2013-03-17 18:33:46 +00:00
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
2015-07-22 17:23:01 +00:00
|
|
|
class SkDrawImageCommand : public SkDrawCommand {
|
|
|
|
public:
|
|
|
|
SkDrawImageCommand(const SkImage* image, SkScalar left, SkScalar top, const SkPaint* paint);
|
|
|
|
void execute(SkCanvas* canvas) const override;
|
|
|
|
bool render(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkDrawImageCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2015-07-22 17:23:01 +00:00
|
|
|
private:
|
2016-11-03 20:26:13 +00:00
|
|
|
sk_sp<const SkImage> fImage;
|
|
|
|
SkScalar fLeft;
|
|
|
|
SkScalar fTop;
|
|
|
|
SkTLazy<SkPaint> fPaint;
|
2015-07-22 17:23:01 +00:00
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
|
|
|
};
|
|
|
|
|
2017-01-12 21:20:50 +00:00
|
|
|
class SkDrawImageLatticeCommand : public SkDrawCommand {
|
|
|
|
public:
|
|
|
|
SkDrawImageLatticeCommand(const SkImage* image, const SkCanvas::Lattice& lattice,
|
|
|
|
const SkRect& dst, const SkPaint* paint);
|
|
|
|
void execute(SkCanvas* canvas) const override;
|
|
|
|
bool render(SkCanvas* canvas) const override;
|
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
sk_sp<const SkImage> fImage;
|
|
|
|
SkCanvas::Lattice fLattice;
|
|
|
|
SkRect fDst;
|
|
|
|
SkTLazy<SkPaint> fPaint;
|
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
|
|
|
};
|
|
|
|
|
2015-07-22 17:23:01 +00:00
|
|
|
class SkDrawImageRectCommand : public SkDrawCommand {
|
|
|
|
public:
|
|
|
|
SkDrawImageRectCommand(const SkImage* image, const SkRect* src, const SkRect& dst,
|
|
|
|
const SkPaint* paint, SkCanvas::SrcRectConstraint constraint);
|
|
|
|
void execute(SkCanvas* canvas) const override;
|
|
|
|
bool render(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkDrawImageRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2015-07-22 17:23:01 +00:00
|
|
|
private:
|
2016-11-03 20:26:13 +00:00
|
|
|
sk_sp<const SkImage> fImage;
|
2015-07-22 17:23:01 +00:00
|
|
|
SkTLazy<SkRect> fSrc;
|
|
|
|
SkRect fDst;
|
|
|
|
SkTLazy<SkPaint> fPaint;
|
|
|
|
SkCanvas::SrcRectConstraint fConstraint;
|
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
|
|
|
};
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkDrawOvalCommand : public SkDrawCommand {
|
2013-01-02 20:20:31 +00:00
|
|
|
public:
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint);
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
|
|
|
bool render(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkDrawOvalCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2013-01-02 20:20:31 +00:00
|
|
|
private:
|
2013-03-22 12:25:30 +00:00
|
|
|
SkRect fOval;
|
|
|
|
SkPaint fPaint;
|
|
|
|
|
2016-08-19 18:25:19 +00:00
|
|
|
typedef SkDrawCommand INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SkDrawArcCommand : public SkDrawCommand {
|
|
|
|
public:
|
|
|
|
SkDrawArcCommand(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter,
|
|
|
|
const SkPaint& paint);
|
|
|
|
void execute(SkCanvas* canvas) const override;
|
|
|
|
bool render(SkCanvas* canvas) const override;
|
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkDrawArcCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
|
|
|
|
|
|
|
private:
|
|
|
|
SkRect fOval;
|
|
|
|
SkScalar fStartAngle;
|
|
|
|
SkScalar fSweepAngle;
|
|
|
|
bool fUseCenter;
|
|
|
|
SkPaint fPaint;
|
|
|
|
|
2013-03-22 12:25:30 +00:00
|
|
|
typedef SkDrawCommand INHERITED;
|
2013-01-02 20:20:31 +00:00
|
|
|
};
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkDrawPaintCommand : public SkDrawCommand {
|
2012-06-29 14:21:22 +00:00
|
|
|
public:
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawPaintCommand(const SkPaint& paint);
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
|
|
|
bool render(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkDrawPaintCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
private:
|
2013-03-22 12:25:30 +00:00
|
|
|
SkPaint fPaint;
|
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkDrawPathCommand : public SkDrawCommand {
|
2012-06-29 14:21:22 +00:00
|
|
|
public:
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawPathCommand(const SkPath& path, const SkPaint& paint);
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
|
|
|
bool render(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkDrawPathCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2012-11-21 17:11:02 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
private:
|
2013-03-25 11:50:42 +00:00
|
|
|
SkPath fPath;
|
|
|
|
SkPaint fPaint;
|
2013-03-17 18:33:46 +00:00
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
2015-04-02 03:58:37 +00:00
|
|
|
class SkBeginDrawPictureCommand : public SkDrawCommand {
|
2012-06-29 14:21:22 +00:00
|
|
|
public:
|
2015-04-02 03:58:37 +00:00
|
|
|
SkBeginDrawPictureCommand(const SkPicture* picture,
|
|
|
|
const SkMatrix* matrix,
|
|
|
|
const SkPaint* paint);
|
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
|
|
|
bool render(SkCanvas* canvas) const override;
|
2013-11-21 17:08:12 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
private:
|
2016-11-03 20:26:13 +00:00
|
|
|
sk_sp<const SkPicture> fPicture;
|
|
|
|
SkTLazy<SkMatrix> fMatrix;
|
|
|
|
SkTLazy<SkPaint> fPaint;
|
2015-04-02 03:58:37 +00:00
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SkEndDrawPictureCommand : public SkDrawCommand {
|
|
|
|
public:
|
|
|
|
SkEndDrawPictureCommand(bool restore);
|
|
|
|
|
|
|
|
void execute(SkCanvas* canvas) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool fRestore;
|
2013-03-25 11:50:42 +00:00
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkDrawPointsCommand : public SkDrawCommand {
|
2012-06-29 14:21:22 +00:00
|
|
|
public:
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
|
2014-03-25 23:31:33 +00:00
|
|
|
const SkPaint& paint);
|
2017-03-22 16:05:03 +00:00
|
|
|
~SkDrawPointsCommand() override { delete [] fPts; }
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
|
|
|
bool render(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkDrawPointsCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
private:
|
|
|
|
SkCanvas::PointMode fMode;
|
2013-03-22 12:25:30 +00:00
|
|
|
size_t fCount;
|
|
|
|
SkPoint* fPts;
|
|
|
|
SkPaint fPaint;
|
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkDrawTextCommand : public SkDrawCommand {
|
2012-06-29 14:21:22 +00:00
|
|
|
public:
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar y,
|
2014-03-25 23:31:33 +00:00
|
|
|
const SkPaint& paint);
|
2017-03-22 16:05:03 +00:00
|
|
|
~SkDrawTextCommand() override { delete [] fText; }
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkDrawTextCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
private:
|
2013-03-25 12:01:45 +00:00
|
|
|
char* fText;
|
2013-03-25 11:50:42 +00:00
|
|
|
size_t fByteLength;
|
2012-06-29 14:21:22 +00:00
|
|
|
SkScalar fX;
|
|
|
|
SkScalar fY;
|
2013-03-25 11:50:42 +00:00
|
|
|
SkPaint fPaint;
|
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkDrawPosTextCommand : public SkDrawCommand {
|
2012-06-29 14:21:22 +00:00
|
|
|
public:
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawPosTextCommand(const void* text, size_t byteLength, const SkPoint pos[],
|
|
|
|
const SkPaint& paint);
|
2017-03-22 16:05:03 +00:00
|
|
|
~SkDrawPosTextCommand() override { delete [] fPos; delete [] fText; }
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkDrawPosTextCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
private:
|
2013-03-25 11:50:42 +00:00
|
|
|
char* fText;
|
|
|
|
size_t fByteLength;
|
2013-03-22 12:25:30 +00:00
|
|
|
SkPoint* fPos;
|
2013-03-25 11:50:42 +00:00
|
|
|
SkPaint fPaint;
|
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkDrawTextOnPathCommand : public SkDrawCommand {
|
2012-06-29 14:21:22 +00:00
|
|
|
public:
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawTextOnPathCommand(const void* text, size_t byteLength, const SkPath& path,
|
|
|
|
const SkMatrix* matrix, const SkPaint& paint);
|
2017-03-22 16:05:03 +00:00
|
|
|
~SkDrawTextOnPathCommand() override { delete [] fText; }
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkDrawTextOnPathCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
private:
|
2013-03-25 12:01:45 +00:00
|
|
|
char* fText;
|
2013-03-25 11:50:42 +00:00
|
|
|
size_t fByteLength;
|
|
|
|
SkPath fPath;
|
|
|
|
SkMatrix fMatrix;
|
|
|
|
SkPaint fPaint;
|
|
|
|
|
2016-07-07 19:47:17 +00:00
|
|
|
typedef SkDrawCommand INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SkDrawTextRSXformCommand : public SkDrawCommand {
|
|
|
|
public:
|
|
|
|
SkDrawTextRSXformCommand(const void* text, size_t byteLength, const SkRSXform[],
|
|
|
|
const SkRect*, const SkPaint& paint);
|
|
|
|
~SkDrawTextRSXformCommand() override { delete[] fText; delete[] fXform; }
|
|
|
|
void execute(SkCanvas* canvas) const override;
|
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkDrawTextRSXformCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
|
|
|
|
|
|
|
private:
|
|
|
|
char* fText;
|
|
|
|
size_t fByteLength;
|
|
|
|
SkRSXform* fXform;
|
|
|
|
SkRect* fCull;
|
|
|
|
SkRect fCullStorage;
|
|
|
|
SkPaint fPaint;
|
|
|
|
|
2013-03-25 11:50:42 +00:00
|
|
|
typedef SkDrawCommand INHERITED;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkDrawPosTextHCommand : public SkDrawCommand {
|
2012-06-29 14:21:22 +00:00
|
|
|
public:
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawPosTextHCommand(const void* text, size_t byteLength, const SkScalar xpos[],
|
|
|
|
SkScalar constY, const SkPaint& paint);
|
2017-03-22 16:05:03 +00:00
|
|
|
~SkDrawPosTextHCommand() override { delete [] fXpos; delete [] fText; }
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
2016-03-09 15:42:54 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkDrawPosTextHCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
private:
|
2013-03-22 12:25:30 +00:00
|
|
|
SkScalar* fXpos;
|
2013-03-25 11:50:42 +00:00
|
|
|
char* fText;
|
|
|
|
size_t fByteLength;
|
|
|
|
SkScalar fConstY;
|
|
|
|
SkPaint fPaint;
|
2013-03-17 18:33:46 +00:00
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
2014-08-26 14:56:44 +00:00
|
|
|
class SkDrawTextBlobCommand : public SkDrawCommand {
|
|
|
|
public:
|
2016-09-13 17:00:23 +00:00
|
|
|
SkDrawTextBlobCommand(sk_sp<SkTextBlob> blob, SkScalar x, SkScalar y, const SkPaint& paint);
|
2014-08-26 14:56:44 +00:00
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
|
|
|
bool render(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkDrawTextBlobCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2014-08-26 14:56:44 +00:00
|
|
|
|
|
|
|
private:
|
2016-09-13 17:00:23 +00:00
|
|
|
sk_sp<SkTextBlob> fBlob;
|
|
|
|
SkScalar fXPos;
|
|
|
|
SkScalar fYPos;
|
|
|
|
SkPaint fPaint;
|
2014-08-26 14:56:44 +00:00
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
|
|
|
};
|
|
|
|
|
2015-02-13 19:13:00 +00:00
|
|
|
class SkDrawPatchCommand : public SkDrawCommand {
|
|
|
|
public:
|
|
|
|
SkDrawPatchCommand(const SkPoint cubics[12], const SkColor colors[4],
|
2016-10-28 19:42:34 +00:00
|
|
|
const SkPoint texCoords[4], SkBlendMode bmode,
|
2015-02-13 19:13:00 +00:00
|
|
|
const SkPaint& paint);
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkDrawPatchCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2015-02-13 19:13:00 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
SkPoint fCubics[12];
|
2016-02-10 22:05:02 +00:00
|
|
|
SkColor* fColorsPtr;
|
|
|
|
SkColor fColors[4];
|
|
|
|
SkPoint* fTexCoordsPtr;
|
|
|
|
SkPoint fTexCoords[4];
|
2016-10-28 19:42:34 +00:00
|
|
|
SkBlendMode fBlendMode;
|
2015-02-13 19:13:00 +00:00
|
|
|
SkPaint fPaint;
|
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkDrawRectCommand : public SkDrawCommand {
|
2012-06-29 14:21:22 +00:00
|
|
|
public:
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawRectCommand(const SkRect& rect, const SkPaint& paint);
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkDrawRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2013-03-11 22:53:11 +00:00
|
|
|
|
2013-03-17 18:33:46 +00:00
|
|
|
const SkRect& rect() const { return fRect; }
|
|
|
|
const SkPaint& paint() const { return fPaint; }
|
2012-06-29 14:21:22 +00:00
|
|
|
private:
|
2013-03-17 18:33:46 +00:00
|
|
|
SkRect fRect;
|
|
|
|
SkPaint fPaint;
|
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkDrawRRectCommand : public SkDrawCommand {
|
2013-01-02 20:20:31 +00:00
|
|
|
public:
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint);
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
|
|
|
bool render(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkDrawRRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2013-01-02 20:20:31 +00:00
|
|
|
private:
|
|
|
|
SkRRect fRRect;
|
2013-03-11 22:53:11 +00:00
|
|
|
SkPaint fPaint;
|
2013-03-25 11:50:42 +00:00
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
2013-01-02 20:20:31 +00:00
|
|
|
};
|
|
|
|
|
2014-02-24 17:28:55 +00:00
|
|
|
class SkDrawDRRectCommand : public SkDrawCommand {
|
|
|
|
public:
|
|
|
|
SkDrawDRRectCommand(const SkRRect& outer, const SkRRect& inner,
|
|
|
|
const SkPaint& paint);
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
|
|
|
bool render(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkDrawDRRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2014-02-24 17:28:55 +00:00
|
|
|
private:
|
|
|
|
SkRRect fOuter;
|
|
|
|
SkRRect fInner;
|
|
|
|
SkPaint fPaint;
|
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
|
|
|
};
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkDrawVerticesCommand : public SkDrawCommand {
|
2012-06-29 14:21:22 +00:00
|
|
|
public:
|
2017-03-17 16:09:04 +00:00
|
|
|
SkDrawVerticesCommand(sk_sp<SkVertices>, SkBlendMode, const SkPaint&);
|
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
private:
|
2017-03-17 16:09:04 +00:00
|
|
|
sk_sp<SkVertices> fVertices;
|
|
|
|
SkBlendMode fBlendMode;
|
|
|
|
SkPaint fPaint;
|
2013-03-25 11:50:42 +00:00
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkSaveCommand : public SkDrawCommand {
|
2012-06-29 14:21:22 +00:00
|
|
|
public:
|
2014-06-30 14:13:28 +00:00
|
|
|
SkSaveCommand();
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
|
|
|
Action action() const override { return kPushLayer_Action; }
|
2016-02-11 18:35:21 +00:00
|
|
|
static SkSaveCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
private:
|
2013-03-22 16:33:31 +00:00
|
|
|
typedef SkDrawCommand INHERITED;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkSaveLayerCommand : public SkDrawCommand {
|
2012-06-29 14:21:22 +00:00
|
|
|
public:
|
2015-12-18 15:09:18 +00:00
|
|
|
SkSaveLayerCommand(const SkCanvas::SaveLayerRec&);
|
2017-03-22 16:05:03 +00:00
|
|
|
~SkSaveLayerCommand() override;
|
2015-03-26 01:17:31 +00:00
|
|
|
void execute(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkSaveLayerCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2015-03-26 01:17:31 +00:00
|
|
|
void vizExecute(SkCanvas* canvas) const override;
|
|
|
|
Action action() const override{ return kPushLayer_Action; }
|
|
|
|
void setActive(bool active) override { fActive = active; }
|
|
|
|
bool active() const override { return fActive; }
|
2013-01-31 15:56:22 +00:00
|
|
|
|
2013-03-22 16:33:31 +00:00
|
|
|
const SkPaint* paint() const { return fPaintPtr; }
|
2013-01-31 15:56:22 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
private:
|
2016-02-10 13:40:46 +00:00
|
|
|
SkRect fBounds;
|
|
|
|
SkPaint fPaint;
|
|
|
|
SkPaint* fPaintPtr;
|
|
|
|
const SkImageFilter* fBackdrop;
|
|
|
|
uint32_t fSaveLayerFlags;
|
2013-03-22 16:33:31 +00:00
|
|
|
|
2015-12-18 15:09:18 +00:00
|
|
|
bool fActive;
|
2014-03-03 16:32:17 +00:00
|
|
|
|
2013-03-22 16:33:31 +00:00
|
|
|
typedef SkDrawCommand INHERITED;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
class SkSetMatrixCommand : public SkDrawCommand {
|
2012-06-29 14:21:22 +00:00
|
|
|
public:
|
2013-06-18 20:20:55 +00:00
|
|
|
SkSetMatrixCommand(const SkMatrix& matrix);
|
2015-03-26 01:17:31 +00:00
|
|
|
void setUserMatrix(const SkMatrix&) override;
|
|
|
|
void execute(SkCanvas* canvas) const override;
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
|
|
|
static SkSetMatrixCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
private:
|
2014-10-16 21:28:28 +00:00
|
|
|
SkMatrix fUserMatrix;
|
2013-02-19 21:00:26 +00:00
|
|
|
SkMatrix fMatrix;
|
2013-03-25 11:50:42 +00:00
|
|
|
|
|
|
|
typedef SkDrawCommand INHERITED;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
#endif
|
2016-08-25 13:30:23 +00:00
|
|
|
|