2013-08-21 16:31:37 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkTrackDevice_DEFINED
|
|
|
|
#define SkTrackDevice_DEFINED
|
2013-07-22 15:36:39 +00:00
|
|
|
|
2013-09-04 17:29:06 +00:00
|
|
|
#include "SkBitmapDevice.h"
|
2013-07-22 15:36:39 +00:00
|
|
|
#include "SkTracker.h"
|
|
|
|
|
2013-10-11 16:17:44 +00:00
|
|
|
/** \class SkTrackDevice
|
|
|
|
*
|
|
|
|
* A Track Device is used to track that callstack of an operation that affected some pixels.
|
|
|
|
* It can be used with SampleApp to investigate bugs (CL not checked in yet).
|
|
|
|
*
|
2013-10-11 18:26:45 +00:00
|
|
|
* every drawFoo is implemented as such:
|
|
|
|
* before(); // - collects state of interesting pixels
|
|
|
|
* INHERITED::drawFoo(...);
|
|
|
|
* after(); // - checks if pixels of interest, and issue a breakpoint.
|
|
|
|
*
|
2013-10-11 16:17:44 +00:00
|
|
|
*/
|
2013-08-29 11:54:56 +00:00
|
|
|
class SkTrackDevice : public SkBitmapDevice {
|
2013-07-22 15:36:39 +00:00
|
|
|
public:
|
|
|
|
SK_DECLARE_INST_COUNT(SkTrackDevice)
|
|
|
|
|
2013-08-29 11:54:56 +00:00
|
|
|
SkTrackDevice(const SkBitmap& bitmap) : SkBitmapDevice(bitmap)
|
2013-07-22 15:36:39 +00:00
|
|
|
, fTracker(NULL) {}
|
|
|
|
|
|
|
|
virtual ~SkTrackDevice() {}
|
|
|
|
|
2013-10-11 18:26:45 +00:00
|
|
|
// Install a tracker - we can reuse the tracker between multiple devices, and the state of the
|
|
|
|
// tracker is preserved - number and location of poinbts, ...
|
2013-07-22 15:36:39 +00:00
|
|
|
void installTracker(SkTracker* tracker) {
|
|
|
|
fTracker = tracker;
|
|
|
|
fTracker->newFrame();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2014-12-04 16:39:09 +00:00
|
|
|
#if 0 // clear is deprecated (and private)
|
2013-07-22 15:36:39 +00:00
|
|
|
virtual void clear(SkColor color) {
|
|
|
|
before();
|
|
|
|
INHERITED::clear(color);
|
|
|
|
after();
|
|
|
|
}
|
2014-12-04 16:39:09 +00:00
|
|
|
#endif
|
2013-07-22 15:36:39 +00:00
|
|
|
|
|
|
|
virtual void drawPaint(const SkDraw& dummy1, const SkPaint& paint) {
|
|
|
|
before();
|
|
|
|
INHERITED::drawPaint(dummy1, paint);
|
|
|
|
after();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void drawPoints(const SkDraw& dummy1, SkCanvas::PointMode mode, size_t count,
|
|
|
|
const SkPoint dummy2[], const SkPaint& paint) {
|
|
|
|
before();
|
|
|
|
INHERITED::drawPoints(dummy1, mode, count, dummy2, paint);
|
|
|
|
after();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void drawRect(const SkDraw& dummy1, const SkRect& r,
|
|
|
|
const SkPaint& paint) {
|
|
|
|
before();
|
|
|
|
INHERITED::drawRect(dummy1, r, paint);
|
|
|
|
after();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual void drawOval(const SkDraw& dummy1, const SkRect& oval,
|
|
|
|
const SkPaint& paint) {
|
|
|
|
before();
|
|
|
|
INHERITED::drawOval(dummy1, oval, paint);
|
|
|
|
after();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void drawRRect(const SkDraw& dummy1, const SkRRect& rr,
|
|
|
|
const SkPaint& paint) {
|
|
|
|
before();
|
|
|
|
INHERITED::drawRRect(dummy1, rr, paint);
|
|
|
|
after();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void drawPath(const SkDraw& dummy1, const SkPath& path,
|
|
|
|
const SkPaint& paint,
|
|
|
|
const SkMatrix* prePathMatrix = NULL,
|
|
|
|
bool pathIsMutable = false) {
|
|
|
|
before();
|
|
|
|
INHERITED::drawPath(dummy1, path, paint, prePathMatrix, pathIsMutable);
|
|
|
|
after();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void drawBitmap(const SkDraw& dummy1, const SkBitmap& bitmap,
|
|
|
|
const SkMatrix& matrix, const SkPaint& paint) {
|
|
|
|
before();
|
2013-07-25 15:33:13 +00:00
|
|
|
INHERITED::drawBitmap(dummy1, bitmap, matrix, paint);
|
2013-07-22 15:36:39 +00:00
|
|
|
after();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void drawSprite(const SkDraw& dummy1, const SkBitmap& bitmap,
|
|
|
|
int x, int y, const SkPaint& paint) {
|
|
|
|
before();
|
|
|
|
INHERITED::drawSprite(dummy1, bitmap, x, y, paint);
|
|
|
|
after();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void drawBitmapRect(const SkDraw& dummy1, const SkBitmap& dummy2,
|
|
|
|
const SkRect* srcOrNull, const SkRect& dst,
|
2013-08-16 16:30:02 +00:00
|
|
|
const SkPaint& paint,
|
|
|
|
SkCanvas::DrawBitmapRectFlags flags) {
|
2013-07-22 15:36:39 +00:00
|
|
|
before();
|
2013-08-16 16:30:02 +00:00
|
|
|
INHERITED::drawBitmapRect(dummy1, dummy2, srcOrNull, dst, paint, flags);
|
2013-07-22 15:36:39 +00:00
|
|
|
after();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void drawText(const SkDraw& dummy1, const void* text, size_t len,
|
|
|
|
SkScalar x, SkScalar y, const SkPaint& paint) {
|
|
|
|
before();
|
|
|
|
INHERITED::drawText(dummy1, text, len, x, y, paint);
|
|
|
|
after();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void drawPosText(const SkDraw& dummy1, const void* text, size_t len,
|
Revert of Revert of Fix SkTextBlob offset semantics. (patchset #1 id:1 of https://codereview.chromium.org/609223003/)
Reason for revert:
Re-landing: Chromium-side fix to be landed with the roll (https://codereview.chromium.org/607853003/)
Original issue's description:
> Revert of Fix SkTextBlob offset semantics. (patchset #2 id:20001 of https://codereview.chromium.org/605533002/)
>
> Reason for revert:
> Breaking the Chrome builds with the error:
>
> [14:54:14.317833] ../../skia/ext/pixel_ref_utils.cc:221:16: error: 'drawPosText' marked 'override' but does not override any member functions
> [14:54:14.318022] virtual void drawPosText(const SkDraw& draw,
> [14:54:14.318082] ^
>
> Original issue's description:
> > Fix SkTextBlob offset semantics.
> >
> > Implement proper x/y drawTextBlob() handling by plumbing a
> > drawPosText() offset parameter (to act as an additional glyph pos
> > translation) throughout the device layer.
> >
> > The new offset superceeds the existing constY, with a minor semantic
> > tweak: whereas previous implementations were ignoring constY in 2D
> > positioning mode (scalarsPerGlyph == 2), now the offset is always
> > observed, in all positioning modes. We can do this because existing
> > drawPosText() clients always pass constY == 0 for full positioning mode.
> >
> > R=reed@google.com, jvanverth@google.com, robertphillips@google.com
> >
> > Committed: https://skia.googlesource.com/skia/+/c13bc571d3e61a43b87eb97f0719abd304cafaf2
>
> TBR=jvanverth@google.com,reed@google.com,bsalomon@google.com,fmalita@chromium.org
> NOTREECHECKS=true
> NOTRY=true
>
> Committed: https://skia.googlesource.com/skia/+/d46b8d2bab7cfba8458432248e1568ac377429e9
R=jvanverth@google.com, reed@google.com, bsalomon@google.com, robertphillips@google.com
TBR=bsalomon@google.com, jvanverth@google.com, reed@google.com, robertphillips@google.com
NOTREECHECKS=true
NOTRY=true
Author: fmalita@chromium.org
Review URL: https://codereview.chromium.org/607413003
2014-09-29 13:29:53 +00:00
|
|
|
const SkScalar pos[], int scalarsPerPos,
|
|
|
|
const SkPoint& offset, const SkPaint& paint) {
|
2013-07-22 15:36:39 +00:00
|
|
|
before();
|
Revert of Revert of Fix SkTextBlob offset semantics. (patchset #1 id:1 of https://codereview.chromium.org/609223003/)
Reason for revert:
Re-landing: Chromium-side fix to be landed with the roll (https://codereview.chromium.org/607853003/)
Original issue's description:
> Revert of Fix SkTextBlob offset semantics. (patchset #2 id:20001 of https://codereview.chromium.org/605533002/)
>
> Reason for revert:
> Breaking the Chrome builds with the error:
>
> [14:54:14.317833] ../../skia/ext/pixel_ref_utils.cc:221:16: error: 'drawPosText' marked 'override' but does not override any member functions
> [14:54:14.318022] virtual void drawPosText(const SkDraw& draw,
> [14:54:14.318082] ^
>
> Original issue's description:
> > Fix SkTextBlob offset semantics.
> >
> > Implement proper x/y drawTextBlob() handling by plumbing a
> > drawPosText() offset parameter (to act as an additional glyph pos
> > translation) throughout the device layer.
> >
> > The new offset superceeds the existing constY, with a minor semantic
> > tweak: whereas previous implementations were ignoring constY in 2D
> > positioning mode (scalarsPerGlyph == 2), now the offset is always
> > observed, in all positioning modes. We can do this because existing
> > drawPosText() clients always pass constY == 0 for full positioning mode.
> >
> > R=reed@google.com, jvanverth@google.com, robertphillips@google.com
> >
> > Committed: https://skia.googlesource.com/skia/+/c13bc571d3e61a43b87eb97f0719abd304cafaf2
>
> TBR=jvanverth@google.com,reed@google.com,bsalomon@google.com,fmalita@chromium.org
> NOTREECHECKS=true
> NOTRY=true
>
> Committed: https://skia.googlesource.com/skia/+/d46b8d2bab7cfba8458432248e1568ac377429e9
R=jvanverth@google.com, reed@google.com, bsalomon@google.com, robertphillips@google.com
TBR=bsalomon@google.com, jvanverth@google.com, reed@google.com, robertphillips@google.com
NOTREECHECKS=true
NOTRY=true
Author: fmalita@chromium.org
Review URL: https://codereview.chromium.org/607413003
2014-09-29 13:29:53 +00:00
|
|
|
INHERITED::drawPosText(dummy1, text, len, pos, scalarsPerPos, offset, paint);
|
2013-07-22 15:36:39 +00:00
|
|
|
after();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void drawTextOnPath(const SkDraw& dummy1, const void* text, size_t len,
|
|
|
|
const SkPath& path, const SkMatrix* matrix,
|
|
|
|
const SkPaint& paint) {
|
|
|
|
before();
|
|
|
|
INHERITED::drawTextOnPath(dummy1, text, len, path, matrix, paint);
|
|
|
|
after();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void drawVertices(const SkDraw& dummy1, SkCanvas::VertexMode dummy2, int vertexCount,
|
|
|
|
const SkPoint verts[], const SkPoint texs[],
|
|
|
|
const SkColor colors[], SkXfermode* xmode,
|
|
|
|
const uint16_t indices[], int indexCount,
|
|
|
|
const SkPaint& paint) {
|
|
|
|
before();
|
2013-10-10 20:58:22 +00:00
|
|
|
INHERITED::drawVertices(dummy1, dummy2, vertexCount,verts, texs,colors, xmode, indices,
|
|
|
|
indexCount, paint);
|
2013-07-22 15:36:39 +00:00
|
|
|
after();
|
|
|
|
}
|
|
|
|
|
2013-08-29 11:54:56 +00:00
|
|
|
virtual void drawDevice(const SkDraw& dummy1, SkBaseDevice* dummy2, int x, int y,
|
2013-07-22 15:36:39 +00:00
|
|
|
const SkPaint& dummy3) {
|
|
|
|
before();
|
|
|
|
INHERITED::drawDevice(dummy1, dummy2, x, y, dummy3);
|
|
|
|
after();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void before() {
|
|
|
|
if (fTracker) {
|
|
|
|
fTracker->before(accessBitmap(false));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// any/all of the expected touched has to be changed, and all expected untouched must be intact
|
|
|
|
void after() {
|
|
|
|
if (fTracker) {
|
|
|
|
fTracker->after(accessBitmap(false));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
SkTracker* fTracker;
|
|
|
|
|
2013-08-29 11:54:56 +00:00
|
|
|
typedef SkBitmapDevice INHERITED;
|
2013-07-22 15:36:39 +00:00
|
|
|
};
|
|
|
|
|
2013-08-21 16:31:37 +00:00
|
|
|
#endif // SkTrackDevice_DEFINED
|