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.
|
|
|
|
*/
|
|
|
|
|
2016-02-12 15:15:45 +00:00
|
|
|
#include "SkCanvasPriv.h"
|
2012-06-29 14:21:22 +00:00
|
|
|
#include "SkDebugCanvas.h"
|
|
|
|
#include "SkDrawCommand.h"
|
2016-09-13 17:00:23 +00:00
|
|
|
#include "SkPaintFilterCanvas.h"
|
2018-04-06 18:51:42 +00:00
|
|
|
#include "SkPicture.h"
|
2018-01-08 20:05:02 +00:00
|
|
|
#include "SkRectPriv.h"
|
2016-09-13 17:00:23 +00:00
|
|
|
#include "SkTextBlob.h"
|
2016-12-12 15:02:12 +00:00
|
|
|
#include "SkClipOpPriv.h"
|
2015-03-26 14:24:48 +00:00
|
|
|
|
2016-02-29 19:15:06 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
#include "GrAuditTrail.h"
|
|
|
|
#include "GrContext.h"
|
2016-12-20 13:57:26 +00:00
|
|
|
#include "GrRenderTargetContext.h"
|
2016-02-29 19:15:06 +00:00
|
|
|
#endif
|
|
|
|
|
2016-03-04 18:45:05 +00:00
|
|
|
#define SKDEBUGCANVAS_VERSION 1
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_VERSION "version"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_COMMANDS "commands"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_AUDITTRAIL "auditTrail"
|
2016-02-10 20:57:30 +00:00
|
|
|
|
2015-03-26 14:24:48 +00:00
|
|
|
class DebugPaintFilterCanvas : public SkPaintFilterCanvas {
|
|
|
|
public:
|
2016-10-17 19:20:02 +00:00
|
|
|
DebugPaintFilterCanvas(SkCanvas* canvas,
|
2018-04-06 18:51:42 +00:00
|
|
|
bool overdrawViz)
|
2016-10-17 19:20:02 +00:00
|
|
|
: INHERITED(canvas)
|
2018-04-06 18:51:42 +00:00
|
|
|
, fOverdrawViz(overdrawViz) {}
|
2015-03-26 14:24:48 +00:00
|
|
|
|
|
|
|
protected:
|
2016-01-12 15:21:11 +00:00
|
|
|
bool onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Type) const override {
|
|
|
|
if (*paint) {
|
2016-10-17 19:20:02 +00:00
|
|
|
if (fOverdrawViz) {
|
|
|
|
paint->writable()->setColor(SK_ColorRED);
|
|
|
|
paint->writable()->setAlpha(0x08);
|
|
|
|
paint->writable()->setBlendMode(SkBlendMode::kSrcOver);
|
2016-01-11 21:58:29 +00:00
|
|
|
}
|
2015-03-26 14:24:48 +00:00
|
|
|
}
|
2016-01-11 21:58:29 +00:00
|
|
|
return true;
|
2015-03-26 14:24:48 +00:00
|
|
|
}
|
|
|
|
|
2015-07-13 13:18:39 +00:00
|
|
|
void onDrawPicture(const SkPicture* picture,
|
|
|
|
const SkMatrix* matrix,
|
|
|
|
const SkPaint* paint) override {
|
2015-03-26 14:24:48 +00:00
|
|
|
// We need to replay the picture onto this canvas in order to filter its internal paints.
|
|
|
|
this->SkCanvas::onDrawPicture(picture, matrix, paint);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2016-10-17 19:20:02 +00:00
|
|
|
bool fOverdrawViz;
|
2015-03-26 14:24:48 +00:00
|
|
|
|
|
|
|
typedef SkPaintFilterCanvas INHERITED;
|
|
|
|
};
|
|
|
|
|
2015-01-05 20:58:56 +00:00
|
|
|
SkDebugCanvas::SkDebugCanvas(int width, int height)
|
|
|
|
: INHERITED(width, height)
|
2013-02-06 20:13:54 +00:00
|
|
|
, fOverdrawViz(false)
|
2016-02-29 19:15:06 +00:00
|
|
|
, fClipVizColor(SK_ColorTRANSPARENT)
|
2016-12-20 21:48:59 +00:00
|
|
|
, fDrawGpuOpBounds(false) {
|
2013-11-07 22:20:31 +00:00
|
|
|
// SkPicturePlayback uses the base-class' quickReject calls to cull clipped
|
|
|
|
// operations. This can lead to problems in the debugger which expects all
|
|
|
|
// the operations in the captured skp to appear in the debug canvas. To
|
|
|
|
// circumvent this we create a wide open clip here (an empty clip rect
|
|
|
|
// is not sufficient).
|
|
|
|
// Internally, the SkRect passed to clipRect is converted to an SkIRect and
|
|
|
|
// rounded out. The following code creates a nearly maximal rect that will
|
|
|
|
// not get collapsed by the coming conversions (Due to precision loss the
|
|
|
|
// inset has to be surprisingly large).
|
2018-01-17 17:20:04 +00:00
|
|
|
SkIRect largeIRect = SkRectPriv::MakeILarge();
|
2013-11-07 22:20:31 +00:00
|
|
|
largeIRect.inset(1024, 1024);
|
2013-11-10 15:08:45 +00:00
|
|
|
SkRect large = SkRect::Make(largeIRect);
|
2013-11-07 22:20:31 +00:00
|
|
|
#ifdef SK_DEBUG
|
2014-11-19 13:03:18 +00:00
|
|
|
SkASSERT(!large.roundOut().isEmpty());
|
2013-11-07 22:20:31 +00:00
|
|
|
#endif
|
2014-02-28 18:19:39 +00:00
|
|
|
// call the base class' version to avoid adding a draw command
|
2016-12-09 14:00:50 +00:00
|
|
|
this->INHERITED::onClipRect(large, kReplace_SkClipOp, kHard_ClipEdgeStyle);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-08-07 15:08:33 +00:00
|
|
|
SkDebugCanvas::~SkDebugCanvas() {
|
2013-01-02 20:20:31 +00:00
|
|
|
fCommandVector.deleteAll();
|
2012-08-07 15:08:33 +00:00
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
void SkDebugCanvas::addDrawCommand(SkDrawCommand* command) {
|
2013-01-02 20:20:31 +00:00
|
|
|
fCommandVector.push(command);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebugCanvas::draw(SkCanvas* canvas) {
|
2013-12-04 13:42:46 +00:00
|
|
|
if (!fCommandVector.isEmpty()) {
|
2014-03-25 23:31:33 +00:00
|
|
|
this->drawTo(canvas, fCommandVector.count() - 1);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-21 22:41:03 +00:00
|
|
|
void SkDebugCanvas::drawTo(SkCanvas* originalCanvas, int index, int m) {
|
2013-01-02 20:20:31 +00:00
|
|
|
SkASSERT(!fCommandVector.isEmpty());
|
|
|
|
SkASSERT(index < fCommandVector.count());
|
2015-01-14 07:09:19 +00:00
|
|
|
|
2016-12-21 22:41:03 +00:00
|
|
|
int saveCount = originalCanvas->save();
|
2015-01-14 07:09:19 +00:00
|
|
|
|
2016-12-21 22:41:03 +00:00
|
|
|
SkRect windowRect = SkRect::MakeWH(SkIntToScalar(originalCanvas->getBaseLayerSize().width()),
|
|
|
|
SkIntToScalar(originalCanvas->getBaseLayerSize().height()));
|
2012-08-01 15:57:52 +00:00
|
|
|
|
2016-12-21 22:41:03 +00:00
|
|
|
originalCanvas->clear(SK_ColorWHITE);
|
|
|
|
originalCanvas->resetMatrix();
|
2015-01-14 07:09:19 +00:00
|
|
|
if (!windowRect.isEmpty()) {
|
2016-12-21 22:41:03 +00:00
|
|
|
originalCanvas->clipRect(windowRect, kReplace_SkClipOp);
|
2013-08-05 16:31:27 +00:00
|
|
|
}
|
2013-02-06 20:13:54 +00:00
|
|
|
|
2018-04-06 18:51:42 +00:00
|
|
|
DebugPaintFilterCanvas filterCanvas(originalCanvas, fOverdrawViz);
|
2016-03-29 16:03:52 +00:00
|
|
|
|
2016-03-11 19:45:53 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2016-12-20 21:48:59 +00:00
|
|
|
// If we have a GPU backend we can also visualize the op information
|
2016-02-29 19:15:06 +00:00
|
|
|
GrAuditTrail* at = nullptr;
|
2016-12-20 21:48:59 +00:00
|
|
|
if (fDrawGpuOpBounds || m != -1) {
|
2016-12-21 22:41:03 +00:00
|
|
|
// The audit trail must be obtained from the original canvas.
|
|
|
|
at = this->getAuditTrail(originalCanvas);
|
2016-02-29 19:15:06 +00:00
|
|
|
}
|
2016-03-11 19:45:53 +00:00
|
|
|
#endif
|
2014-03-03 16:32:17 +00:00
|
|
|
|
2015-01-14 07:09:19 +00:00
|
|
|
for (int i = 0; i <= index; i++) {
|
2016-02-29 19:15:06 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2016-12-20 21:48:59 +00:00
|
|
|
// We need to flush any pending operations, or they might combine with commands below.
|
2016-04-15 18:00:51 +00:00
|
|
|
// Previous operations were not registered with the audit trail when they were
|
|
|
|
// created, so if we allow them to combine, the audit trail will fail to find them.
|
2016-12-21 22:41:03 +00:00
|
|
|
filterCanvas.flush();
|
2016-04-15 18:00:51 +00:00
|
|
|
|
2016-12-20 21:14:45 +00:00
|
|
|
GrAuditTrail::AutoCollectOps* acb = nullptr;
|
2016-02-29 19:15:06 +00:00
|
|
|
if (at) {
|
2016-12-20 21:14:45 +00:00
|
|
|
acb = new GrAuditTrail::AutoCollectOps(at, i);
|
2016-02-29 19:15:06 +00:00
|
|
|
}
|
|
|
|
#endif
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-01-02 20:20:31 +00:00
|
|
|
if (fCommandVector[i]->isVisible()) {
|
2018-04-06 18:51:42 +00:00
|
|
|
fCommandVector[i]->execute(&filterCanvas);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
2016-02-29 19:15:06 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
if (at && acb) {
|
|
|
|
delete acb;
|
|
|
|
}
|
|
|
|
#endif
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
2014-03-03 16:32:17 +00:00
|
|
|
|
2016-02-12 20:06:53 +00:00
|
|
|
if (SkColorGetA(fClipVizColor) != 0) {
|
2016-12-21 22:41:03 +00:00
|
|
|
filterCanvas.save();
|
2016-02-12 20:06:53 +00:00
|
|
|
#define LARGE_COORD 1000000000
|
2016-12-21 22:41:03 +00:00
|
|
|
filterCanvas.clipRect(
|
|
|
|
SkRect::MakeLTRB(-LARGE_COORD, -LARGE_COORD, LARGE_COORD, LARGE_COORD),
|
|
|
|
kReverseDifference_SkClipOp);
|
2016-02-12 20:06:53 +00:00
|
|
|
SkPaint clipPaint;
|
|
|
|
clipPaint.setColor(fClipVizColor);
|
2016-12-21 22:41:03 +00:00
|
|
|
filterCanvas.drawPaint(clipPaint);
|
|
|
|
filterCanvas.restore();
|
2016-02-12 20:06:53 +00:00
|
|
|
}
|
|
|
|
|
2016-12-21 22:41:03 +00:00
|
|
|
fMatrix = filterCanvas.getTotalMatrix();
|
2017-01-23 16:39:45 +00:00
|
|
|
fClip = filterCanvas.getDeviceClipBounds();
|
2016-12-21 22:41:03 +00:00
|
|
|
filterCanvas.restoreToCount(saveCount);
|
2015-03-26 14:24:48 +00:00
|
|
|
|
2016-02-29 19:15:06 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2016-12-20 21:48:59 +00:00
|
|
|
// draw any ops if required and issue a full reset onto GrAuditTrail
|
2016-02-29 19:15:06 +00:00
|
|
|
if (at) {
|
2016-03-04 18:45:05 +00:00
|
|
|
// just in case there is global reordering, we flush the canvas before querying
|
|
|
|
// GrAuditTrail
|
2016-03-08 18:43:41 +00:00
|
|
|
GrAuditTrail::AutoEnable ae(at);
|
2016-12-21 22:41:03 +00:00
|
|
|
filterCanvas.flush();
|
2016-03-04 18:45:05 +00:00
|
|
|
|
2016-03-01 22:22:02 +00:00
|
|
|
// we pick three colorblind-safe colors, 75% alpha
|
|
|
|
static const SkColor kTotalBounds = SkColorSetARGB(0xC0, 0x6A, 0x3D, 0x9A);
|
2016-12-20 21:48:59 +00:00
|
|
|
static const SkColor kCommandOpBounds = SkColorSetARGB(0xC0, 0xE3, 0x1A, 0x1C);
|
|
|
|
static const SkColor kOtherOpBounds = SkColorSetARGB(0xC0, 0xFF, 0x7F, 0x00);
|
2016-03-01 22:22:02 +00:00
|
|
|
|
2016-12-21 22:41:03 +00:00
|
|
|
// get the render target of the top device (from the original canvas) so we can ignore ops
|
|
|
|
// drawn offscreen
|
|
|
|
GrRenderTargetContext* rtc =
|
|
|
|
originalCanvas->internal_private_accessTopLayerRenderTargetContext();
|
2017-05-17 13:36:38 +00:00
|
|
|
GrSurfaceProxy::UniqueID proxyID = rtc->asSurfaceProxy()->uniqueID();
|
2016-03-01 15:15:52 +00:00
|
|
|
|
|
|
|
// get the bounding boxes to draw
|
2016-12-20 21:14:45 +00:00
|
|
|
SkTArray<GrAuditTrail::OpInfo> childrenBounds;
|
2016-03-02 16:32:37 +00:00
|
|
|
if (m == -1) {
|
|
|
|
at->getBoundsByClientID(&childrenBounds, index);
|
|
|
|
} else {
|
2016-12-20 21:48:59 +00:00
|
|
|
// the client wants us to draw the mth op
|
2016-12-20 21:14:45 +00:00
|
|
|
at->getBoundsByOpListID(&childrenBounds.push_back(), m);
|
2016-03-02 16:32:37 +00:00
|
|
|
}
|
2016-02-29 19:15:06 +00:00
|
|
|
SkPaint paint;
|
|
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
|
|
paint.setStrokeWidth(1);
|
|
|
|
for (int i = 0; i < childrenBounds.count(); i++) {
|
2017-05-17 13:36:38 +00:00
|
|
|
if (childrenBounds[i].fProxyUniqueID != proxyID) {
|
2016-03-01 15:15:52 +00:00
|
|
|
// offscreen draw, ignore for now
|
|
|
|
continue;
|
|
|
|
}
|
2016-03-01 22:22:02 +00:00
|
|
|
paint.setColor(kTotalBounds);
|
2016-12-21 22:41:03 +00:00
|
|
|
filterCanvas.drawRect(childrenBounds[i].fBounds, paint);
|
2016-12-20 21:14:45 +00:00
|
|
|
for (int j = 0; j < childrenBounds[i].fOps.count(); j++) {
|
2016-12-20 21:48:59 +00:00
|
|
|
const GrAuditTrail::OpInfo::Op& op = childrenBounds[i].fOps[j];
|
|
|
|
if (op.fClientID != index) {
|
|
|
|
paint.setColor(kOtherOpBounds);
|
2016-02-29 19:15:06 +00:00
|
|
|
} else {
|
2016-12-20 21:48:59 +00:00
|
|
|
paint.setColor(kCommandOpBounds);
|
2016-02-29 19:15:06 +00:00
|
|
|
}
|
2016-12-21 22:41:03 +00:00
|
|
|
filterCanvas.drawRect(op.fBounds, paint);
|
2016-02-29 19:15:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2016-12-21 22:41:03 +00:00
|
|
|
this->cleanupAuditTrail(originalCanvas);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-04-01 18:18:49 +00:00
|
|
|
void SkDebugCanvas::deleteDrawCommandAt(int index) {
|
|
|
|
SkASSERT(index < fCommandVector.count());
|
|
|
|
delete fCommandVector[index];
|
|
|
|
fCommandVector.remove(index);
|
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
SkDrawCommand* SkDebugCanvas::getDrawCommandAt(int index) {
|
2013-01-02 20:20:31 +00:00
|
|
|
SkASSERT(index < fCommandVector.count());
|
|
|
|
return fCommandVector[index];
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2016-03-10 21:29:36 +00:00
|
|
|
GrAuditTrail* SkDebugCanvas::getAuditTrail(SkCanvas* canvas) {
|
|
|
|
GrAuditTrail* at = nullptr;
|
2016-03-04 18:45:05 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2016-04-28 21:32:04 +00:00
|
|
|
GrContext* ctx = canvas->getGrContext();
|
|
|
|
if (ctx) {
|
2018-03-06 13:20:37 +00:00
|
|
|
at = ctx->contextPriv().getAuditTrail();
|
2016-03-10 21:29:36 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return at;
|
|
|
|
}
|
2016-03-04 18:45:05 +00:00
|
|
|
|
2016-12-20 21:48:59 +00:00
|
|
|
void SkDebugCanvas::drawAndCollectOps(int n, SkCanvas* canvas) {
|
2016-03-11 19:45:53 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2016-03-10 21:29:36 +00:00
|
|
|
GrAuditTrail* at = this->getAuditTrail(canvas);
|
|
|
|
if (at) {
|
|
|
|
// loop over all of the commands and draw them, this is to collect reordering
|
|
|
|
// information
|
|
|
|
for (int i = 0; i < this->getSize() && i <= n; i++) {
|
2016-12-20 21:14:45 +00:00
|
|
|
GrAuditTrail::AutoCollectOps enable(at, i);
|
2016-03-10 21:29:36 +00:00
|
|
|
fCommandVector[i]->execute(canvas);
|
|
|
|
}
|
2016-03-04 18:45:05 +00:00
|
|
|
|
2016-03-10 21:29:36 +00:00
|
|
|
// in case there is some kind of global reordering
|
|
|
|
{
|
|
|
|
GrAuditTrail::AutoEnable ae(at);
|
|
|
|
canvas->flush();
|
2016-03-04 18:45:05 +00:00
|
|
|
}
|
|
|
|
}
|
2016-03-11 19:45:53 +00:00
|
|
|
#endif
|
2016-03-10 21:29:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebugCanvas::cleanupAuditTrail(SkCanvas* canvas) {
|
|
|
|
GrAuditTrail* at = this->getAuditTrail(canvas);
|
|
|
|
if (at) {
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
GrAuditTrail::AutoEnable ae(at);
|
|
|
|
at->fullReset();
|
2016-03-04 18:45:05 +00:00
|
|
|
#endif
|
2016-03-10 21:29:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Json::Value SkDebugCanvas::toJSON(UrlDataManager& urlDataManager, int n, SkCanvas* canvas) {
|
2016-12-20 21:48:59 +00:00
|
|
|
this->drawAndCollectOps(n, canvas);
|
2016-03-29 16:03:52 +00:00
|
|
|
|
2016-03-04 18:45:05 +00:00
|
|
|
// now collect json
|
2016-03-11 19:45:53 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2016-03-10 21:29:36 +00:00
|
|
|
GrAuditTrail* at = this->getAuditTrail(canvas);
|
2016-03-11 19:45:53 +00:00
|
|
|
#endif
|
2016-02-10 20:57:30 +00:00
|
|
|
Json::Value result = Json::Value(Json::objectValue);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_VERSION] = Json::Value(SKDEBUGCANVAS_VERSION);
|
|
|
|
Json::Value commands = Json::Value(Json::arrayValue);
|
2016-02-12 20:06:53 +00:00
|
|
|
for (int i = 0; i < this->getSize() && i <= n; i++) {
|
2016-03-04 18:45:05 +00:00
|
|
|
commands[i] = this->getDrawCommandAt(i)->toJSON(urlDataManager);
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
if (at) {
|
|
|
|
// TODO if this is inefficient we could add a method to GrAuditTrail which takes
|
|
|
|
// a Json::Value and is only compiled in this file
|
|
|
|
Json::Value parsedFromString;
|
|
|
|
Json::Reader reader;
|
|
|
|
SkAssertResult(reader.parse(at->toJson(i).c_str(), parsedFromString));
|
|
|
|
|
|
|
|
commands[i][SKDEBUGCANVAS_ATTRIBUTE_AUDITTRAIL] = parsedFromString;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2016-03-10 21:29:36 +00:00
|
|
|
this->cleanupAuditTrail(canvas);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_COMMANDS] = commands;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-12-20 21:48:59 +00:00
|
|
|
Json::Value SkDebugCanvas::toJSONOpList(int n, SkCanvas* canvas) {
|
|
|
|
this->drawAndCollectOps(n, canvas);
|
2016-03-10 21:29:36 +00:00
|
|
|
|
|
|
|
Json::Value parsedFromString;
|
2016-03-04 18:45:05 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2016-03-11 19:45:53 +00:00
|
|
|
GrAuditTrail* at = this->getAuditTrail(canvas);
|
2016-03-04 18:45:05 +00:00
|
|
|
if (at) {
|
2016-12-20 21:14:45 +00:00
|
|
|
GrAuditTrail::AutoManageOpList enable(at);
|
2016-03-10 21:29:36 +00:00
|
|
|
Json::Reader reader;
|
|
|
|
SkAssertResult(reader.parse(at->toJson().c_str(), parsedFromString));
|
2016-02-10 20:57:30 +00:00
|
|
|
}
|
2016-03-04 18:45:05 +00:00
|
|
|
#endif
|
2016-03-10 21:29:36 +00:00
|
|
|
this->cleanupAuditTrail(canvas);
|
|
|
|
return parsedFromString;
|
2016-02-10 20:57:30 +00:00
|
|
|
}
|
|
|
|
|
2015-03-26 14:24:48 +00:00
|
|
|
void SkDebugCanvas::setOverdrawViz(bool overdrawViz) {
|
|
|
|
fOverdrawViz = overdrawViz;
|
|
|
|
}
|
|
|
|
|
2016-12-09 14:00:50 +00:00
|
|
|
void SkDebugCanvas::onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle edgeStyle) {
|
2014-02-28 18:19:39 +00:00
|
|
|
this->addDrawCommand(new SkClipPathCommand(path, op, kSoft_ClipEdgeStyle == edgeStyle));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2016-12-09 14:00:50 +00:00
|
|
|
void SkDebugCanvas::onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle edgeStyle) {
|
2014-02-28 18:19:39 +00:00
|
|
|
this->addDrawCommand(new SkClipRectCommand(rect, op, kSoft_ClipEdgeStyle == edgeStyle));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2016-12-09 14:00:50 +00:00
|
|
|
void SkDebugCanvas::onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle edgeStyle) {
|
2014-02-28 18:19:39 +00:00
|
|
|
this->addDrawCommand(new SkClipRRectCommand(rrect, op, kSoft_ClipEdgeStyle == edgeStyle));
|
2013-01-02 20:20:31 +00:00
|
|
|
}
|
|
|
|
|
2016-12-09 14:00:50 +00:00
|
|
|
void SkDebugCanvas::onClipRegion(const SkRegion& region, SkClipOp op) {
|
2014-02-28 18:19:39 +00:00
|
|
|
this->addDrawCommand(new SkClipRegionCommand(region, op));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-03-13 20:03:58 +00:00
|
|
|
void SkDebugCanvas::didConcat(const SkMatrix& matrix) {
|
2015-02-13 19:13:00 +00:00
|
|
|
this->addDrawCommand(new SkConcatCommand(matrix));
|
2014-03-13 20:03:58 +00:00
|
|
|
this->INHERITED::didConcat(matrix);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2016-06-29 01:54:19 +00:00
|
|
|
void SkDebugCanvas::onDrawAnnotation(const SkRect& rect, const char key[], SkData* value) {
|
|
|
|
this->addDrawCommand(new SkDrawAnnotationCommand(rect, key, sk_ref_sp(value)));
|
|
|
|
}
|
|
|
|
|
2015-01-05 15:49:08 +00:00
|
|
|
void SkDebugCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar left,
|
|
|
|
SkScalar top, const SkPaint* paint) {
|
2014-03-25 23:31:33 +00:00
|
|
|
this->addDrawCommand(new SkDrawBitmapCommand(bitmap, left, top, paint));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2015-01-05 15:49:08 +00:00
|
|
|
void SkDebugCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
|
2015-07-28 14:35:14 +00:00
|
|
|
const SkPaint* paint, SrcRectConstraint constraint) {
|
2015-07-14 17:54:12 +00:00
|
|
|
this->addDrawCommand(new SkDrawBitmapRectCommand(bitmap, src, dst, paint,
|
|
|
|
(SrcRectConstraint)constraint));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2015-01-05 15:49:08 +00:00
|
|
|
void SkDebugCanvas::onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
|
|
|
|
const SkRect& dst, const SkPaint* paint) {
|
2014-03-25 23:31:33 +00:00
|
|
|
this->addDrawCommand(new SkDrawBitmapNineCommand(bitmap, center, dst, paint));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2015-01-05 15:49:08 +00:00
|
|
|
void SkDebugCanvas::onDrawImage(const SkImage* image, SkScalar left, SkScalar top,
|
|
|
|
const SkPaint* paint) {
|
2015-07-22 17:23:01 +00:00
|
|
|
this->addDrawCommand(new SkDrawImageCommand(image, left, top, paint));
|
2015-01-05 15:49:08 +00:00
|
|
|
}
|
|
|
|
|
2017-01-12 21:20:50 +00:00
|
|
|
void SkDebugCanvas::onDrawImageLattice(const SkImage* image, const Lattice& lattice,
|
|
|
|
const SkRect& dst, const SkPaint* paint) {
|
|
|
|
this->addDrawCommand(new SkDrawImageLatticeCommand(image, lattice, dst, paint));
|
|
|
|
}
|
|
|
|
|
2015-01-05 15:49:08 +00:00
|
|
|
void SkDebugCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
|
2015-07-28 14:35:14 +00:00
|
|
|
const SkPaint* paint, SrcRectConstraint constraint) {
|
2015-07-22 17:23:01 +00:00
|
|
|
this->addDrawCommand(new SkDrawImageRectCommand(image, src, dst, paint, constraint));
|
2015-01-05 15:49:08 +00:00
|
|
|
}
|
|
|
|
|
2018-03-12 14:57:28 +00:00
|
|
|
void SkDebugCanvas::onDrawImageNine(const SkImage* image, const SkIRect& center,
|
|
|
|
const SkRect& dst, const SkPaint* paint) {
|
|
|
|
this->addDrawCommand(new SkDrawImageNineCommand(image, center, dst, paint));
|
|
|
|
}
|
|
|
|
|
2015-01-05 15:49:08 +00:00
|
|
|
void SkDebugCanvas::onDrawOval(const SkRect& oval, const SkPaint& paint) {
|
2014-03-25 23:31:33 +00:00
|
|
|
this->addDrawCommand(new SkDrawOvalCommand(oval, paint));
|
2013-01-02 20:20:31 +00:00
|
|
|
}
|
|
|
|
|
2016-08-19 18:25:19 +00:00
|
|
|
void SkDebugCanvas::onDrawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
|
|
|
|
bool useCenter, const SkPaint& paint) {
|
|
|
|
this->addDrawCommand(new SkDrawArcCommand(oval, startAngle, sweepAngle, useCenter, paint));
|
|
|
|
}
|
|
|
|
|
2015-01-05 15:49:08 +00:00
|
|
|
void SkDebugCanvas::onDrawPaint(const SkPaint& paint) {
|
2014-03-25 23:31:33 +00:00
|
|
|
this->addDrawCommand(new SkDrawPaintCommand(paint));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2015-01-05 15:49:08 +00:00
|
|
|
void SkDebugCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) {
|
2014-03-25 23:31:33 +00:00
|
|
|
this->addDrawCommand(new SkDrawPathCommand(path, paint));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2018-03-12 14:57:28 +00:00
|
|
|
void SkDebugCanvas::onDrawRegion(const SkRegion& region, const SkPaint& paint) {
|
|
|
|
this->addDrawCommand(new SkDrawRegionCommand(region, paint));
|
|
|
|
}
|
|
|
|
|
2014-12-12 16:46:25 +00:00
|
|
|
void SkDebugCanvas::onDrawPicture(const SkPicture* picture,
|
|
|
|
const SkMatrix* matrix,
|
2014-08-13 17:46:23 +00:00
|
|
|
const SkPaint* paint) {
|
2015-04-02 03:58:37 +00:00
|
|
|
this->addDrawCommand(new SkBeginDrawPictureCommand(picture, matrix, paint));
|
2016-02-12 15:15:45 +00:00
|
|
|
SkAutoCanvasMatrixPaint acmp(this, matrix, paint, picture->cullRect());
|
|
|
|
picture->playback(this);
|
2015-04-02 03:58:37 +00:00
|
|
|
this->addDrawCommand(new SkEndDrawPictureCommand(SkToBool(matrix) || SkToBool(paint)));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2015-01-05 15:49:08 +00:00
|
|
|
void SkDebugCanvas::onDrawPoints(PointMode mode, size_t count,
|
|
|
|
const SkPoint pts[], const SkPaint& paint) {
|
2014-03-25 23:31:33 +00:00
|
|
|
this->addDrawCommand(new SkDrawPointsCommand(mode, count, pts, paint));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-04-23 04:00:17 +00:00
|
|
|
void SkDebugCanvas::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
|
|
|
|
const SkPaint& paint) {
|
2014-03-25 23:31:33 +00:00
|
|
|
this->addDrawCommand(new SkDrawPosTextCommand(text, byteLength, pos, paint));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-04-23 04:00:17 +00:00
|
|
|
void SkDebugCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
|
|
|
|
SkScalar constY, const SkPaint& paint) {
|
2014-03-25 23:31:33 +00:00
|
|
|
this->addDrawCommand(
|
2013-06-18 20:20:55 +00:00
|
|
|
new SkDrawPosTextHCommand(text, byteLength, xpos, constY, paint));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2015-01-05 15:49:08 +00:00
|
|
|
void SkDebugCanvas::onDrawRect(const SkRect& rect, const SkPaint& paint) {
|
2012-06-29 14:21:22 +00:00
|
|
|
// NOTE(chudy): Messing up when renamed to DrawRect... Why?
|
2013-06-18 20:20:55 +00:00
|
|
|
addDrawCommand(new SkDrawRectCommand(rect, paint));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2015-01-05 15:49:08 +00:00
|
|
|
void SkDebugCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) {
|
2014-03-25 23:31:33 +00:00
|
|
|
this->addDrawCommand(new SkDrawRRectCommand(rrect, paint));
|
2013-01-02 20:20:31 +00:00
|
|
|
}
|
|
|
|
|
2014-02-21 12:20:45 +00:00
|
|
|
void SkDebugCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner,
|
|
|
|
const SkPaint& paint) {
|
2014-02-24 17:28:55 +00:00
|
|
|
this->addDrawCommand(new SkDrawDRRectCommand(outer, inner, paint));
|
2014-02-21 12:20:45 +00:00
|
|
|
}
|
|
|
|
|
2014-04-23 04:00:17 +00:00
|
|
|
void SkDebugCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
|
|
|
|
const SkPaint& paint) {
|
2014-03-25 23:31:33 +00:00
|
|
|
this->addDrawCommand(new SkDrawTextCommand(text, byteLength, x, y, paint));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-04-23 04:00:17 +00:00
|
|
|
void SkDebugCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
|
|
|
|
const SkMatrix* matrix, const SkPaint& paint) {
|
2014-03-25 23:31:33 +00:00
|
|
|
this->addDrawCommand(
|
2013-06-18 20:20:55 +00:00
|
|
|
new SkDrawTextOnPathCommand(text, byteLength, path, matrix, paint));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2016-07-07 19:47:17 +00:00
|
|
|
void SkDebugCanvas::onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
|
|
|
|
const SkRect* cull, const SkPaint& paint) {
|
|
|
|
this->addDrawCommand(new SkDrawTextRSXformCommand(text, byteLength, xform, cull, paint));
|
|
|
|
}
|
|
|
|
|
2014-08-26 14:56:44 +00:00
|
|
|
void SkDebugCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
|
|
|
|
const SkPaint& paint) {
|
2016-09-13 17:00:23 +00:00
|
|
|
this->addDrawCommand(new SkDrawTextBlobCommand(sk_ref_sp(const_cast<SkTextBlob*>(blob)),
|
|
|
|
x, y, paint));
|
2014-08-26 14:56:44 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 19:13:00 +00:00
|
|
|
void SkDebugCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
|
2016-11-03 18:45:31 +00:00
|
|
|
const SkPoint texCoords[4], SkBlendMode bmode,
|
2015-02-13 19:13:00 +00:00
|
|
|
const SkPaint& paint) {
|
2016-10-28 19:42:34 +00:00
|
|
|
this->addDrawCommand(new SkDrawPatchCommand(cubics, colors, texCoords, bmode, paint));
|
2015-02-13 19:13:00 +00:00
|
|
|
}
|
|
|
|
|
2017-03-17 16:09:04 +00:00
|
|
|
void SkDebugCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmode,
|
|
|
|
const SkPaint& paint) {
|
|
|
|
this->addDrawCommand(new SkDrawVerticesCommand(sk_ref_sp(const_cast<SkVertices*>(vertices)),
|
|
|
|
bmode, paint));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2018-04-12 16:45:58 +00:00
|
|
|
void SkDebugCanvas::onDrawShadowRec(const SkPath& path, const SkDrawShadowRec& rec) {
|
|
|
|
this->addDrawCommand(new SkDrawShadowCommand(path, rec));
|
|
|
|
}
|
|
|
|
|
2014-03-12 20:21:48 +00:00
|
|
|
void SkDebugCanvas::willRestore() {
|
|
|
|
this->addDrawCommand(new SkRestoreCommand());
|
|
|
|
this->INHERITED::willRestore();
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-06-30 14:13:28 +00:00
|
|
|
void SkDebugCanvas::willSave() {
|
|
|
|
this->addDrawCommand(new SkSaveCommand());
|
|
|
|
this->INHERITED::willSave();
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2015-12-18 15:09:18 +00:00
|
|
|
SkCanvas::SaveLayerStrategy SkDebugCanvas::getSaveLayerStrategy(const SaveLayerRec& rec) {
|
|
|
|
this->addDrawCommand(new SkSaveLayerCommand(rec));
|
|
|
|
(void)this->INHERITED::getSaveLayerStrategy(rec);
|
2014-03-12 20:21:48 +00:00
|
|
|
// No need for a full layer.
|
|
|
|
return kNoLayer_SaveLayerStrategy;
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-03-13 20:03:58 +00:00
|
|
|
void SkDebugCanvas::didSetMatrix(const SkMatrix& matrix) {
|
2014-03-25 23:31:33 +00:00
|
|
|
this->addDrawCommand(new SkSetMatrixCommand(matrix));
|
2014-03-13 20:03:58 +00:00
|
|
|
this->INHERITED::didSetMatrix(matrix);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebugCanvas::toggleCommand(int index, bool toggle) {
|
2013-01-02 20:20:31 +00:00
|
|
|
SkASSERT(index < fCommandVector.count());
|
|
|
|
fCommandVector[index]->setVisible(toggle);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|